office-gobmx/bridges/test/testclient.java

157 lines
5.1 KiB
Java
Raw Normal View History

2000-09-18 09:29:57 -05:00
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2000-09-18 09:29:57 -05:00
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
2000-09-18 09:29:57 -05:00
*
* OpenOffice.org - a multi-platform office productivity suite
2000-09-18 09:29:57 -05:00
*
* This file is part of OpenOffice.org.
2000-09-18 09:29:57 -05:00
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
2000-09-18 09:29:57 -05:00
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
2000-09-18 09:29:57 -05:00
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
2000-09-18 09:29:57 -05:00
*
************************************************************************/
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.IBridge;
import com.sun.star.connection.XConnector;
import com.sun.star.connection.XConnection;
import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.bridge.XInstanceProvider;
import test.XCallMe;
import test.XTestFactory;
class MyInstanceProvider implements XInstanceProvider
{
public Object getInstance( String sName )
{
System.out.println( "getInstance called" );
return new MyTestFactory();
}
}
class MyTestFactory implements XTestFactory
{
public XCallMe createCallMe( ) throws com.sun.star.uno.RuntimeException
{
return new MyCallMe();
}
public test.XInterfaceTest createInterfaceTest( ) throws com.sun.star.uno.RuntimeException
{
return null;
}
}
class MyCallMe implements XCallMe
{
public String getsAttribute() throws com.sun.star.uno.RuntimeException
{
return "";
}
public void setsAttribute( String _sattribute ) throws com.sun.star.uno.RuntimeException
{
}
// Methods
public void call( /*IN*/String s, /*IN*/int nToDo ) throws test.TestBridgeException, com.sun.star.uno.RuntimeException
{
}
public void callOneway( /*IN*/String s, /*IN*/int nToDo ) throws com.sun.star.uno.RuntimeException
{
System.out.println( "entering callOneway" );
// this.wait( 5 );
try {
Thread.currentThread().sleep( 4000 );
}
catch ( java.lang.Exception e )
{
System.out.println( e );
}
System.out.println( "leaving callOneway" );
}
public void callAgain( /*IN*/XCallMe callAgain, /*IN*/int nToCall ) throws com.sun.star.uno.RuntimeException
{
}
public test.TestTypes transport( /*IN*/test.TestTypes types ) throws com.sun.star.uno.RuntimeException
{
return new test.TestTypes();
}
}
public class testclient
{
static void main( String[] args )
{
try {
com.sun.star.comp.servicemanager.ServiceManager smgr =
new com.sun.star.comp.servicemanager.ServiceManager();
smgr.addFactories( new String[] { "com.sun.star.comp.connections.Connector" });
Object x = smgr.createInstance("com.sun.star.connection.Connector");
if( x == null )
{
System.out.println( "couldn't create connector\n" );
return;
}
XConnector xConnector =
CWS-TOOLING: integrate CWS sb113 2009-09-01 sb #i76393# second attempt at properly #ifdef-ing previous HG commit d598efdbf012 2009-08-28 sb #i102469# change back <T extends XInterface> to just <T> on queryInterface, to avoid binary incompatibility (method changing its signature from (Ljava/lang/Class;Ljava/lang/Object;)Ljava/lang/Object; to (Ljava/lang/Class;Ljava/lang/Object;)Lcom/sun/star/uno/XInterface;) 2009-08-28 sb #i76393# properly #ifdef previous HG commit d598efdbf012 2009-08-27 sb #i94421# work around compiler error (based on a patch supplied by cloph) 2009-08-26 sb merged in DEV300_m56 2009-08-26 sb #i76393# on Linux, include dynamic section offset in crash report so as to be able to map "prelinked" callstacks back to original (patch by cmc) 2009-08-26 sb #i88162# remove unnecessary whitespace lines from per-locale xcu files (patch by tora) 2009-08-17 Juergen Schmidt #i104292# set context classloader after create new custom UNO loader 2009-08-17 Juergen Schmidt #i103749# integrate patch 2009-08-14 sb #i103269# cherry-picked ssh://hg@hg.services.openoffice.org/cws/sb111 -r 5124ebd5edd1 ("#i101955# changed encoding of XML file content from erroneous ISO-8859-1 to UTF-8") 2009-08-12 sb #i102469# fixed mis-applications of UnoRuntime.queryInterface (detected via the simplified UnoRuntime.queryInterface, the HG changeset 29de35fc9554) to use AnyConverter instead; changed qadevOOo's lib.MultiMethodTest.before to allow throwing arbitrary exceptions, to cater for IllegalArgumentException thrown by AnyConverter 2009-08-12 sb #i104178# drop extra libxml2-config script from libxmlsec 2009-08-10 sb #i101754# simplified osl_getProcessInfo for LINUX (patch by cmc) 2009-08-10 sb #i95018# avoid closing -1 fds (patch supplied by cmc) 2009-08-10 sb #i103585# removed (apparently unnecessary) zlib support from libxml2; in turn, removed zlib dependencies from libxmlsec, libxslt, and redland (assuming those were transitive dependencies brought in by direct dependencies on libxml2) 2009-08-10 sb #i102469# simplified UnoRuntime.queryInterface using Java 5 generics; adapted URE-related modules accordingly 2009-08-10 sb #i101213# adapted setsolar env (solenv/config/) to set PYTHONPATH (and not set PYTHONHOME) in accordance with configure env (set_soenv.in); fixed testtools/source/bridgetest/pyuno (which now should work everywhere out of the box, thanks to the fixed setsolar PYTHONPATH) 2009-08-10 sb cherry-picked ssh://hg@hg.services.openoffice.org/cws/sb111 -r ea8de6d9396b ("#i101955# work in progress for a .hgignore file, continued")
2009-09-16 09:37:52 -05:00
UnoRuntime.queryInterface( XConnector.class , x );
2000-09-18 09:29:57 -05:00
XConnection xConnection = xConnector.connect(args[0]);
if( null != xConnection )
{
System.out.println( "after connect" );
String rootOid = "OfficeDaemon.Factory";
com.sun.star.uno.IBridge bridge = (IBridge ) UnoRuntime.getBridgeByName(
"java",
null,
"remote",
null,
new Object[]{"iiop", xConnection, new MyInstanceProvider()});
System.out.println( "after building bridge" );
// Object rInitialObject = m_bridge.mapInterfaceFrom(rootOid, XInterface.class);
CWS-TOOLING: integrate CWS sb113 2009-09-01 sb #i76393# second attempt at properly #ifdef-ing previous HG commit d598efdbf012 2009-08-28 sb #i102469# change back <T extends XInterface> to just <T> on queryInterface, to avoid binary incompatibility (method changing its signature from (Ljava/lang/Class;Ljava/lang/Object;)Ljava/lang/Object; to (Ljava/lang/Class;Ljava/lang/Object;)Lcom/sun/star/uno/XInterface;) 2009-08-28 sb #i76393# properly #ifdef previous HG commit d598efdbf012 2009-08-27 sb #i94421# work around compiler error (based on a patch supplied by cloph) 2009-08-26 sb merged in DEV300_m56 2009-08-26 sb #i76393# on Linux, include dynamic section offset in crash report so as to be able to map "prelinked" callstacks back to original (patch by cmc) 2009-08-26 sb #i88162# remove unnecessary whitespace lines from per-locale xcu files (patch by tora) 2009-08-17 Juergen Schmidt #i104292# set context classloader after create new custom UNO loader 2009-08-17 Juergen Schmidt #i103749# integrate patch 2009-08-14 sb #i103269# cherry-picked ssh://hg@hg.services.openoffice.org/cws/sb111 -r 5124ebd5edd1 ("#i101955# changed encoding of XML file content from erroneous ISO-8859-1 to UTF-8") 2009-08-12 sb #i102469# fixed mis-applications of UnoRuntime.queryInterface (detected via the simplified UnoRuntime.queryInterface, the HG changeset 29de35fc9554) to use AnyConverter instead; changed qadevOOo's lib.MultiMethodTest.before to allow throwing arbitrary exceptions, to cater for IllegalArgumentException thrown by AnyConverter 2009-08-12 sb #i104178# drop extra libxml2-config script from libxmlsec 2009-08-10 sb #i101754# simplified osl_getProcessInfo for LINUX (patch by cmc) 2009-08-10 sb #i95018# avoid closing -1 fds (patch supplied by cmc) 2009-08-10 sb #i103585# removed (apparently unnecessary) zlib support from libxml2; in turn, removed zlib dependencies from libxmlsec, libxslt, and redland (assuming those were transitive dependencies brought in by direct dependencies on libxml2) 2009-08-10 sb #i102469# simplified UnoRuntime.queryInterface using Java 5 generics; adapted URE-related modules accordingly 2009-08-10 sb #i101213# adapted setsolar env (solenv/config/) to set PYTHONPATH (and not set PYTHONHOME) in accordance with configure env (set_soenv.in); fixed testtools/source/bridgetest/pyuno (which now should work everywhere out of the box, thanks to the fixed setsolar PYTHONPATH) 2009-08-10 sb cherry-picked ssh://hg@hg.services.openoffice.org/cws/sb111 -r ea8de6d9396b ("#i101955# work in progress for a .hgignore file, continued")
2009-09-16 09:37:52 -05:00
// XTestFactory rFactory =
2000-09-18 09:29:57 -05:00
// UnoRuntime.queryInterface(XTestFactory.class,rInitialObject );
// XCallMe callMerFactory->
Thread.currentThread().sleep( 100000 );
}
}
catch( com.sun.star.uno.Exception e)
{
System.out.println( "Exception thrown" );
}
catch( java.lang.Exception e)
{
System.out.println( "java.lang.Exception thrown" );
}
System.out.println( "exiting" );
}
}