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 com
.sun
.star
.lib
.connections
.pipe
;
21 import com
.sun
.star
.comp
.loader
.FactoryHelper
;
22 import com
.sun
.star
.connection
.ConnectionSetupException
;
23 import com
.sun
.star
.connection
.NoConnectException
;
24 import com
.sun
.star
.connection
.XConnection
;
25 import com
.sun
.star
.connection
.XConnector
;
26 import com
.sun
.star
.lang
.XMultiServiceFactory
;
27 import com
.sun
.star
.lang
.XSingleServiceFactory
;
28 import com
.sun
.star
.registry
.XRegistryKey
;
31 * A component that implements the <code>XConnector</code> interface.
33 * <p>The <code>pipeConnector</code> is a specialized component that uses TCP
34 * pipes for communication. The <code>pipeConnector</code> is generally
35 * used by the <code>com.sun.star.connection.Connector</code> service.</p>
37 * @see com.sun.star.connection.XAcceptor
38 * @see com.sun.star.connection.XConnection
39 * @see com.sun.star.connection.XConnector
40 * @see com.sun.star.comp.loader.JavaLoader
44 public final class pipeConnector
implements XConnector
{
46 * The name of the service.
48 * <p>The <code>JavaLoader</code> accesses this through reflection.</p>
50 * @see com.sun.star.comp.loader.JavaLoader
52 public static final String __serviceName
= "com.sun.star.connection.pipeConnector";
55 * Returns a factory for creating the service.
57 * <p>This method is called by the <code>JavaLoader</code>.</p>
59 * @param implName the name of the implementation for which a service is
61 * @param multiFactory the service manager to be used (if needed).
62 * @param regKey the registry key.
63 * @return an <code>XSingleServiceFactory</code> for creating the component.
65 * @see com.sun.star.comp.loader.JavaLoader
67 public static XSingleServiceFactory
__getServiceFactory(
68 String implName
, XMultiServiceFactory multiFactory
, XRegistryKey regKey
)
70 return implName
.equals(pipeConnector
.class.getName())
71 ? FactoryHelper
.getServiceFactory(pipeConnector
.class,
72 __serviceName
, multiFactory
,
78 * Connects via the described pipe to a waiting server.
80 * <p>The connection description has the following format:
81 * <code><var>type</var></code><!--
82 * -->*(<code><var>key</var>=<var>value</var></code>),
83 * where <code><var>type</var></code> should be <code>pipe</code>
84 * (ignoring case). Supported keys (ignoring case) currently are</p>
86 * <dt><code>host</code>
87 * <dd>The name or address of the server. Must be present.
88 * <dt><code>port</code>
89 * <dd>The TCP port number of the server (defaults to <code>6001</code>).
90 * <dt><code>tcpnodelay</code>
91 * <dd>A flag (<code>0</code>/<code>1</code>) enabling or disabling Nagle's
92 * algorithm on the resulting connection.
95 * @param connectionDescription the description of the connection.
96 * @return an <code>XConnection</code> to the server.
98 * @see com.sun.star.connection.XAcceptor
99 * @see com.sun.star.connection.XConnection
101 public synchronized XConnection
connect(String connectionDescription
)
102 throws NoConnectException
, ConnectionSetupException
105 throw new ConnectionSetupException("alread connected");
108 XConnection xConn
= new PipeConnection( connectionDescription
);
111 } catch ( java
.io
.IOException e
) {
112 throw new NoConnectException(e
);
116 private boolean bConnected
= false;