KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * @(#)Connection.java 1.21 03/12/19
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 java.io.IOException JavaDoc;
11
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.protocol.MessageMediator;
15 import com.sun.corba.se.pept.transport.EventHandler;
16
17
18 /**
19  * <p><code>Connection</code> represents a <em>transport</em> in the
20  * PEPt architecture.</p>
21  *
22  * @author Harold Carr
23 */

24 public interface Connection
25 {
26     /**
27      * Used to determine if the <code>Connection</code> should register
28      * with the
29      * {@link com.sun.corba.se.pept.transport.TransportManager
30      * TransportManager}
31      * {@link com.sun.corba.se.pept.transport.Selector Selector}
32      * to handle read events.
33      *
34      * For example, an HTTP transport would not register since the requesting
35      * thread would just block on read when waiting for the reply.
36      *
37      * @return <code>true</code> if it should be registered.
38      */

39     public boolean shouldRegisterReadEvent();
40
41     /**
42      * Used to determine if the <code>Connection</code> should register
43      * with the
44      * {@link com.sun.corba.se.pept.transport.TransportManager
45      * TransportManager}
46      * {@link com.sun.corba.se.pept.transport.Selector Selector}
47      * to handle read events.
48      *
49      * For example, an HTTP transport would not register since the requesting
50      * thread would just block on read when waiting for the reply.
51      *
52      * @return <code>true</code> if it should be registered.
53      */

54     public boolean shouldRegisterServerReadEvent(); // REVISIT - why special?
55

56     /**
57      * Called to read incoming messages.
58      *
59      * @return <code>true</code> if the thread calling read can be released.
60      */

61     public boolean read();
62
63     /**
64      * Close the <code>Connection</code>.
65      *
66      */

67     public void close();
68
69     // REVISIT: replace next two with PlugInFactory (implemented by ContactInfo
70
// and Acceptor).
71

72     /**
73      * Get the
74      * {@link com.sun.corba.se.pept.transport.Acceptor Acceptor}
75      * that created this <code>Connection</code>.
76      *
77      * @return
78      * {@link com.sun.corba.se.pept.transport.Acceptor Acceptor}
79      */

80     public Acceptor getAcceptor();
81
82     /**
83      * Get the
84      * {@link com.sun.corba.se.pept.transport.ContactInfo ContactInfo}
85      * that created this <code>Connection</code>.
86      *
87      * @return
88      * {@link com.sun.corba.se.pept.transport.ContactInfo ContactInfo}
89      */

90     public ContactInfo getContactInfo();
91
92     /**
93      * Get the
94      * {@link com.sun.corba.se.pept.transport.EventHandler EventHandler}
95      * associated with this <code>Acceptor</code>.
96      *
97      * @return
98      * {@link com.sun.corba.se.pept.transport.EventHandler EventHandler}
99      */

100     public EventHandler getEventHandler();
101
102     /**
103      * Indicates whether a
104      * {@link com.sun.corba.se.pept.transport.ContactInfo ContactInfo}
105      * or a
106      * {@link com.sun.corba.se.pept.transport.Acceptor Acceptor}
107      * created the
108      * <code>Connection</code>.
109      *
110      * @return <code>true</code> if <code>Connection</code> an
111      * {@link com.sun.corba.se.pept.transport.Acceptor Acceptor}
112      * created the <code>Connection</code>.
113      */

114     public boolean isServer();
115
116     /**
117      * Indicates if the <code>Connection</code> is in the process of
118      * sending or receiving a message.
119      *
120      * @return <code>true</code> if the <code>Connection</code> is busy.
121      */

122     public boolean isBusy();
123
124     /**
125      * Timestamps are used for connection management, in particular, for
126      * reclaiming idle <code>Connection</code>s.
127      *
128      * @return the "time" the <code>Connection</code> was last used.
129      */

130     public long getTimeStamp();
131
132     /**
133      * Timestamps are used for connection management, in particular, for
134      * reclaiming idle <code>Connection</code>s.
135      *
136      * @param time - the "time" the <code>Connection</code> was last used.
137      */

138     public void setTimeStamp(long time);
139
140     /**
141      * The "state" of the <code>Connection</code>.
142      *
143      * param state
144      */

145     public void setState(String JavaDoc state);
146
147     /**
148      * Grab a write lock on the <code>Connection</code>.
149      *
150      * If another thread already has a write lock then the calling
151      * thread will block until the lock is released. The calling
152      * thread must call
153      * {@link #writeUnlock}
154      * when it is done.
155      */

156     public void writeLock();
157
158     /**
159      * Release a write lock on the <code>Connection</code>.
160      */

161     public void writeUnlock();
162
163     /*
164      * Send the data encoded in
165      * {@link com.sun.corba.se.pept.encoding.OutputObject OutputObject}
166      * on the <code>Connection</code>.
167      *
168      * @param outputObject
169      */

170     public void sendWithoutLock(OutputObject outputObject);
171
172     /**
173      * Register an invocation's
174      * {@link com.sun.corba.se.pept.protocol.MessageMediator MessageMediator}
175      * with the <code>Connection</code>.
176      *
177      * This is useful in protocols which support fragmentation.
178      *
179      * @param messageMediator
180      */

181     public void registerWaiter(MessageMediator messageMediator);
182
183     /**
184      * If a message expect's a response then this method is called.
185      *
186      * This method might block on a read (e.g., HTTP), put the calling
187      * thread to sleep while another thread read's the response (e.g., GIOP),
188      * or it may use the calling thread to perform the server-side work
189      * (e.g., Solaris Doors).
190      *
191      * @param messageMediator
192      */

193     public InputObject waitForResponse(MessageMediator messageMediator);
194
195     /**
196      * Unregister an invocation's
197      * {@link com.sun.corba.se.pept.protocol.MessageMediator MessageMediator}
198      * with the <code>Connection</code>.
199      *
200      * @param messageMediator
201      */

202     public void unregisterWaiter(MessageMediator messageMediator);
203
204     public void setConnectionCache(ConnectionCache connectionCache);
205
206     public ConnectionCache getConnectionCache();
207 }
208
209 // End of file.
210

211
212
213
214
Popular Tags