org.eodisp.remote.jeri.jxta
Class JxtaServerEndpoint

java.lang.Object
  extended by org.eodisp.remote.jeri.jxta.JxtaServerEndpoint
All Implemented Interfaces:
net.jini.jeri.ServerCapabilities, net.jini.jeri.ServerEndpoint

public final class JxtaServerEndpoint
extends java.lang.Object
implements net.jini.jeri.ServerEndpoint

An implementation of the ServerEndpoint abstraction that uses JXTA sockets (instances of JxtaServerSocket) for the underlying communication mechanism.

Most of the implementation was copied from the the TcpServerEndpoint class.

All TcpServerEndpoint instances in the same JVM use the same peer and peer group advertisement. This information is statically received from JxtaNetwork.

JxtaServerEndpoint uses the Jini(TM) extensible remote invocation (Jini ERI) multiplexing protocol to map incoming requests to socket connections.

Author:
ibirrer
See Also:
JxtaEndpoint

Nested Class Summary
 
Nested classes/interfaces inherited from interface net.jini.jeri.ServerEndpoint
net.jini.jeri.ServerEndpoint.ListenContext, net.jini.jeri.ServerEndpoint.ListenCookie, net.jini.jeri.ServerEndpoint.ListenEndpoint, net.jini.jeri.ServerEndpoint.ListenHandle
 
Method Summary
 net.jini.core.constraint.InvocationConstraints checkConstraints(net.jini.core.constraint.InvocationConstraints constraints)
          
 net.jini.jeri.Endpoint enumerateListenEndpoints(net.jini.jeri.ServerEndpoint.ListenContext listenContext)
          Passes the ListenEndpoint for this JxtaServerEndpoint to listenContext, which will ensure an active listen operation on the endpoint, and returns a JxtaEndpoint instance corresponding to the listen operation chosen by listenContext.
 boolean equals(java.lang.Object obj)
          Compares the specified object with this JxtaServerEndpoint for equality.
static JxtaServerEndpoint getInstance()
          Returns a JxtaServerEndpoint instance.
 int hashCode()
          Returns the hash code value for this JxtaServerEndpoint.
 java.lang.String toString()
          Returns a string representation of this JxtaServerEndpoint.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

getInstance

public static JxtaServerEndpoint getInstance()
Returns a JxtaServerEndpoint instance. All information about the peer and peer group is obtained statically from the JxtaNetwork class.

Returns:
a JxtaServerEndpoint instance

checkConstraints

public net.jini.core.constraint.InvocationConstraints checkConstraints(net.jini.core.constraint.InvocationConstraints constraints)
                                                                throws net.jini.io.UnsupportedConstraintException

Specified by:
checkConstraints in interface net.jini.jeri.ServerCapabilities
Throws:
java.lang.NullPointerException
net.jini.io.UnsupportedConstraintException

enumerateListenEndpoints

public net.jini.jeri.Endpoint enumerateListenEndpoints(net.jini.jeri.ServerEndpoint.ListenContext listenContext)
                                                throws java.io.IOException
Passes the ListenEndpoint for this JxtaServerEndpoint to listenContext, which will ensure an active listen operation on the endpoint, and returns a JxtaEndpoint instance corresponding to the listen operation chosen by listenContext.

This method invokes addListenEndpoint on listenContext once, passing a ListenEndpoint as described below. If addListenEndpoint throws an exception, then this method throws that exception. Otherwise, this method returns a JxtaEndpoint instance.

The ListenEndpoint passed to addListenEndpoint behaves as follows:

ListenHandle listen(RequestDispatcher):

Listens for requests received on this endpoint, dispatching them to the supplied RequestDispatcher in the form of InboundRequest instances.

When the implementation of this method needs to create a new ServerSocket, it will do so by creating a new JxtaServerSocket with the following arguments: JxtaNetwork.getJeriPeerGroup() and JxtaNetwork.getJeriPipeAdvertisement().

Requests will be dispatched in a PrivilegedAction wrapped by a SecurityContext obtained when this method was invoked, with the AccessControlContext of that SecurityContext in effect.

Dispatched requests will implement populateContext to populate the given collection with an element that implements the ClientHost interface. That ClientHost element implements getClientHost to return the IP address of the Socket that the request was received over (see Socket.getInetAddress()).

Throws IOException if an I/O exception occurs while performing this operation.

Throws NullPointerException if requestDispatcher is null

void checkPermissions():

Does not do any checks at all.

boolean equals(Object):

Compares the specified object with this ListenEndpoint for equality.

This method returns true if and only if the specified object is also a ListenEndpoint produced by a JxtaServerEndpoint and is not null.

Specified by:
enumerateListenEndpoints in interface net.jini.jeri.ServerEndpoint
Parameters:
listenContext - the ListenContext to pass this JxtaServerEndpoint's ListenEndpoint to
Returns:
the JxtaEndpoint instance for sending requests to this JxtaServerEndpoint's endpoint being listened on
Throws:
java.io.IOException - if an I/O exception occurs while performing this operation
java.lang.IllegalArgumentException
java.lang.NullPointerException

hashCode

public int hashCode()
Returns the hash code value for this JxtaServerEndpoint. Always returns the same value, because all JxtaServerEndpoints are the same.

Overrides:
hashCode in class java.lang.Object
Returns:
the hash code value for this JxtaServerEndpoint. Always returns 1.

equals

public boolean equals(java.lang.Object obj)
Compares the specified object with this JxtaServerEndpoint for equality.

This method returns true if and only if the specified object is also a JxtaServerEndpoint and is not null.

Overrides:
equals in class java.lang.Object
Parameters:
obj - the object to compare with
Returns:
true if obj is equivalent to this object; false otherwise

toString

public java.lang.String toString()
Returns a string representation of this JxtaServerEndpoint.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of this JxtaServerEndpoint