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