1 import com.sun.star.comp.loader.FactoryHelper;
2 import com.sun.star.lang.*;
3 import com.sun.star.uno.*;
4 import com.sun.star.registry.XRegistryKey;
5 import java.io.*;
6 import java.net.*;
7 //import com.sun.star.lib.sandbox.*;
8 
9 
10 /** This component implements XTypeProvider for use with StarBasic.
11  *  The XServiceInfo is implemented to have an interface in which we can put some
12  *  code just for the sake of debugging.
13  *
14  *  To debug with JPDA (jdk 1.3), put these lines in the java.ini within the  [Java] section:
15  *  -Xdebug
16  *  -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y
17  *
18  *  When the Virtual Machine service is instantiated it will block until the debugger
19  *  attaches to it on port 8000. You can chose a different port. You attach to the VM using
20  *  jdb by
21  *
22  *  jdb -connect com.sun.jdi.SocketAttach:hostname=myhost,port=8000
23  *
24  *  myhost is the hostname where the VM is running.
25 */
26 public class TestComponent implements XServiceInfo, XTypeProvider
27 {
28     public static final String __serviceName="JavaTestComponent";
29 
30     // XTypeProvider
31     public com.sun.star.uno.Type[] getTypes(  )
32     {
33         Type[] retValue= new Type[2];
34         retValue[0]= new Type( XServiceInfo.class);
35         retValue[1]= new Type( XTypeProvider.class);
36         return retValue;
37     }
38     // XTypeProvider
39     public byte[] getImplementationId(  )
40     {
41         return TestComponent.class.getName().getBytes();
42     }
43 
44 
45     // XServiceName
46     public String getImplementationName(  )
47     {
48         String a= "the functions are for debugging";
49         int abc= 34;
50         String prop= System.getProperty("ftp.proxyHost");
51         prop= System.getProperty("ftp.proxyPort");
52         prop= System.getProperty("http.proxyHost");
53         prop= System.getProperty("http.proxyPort");
54         prop= System.getProperty("ftp.nonProxyHosts");
55         prop= System.getProperty("http.nonProxyHosts");
56         prop= System.getProperty("socksProxyHost");
57         prop= System.getProperty("socksProxyPort");
58 
59 		prop= System.getProperty("stardiv.security.disableSecurity");
60 		prop= System.getProperty("appletviewer.security.mode");
61 
62         // Test security settings
63         File f= new File("c:/temp/javasecurity.txt");
64         try {
65             f.createNewFile();
66 
67                // local connection
68         URL url= new URL("http://localhost:8080/index.html");
69         InputStream is= url.openStream();
70         // remote connection
71         url= new URL("http://www.w3.org/index.html");
72         is= url.openStream();
73         }catch( MalformedURLException mue) {
74         }catch( IOException e) {
75             String s= e.getMessage();
76             System.out.println(s);
77         }/*catch( SandboxSecurityException sse) {
78             String s= sse.getMessage();
79             System.out.println("s");
80         }
81 */
82 
83         return __serviceName;
84     }
85     // XServiceName
86     public boolean supportsService( /*IN*/String ServiceName )
87     {
88 
89         return false;
90     }
91 
92     //XServiceName
93     public String[] getSupportedServiceNames(  )
94     {
95         String[] retValue= new String[0];
96         return retValue;
97     }
98 
99     public static XSingleServiceFactory __getServiceFactory(String implName,
100     XMultiServiceFactory multiFactory,
101     XRegistryKey regKey)
102     {
103         XSingleServiceFactory xSingleServiceFactory = null;
104 
105         if (implName.equals( TestComponent.class.getName()) )
106             xSingleServiceFactory = FactoryHelper.getServiceFactory( TestComponent.class,
107             TestComponent.__serviceName,
108             multiFactory,
109             regKey);
110 
111         return xSingleServiceFactory;
112     }
113 
114   /**
115    * Writes the service information into the given registry key.
116    * This method is called by the <code>JavaLoader</code>
117    * <p>
118    * @return  returns true if the operation succeeded
119    * @param   regKey       the registryKey
120    * @see                  com.sun.star.comp.loader.JavaLoader
121    */
122     public static boolean __writeRegistryServiceInfo(XRegistryKey regKey)
123     {
124         return FactoryHelper.writeRegistryServiceInfo( TestComponent.class.getName(),
125         TestComponent.__serviceName, regKey);
126     }
127 
128 }
129