Hi folks,
I've been sitting on this one for a while. Now that we are close to
finishing v 1.0, its time to bring it out ! It's not really a big
refactoring, but it could have some benefits in clarity and being able
to extend RemoteEndpoint functionality in the future in a more organized
way.
I'm on the fence about it, and would appreciate some other opinions.
The proposal is to divide up the functionality on the RemoteEndpoint
interface into a RemoteEndpoint.Basic interface devoted to synchronous
processing, and a RemoteEndpoint.Async devoted to async processing, and
a common super interface RemoteEndpoint for functions common to both.
Probably the container would use the same object to represent both: its
really a cosmetic change.
Instead of:-
OLD: Session: RemoteEndpoint getRemoteEndpoint(), we would have
NEW: Session: T getRemoteEndpoint(T extends RemoteEndpoint);
So, T could be RemoteEndpoint.Basic or RemoteEndpoint.Async.
Here's a full listing of the NEW API under the proposal, and below that
is the OLD (existing) API.
public interface NewRemoteEndpoint {
void setBatchingAllowed(boolean allowed) throws IOException;
boolean getBatchingAllowed();
void flushBatch() throws IOException;
public interface Async extends NewRemoteEndpoint {
long getAsyncSendTimeout();
void setAsyncSendTimeout(long timeoutmillis);
void sendStringByCompletion(String text, SendHandler completion);
Future<SendResult> sendStringByFuture(String text);
Future<SendResult> sendBytesByFuture(ByteBuffer data);
void sendBytesByCompletion(ByteBuffer data, SendHandler
completion);
Future<SendResult> sendObjectByFuture(Object o);
void sendObjectByCompletion(Object o, SendHandler handler);
}
public interface Basic extends NewRemoteEndpoint {
void sendString(String text) throws IOException;
void sendBytes(ByteBuffer data) throws IOException;
void sendObject(Object o) throws IOException, EncodeException;
void sendPartialString(String partialMessage, boolean isLast)
throws IOException;
void sendPartialBytes(ByteBuffer partialByte, boolean isLast)
throws IOException; // or Iterable<byte[]>
void sendPing(ByteBuffer applicationData) throws IOException,
IllegalArgumentException;
OutputStream getSendStream() throws IOException;
Writer getSendWriter() throws IOException;
}
public interface RemoteEndpoint {
void setBatchingAllowed(boolean allowed) throws IOException;
boolean getBatchingAllowed();
void flushBatch() throws IOException;
long getAsyncSendTimeout();
void setAsyncSendTimeout(long timeoutmillis);
void sendString(String text) throws IOException;
void sendBytes(ByteBuffer data) throws IOException;
void sendPartialString(String partialMessage, boolean isLast)
throws IOException;
void sendPartialBytes(ByteBuffer partialByte, boolean isLast)
throws IOException; // or Iterable<byte[]>
OutputStream getSendStream() throws IOException;
Writer getSendWriter() throws IOException;
void sendObject(Object o) throws IOException, EncodeException;
void sendStringByCompletion(String text, SendHandler completion);
Future<SendResult> sendStringByFuture(String text);
Future<SendResult> sendBytesByFuture(ByteBuffer data);
void sendBytesByCompletion(ByteBuffer data, SendHandler completion);
Future<SendResult> sendObjectByFuture(Object o);
void sendObjectByCompletion(Object o, SendHandler handler);
void sendPing(ByteBuffer applicationData) throws IOException,
IllegalArgumentException;
void sendPong(ByteBuffer applicationData) throws IOException,
IllegalArgumentException;
}
--
<http://www.oracle.com> *Danny Coward *
Java EE
Oracle Corporation