summaryrefslogtreecommitdiff
path: root/bridges/test/java_uno/nativethreadpool
diff options
context:
space:
mode:
Diffstat (limited to 'bridges/test/java_uno/nativethreadpool')
-rw-r--r--bridges/test/java_uno/nativethreadpool/Relay.java125
-rw-r--r--bridges/test/java_uno/nativethreadpool/makefile.mk121
-rw-r--r--bridges/test/java_uno/nativethreadpool/readme39
-rw-r--r--bridges/test/java_uno/nativethreadpool/relay.manifest2
-rw-r--r--bridges/test/java_uno/nativethreadpool/testnativethreadpoolclient.cxx184
-rw-r--r--bridges/test/java_uno/nativethreadpool/testnativethreadpoolserver.cxx146
-rw-r--r--bridges/test/java_uno/nativethreadpool/types.idl40
-rw-r--r--bridges/test/java_uno/nativethreadpool/version.map35
8 files changed, 692 insertions, 0 deletions
diff --git a/bridges/test/java_uno/nativethreadpool/Relay.java b/bridges/test/java_uno/nativethreadpool/Relay.java
new file mode 100644
index 000000000000..50e198a2d819
--- /dev/null
+++ b/bridges/test/java_uno/nativethreadpool/Relay.java
@@ -0,0 +1,125 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * 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.
+ *
+ * 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).
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+package test.javauno.nativethreadpool;
+
+import com.sun.star.bridge.BridgeExistsException;
+import com.sun.star.bridge.XBridgeFactory;
+import com.sun.star.bridge.XInstanceProvider;
+import com.sun.star.comp.helper.Bootstrap;
+import com.sun.star.comp.loader.FactoryHelper;
+import com.sun.star.connection.AlreadyAcceptingException;
+import com.sun.star.connection.ConnectionSetupException;
+import com.sun.star.connection.Acceptor;
+import com.sun.star.connection.XAcceptor;
+import com.sun.star.connection.XConnection;
+import com.sun.star.lang.WrappedTargetRuntimeException;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XSingleServiceFactory;
+import com.sun.star.registry.XRegistryKey;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+
+public final class Relay implements XRelay, XSource {
+ public void start(XSource source) {
+ this.source = source;
+ XComponentContext context;
+ try {
+ context = Bootstrap.createInitialComponentContext(null);
+ } catch (RuntimeException e) {
+ throw e;
+ } catch (com.sun.star.uno.Exception e) {
+ throw new WrappedTargetRuntimeException(e.toString(), this, e);
+ } catch (Exception e) {
+ throw new com.sun.star.uno.RuntimeException(e.toString(), this);
+ }
+ final XAcceptor acceptor = Acceptor.create(context);
+ final XBridgeFactory factory;
+ try {
+ factory = UnoRuntime.queryInterface(
+ XBridgeFactory.class,
+ context.getServiceManager().createInstanceWithContext(
+ "com.sun.star.bridge.BridgeFactory", context));
+ } catch (com.sun.star.uno.Exception e) {
+ throw new WrappedTargetRuntimeException(e.toString(), this, e);
+ }
+ new Thread() {
+ public void run() {
+ try {
+ // Use "127.0.0.1" instead of "localhost", see #i32281#:
+ factory.createBridge(
+ "", "urp",
+ acceptor.accept("socket,host=127.0.0.1,port=3831"),
+ new XInstanceProvider() {
+ public Object getInstance(String instanceName) {
+ return Relay.this;
+ }
+ });
+ } catch (AlreadyAcceptingException e) {
+ e.printStackTrace(System.err);
+ } catch (ConnectionSetupException e) {
+ e.printStackTrace(System.err);
+ } catch (BridgeExistsException e) {
+ e.printStackTrace(System.err);
+ } catch (com.sun.star.lang.IllegalArgumentException e) {
+ e.printStackTrace(System.err);
+ }
+ }
+ }.start();
+ try {
+ Thread.sleep(3000); // wait for new thread to accept connection
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ throw new com.sun.star.uno.RuntimeException(e.toString(), this);
+ }
+ }
+
+ public int get() {
+ return source.get();
+ }
+
+ public static XSingleServiceFactory __getServiceFactory(
+ String implName, XMultiServiceFactory multiFactory, XRegistryKey regKey)
+ {
+ return implName.equals(implementationName)
+ ? FactoryHelper.getServiceFactory(
+ Relay.class, serviceName, multiFactory, regKey)
+ : null;
+ }
+
+ public static boolean __writeRegistryServiceInfo(XRegistryKey regKey) {
+ return FactoryHelper.writeRegistryServiceInfo(
+ implementationName, serviceName, regKey);
+ }
+
+ private static final String implementationName
+ = "test.javauno.nativethreadpool.comp.Relay";
+ private static final String serviceName
+ = "test.javauno.nativethreadpool.Relay";
+
+ private XSource source;
+}
diff --git a/bridges/test/java_uno/nativethreadpool/makefile.mk b/bridges/test/java_uno/nativethreadpool/makefile.mk
new file mode 100644
index 000000000000..d4926e07307b
--- /dev/null
+++ b/bridges/test/java_uno/nativethreadpool/makefile.mk
@@ -0,0 +1,121 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# 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.
+#
+# 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).
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ := ..$/..$/..
+PRJNAME := bridges
+
+TARGET := test_javauno_nativethreadpool
+PACKAGE := test$/javauno$/nativethreadpool
+
+ENABLE_EXCEPTIONS := TRUE
+
+#TODO:
+.IF "$(OS)" == "LINUX"
+JVM_LIB_URL := file:///net/grande.germany/develop6/update/dev/Linux_JDK_1.4.1_03/jre/lib/i386/client/libjvm.so
+.ELSE
+ERROR -- missing platform
+.ENDIF
+
+.INCLUDE: settings.mk
+
+DLLPRE = # no leading "lib" on .so files
+INCPRE += $(MISC)$/$(TARGET)$/inc
+
+SHL1TARGET = $(TARGET)_client.uno
+SHL1OBJS = $(SLO)$/testnativethreadpoolclient.obj
+SHL1STDLIBS = $(CPPULIB) $(CPPUHELPERLIB) $(SALLIB)
+SHL1VERSIONMAP = version.map
+SHL1IMPLIB = i$(TARGET)_client
+
+SHL2TARGET = $(TARGET)_server.uno
+SHL2OBJS = $(SLO)$/testnativethreadpoolserver.obj
+SHL2STDLIBS = $(CPPULIB) $(CPPUHELPERLIB) $(SALLIB)
+SHL2VERSIONMAP = version.map
+SHL2IMPLIB = i$(TARGET)_server
+
+SLOFILES = $(SHL1OBJS) $(SHL2OBJS)
+
+JAVAFILES = Relay.java
+JARFILES = java_uno.jar juh.jar jurt.jar ridl.jar
+
+.INCLUDE: target.mk
+
+ALLTAR: test
+
+EXEC_CLASSPATH_TMP = $(foreach,i,$(JARFILES) $(SOLARBINDIR)$/$i)
+EXEC_CLASSPATH = \
+ $(strip $(subst,!,$(PATH_SEPERATOR) $(EXEC_CLASSPATH_TMP:s/ /!/)))
+
+$(MISC)$/$(TARGET)$/types.rdb: types.idl
+ - rm $@
+ - $(MKDIR) $(MISC)$/$(TARGET)
+ - $(MKDIR) $(MISC)$/$(TARGET)$/inc
+ $(IDLC) -I$(SOLARIDLDIR) -O$(MISC)$/$(TARGET) $<
+ $(REGMERGE) $@ /UCR $(MISC)$/$(TARGET)$/types.urd
+ $(CPPUMAKER) -BUCR -C -O$(MISC)$/$(TARGET)$/inc $@ -X$(SOLARBINDIR)$/types.rdb
+ $(JAVAMAKER) -BUCR -nD -O$(CLASSDIR) $@ -X$(SOLARBINDIR)$/types.rdb
+
+$(SLOFILES) $(JAVACLASSFILES): $(MISC)$/$(TARGET)$/types.rdb
+
+$(BIN)$/$(TARGET).uno.jar: $(JAVACLASSFILES) relay.manifest
+ jar cfm $@ relay.manifest -C $(CLASSDIR) test/javauno/nativethreadpool
+
+$(BIN)$/$(TARGET).rdb .ERRREMOVE: $(MISC)$/$(TARGET)$/types.rdb \
+ $(BIN)$/$(TARGET).uno.jar
+ cp $(MISC)$/$(TARGET)$/types.rdb $@
+ $(REGMERGE) $@ / $(SOLARBINDIR)$/types.rdb
+ $(REGCOMP) -register -r $@ -c acceptor.uno$(DLLPOST) \
+ -c bridgefac.uno$(DLLPOST) -c connector.uno$(DLLPOST) \
+ -c remotebridge.uno$(DLLPOST) -c uuresolver.uno$(DLLPOST) \
+ -c javaloader.uno$(DLLPOST) -c javavm.uno$(DLLPOST) \
+ -c stocservices.uno$(DLLPOST)
+ cp $(SOLARBINDIR)$/types.rdb $(MISC)$/$(TARGET)$/bootstrap.rdb
+ $(REGCOMP) -register -r $(MISC)$/$(TARGET)$/bootstrap.rdb \
+ -c javaloader.uno$(DLLPOST) -c javavm.uno$(DLLPOST) \
+ -c stocservices.uno$(DLLPOST)
+.IF "$(GUI)" == "WNT"
+ ERROR -- missing platform
+.ELSE # GUI, WNT
+ + export OO_JAVA_PROPERTIES='RuntimeLib=$(JVM_LIB_URL)' && \
+ $(REGCOMP) -register -r $@ -c file://$(PWD)/$(BIN)$/$(TARGET).uno.jar \
+ -br $(MISC)$/$(TARGET)$/bootstrap.rdb -classpath $(EXEC_CLASSPATH) \
+ -env:URE_INTERNAL_JAVA_DIR=file://$(SOLARBINDIR)
+.ENDIF # GUI, WNT
+
+test .PHONY: $(SHL1TARGETN) $(BIN)$/$(TARGET).uno.jar $(BIN)$/$(TARGET).rdb
+.IF "$(GUI)" == "WNT"
+ ERROR -- missing platform
+.ELSE # GUI, WNT
+ $(AUGMENT_LIBRARY_PATH) uno -c test.javauno.nativethreadpool.server \
+ -l $(SHL2TARGETN) -ro $(BIN)$/$(TARGET).rdb \
+ -u 'uno:socket,host=localhost,port=3830;urp;test' --singleaccept &
+ + $(AUGMENT_LIBRARY_PATH) OO_JAVA_PROPERTIES='RuntimeLib=$(JVM_LIB_URL)' \
+ CLASSPATH=$(EXEC_CLASSPATH)$(PATH_SEPERATOR)$(BIN)$/$(TARGET).uno.jar \
+ uno -c test.javauno.nativethreadpool.client -l $(SHL1TARGETN) \
+ -ro $(BIN)$/$(TARGET).rdb \
+ -env:URE_INTERNAL_JAVA_DIR=file://$(SOLARBINDIR)
+.ENDIF # GUI, WNT
diff --git a/bridges/test/java_uno/nativethreadpool/readme b/bridges/test/java_uno/nativethreadpool/readme
new file mode 100644
index 000000000000..c137ed162372
--- /dev/null
+++ b/bridges/test/java_uno/nativethreadpool/readme
@@ -0,0 +1,39 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# 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.
+#
+# 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).
+#
+# 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.
+#
+#*************************************************************************
+
+Test that a Java URP bridge started in a native process uses the same thread
+pool as a C++ URP bridge. This test currently only works on Linux Intel.
+
+There are two processes involved. The client starts as a native process. It
+first loads a Java component (Relay) via the in-process JNI bridge, which in
+turn starts to accept incomming URP connections. The native part of the client
+then connects to the server, retrieves a thread-local token from it, and checks
+the token for correctness. The server simply waits for a connection from the
+native part of the client, creates a connection to the Java part of the client,
+and routes all requests from the native part of the client to the Java part of
+the client. The Java part of the client in turn uses the in-process JNI bridge
+to obtain the thread-local token.
diff --git a/bridges/test/java_uno/nativethreadpool/relay.manifest b/bridges/test/java_uno/nativethreadpool/relay.manifest
new file mode 100644
index 000000000000..6cd1d9dbd611
--- /dev/null
+++ b/bridges/test/java_uno/nativethreadpool/relay.manifest
@@ -0,0 +1,2 @@
+Manifest-Version: 1.0
+RegistrationClassName: test.javauno.nativethreadpool.Relay
diff --git a/bridges/test/java_uno/nativethreadpool/testnativethreadpoolclient.cxx b/bridges/test/java_uno/nativethreadpool/testnativethreadpoolclient.cxx
new file mode 100644
index 000000000000..1964a73d1878
--- /dev/null
+++ b/bridges/test/java_uno/nativethreadpool/testnativethreadpoolclient.cxx
@@ -0,0 +1,184 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * 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.
+ *
+ * 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).
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_bridges.hxx"
+
+#include "test/javauno/nativethreadpool/XRelay.hpp"
+#include "test/javauno/nativethreadpool/XSource.hpp"
+
+#include "com/sun/star/bridge/UnoUrlResolver.hpp"
+#include "com/sun/star/bridge/XUnoUrlResolver.hpp"
+#include "com/sun/star/connection/ConnectionSetupException.hpp"
+#include "com/sun/star/connection/NoConnectException.hpp"
+#include "com/sun/star/lang/IllegalArgumentException.hpp"
+#include "com/sun/star/lang/WrappedTargetRuntimeException.hpp"
+#include "com/sun/star/lang/XMain.hpp"
+#include "com/sun/star/lang/XMultiComponentFactory.hpp"
+#include "com/sun/star/uno/Exception.hpp"
+#include "com/sun/star/uno/Reference.hxx"
+#include "com/sun/star/uno/RuntimeException.hpp"
+#include "com/sun/star/uno/Sequence.hxx"
+#include "com/sun/star/uno/XComponentContext.hpp"
+#include "com/sun/star/uno/XInterface.hpp"
+#include "cppuhelper/factory.hxx"
+#include "cppuhelper/implbase2.hxx"
+#include "cppuhelper/implementationentry.hxx"
+#include "cppuhelper/weak.hxx"
+#include "osl/thread.hxx"
+#include "rtl/ustring.hxx"
+#include "sal/types.h"
+#include "uno/lbnames.h"
+
+#include <iostream>
+
+namespace css = com::sun::star;
+
+namespace {
+
+class Client: public cppu::WeakImplHelper2<
+ css::lang::XMain, test::javauno::nativethreadpool::XSource >
+{
+public:
+ explicit Client(
+ css::uno::Reference< css::uno::XComponentContext > const & theContext):
+ context(theContext) {}
+
+private:
+ virtual ~Client() {}
+
+ virtual sal_Int32 SAL_CALL run(css::uno::Sequence< rtl::OUString > const &)
+ throw (css::uno::RuntimeException);
+
+ virtual sal_Int32 SAL_CALL get() throw (css::uno::RuntimeException);
+
+ css::uno::Reference< css::uno::XComponentContext > context;
+ osl::ThreadData data;
+};
+
+sal_Int32 Client::run(css::uno::Sequence< rtl::OUString > const &)
+ throw (css::uno::RuntimeException)
+{
+ css::uno::Reference< css::lang::XMultiComponentFactory > factory(
+ context->getServiceManager());
+ if (!factory.is()) {
+ throw new css::uno::RuntimeException(
+ rtl::OUString::createFromAscii(
+ "no component context service manager"),
+ static_cast< cppu::OWeakObject * >(this));
+ }
+ css::uno::Reference< test::javauno::nativethreadpool::XRelay > relay;
+ try {
+ relay = css::uno::Reference< test::javauno::nativethreadpool::XRelay >(
+ factory->createInstanceWithContext(
+ rtl::OUString::createFromAscii(
+ "test.javauno.nativethreadpool.Relay"),
+ context),
+ css::uno::UNO_QUERY_THROW);
+ } catch (css::uno::RuntimeException &) {
+ throw;
+ } catch (css::uno::Exception & e) {
+ throw css::lang::WrappedTargetRuntimeException(
+ rtl::OUString::createFromAscii(
+ "creating test.javauno.nativethreadpool.Relay service"),
+ static_cast< cppu::OWeakObject * >(this), css::uno::makeAny(e));
+ }
+ relay->start(this);
+ if (!data.setData(reinterpret_cast< void * >(12345))) {
+ throw new css::uno::RuntimeException(
+ rtl::OUString::createFromAscii("osl::ThreadData::setData failed"),
+ static_cast< cppu::OWeakObject * >(this));
+ }
+ css::uno::Reference< test::javauno::nativethreadpool::XSource > source;
+ try {
+ source
+ = css::uno::Reference< test::javauno::nativethreadpool::XSource >(
+ css::bridge::UnoUrlResolver::create(context)->resolve(
+ rtl::OUString::createFromAscii(
+ "uno:socket,host=localhost,port=3830;urp;test")),
+ css::uno::UNO_QUERY_THROW);
+ } catch (css::connection::NoConnectException & e) {
+ throw css::lang::WrappedTargetRuntimeException(
+ rtl::OUString::createFromAscii(
+ "com.sun.star.uno.UnoUrlResolver.resolve"),
+ static_cast< cppu::OWeakObject * >(this), css::uno::makeAny(e));
+ } catch (css::connection::ConnectionSetupException & e) {
+ throw css::lang::WrappedTargetRuntimeException(
+ rtl::OUString::createFromAscii(
+ "com.sun.star.uno.UnoUrlResolver.resolve"),
+ static_cast< cppu::OWeakObject * >(this), css::uno::makeAny(e));
+ } catch (css::lang::IllegalArgumentException & e) {
+ throw css::lang::WrappedTargetRuntimeException(
+ rtl::OUString::createFromAscii(
+ "com.sun.star.uno.UnoUrlResolver.resolve"),
+ static_cast< cppu::OWeakObject * >(this), css::uno::makeAny(e));
+ }
+ bool success = source->get() == 12345;
+ std::cout << "success? " << (success ? "yes" : "no") << '\n';
+ return success ? 0 : 1;
+}
+
+sal_Int32 Client::get() throw (css::uno::RuntimeException) {
+ return reinterpret_cast< sal_Int32 >(data.getData());
+}
+
+css::uno::Reference< css::uno::XInterface > SAL_CALL create(
+ css::uno::Reference< css::uno::XComponentContext > const & context)
+ SAL_THROW((css::uno::Exception))
+{
+ return static_cast< cppu::OWeakObject * >(new Client(context));
+}
+
+rtl::OUString SAL_CALL getImplementationName() {
+ return rtl::OUString::createFromAscii(
+ "test.javauno.nativethreadpool.client");
+}
+
+css::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames() {
+ return css::uno::Sequence< rtl::OUString >();
+}
+
+cppu::ImplementationEntry entries[] = {
+ { &create, &getImplementationName, &getSupportedServiceNames,
+ &cppu::createSingleComponentFactory, 0, 0 },
+ { 0, 0, 0, 0, 0, 0 }
+};
+
+}
+
+extern "C" void * SAL_CALL component_getFactory(
+ char const * implName, void * serviceManager, void * registryKey)
+{
+ return cppu::component_getFactoryHelper(
+ implName, serviceManager, registryKey, entries);
+}
+
+extern "C" void SAL_CALL component_getImplementationEnvironment(
+ char const ** envTypeName, uno_Environment **)
+{
+ *envTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
diff --git a/bridges/test/java_uno/nativethreadpool/testnativethreadpoolserver.cxx b/bridges/test/java_uno/nativethreadpool/testnativethreadpoolserver.cxx
new file mode 100644
index 000000000000..0e3b30effb7e
--- /dev/null
+++ b/bridges/test/java_uno/nativethreadpool/testnativethreadpoolserver.cxx
@@ -0,0 +1,146 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * 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.
+ *
+ * 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).
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_bridges.hxx"
+
+#include "test/javauno/nativethreadpool/XSource.hpp"
+
+#include "com/sun/star/bridge/UnoUrlResolver.hpp"
+#include "com/sun/star/bridge/XUnoUrlResolver.hpp"
+#include "com/sun/star/connection/ConnectionSetupException.hpp"
+#include "com/sun/star/connection/NoConnectException.hpp"
+#include "com/sun/star/lang/IllegalArgumentException.hpp"
+#include "com/sun/star/lang/WrappedTargetRuntimeException.hpp"
+#include "com/sun/star/lang/XMultiComponentFactory.hpp"
+#include "com/sun/star/uno/Exception.hpp"
+#include "com/sun/star/uno/Reference.hxx"
+#include "com/sun/star/uno/RuntimeException.hpp"
+#include "com/sun/star/uno/Sequence.hxx"
+#include "com/sun/star/uno/XComponentContext.hpp"
+#include "com/sun/star/uno/XInterface.hpp"
+#include "cppuhelper/factory.hxx"
+#include "cppuhelper/implbase1.hxx"
+#include "cppuhelper/implementationentry.hxx"
+#include "cppuhelper/weak.hxx"
+#include "rtl/ustring.hxx"
+#include "sal/types.h"
+#include "uno/lbnames.h"
+
+namespace css = com::sun::star;
+
+namespace {
+
+class Server:
+ public cppu::WeakImplHelper1< test::javauno::nativethreadpool::XSource >
+{
+public:
+ explicit Server(
+ css::uno::Reference< css::uno::XComponentContext > const & theContext):
+ context(theContext) {}
+
+private:
+ virtual ~Server() {}
+
+ virtual sal_Int32 SAL_CALL get() throw (css::uno::RuntimeException);
+
+ css::uno::Reference< css::uno::XComponentContext > context;
+};
+
+sal_Int32 Server::get() throw (css::uno::RuntimeException) {
+ css::uno::Reference< css::lang::XMultiComponentFactory > factory(
+ context->getServiceManager());
+ if (!factory.is()) {
+ throw new css::uno::RuntimeException(
+ rtl::OUString::createFromAscii(
+ "no component context service manager"),
+ static_cast< cppu::OWeakObject * >(this));
+ }
+ css::uno::Reference< test::javauno::nativethreadpool::XSource > source;
+ try {
+ // Use "127.0.0.1" instead of "localhost", see #i32281#:
+ source
+ = css::uno::Reference< test::javauno::nativethreadpool::XSource >(
+ css::bridge::UnoUrlResolver::create(context)->resolve(
+ rtl::OUString::createFromAscii(
+ "uno:socket,host=127.0.0.1,port=3831;urp;test")),
+ css::uno::UNO_QUERY_THROW);
+ } catch (css::connection::NoConnectException & e) {
+ throw css::lang::WrappedTargetRuntimeException(
+ rtl::OUString::createFromAscii(
+ "com.sun.star.uno.UnoUrlResolver.resolve"),
+ static_cast< cppu::OWeakObject * >(this), css::uno::makeAny(e));
+ } catch (css::connection::ConnectionSetupException & e) {
+ throw css::lang::WrappedTargetRuntimeException(
+ rtl::OUString::createFromAscii(
+ "com.sun.star.uno.UnoUrlResolver.resolve"),
+ static_cast< cppu::OWeakObject * >(this), css::uno::makeAny(e));
+ } catch (css::lang::IllegalArgumentException & e) {
+ throw css::lang::WrappedTargetRuntimeException(
+ rtl::OUString::createFromAscii(
+ "com.sun.star.uno.UnoUrlResolver.resolve"),
+ static_cast< cppu::OWeakObject * >(this), css::uno::makeAny(e));
+ }
+ return source->get();
+}
+
+css::uno::Reference< css::uno::XInterface > SAL_CALL create(
+ css::uno::Reference< css::uno::XComponentContext > const & context)
+ SAL_THROW((css::uno::Exception))
+{
+ return static_cast< cppu::OWeakObject * >(new Server(context));
+}
+
+rtl::OUString SAL_CALL getImplementationName() {
+ return rtl::OUString::createFromAscii(
+ "test.javauno.nativethreadpool.server");
+}
+
+css::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames() {
+ return css::uno::Sequence< rtl::OUString >();
+}
+
+cppu::ImplementationEntry entries[] = {
+ { &create, &getImplementationName, &getSupportedServiceNames,
+ &cppu::createSingleComponentFactory, 0, 0 },
+ { 0, 0, 0, 0, 0, 0 }
+};
+
+}
+
+extern "C" void * SAL_CALL component_getFactory(
+ char const * implName, void * serviceManager, void * registryKey)
+{
+ return cppu::component_getFactoryHelper(
+ implName, serviceManager, registryKey, entries);
+}
+
+extern "C" void SAL_CALL component_getImplementationEnvironment(
+ char const ** envTypeName, uno_Environment **)
+{
+ *envTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
diff --git a/bridges/test/java_uno/nativethreadpool/types.idl b/bridges/test/java_uno/nativethreadpool/types.idl
new file mode 100644
index 000000000000..36ca44af37e0
--- /dev/null
+++ b/bridges/test/java_uno/nativethreadpool/types.idl
@@ -0,0 +1,40 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * 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.
+ *
+ * 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).
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "com/sun/star/uno/XInterface.idl"
+
+module test { module javauno { module nativethreadpool {
+
+interface XSource: com::sun::star::uno::XInterface {
+ long get();
+};
+
+interface XRelay: com::sun::star::uno::XInterface {
+ void start([in] XSource source);
+};
+
+}; }; };
diff --git a/bridges/test/java_uno/nativethreadpool/version.map b/bridges/test/java_uno/nativethreadpool/version.map
new file mode 100644
index 000000000000..b560ad15b99f
--- /dev/null
+++ b/bridges/test/java_uno/nativethreadpool/version.map
@@ -0,0 +1,35 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# 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.
+#
+# 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).
+#
+# 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.
+#
+#*************************************************************************
+
+UDK_3_0_0 {
+ global:
+ component_getFactory;
+ component_getImplementationEnvironment;
+
+ local:
+ *;
+};