com.sun.jini.discovery.internal
Class EndpointBasedClient

java.lang.Object
  extended by com.sun.jini.discovery.internal.BaseProvider
      extended by com.sun.jini.discovery.internal.EndpointBasedProvider
          extended by com.sun.jini.discovery.internal.EndpointBasedClient
All Implemented Interfaces:
DiscoveryFormatProvider, UnicastDiscoveryClient
Direct Known Subclasses:
Client.ClientImpl, Client.ClientImpl

public abstract class EndpointBasedClient
extends EndpointBasedProvider
implements UnicastDiscoveryClient

Provides an abstract endpoint-based UnicastDiscoveryClient implementation, which serves as a superclass for client-side providers for the net.jini.discovery.ssl and net.jini.discovery.kerberos unicast discovery formats.


Nested Class Summary
private static class EndpointBasedClient.ConnectionInfo
          Components for initiating a connection.
private static class EndpointBasedClient.ConnManagerFactoryImpl
          Factory which produces connection managers that capture the OutboundRequestHandle and ConnectionEndpoint instances used to initiate connections, and then return empty OutboundRequestIterators.
private static class EndpointBasedClient.PrearrangedSocketFactory
          Socket factory which returns a prearranged socket.
 
Field Summary
 
Fields inherited from class com.sun.jini.discovery.internal.EndpointBasedProvider
endpointInternals
 
Fields inherited from class com.sun.jini.discovery.internal.BaseProvider
formatName
 
Constructor Summary
protected EndpointBasedClient(String formatName, EndpointInternals endpointInternals)
          Constructs instance with the given format name and object providing access to non-public endpoint operations.
 
Method Summary
 void checkUnicastDiscoveryConstraints(InvocationConstraints constraints)
          Checks and returns normally if this client is capable of fulfilling the given absolute constraints.
 UnicastResponse doUnicastDiscovery(Socket socket, InvocationConstraints constraints, ClassLoader defaultLoader, ClassLoader verifierLoader, Collection context, ByteBuffer sent, ByteBuffer received)
          Performs the client side of unicast discovery, obtaining the returned response data over the provided socket using the given default and codebase verifier class loaders and collection of object stream context objects in a manner that satisfies the specified absolute constraints.
private  EndpointBasedClient.ConnectionInfo getConnectionInfo(Socket socket, InvocationConstraints constraints)
          Returns components needed to initiate a connection over the given socket in accordance with the specified constraints.
protected abstract  Endpoint getEndpoint(SocketFactory factory, InvocationConstraints constraints)
          Returns an endpoint which uses the given socket factory, if non-null, and may incorporate information (such as the expected server principal) from the given set of constraints, if non-null.
 
Methods inherited from class com.sun.jini.discovery.internal.EndpointBasedProvider
calcHandshakeHash, checkIntegrity
 
Methods inherited from class com.sun.jini.discovery.internal.BaseProvider
getFormatName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.sun.jini.discovery.DiscoveryFormatProvider
getFormatName
 

Constructor Detail

EndpointBasedClient

protected EndpointBasedClient(String formatName,
                              EndpointInternals endpointInternals)
Constructs instance with the given format name and object providing access to non-public endpoint operations.

Method Detail

checkUnicastDiscoveryConstraints

public void checkUnicastDiscoveryConstraints(InvocationConstraints constraints)
                                      throws UnsupportedConstraintException
Description copied from interface: UnicastDiscoveryClient
Checks and returns normally if this client is capable of fulfilling the given absolute constraints. null constraints are considered equivalent to empty constraints.

Specified by:
checkUnicastDiscoveryConstraints in interface UnicastDiscoveryClient
Parameters:
constraints - the constraints to check, or null
Throws:
UnsupportedConstraintException - if unable to satisfy the specified constraints

doUnicastDiscovery

public UnicastResponse doUnicastDiscovery(Socket socket,
                                          InvocationConstraints constraints,
                                          ClassLoader defaultLoader,
                                          ClassLoader verifierLoader,
                                          Collection context,
                                          ByteBuffer sent,
                                          ByteBuffer received)
                                   throws IOException,
                                          ClassNotFoundException
Description copied from interface: UnicastDiscoveryClient
Performs the client side of unicast discovery, obtaining the returned response data over the provided socket using the given default and codebase verifier class loaders and collection of object stream context objects in a manner that satisfies the specified absolute constraints. Byte buffers containing the data sent and received so far over the given socket (for the unicast discovery protocol 2 handshake) are provided for use by formats which integrity protect or otherwise incorporate the handshake data. null constraints are considered equivalent to empty constraints.

Specified by:
doUnicastDiscovery in interface UnicastDiscoveryClient
Parameters:
socket - the socket on which to perform unicast discovery
constraints - the constraints to apply to unicast discovery, or null
defaultLoader - the class loader value (possibly null) to be passed as the defaultLoader argument to RMIClassLoader methods when unmarshalling the registrar proxy
verifierLoader - the class loader value (possibly null) to pass to Security.verifyCodebaseIntegrity, if codebase integrity verification is used when unmarshalling the registrar proxy
context - the collection of context information objects (possibly null) to use when unmarshalling the registrar proxy
sent - a buffer containing the data already sent
received - a buffer containing the data already received
Returns:
the received unicast response data
Throws:
IOException - if an error occurs in interpreting received data or in formatting data to send
UnsupportedConstraintException - if unable to satisfy the specified constraints
ClassNotFoundException - if the class of the discovered registrar cannot be resolved

getEndpoint

protected abstract Endpoint getEndpoint(SocketFactory factory,
                                        InvocationConstraints constraints)
                                 throws UnsupportedConstraintException
Returns an endpoint which uses the given socket factory, if non-null, and may incorporate information (such as the expected server principal) from the given set of constraints, if non-null. Other parameters of the endpoint, such as the target host and port, are irrelevant from the standpoint of this class and can be chosen arbitrarily. Throws an UnsupportedConstraintException if the given constraints lack information needed to construct the endpoint.

Throws:
UnsupportedConstraintException

getConnectionInfo

private EndpointBasedClient.ConnectionInfo getConnectionInfo(Socket socket,
                                                             InvocationConstraints constraints)
                                                      throws UnsupportedConstraintException
Returns components needed to initiate a connection over the given socket in accordance with the specified constraints.

Throws:
UnsupportedConstraintException


Copyright 2007-2010, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.