Debian Codegraph @

stoc/test/javavm/testcomponent/TestComponent.java

raw symbols SCIP
1 /*
2 * This file is part of the LibreOffice project.
3 *
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/.
7 *
8 * This file incorporates work covered by the following license notice:
9 *
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 .
17 */
18
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.*;
25
26
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.
30 *
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
34 *
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
38 *
39 * jdb -connect com.sun.jdi.SocketAttach:hostname=myhost,port=8000
40 *
41 * myhost is the hostname where the VM is running.
42 */
43 public class TestComponent implements XServiceInfo, XTypeProvider
44 {
45 public static final String __serviceName="JavaTestComponent";
46
47 // XTypeProvider
48 public com.sun.star.uno.Type[] getTypes( )
49 {
50 Type[] retValue= new Type[2];
51 retValue[0]= new Type( XServiceInfo.class);
52 retValue[1]= new Type( XTypeProvider.class);
53 return retValue;
54 }
55 // XTypeProvider
56 public byte[] getImplementationId( )
57 {
58 return new byte[0];
59 }
60
61
62 // XServiceName
63 public String getImplementationName( )
64 {
65 // the functions are for debugging
66
67 // Test security settings
68 File f= new File("c:/temp/javasecurity.txt");
69 try {
70 f.createNewFile();
71
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);
82 }
83
84 return __serviceName;
85 }
86 // XServiceName
87 public boolean supportsService( /*IN*/String ServiceName )
88 {
89
90 return false;
91 }
92
93 //XServiceName
94 public String[] getSupportedServiceNames( )
95 {
96 String[] retValue= new String[0];
97 return retValue;
98 }
99
100 public static XSingleServiceFactory __getServiceFactory(String implName,
101 XMultiServiceFactory multiFactory,
102 XRegistryKey regKey)
103 {
104 XSingleServiceFactory xSingleServiceFactory = null;
105
106 if (implName.equals( TestComponent.class.getName()) )
107 xSingleServiceFactory = FactoryHelper.getServiceFactory( TestComponent.class,
108 TestComponent.__serviceName,
109 multiFactory,
110 regKey);
111
112 return xSingleServiceFactory;
113 }
114
115 /**
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
122 */
123 public static boolean __writeRegistryServiceInfo(XRegistryKey regKey)
124 {
125 return FactoryHelper.writeRegistryServiceInfo( TestComponent.class.getName(),
126 TestComponent.__serviceName, regKey);
127 }
128
129 }