KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > corba > se > pept > transport > Acceptor


1 /*
2  * @(#)Acceptor.java 1.21 04/06/21
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package com.sun.corba.se.pept.transport;
9
10 import com.sun.corba.se.pept.broker.Broker;
11 import com.sun.corba.se.pept.protocol.MessageMediator;
12 import com.sun.corba.se.pept.encoding.InputObject;
13 import com.sun.corba.se.pept.encoding.OutputObject;
14 import com.sun.corba.se.pept.transport.Connection;
15 import com.sun.corba.se.pept.transport.EventHandler;
16
17 /**
18  * <p>The <b><em>primary</em></b> PEPt server-side plug-in point and enabler
19  * for <b><em>altenate encodings, protocols and transports</em></b>.</p>
20  *
21  * <p><code>Acceptor</code> is a <em>factory</em> for client-side
22  * artifacts used to receive a message (and possibly send a response).</p>
23  *
24  * @author Harold Carr
25  */

26 public interface Acceptor
27 {
28     /**
29      * Used to initialize an <code>Acceptor</code>.
30      *
31      * For example, initialization may mean to create a
32      * {@link java.nio.channels.ServerSocketChannel ServerSocketChannel}.
33      *
34      * Note: this must be prepared to be be called multiple times.
35      *
36      * @return <code>true</code> when it performs initializatin
37      * actions (typically the first call.
38      */

39     public boolean initialize();
40
41     /**
42      * Used to determine if an <code>Acceptor</code> has been initialized.
43      *
44      * @return <code>true</code. if the <code>Acceptor</code> has been
45      * initialized.
46      */

47     public boolean initialized();
48
49     /**
50      * PEPt uses separate caches for each type of <code>Acceptor</code>
51      * as given by <code>getConnectionCacheType</code>.
52      *
53      * @return {@link java.lang.String}
54      */

55     public String JavaDoc getConnectionCacheType();
56
57     /**
58      * Set the
59      * {@link com.sun.corba.se.pept.transport.Inbound.ConnectionCache InboundConnectionCache}
60      * to be used by this <code>Acceptor</code>.
61      *
62      * PEPt uses separate caches for each type of <code>Acceptor</code>
63      * as given by {@link #getConnectionCacheType}.
64      * {@link #setConnectionCache} and {@link #getConnectionCache} support
65      * an optimzation to avoid hashing to find that cache.
66      *
67      * @param connectionCache.
68      */

69     public void setConnectionCache(InboundConnectionCache connectionCache);
70
71     /**
72      * Get the
73      * {@link com.sun.corba.se.pept.transport.Inbound.ConnectionCache InboundConnectionCache}
74      * used by this <code>Acceptor</code>
75      *
76      * PEPt uses separate caches for each type of <code>Acceptor</code>
77      * as given by {@link #getConnectionCacheType}.
78      * {@link #setConnectionCache} and {@link #getConnectionCache} support
79      * an optimzation to avoid hashing to find that cache.
80      *
81      * @return
82      * {@link com.sun.corba.se.pept.transport.ConnectionCache ConnectionCache}
83      */

84     public InboundConnectionCache getConnectionCache();
85
86     /**
87      * Used to determine if the <code>Acceptor</code> should register
88      * with
89      * {@link com.sun.corba.se.pept.transport.Selector Selector}
90      * to handle accept events.
91      *
92      * For example, this may be <em>false</em> in the case of Solaris Doors
93      * which do not actively listen.
94      *
95      * @return <code>true</code> if the <code>Acceptor</code> should be
96      * registered with
97      * {@link com.sun.corba.se.pept.transport.Selector Selector}
98      */

99     public boolean shouldRegisterAcceptEvent();
100
101     /**
102      * Accept a connection request.
103      *
104      * This is called either when the selector gets an accept event
105      * for this <code>Acceptor</code> or by a
106      * {@link com.sun.corba.se.pept.transport.ListenerThread ListenerThread}.
107      *
108      * It results in a
109      * {@link com.sun.corba.se.pept.transport.Connection Connection}
110      * being created.
111      */

112     public void accept();
113
114     /**
115      * Close the <code>Acceptor</code>.
116      */

117     public void close();
118
119     /**
120      * Get the
121      * {@link com.sun.corba.se.pept.transport.EventHandler EventHandler}
122      * associated with this <code>Acceptor</code>.
123      *
124      * @return
125      * {@link com.sun.corba.se.pept.transport.EventHandler EventHandler}
126      */

127     public EventHandler getEventHandler();
128
129     //
130
// Factory methods
131
//
132

133     // REVISIT: Identical to ContactInfo method. Refactor into base interface.
134

135     /**
136      * Used to get a
137      * {@link com.sun.corba.se.pept.protocol.MessageMeidator MessageMediator}
138      * to hold internal data for a message received using the specific
139      * encoding, protocol, transport combination represented by this
140      * <code>Acceptor</code>.
141      *
142      * @return
143      * {@link com.sun.corba.se.pept.protocol.MessageMeidator MessageMediator}
144      */

145     public MessageMediator createMessageMediator(Broker xbroker,
146                          Connection xconnection);
147
148     // REVISIT: Identical to ContactInfo method. Refactor into base interface.
149

150     /**
151      * Used to finish creating a
152      * {@link com.sun.corba.se.pept.protocol.MessageMeidator MessageMediator}
153      * to with internal data for a message received using the specific
154      * encoding, protocol, transport combination represented by this
155      * <code>Acceptor</code>.
156      *
157      * @return
158      * {@link com.sun.corba.se.pept.protocol.MessageMediator MessageMediator}
159      */

160
161     public MessageMediator finishCreatingMessageMediator(Broker broker,
162                                                          Connection xconnection,
163                                  MessageMediator messageMediator);
164
165     /**
166      * Used to get a
167      * {@link com.sun.corba.se.pept.encoding.InputObject InputObject}
168      * for the specific <em>encoding</em> represented by this
169      * <code>Acceptor</code>.
170      *
171      * @return
172      * {@link com.sun.corba.se.pept.encoding.InputObject InputObject}
173      */

174     public InputObject createInputObject(Broker broker,
175                      MessageMediator messageMediator);
176
177     /**
178      * Used to get a
179      * {@link com.sun.corba.se.pept.encoding.OutputObject OutputObject}
180      * for the specific <em>encoding</em> represented by this
181      * <code>Acceptor</code>.
182      *
183      * @return
184      * {@link com.sun.corba.se.pept.encoding.OutputObject OutputObject}
185      */

186     public OutputObject createOutputObject(Broker broker,
187                        MessageMediator messageMediator);
188
189     //
190
// Usage dictates implementation equals and hashCode.
191
//
192
}
193
194 // End of file.
195
Popular Tags