1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 package com.sun.star.comp.loader;
25 
26 import com.sun.star.lang.XSingleServiceFactory;
27 import com.sun.star.lang.XMultiServiceFactory;
28 import com.sun.star.lang.XServiceInfo;
29 
30 
31 public class JavaLoaderFactory implements XSingleServiceFactory, XServiceInfo {
32 
33     private static String[] supportedServices = {
34         "com.sun.star.loader.Java",
35         "com.sun.star.loader.Java2"
36     };
37 
38 	private static final boolean DEBUG = false;
39 
DEBUG(String dbg)40 	private static final void DEBUG(String dbg) {
41 	    if (DEBUG)
42 	        System.err.println(" >>> JavaLoaderFactory - " + dbg);
43 	}
44 
45 	protected XMultiServiceFactory multiServiceFactory = null;
46 
47 	/** default constructor
48 	 */
49 //  	public JavaLoaderFactory() {}
50 
JavaLoaderFactory(XMultiServiceFactory factory)51 	public JavaLoaderFactory(XMultiServiceFactory factory) {
52 	    multiServiceFactory = factory;
53 	}
54 
createInstance()55     public java.lang.Object createInstance()
56             throws com.sun.star.uno.Exception,
57                    com.sun.star.uno.RuntimeException
58     {
59         return new JavaLoader(multiServiceFactory);
60     }
61 
createInstanceWithArguments( java.lang.Object[] args )62     public java.lang.Object createInstanceWithArguments( java.lang.Object[] args )
63             throws com.sun.star.uno.Exception,
64                    com.sun.star.uno.RuntimeException
65     {
66         JavaLoader loader = new JavaLoader();
67         loader.initialize(args);
68 
69         return loader;
70     }
71 
72     /** implements the XServiceInfo interface
73 	 */
getImplementationName()74 	public String getImplementationName()
75 	        throws com.sun.star.uno.RuntimeException
76     {
77 		return JavaLoader.class.getName();
78 	}
79 
80     /** implements the XServiceInfo interface
81 	 */
supportsService(String serviceName)82 	public boolean supportsService(String serviceName)
83 	        throws com.sun.star.uno.RuntimeException
84 	{
85 		for ( int i = 0; i < supportedServices.length; i++ ) {
86 			if ( supportedServices[i].equals(serviceName) )
87 				return true;
88 		}
89 		return false;
90 	}
91 
92     /** implements the XServiceInfo interface
93 	 */
getSupportedServiceNames()94 	public String[] getSupportedServiceNames()
95 	        throws com.sun.star.uno.RuntimeException
96 	{
97 		return supportedServices;
98 	}
99 }
100 
101