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