1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: pipeAcceptor.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package com
.sun
.star
.lib
.connections
.pipe
;
33 import com
.sun
.star
.comp
.loader
.FactoryHelper
;
34 import com
.sun
.star
.connection
.AlreadyAcceptingException
;
35 import com
.sun
.star
.connection
.ConnectionSetupException
;
36 import com
.sun
.star
.connection
.XAcceptor
;
37 import com
.sun
.star
.connection
.XConnection
;
38 import com
.sun
.star
.lang
.XMultiServiceFactory
;
39 import com
.sun
.star
.lang
.XSingleServiceFactory
;
40 import com
.sun
.star
.registry
.XRegistryKey
;
43 * A component that implements the <code>XAcceptor</code> interface.
45 * <p>The <code>pipeAcceptor</code> is a specialized component that uses TCP
46 * pipes for communication. The <code>pipeAcceptor</code> is generally used
47 * by the <code>com.sun.star.connection.Acceptor</code> service.</p>
49 * @see com.sun.star.connections.XAcceptor
50 * @see com.sun.star.connections.XConnection
51 * @see com.sun.star.connections.XConnector
52 * @see com.sun.star.loader.JavaLoader
56 public final class pipeAcceptor
implements XAcceptor
{
58 * The name of the service.
60 * <p>The <code>JavaLoader</code> acceses this through reflection.</p>
62 * @see com.sun.star.comp.loader.JavaLoader
64 public static final String __serviceName
65 = "com.sun.star.connection.pipeAcceptor";
68 * Returns a factory for creating the service.
70 * <p>This method is called by the <code>JavaLoader</code>.</p>
72 * @param implName the name of the implementation for which a service is
74 * @param multiFactory the service manager to be used (if needed).
75 * @param regKey the registry key.
76 * @return an <code>XSingleServiceFactory</code> for creating the component.
78 * @see com.sun.star.comp.loader.JavaLoader
80 public static XSingleServiceFactory
__getServiceFactory(
81 String implName
, XMultiServiceFactory multiFactory
, XRegistryKey regKey
)
83 return implName
.equals(pipeAcceptor
.class.getName())
84 ? FactoryHelper
.getServiceFactory(
85 pipeAcceptor
.class, __serviceName
, multiFactory
, regKey
)
90 * Writes the service information into the given registry key.
92 * <p>This method is called by the <code>JavaLoader</code>.</p>
94 * @param regKey the registry key.
95 * @return <code>true</code> if the operation succeeded.
97 * @see com.sun.star.comp.loader.JavaLoader
99 public static boolean __writeRegistryServiceInfo(XRegistryKey regKey
) {
100 return FactoryHelper
.writeRegistryServiceInfo(
101 pipeAcceptor
.class.getName(), __serviceName
, regKey
);
105 * Accepts a connection request via the described pipe.
107 * <p>This call blocks until a connection has been established.</p>
109 * <p>The connection description has the following format:
110 * <code><var>type</var></code><!--
111 * -->*(<code><var>key</var>=<var>value</var></code>),
112 * where <code><var>type</var></code> should be <code>pipe</code>
113 * (ignoring case). Supported keys (ignoring case) currently are
115 * <dt><code>host</code>
116 * <dd>The name or address of the accepting interface (defaults to
117 * <code>0</code>, meaning any interface).
118 * <dt><code>port</code>
119 * <dd>The TCP port number to accept on (defaults to <code>6001</code>).
120 * <dt><code>backlog</code>
121 * <dd>The maximum length of the acceptor's queue (defaults to
123 * <dt><code>tcpnodelay</code>
124 * <dd>A flag (<code>0</code>/<code>1</code>) enabling or disabling Nagle's
125 * algorithm on the resulting connection.
128 * @param connectionDescription the description of the connection.
129 * @return an <code>XConnection</code> to the client.
131 * @see com.sun.star.connections.XConnection
132 * @see com.sun.star.connections.XConnector
134 public XConnection
accept(String connectionDescription
) throws
135 AlreadyAcceptingException
, ConnectionSetupException
,
136 com
.sun
.star
.lang
.IllegalArgumentException
138 throw new java
.lang
.NoSuchMethodError( "pipeAcceptor not fully implemented yet" );
140 //try { return new PipeConnection( connectionDescription ); }
141 //catch ( java.io.IOException e ) { return null; }
144 // see com.sun.star.connection.XAcceptor#stopAccepting
145 public void stopAccepting() {
148 private static final boolean DEBUG
= false;