summaryrefslogtreecommitdiff
path: root/stoc/test/javavm/testcomponent/TestComponent.java
blob: 5622ba087d7a5a946018ae0d36a66516a3bfc3e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import com.sun.star.comp.loader.FactoryHelper;
import com.sun.star.lang.*;
import com.sun.star.uno.*;
import com.sun.star.registry.XRegistryKey;
import java.io.*;
import java.net.*;
//import com.sun.star.lib.sandbox.*;


/** This component implements XTypeProvider for use with StarBasic.
 *  The XServiceInfo is implemented to have an interface in which we can put some
 *  code just for the sake of debugging.
 *
 *  To debug with JPDA (jdk 1.3), put these lines in the java.ini within the  [Java] section:
 *  -Xdebug
 *  -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y
 *
 *  When the Virtual Machine service is instantiated it will block until the debugger
 *  attaches to it on port 8000. You can chose a different port. You attach to the VM using
 *  jdb by
 *
 *  jdb -connect com.sun.jdi.SocketAttach:hostname=myhost,port=8000
 *
 *  myhost is the hostname where the VM is running.
*/
public class TestComponent implements XServiceInfo, XTypeProvider
{
    public static final String __serviceName="JavaTestComponent";

    // XTypeProvider
    public com.sun.star.uno.Type[] getTypes(  )
    {
        Type[] retValue= new Type[2];
        retValue[0]= new Type( XServiceInfo.class);
        retValue[1]= new Type( XTypeProvider.class);
        return retValue;
    }
    // XTypeProvider
    public byte[] getImplementationId(  )
    {
        return TestComponent.class.getName().getBytes();
    }


    // XServiceName
    public String getImplementationName(  )
    {
        String a= "the functions are for debugging";
        int abc= 34;
        String prop= System.getProperty("ftp.proxyHost");
        prop= System.getProperty("ftp.proxyPort");
        prop= System.getProperty("http.proxyHost");
        prop= System.getProperty("http.proxyPort");
        prop= System.getProperty("ftp.nonProxyHosts");
        prop= System.getProperty("http.nonProxyHosts");
        prop= System.getProperty("socksProxyHost");
        prop= System.getProperty("socksProxyPort");

        prop= System.getProperty("stardiv.security.disableSecurity");
        prop= System.getProperty("appletviewer.security.mode");

        // Test security settings
        File f= new File("c:/temp/javasecurity.txt");
        try {
            f.createNewFile();

               // local connection
        URL url= new URL("http://localhost:8080/index.html");
        InputStream is= url.openStream();
        // remote connection
        url= new URL("http://www.w3.org/index.html");
        is= url.openStream();
        }catch( MalformedURLException mue) {
        }catch( IOException e) {
            String s= e.getMessage();
            System.out.println(s);
        }/*catch( SandboxSecurityException sse) {
            String s= sse.getMessage();
            System.out.println("s");
        }
*/

        return __serviceName;
    }
    // XServiceName
    public boolean supportsService( /*IN*/String ServiceName )
    {

        return false;
    }

    //XServiceName
    public String[] getSupportedServiceNames(  )
    {
        String[] retValue= new String[0];
        return retValue;
    }

    public static XSingleServiceFactory __getServiceFactory(String implName,
    XMultiServiceFactory multiFactory,
    XRegistryKey regKey)
    {
        XSingleServiceFactory xSingleServiceFactory = null;

        if (implName.equals( TestComponent.class.getName()) )
            xSingleServiceFactory = FactoryHelper.getServiceFactory( TestComponent.class,
            TestComponent.__serviceName,
            multiFactory,
            regKey);

        return xSingleServiceFactory;
    }

  /**
   * Writes the service information into the given registry key.
   * This method is called by the <code>JavaLoader</code>
   * <p>
   * @return  returns true if the operation succeeded
   * @param   regKey       the registryKey
   * @see                  com.sun.star.comp.loader.JavaLoader
   */
    public static boolean __writeRegistryServiceInfo(XRegistryKey regKey)
    {
        return FactoryHelper.writeRegistryServiceInfo( TestComponent.class.getName(),
        TestComponent.__serviceName, regKey);
    }

}