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