1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: TestComponent.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package com
.sun
.star
.comp
.jvmaccess
.workbench
;
33 import com
.sun
.star
.comp
.loader
.FactoryHelper
;
34 import com
.sun
.star
.lang
.XMain
;
35 import com
.sun
.star
.lang
.XMultiServiceFactory
;
36 import com
.sun
.star
.lang
.XServiceInfo
;
37 import com
.sun
.star
.lang
.XSingleServiceFactory
;
38 import com
.sun
.star
.lang
.XTypeProvider
;
39 import com
.sun
.star
.registry
.XRegistryKey
;
40 import com
.sun
.star
.uno
.Type
;
42 /* Deploy this component with pkgchk, and call it with the Basic program
46 o = createunoservice("com.sun.star.comp.jvmaccess.workbench.TestComponent")
50 The name of the context class loader should appear on the console.
53 public final class TestComponent
implements XTypeProvider
, XServiceInfo
, XMain
{
54 public Type
[] getTypes() {
55 return new Type
[] { new Type(XTypeProvider
.class),
56 new Type(XServiceInfo
.class),
57 new Type(XMain
.class) };
60 public byte[] getImplementationId() {
61 byte[] id
= new byte[16];
63 id
[0] = (byte) (n
& 0xFF);
64 id
[1] = (byte) ((n
>> 8) & 0xFF);
65 id
[2] = (byte) ((n
>> 16) & 0xFF);
66 id
[3] = (byte) ((n
>> 24) & 0xFF);
70 public String
getImplementationName() {
71 return getClass().getName();
74 public boolean supportsService(String serviceName
) {
75 return serviceName
.equals(serviceName
);
78 public String
[] getSupportedServiceNames() {
79 return new String
[] { serviceName
};
82 public int run(String
[] arguments
) {
83 System
.out
.println("context class loader: "
84 + Thread
.currentThread().getContextClassLoader());
88 public static XSingleServiceFactory
__getServiceFactory(
89 String implName
, XMultiServiceFactory multiFactory
, XRegistryKey regKey
)
91 if (implName
.equals(TestComponent
.class.getName())) {
92 return FactoryHelper
.getServiceFactory(TestComponent
.class,
93 serviceName
, multiFactory
,
100 public static boolean __writeRegistryServiceInfo(XRegistryKey regKey
) {
101 return FactoryHelper
.writeRegistryServiceInfo(
102 TestComponent
.class.getName(), serviceName
, regKey
);
105 private static final String serviceName
106 = "com.sun.star.comp.jvmaccess.workbench.TestComponent";