bump product version to 4.1.6.2
[LibreOffice.git] / bridges / test / testclient.java
blob3aa562e744bee52cbe857d1cff68a98e4b17b52f
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package test;
21 import com.sun.star.uno.UnoRuntime;
22 import com.sun.star.connection.XConnector;
23 import com.sun.star.connection.XConnection;
24 import com.sun.star.bridge.XInstanceProvider;
26 import test.XCallMe;
27 import test.XTestFactory;
30 class MyInstanceProvider implements XInstanceProvider
32 public Object getInstance( String sName )
34 System.out.println( "getInstance called" );
35 return new MyTestFactory();
41 class MyTestFactory implements XTestFactory
43 public XCallMe createCallMe( ) throws com.sun.star.uno.RuntimeException
45 return new MyCallMe();
48 public test.XInterfaceTest createInterfaceTest( ) throws com.sun.star.uno.RuntimeException
50 return null;
54 class MyCallMe implements XCallMe
56 public String getsAttribute() throws com.sun.star.uno.RuntimeException
58 return "";
60 public void setsAttribute( String _sattribute ) throws com.sun.star.uno.RuntimeException
64 // Methods
65 public void call( /*IN*/String s, /*IN*/int nToDo ) throws test.TestBridgeException, com.sun.star.uno.RuntimeException
69 public void callOneway( /*IN*/String s, /*IN*/int nToDo ) throws com.sun.star.uno.RuntimeException
71 System.out.println( "entering callOneway" );
72 try {
73 Thread.sleep( 4000 );
75 catch ( java.lang.Exception e )
77 System.out.println( e );
79 System.out.println( "leaving callOneway" );
81 public void callAgain( /*IN*/XCallMe callAgain, /*IN*/int nToCall ) throws com.sun.star.uno.RuntimeException
85 public test.TestTypes transport( /*IN*/test.TestTypes types ) throws com.sun.star.uno.RuntimeException
87 return new test.TestTypes();
92 public class testclient
94 static void main( String[] args )
96 try {
98 com.sun.star.comp.servicemanager.ServiceManager smgr =
99 new com.sun.star.comp.servicemanager.ServiceManager();
100 smgr.insert( "com.sun.star.comp.connections.Connector" );
102 Object x = smgr.createInstance("com.sun.star.connection.Connector");
103 if( x == null )
105 System.out.println( "couldn't create connector\n" );
106 return;
110 XConnector xConnector =
111 UnoRuntime.queryInterface( XConnector.class , x );
113 XConnection xConnection = xConnector.connect(args[0]);
115 if( null != xConnection )
117 System.out.println( "after connect" );
118 String rootOid = "OfficeDaemon.Factory";
119 com.sun.star.uno.IBridge bridge = UnoRuntime.getBridgeByName(
120 "java",
121 null,
122 "remote",
123 null,
124 new Object[]{"iiop", xConnection, new MyInstanceProvider()});
126 System.out.println( "after building bridge" );
128 Thread.sleep( 100000 );
131 catch( com.sun.star.uno.Exception e)
133 System.out.println( "Exception thrown" );
135 catch( java.lang.Exception e)
137 System.out.println( "java.lang.Exception thrown" );
140 System.out.println( "exiting" );