Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / stoc / test / javavm / testcomponent / TestComponent.java
blobd976323c5f7697c91c9e070dd5cb0001395ac0d3
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 import com.sun.star.comp.loader.FactoryHelper;
20 import com.sun.star.lang.*;
21 import com.sun.star.uno.*;
22 import com.sun.star.registry.XRegistryKey;
23 import java.io.*;
24 import java.net.*;
27 /** This component implements XTypeProvider for use with StarBasic.
28 * The XServiceInfo is implemented to have an interface in which we can put some
29 * code just for the sake of debugging.
31 * To debug with JPDA (jdk 1.3), put these lines in the java.ini within the [Java] section:
32 * -Xdebug
33 * -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y
35 * When the Virtual Machine service is instantiated it will block until the debugger
36 * attaches to it on port 8000. You can chose a different port. You attach to the VM using
37 * jdb by
39 * jdb -connect com.sun.jdi.SocketAttach:hostname=myhost,port=8000
41 * myhost is the hostname where the VM is running.
43 public class TestComponent implements XServiceInfo, XTypeProvider
45 public static final String __serviceName="JavaTestComponent";
47 // XTypeProvider
48 public com.sun.star.uno.Type[] getTypes( )
50 Type[] retValue= new Type[2];
51 retValue[0]= new Type( XServiceInfo.class);
52 retValue[1]= new Type( XTypeProvider.class);
53 return retValue;
55 // XTypeProvider
56 public byte[] getImplementationId( )
58 return new byte[0];
62 // XServiceName
63 public String getImplementationName( )
65 // the functions are for debugging
67 // Test security settings
68 File f= new File("c:/temp/javasecurity.txt");
69 try {
70 f.createNewFile();
72 // local connection
73 URL url= new URL("http://localhost:8080/index.html");
74 url.openStream();
75 // remote connection
76 url= new URL("http://www.w3.org/index.html");
77 url.openStream();
78 }catch( MalformedURLException mue) {
79 }catch( IOException e) {
80 String s= e.getMessage();
81 System.out.println(s);
84 return __serviceName;
86 // XServiceName
87 public boolean supportsService( /*IN*/String ServiceName )
90 return false;
93 //XServiceName
94 public String[] getSupportedServiceNames( )
96 String[] retValue= new String[0];
97 return retValue;
100 public static XSingleServiceFactory __getServiceFactory(String implName,
101 XMultiServiceFactory multiFactory,
102 XRegistryKey regKey)
104 XSingleServiceFactory xSingleServiceFactory = null;
106 if (implName.equals( TestComponent.class.getName()) )
107 xSingleServiceFactory = FactoryHelper.getServiceFactory( TestComponent.class,
108 TestComponent.__serviceName,
109 multiFactory,
110 regKey);
112 return xSingleServiceFactory;
116 * Writes the service information into the given registry key.
117 * This method is called by the <code>JavaLoader</code>
118 * <p>
119 * @return returns true if the operation succeeded
120 * @param regKey the registryKey
121 * @see com.sun.star.comp.loader.JavaLoader
123 public static boolean __writeRegistryServiceInfo(XRegistryKey regKey)
125 return FactoryHelper.writeRegistryServiceInfo( TestComponent.class.getName(),
126 TestComponent.__serviceName, regKey);