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