1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: testclient.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 import com
.sun
.star
.uno
.UnoRuntime
;
32 import com
.sun
.star
.uno
.IBridge
;
33 import com
.sun
.star
.connection
.XConnector
;
34 import com
.sun
.star
.connection
.XConnection
;
35 import com
.sun
.star
.lang
.XMultiServiceFactory
;
36 import com
.sun
.star
.bridge
.XInstanceProvider
;
39 import test
.XTestFactory
;
42 class MyInstanceProvider
implements XInstanceProvider
44 public Object
getInstance( String sName
)
46 System
.out
.println( "getInstance called" );
47 return new MyTestFactory();
53 class MyTestFactory
implements XTestFactory
55 public XCallMe
createCallMe( ) throws com
.sun
.star
.uno
.RuntimeException
57 return new MyCallMe();
60 public test
.XInterfaceTest
createInterfaceTest( ) throws com
.sun
.star
.uno
.RuntimeException
66 class MyCallMe
implements XCallMe
68 public String
getsAttribute() throws com
.sun
.star
.uno
.RuntimeException
72 public void setsAttribute( String _sattribute
) throws com
.sun
.star
.uno
.RuntimeException
77 public void call( /*IN*/String s
, /*IN*/int nToDo
) throws test
.TestBridgeException
, com
.sun
.star
.uno
.RuntimeException
81 public void callOneway( /*IN*/String s
, /*IN*/int nToDo
) throws com
.sun
.star
.uno
.RuntimeException
83 System
.out
.println( "entering callOneway" );
86 Thread
.currentThread().sleep( 4000 );
88 catch ( java
.lang
.Exception e
)
90 System
.out
.println( e
);
92 System
.out
.println( "leaving callOneway" );
94 public void callAgain( /*IN*/XCallMe callAgain
, /*IN*/int nToCall
) throws com
.sun
.star
.uno
.RuntimeException
98 public test
.TestTypes
transport( /*IN*/test
.TestTypes types
) throws com
.sun
.star
.uno
.RuntimeException
100 return new test
.TestTypes();
105 public class testclient
107 static void main( String
[] args
)
111 com
.sun
.star
.comp
.servicemanager
.ServiceManager smgr
=
112 new com
.sun
.star
.comp
.servicemanager
.ServiceManager();
113 smgr
.addFactories( new String
[] { "com.sun.star.comp.connections.Connector" });
115 Object x
= smgr
.createInstance("com.sun.star.connection.Connector");
118 System
.out
.println( "couldn't create connector\n" );
123 XConnector xConnector
=
124 ( XConnector
) UnoRuntime
.queryInterface( XConnector
.class , x
);
126 XConnection xConnection
= xConnector
.connect(args
[0]);
128 if( null != xConnection
)
130 System
.out
.println( "after connect" );
131 String rootOid
= "OfficeDaemon.Factory";
132 com
.sun
.star
.uno
.IBridge bridge
= (IBridge
) UnoRuntime
.getBridgeByName(
137 new Object
[]{"iiop", xConnection
, new MyInstanceProvider()});
139 System
.out
.println( "after building bridge" );
140 // Object rInitialObject = m_bridge.mapInterfaceFrom(rootOid, XInterface.class);
141 // XTestFactory rFactory = (XTestFactory )
142 // UnoRuntime.queryInterface(XTestFactory.class,rInitialObject );
144 // XCallMe callMerFactory->
145 Thread
.currentThread().sleep( 100000 );
148 catch( com
.sun
.star
.uno
.Exception e
)
150 System
.out
.println( "Exception thrown" );
152 catch( java
.lang
.Exception e
)
154 System
.out
.println( "java.lang.Exception thrown" );
157 System
.out
.println( "exiting" );