1*34dd1e25SAndrew Rist /************************************************************** 2*34dd1e25SAndrew Rist * 3*34dd1e25SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*34dd1e25SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*34dd1e25SAndrew Rist * distributed with this work for additional information 6*34dd1e25SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*34dd1e25SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*34dd1e25SAndrew Rist * "License"); you may not use this file except in compliance 9*34dd1e25SAndrew Rist * with the License. You may obtain a copy of the License at 10*34dd1e25SAndrew Rist * 11*34dd1e25SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*34dd1e25SAndrew Rist * 13*34dd1e25SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*34dd1e25SAndrew Rist * software distributed under the License is distributed on an 15*34dd1e25SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*34dd1e25SAndrew Rist * KIND, either express or implied. See the License for the 17*34dd1e25SAndrew Rist * specific language governing permissions and limitations 18*34dd1e25SAndrew Rist * under the License. 19*34dd1e25SAndrew Rist * 20*34dd1e25SAndrew Rist *************************************************************/ 21*34dd1e25SAndrew Rist 22*34dd1e25SAndrew Rist 23cdf0e10cSrcweir import com.sun.star.lang.XMultiServiceFactory; 24cdf0e10cSrcweir import com.sun.star.lang.XSingleServiceFactory; 25cdf0e10cSrcweir import com.sun.star.registry.XRegistryKey; 26cdf0e10cSrcweir import com.sun.star.lang.XTypeProvider; 27cdf0e10cSrcweir import com.sun.star.lang.XServiceInfo; 28cdf0e10cSrcweir import com.sun.star.comp.loader.FactoryHelper; 29cdf0e10cSrcweir 30cdf0e10cSrcweir public class TestServiceProvider 31cdf0e10cSrcweir { __getServiceFactory( String implName, XMultiServiceFactory multiFactory, XRegistryKey regKey)32cdf0e10cSrcweir public static XSingleServiceFactory __getServiceFactory( 33cdf0e10cSrcweir String implName, 34cdf0e10cSrcweir XMultiServiceFactory multiFactory, 35cdf0e10cSrcweir XRegistryKey regKey) { 36cdf0e10cSrcweir XSingleServiceFactory xSingleServiceFactory = null; 37cdf0e10cSrcweir 38cdf0e10cSrcweir if (implName.equals( TestComponentA.class.getName()) ) 39cdf0e10cSrcweir xSingleServiceFactory = FactoryHelper.getServiceFactory( 40cdf0e10cSrcweir TestComponentA.class, TestComponentA.__serviceName, 41cdf0e10cSrcweir multiFactory, regKey); 42cdf0e10cSrcweir else if (implName.equals(TestComponentB.class.getName())) 43cdf0e10cSrcweir xSingleServiceFactory= FactoryHelper.getServiceFactory( 44cdf0e10cSrcweir TestComponentB.class, TestComponentB.__serviceName, 45cdf0e10cSrcweir multiFactory, regKey); 46cdf0e10cSrcweir return xSingleServiceFactory; 47cdf0e10cSrcweir } 48cdf0e10cSrcweir 49cdf0e10cSrcweir // This method not longer necessary since OOo 3.4 where the component registration 50cdf0e10cSrcweir // was changed to passive component registration. For more details see 51cdf0e10cSrcweir // http://wiki.services.openoffice.org/wiki/Passive_Component_Registration 52cdf0e10cSrcweir 53cdf0e10cSrcweir // public static boolean __writeRegistryServiceInfo(XRegistryKey regKey){ 54cdf0e10cSrcweir // boolean bregA= FactoryHelper.writeRegistryServiceInfo( 55cdf0e10cSrcweir // TestComponentA.class.getName(), 56cdf0e10cSrcweir // TestComponentA.__serviceName, regKey); 57cdf0e10cSrcweir // boolean bregB= FactoryHelper.writeRegistryServiceInfo( 58cdf0e10cSrcweir // TestComponentB.class.getName(), 59cdf0e10cSrcweir // TestComponentB.__serviceName, regKey); 60cdf0e10cSrcweir // return bregA && bregB; 61cdf0e10cSrcweir // } 62cdf0e10cSrcweir } 63cdf0e10cSrcweir 64cdf0e10cSrcweir 65