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.uno.XComponentContext; 24cdf0e10cSrcweir import com.sun.star.lang.XTypeProvider; 25cdf0e10cSrcweir import com.sun.star.lang.XServiceInfo; 26cdf0e10cSrcweir import com.sun.star.test.XSomethingB; 27cdf0e10cSrcweir import com.sun.star.uno.Type; 28cdf0e10cSrcweir 29cdf0e10cSrcweir // TestComponentB implements all necessary interfaces self, this is only 30cdf0e10cSrcweir // for demonstration. More convenient is to use the impelmentation WeakBase or 31cdf0e10cSrcweir // ComponentBase, see implementation of TestComponentA. 32cdf0e10cSrcweir public class TestComponentB implements XTypeProvider, XServiceInfo, XSomethingB { 33cdf0e10cSrcweir static final String __serviceName= "com.sun.star.test.SomethingB"; 34cdf0e10cSrcweir 35cdf0e10cSrcweir static byte[] _implementationId; 36cdf0e10cSrcweir private XComponentContext context; 37cdf0e10cSrcweir private Object[] args; 38cdf0e10cSrcweir TestComponentB(XComponentContext context, Object[] args)39cdf0e10cSrcweir public TestComponentB(XComponentContext context, Object[] args) { 40cdf0e10cSrcweir this.context= context; 41cdf0e10cSrcweir this.args= args; 42cdf0e10cSrcweir } 43cdf0e10cSrcweir 44cdf0e10cSrcweir // XSomethingB methodTwo(String val)45cdf0e10cSrcweir public String methodTwo(String val) { 46cdf0e10cSrcweir if (args.length > 0 && args[0] instanceof String ) 47cdf0e10cSrcweir return (String) args[0]; 48cdf0e10cSrcweir return val; 49cdf0e10cSrcweir } 50cdf0e10cSrcweir 51cdf0e10cSrcweir //XTypeProvider getTypes( )52cdf0e10cSrcweir public com.sun.star.uno.Type[] getTypes( ) { 53cdf0e10cSrcweir Type[] retValue= new Type[3]; 54cdf0e10cSrcweir retValue[0]= new Type( XServiceInfo.class); 55cdf0e10cSrcweir retValue[1]= new Type( XTypeProvider.class); 56cdf0e10cSrcweir retValue[2]= new Type( XSomethingB.class); 57cdf0e10cSrcweir return retValue; 58cdf0e10cSrcweir } 59cdf0e10cSrcweir //XTypeProvider getImplementationId( )60cdf0e10cSrcweir synchronized public byte[] getImplementationId( ) { 61cdf0e10cSrcweir if (_implementationId == null) { 62cdf0e10cSrcweir _implementationId= new byte[16]; 63cdf0e10cSrcweir int hash = hashCode(); 64cdf0e10cSrcweir _implementationId[0] = (byte)(hash & 0xff); 65cdf0e10cSrcweir _implementationId[1] = (byte)((hash >>> 8) & 0xff); 66cdf0e10cSrcweir _implementationId[2] = (byte)((hash >>> 16) & 0xff); 67cdf0e10cSrcweir _implementationId[3] = (byte)((hash >>>24) & 0xff); 68cdf0e10cSrcweir } 69cdf0e10cSrcweir return _implementationId; 70cdf0e10cSrcweir } 71cdf0e10cSrcweir 72cdf0e10cSrcweir //XServiceInfo getImplementationName( )73cdf0e10cSrcweir public String getImplementationName( ) { 74cdf0e10cSrcweir return getClass().getName(); 75cdf0e10cSrcweir } 76cdf0e10cSrcweir 77cdf0e10cSrcweir // XServiceInfo supportsService( String serviceName )78cdf0e10cSrcweir public boolean supportsService( /*IN*/String serviceName ) { 79cdf0e10cSrcweir if ( serviceName.equals( __serviceName)) 80cdf0e10cSrcweir return true; 81cdf0e10cSrcweir return false; 82cdf0e10cSrcweir } 83cdf0e10cSrcweir //XServiceInfo getSupportedServiceNames( )84cdf0e10cSrcweir public String[] getSupportedServiceNames( ) { 85cdf0e10cSrcweir String[] retValue= new String[0]; 86cdf0e10cSrcweir retValue[0]= __serviceName; 87cdf0e10cSrcweir return retValue; 88cdf0e10cSrcweir } 89cdf0e10cSrcweir } 90