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
.java
.javaclient
;
21 import com
.sun
.star
.bridge
.XBridge
;
22 import com
.sun
.star
.bridge
.XBridgeFactory
;
23 import com
.sun
.star
.comp
.helper
.Bootstrap
;
24 import com
.sun
.star
.connection
.Connector
;
25 import com
.sun
.star
.lang
.XComponent
;
26 import com
.sun
.star
.lib
.uno
.helper
.UnoUrl
;
27 import com
.sun
.star
.uno
.UnoRuntime
;
28 import com
.sun
.star
.uno
.XComponentContext
;
29 import test
.types
.Data
;
30 import test
.types
.XServer
;
32 public final class JavaClient
{
33 public static void main(String
[] arguments
) throws Exception
{
34 XComponentContext context
= Bootstrap
.createInitialComponentContext(
36 XBridgeFactory factory
= UnoRuntime
.queryInterface(
38 context
.getServiceManager().createInstanceWithContext(
39 "com.sun.star.bridge.BridgeFactory", context
));
40 if (factory
== null) {
41 throw new NullPointerException("no bridge factory");
43 UnoUrl url
= UnoUrl
.parseUnoUrl(arguments
[0]);
44 XBridge bridge
= factory
.createBridge(
45 "", url
.getProtocolAndParametersAsString(),
46 Connector
.create(context
).connect(
47 url
.getConnectionAndParametersAsString()),
49 Data d
= UnoRuntime
.queryInterface(
50 XServer
.class, bridge
.getInstance(url
.getRootOid())).getData();
51 UnoRuntime
.queryInterface(XComponent
.class, bridge
).dispose();
52 if (!d
.m1
.equals("Hello") || d
.m2
!= 42) {
53 throw new RuntimeException("Data object contains bad values");
57 private JavaClient() {}