Branch libreoffice-5-0-4
[LibreOffice.git] / odk / examples / DevelopersGuide / Components / SimpleLicense / LicenseTest.java
blob02ca5d9c02b0dae7de0614be6d4ea618b63879d9
1 /*************************************************************************
3 * The Contents of this file are made available subject to the terms of
4 * the BSD license.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * All rights reserved.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
28 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
30 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
31 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *************************************************************************/
35 import com.sun.star.lib.uno.helper.Factory;
36 import com.sun.star.lang.XSingleComponentFactory;
37 import com.sun.star.lib.uno.helper.WeakBase;
38 import com.sun.star.lang.XServiceInfo;
40 /** This class capsulates the class, that implements the minimal component, a
41 * factory for creating the service (<CODE>__getComponentFactory</CODE>) and a
42 * method, that writes the information into the given registry key
43 * (<CODE>__writeRegistryServiceInfo</CODE>).
45 public class LicenseTest {
46 /** This class implements the component. At least the interfaces XServiceInfo,
47 * XTypeProvider, and XInitialization should be provided by the service.
49 public static class _LicenseTest extends WeakBase
50 implements XServiceInfo {
51 /** The service name, that must be used to get an instance of this service.
53 static private final String __serviceName =
54 "org.openoffice.LicenseTest";
56 /** This method returns an array of all supported service names.
57 * @return Array of supported service names.
59 public String[] getSupportedServiceNames() {
60 return getServiceNames();
63 /** This method is a simple helper function to used in the
64 * static component initialisation functions as well as in
65 * getSupportedServiceNames.
67 public static String[] getServiceNames() {
68 String[] sSupportedServiceNames = { __serviceName };
69 return sSupportedServiceNames;
72 /** This method returns true, if the given service will be
73 * supported by the component.
74 * @param sServiceName Service name.
75 * @return True, if the given service name will be supported.
77 public boolean supportsService( String sServiceName ) {
78 return sServiceName.equals( __serviceName );
81 /** Return the class name of the component.
82 * @return Class name of the component.
84 public String getImplementationName() {
85 return _LicenseTest.class.getName();
90 /**
91 * Gives a factory for creating the service.
92 * This method is called by the <code>JavaLoader</code>
93 * <p>
94 * @return returns a <code>XSingleComponentFactory</code> for creating
95 * the component
96 * @param sImplName the name of the implementation for which a
97 * service is desired
98 * @see com.sun.star.comp.loader.JavaLoader
100 public static XSingleComponentFactory __getComponentFactory(String sImplName)
102 XSingleComponentFactory xFactory = null;
104 if ( sImplName.equals( _LicenseTest.class.getName() ) )
105 xFactory = Factory.createComponentFactory(_LicenseTest.class,
106 _LicenseTest.getServiceNames());
108 return xFactory;
111 /** This method is a member of the interface for initializing an object
112 * directly after its creation.
113 * @param object This array of arbitrary objects will be passed to the
114 * component after its creation.
115 * @throws com.sun.star.uno.Exception Every exception will not be handled, but will be
116 * passed to the caller.
118 public void initialize( Object[] object )
119 throws com.sun.star.uno.Exception {
120 /* The component describes what arguments its expected and in which
121 * order!At this point you can read the objects and can intialize
122 * your component using these objects.