LibreOffice Module ure (master) 1
JavaClient.java
Go to the documentation of this file.
1/*
2 * This file is part of the LibreOffice project.
3 *
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/.
7 *
8 * This file incorporates work covered by the following license notice:
9 *
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 .
17 */
18
19package test.java.javaclient;
20
21import com.sun.star.bridge.XBridge;
22import com.sun.star.bridge.XBridgeFactory;
23import com.sun.star.comp.helper.Bootstrap;
24import com.sun.star.connection.Connector;
25import com.sun.star.lang.XComponent;
26import com.sun.star.lib.uno.helper.UnoUrl;
27import com.sun.star.uno.UnoRuntime;
28import com.sun.star.uno.XComponentContext;
29import test.types.Data;
30import test.types.XServer;
31
32public final class JavaClient {
33 public static void main(String[] arguments) throws Exception {
34 XComponentContext context = Bootstrap.createInitialComponentContext(
35 null);
36 XBridgeFactory factory = UnoRuntime.queryInterface(
37 XBridgeFactory.class,
38 context.getServiceManager().createInstanceWithContext(
39 "com.sun.star.bridge.BridgeFactory", context));
40 if (factory == null) {
41 throw new NullPointerException("no bridge factory");
42 }
43 UnoUrl url = UnoUrl.parseUnoUrl(arguments[0]);
44 XBridge bridge = factory.createBridge(
45 "", url.getProtocolAndParametersAsString(),
46 Connector.create(context).connect(
47 url.getConnectionAndParametersAsString()),
48 null);
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");
54 }
55 }
56
57 private JavaClient() {}
58}
double d
static void main(String[] arguments)
Definition: JavaClient.java:33
@ Exception
const rtl::Bootstrap * Bootstrap()