xref: /AOO41X/main/jurt/com/sun/star/lib/connections/pipe/pipeAcceptor.java (revision 2be432768a66cc90838f6a32e76ec156f587e741)
1*2be43276SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2be43276SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2be43276SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2be43276SAndrew Rist  * distributed with this work for additional information
6*2be43276SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2be43276SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2be43276SAndrew Rist  * "License"); you may not use this file except in compliance
9*2be43276SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*2be43276SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*2be43276SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2be43276SAndrew Rist  * software distributed under the License is distributed on an
15*2be43276SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2be43276SAndrew Rist  * KIND, either express or implied.  See the License for the
17*2be43276SAndrew Rist  * specific language governing permissions and limitations
18*2be43276SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*2be43276SAndrew Rist  *************************************************************/
21*2be43276SAndrew Rist 
22*2be43276SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir package com.sun.star.lib.connections.pipe;
25cdf0e10cSrcweir 
26cdf0e10cSrcweir import com.sun.star.comp.loader.FactoryHelper;
27cdf0e10cSrcweir import com.sun.star.connection.AlreadyAcceptingException;
28cdf0e10cSrcweir import com.sun.star.connection.ConnectionSetupException;
29cdf0e10cSrcweir import com.sun.star.connection.XAcceptor;
30cdf0e10cSrcweir import com.sun.star.connection.XConnection;
31cdf0e10cSrcweir import com.sun.star.lang.XMultiServiceFactory;
32cdf0e10cSrcweir import com.sun.star.lang.XSingleServiceFactory;
33cdf0e10cSrcweir import com.sun.star.registry.XRegistryKey;
34cdf0e10cSrcweir 
35cdf0e10cSrcweir /**
36cdf0e10cSrcweir  * A component that implements the <code>XAcceptor</code> interface.
37cdf0e10cSrcweir  *
38cdf0e10cSrcweir  * <p>The <code>pipeAcceptor</code> is a specialized component that uses TCP
39cdf0e10cSrcweir  * pipes for communication.  The <code>pipeAcceptor</code> is generally used
40cdf0e10cSrcweir  * by the <code>com.sun.star.connection.Acceptor</code> service.</p>
41cdf0e10cSrcweir  *
42cdf0e10cSrcweir  * @see com.sun.star.connections.XAcceptor
43cdf0e10cSrcweir  * @see com.sun.star.connections.XConnection
44cdf0e10cSrcweir  * @see com.sun.star.connections.XConnector
45cdf0e10cSrcweir  * @see com.sun.star.loader.JavaLoader
46cdf0e10cSrcweir  *
47cdf0e10cSrcweir  * @since UDK 1.0
48cdf0e10cSrcweir  */
49cdf0e10cSrcweir public final class pipeAcceptor implements XAcceptor {
50cdf0e10cSrcweir     /**
51cdf0e10cSrcweir      * The name of the service.
52cdf0e10cSrcweir      *
53cdf0e10cSrcweir      * <p>The <code>JavaLoader</code> acceses this through reflection.</p>
54cdf0e10cSrcweir      *
55cdf0e10cSrcweir      * @see com.sun.star.comp.loader.JavaLoader
56cdf0e10cSrcweir      */
57cdf0e10cSrcweir     public static final String __serviceName
58cdf0e10cSrcweir     = "com.sun.star.connection.pipeAcceptor";
59cdf0e10cSrcweir 
60cdf0e10cSrcweir     /**
61cdf0e10cSrcweir      * Returns a factory for creating the service.
62cdf0e10cSrcweir      *
63cdf0e10cSrcweir      * <p>This method is called by the <code>JavaLoader</code>.</p>
64cdf0e10cSrcweir      *
65cdf0e10cSrcweir      * @param implName the name of the implementation for which a service is
66cdf0e10cSrcweir      *     requested.
67cdf0e10cSrcweir      * @param multiFactory the service manager to be used (if needed).
68cdf0e10cSrcweir      * @param regKey the registry key.
69cdf0e10cSrcweir      * @return an <code>XSingleServiceFactory</code> for creating the component.
70cdf0e10cSrcweir      *
71cdf0e10cSrcweir      * @see com.sun.star.comp.loader.JavaLoader
72cdf0e10cSrcweir      */
__getServiceFactory( String implName, XMultiServiceFactory multiFactory, XRegistryKey regKey)73cdf0e10cSrcweir     public static XSingleServiceFactory __getServiceFactory(
74cdf0e10cSrcweir         String implName, XMultiServiceFactory multiFactory, XRegistryKey regKey)
75cdf0e10cSrcweir     {
76cdf0e10cSrcweir         return implName.equals(pipeAcceptor.class.getName())
77cdf0e10cSrcweir             ? FactoryHelper.getServiceFactory(
78cdf0e10cSrcweir 		pipeAcceptor.class, __serviceName, multiFactory, regKey)
79cdf0e10cSrcweir             : null;
80cdf0e10cSrcweir     }
81cdf0e10cSrcweir 
82cdf0e10cSrcweir     /**
83cdf0e10cSrcweir      * Accepts a connection request via the described pipe.
84cdf0e10cSrcweir      *
85cdf0e10cSrcweir      * <p>This call blocks until a connection has been established.</p>
86cdf0e10cSrcweir      *
87cdf0e10cSrcweir      * <p>The connection description has the following format:
88cdf0e10cSrcweir      * <code><var>type</var></code><!--
89cdf0e10cSrcweir      *     -->*(<code><var>key</var>=<var>value</var></code>),
90cdf0e10cSrcweir      * where <code><var>type</var></code> should be <code>pipe</code>
91cdf0e10cSrcweir      * (ignoring case).  Supported keys (ignoring case) currently are
92cdf0e10cSrcweir      * <dl>
93cdf0e10cSrcweir      * <dt><code>host</code>
94cdf0e10cSrcweir      * <dd>The name or address of the accepting interface (defaults to
95cdf0e10cSrcweir      *     <code>0</code>, meaning any interface).
96cdf0e10cSrcweir      * <dt><code>port</code>
97cdf0e10cSrcweir      * <dd>The TCP port number to accept on (defaults to <code>6001</code>).
98cdf0e10cSrcweir      * <dt><code>backlog</code>
99cdf0e10cSrcweir      * <dd>The maximum length of the acceptor's queue (defaults to
100cdf0e10cSrcweir      *     <code>50</code>).
101cdf0e10cSrcweir      * <dt><code>tcpnodelay</code>
102cdf0e10cSrcweir      * <dd>A flag (<code>0</code>/<code>1</code>) enabling or disabling Nagle's
103cdf0e10cSrcweir      *     algorithm on the resulting connection.
104cdf0e10cSrcweir      * </dl></p>
105cdf0e10cSrcweir      *
106cdf0e10cSrcweir      * @param connectionDescription the description of the connection.
107cdf0e10cSrcweir      * @return an <code>XConnection</code> to the client.
108cdf0e10cSrcweir      *
109cdf0e10cSrcweir      * @see com.sun.star.connections.XConnection
110cdf0e10cSrcweir      * @see com.sun.star.connections.XConnector
111cdf0e10cSrcweir      */
accept(String connectionDescription)112cdf0e10cSrcweir     public XConnection accept(String connectionDescription) throws
113cdf0e10cSrcweir         AlreadyAcceptingException, ConnectionSetupException,
114cdf0e10cSrcweir         com.sun.star.lang.IllegalArgumentException
115cdf0e10cSrcweir     {
116cdf0e10cSrcweir 	throw new java.lang.NoSuchMethodError( "pipeAcceptor not fully implemented yet" );
117cdf0e10cSrcweir 
118cdf0e10cSrcweir 	//try { return new PipeConnection( connectionDescription ); }
119cdf0e10cSrcweir 	//catch ( java.io.IOException e ) { return null; }
120cdf0e10cSrcweir     }
121cdf0e10cSrcweir 
122cdf0e10cSrcweir     // see com.sun.star.connection.XAcceptor#stopAccepting
stopAccepting()123cdf0e10cSrcweir     public void stopAccepting() {
124cdf0e10cSrcweir     }
125cdf0e10cSrcweir 
126cdf0e10cSrcweir     private static final boolean DEBUG = false;
127cdf0e10cSrcweir }
128