Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / jvmaccess / workbench / java / TestComponent.java
blob4b056b6411014cca50f89192ae98a67be6e64007
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 package com.sun.star.comp.jvmaccess.workbench;
30 import com.sun.star.comp.loader.FactoryHelper;
31 import com.sun.star.lang.XMain;
32 import com.sun.star.lang.XMultiServiceFactory;
33 import com.sun.star.lang.XServiceInfo;
34 import com.sun.star.lang.XSingleServiceFactory;
35 import com.sun.star.lang.XTypeProvider;
36 import com.sun.star.registry.XRegistryKey;
37 import com.sun.star.uno.Type;
39 /* Deploy this component with pkgchk, and call it with the Basic program
41 Sub Main
42 dim args$()
43 o = createunoservice("com.sun.star.comp.jvmaccess.workbench.TestComponent")
44 o.run args$()
45 End Sub
47 The name of the context class loader should appear on the console.
50 public final class TestComponent implements XTypeProvider, XServiceInfo, XMain {
51 public Type[] getTypes() {
52 return new Type[] { new Type(XTypeProvider.class),
53 new Type(XServiceInfo.class),
54 new Type(XMain.class) };
57 public byte[] getImplementationId() {
58 byte[] id = new byte[16];
59 int n = hashCode();
60 id[0] = (byte) (n & 0xFF);
61 id[1] = (byte) ((n >> 8) & 0xFF);
62 id[2] = (byte) ((n >> 16) & 0xFF);
63 id[3] = (byte) ((n >> 24) & 0xFF);
64 return id;
67 public String getImplementationName() {
68 return getClass().getName();
71 public boolean supportsService(String serviceName) {
72 return serviceName.equals(serviceName);
75 public String[] getSupportedServiceNames() {
76 return new String[] { serviceName };
79 public int run(String[] arguments) {
80 System.out.println("context class loader: "
81 + Thread.currentThread().getContextClassLoader());
82 return 0;
85 public static XSingleServiceFactory __getServiceFactory(
86 String implName, XMultiServiceFactory multiFactory, XRegistryKey regKey)
88 if (implName.equals(TestComponent.class.getName())) {
89 return FactoryHelper.getServiceFactory(TestComponent.class,
90 serviceName, multiFactory,
91 regKey);
92 } else {
93 return null;
97 public static boolean __writeRegistryServiceInfo(XRegistryKey regKey) {
98 return FactoryHelper.writeRegistryServiceInfo(
99 TestComponent.class.getName(), serviceName, regKey);
102 private static final String serviceName
103 = "com.sun.star.comp.jvmaccess.workbench.TestComponent";