com.sun.jini.discovery
Class DiscoveryV1

java.lang.Object
  extended by com.sun.jini.discovery.Discovery
      extended by com.sun.jini.discovery.DiscoveryV1

 class DiscoveryV1
extends Discovery

Class providing methods for implementing discovery protocol version 1.


Field Summary
private static DiscoveryV1 instance
           
private static Logger logger
           
private static int SERVICE_ID_LEN
           
 
Fields inherited from class com.sun.jini.discovery.Discovery
MIN_MAX_PACKET_SIZE, PROTOCOL_VERSION_1, PROTOCOL_VERSION_2
 
Constructor Summary
DiscoveryV1()
           
 
Method Summary
private static void checkConstraints(InvocationConstraints constraints)
           
 MulticastAnnouncement decodeMulticastAnnouncement(DatagramPacket packet, InvocationConstraints constraints)
          Decodes the multicast announcement data contained in the given datagram in a manner that satisfies the specified constraints, returning a MulticastAnnouncement instance that contains the decoded data.
 MulticastRequest decodeMulticastRequest(DatagramPacket packet, InvocationConstraints constraints, ClientSubjectChecker checker)
          Decodes the multicast request data contained in the given datagram in a manner that satisfies the specified constraints and client subject checker (if any), returning a MulticastRequest instance that contains the decoded data.
 UnicastResponse doUnicastDiscovery(Socket socket, InvocationConstraints constraints, ClassLoader defaultLoader, ClassLoader verifierLoader, Collection context)
          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 constraints.
private static DatagramPacket[] encode(MulticastAnnouncement announcement, int maxPacketSize, InvocationConstraints constraints)
           
private static DatagramPacket[] encode(MulticastRequest request, int maxPacketSize, InvocationConstraints constraints)
           
 EncodeIterator encodeMulticastAnnouncement(MulticastAnnouncement announcement, int maxPacketSize, InvocationConstraints constraints)
          Returns an iterator which can be used to encode the given multicast announcement data into sets of DatagramPackets, each bounded in length by the specified maximum packet size, in a manner that satisfies the given constraints.
 EncodeIterator encodeMulticastRequest(MulticastRequest request, int maxPacketSize, InvocationConstraints constraints)
          Returns an iterator which can be used to encode the given multicast request data into sets of DatagramPackets, each bounded in length by the specified maximum packet size, in a manner that satisfies the given constraints.
(package private) static DiscoveryV1 getInstance()
           
 void handleUnicastDiscovery(UnicastResponse response, Socket socket, InvocationConstraints constraints, ClientSubjectChecker checker, Collection context)
          Handles the server side of unicast discovery, transmitting the given response data over the provided socket using the given collection of object stream context objects in a manner that satisfies the specified constraints and client subject checker (if any).
 String toString()
           
 
Methods inherited from class com.sun.jini.discovery.Discovery
decodeMulticastAnnouncement, decodeMulticastRequest, getProtocol1, getProtocol2, getProtocol2
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SERVICE_ID_LEN

private static final int SERVICE_ID_LEN
See Also:
Constant Field Values

instance

private static final DiscoveryV1 instance

logger

private static final Logger logger
Constructor Detail

DiscoveryV1

DiscoveryV1()
Method Detail

getInstance

static DiscoveryV1 getInstance()

encodeMulticastRequest

public EncodeIterator encodeMulticastRequest(MulticastRequest request,
                                             int maxPacketSize,
                                             InvocationConstraints constraints)
Description copied from class: Discovery
Returns an iterator which can be used to encode the given multicast request data into sets of DatagramPackets, each bounded in length by the specified maximum packet size, in a manner that satisfies the given constraints. null constraints are considered equivalent to empty constraints. The destination of each DatagramPacket produced by the returned iterator is set to the address returned by Constants.getRequestAddress(), with the value of Constants.discoveryPort used as the destination port.

Specified by:
encodeMulticastRequest in class Discovery
Parameters:
request - the request data to encode
maxPacketSize - the maximum size of packets to produce
constraints - the constraints to apply when encoding the data, or null
Returns:
an iterator to use for encoding the data

encode

private static DatagramPacket[] encode(MulticastRequest request,
                                       int maxPacketSize,
                                       InvocationConstraints constraints)
                                throws IOException
Throws:
IOException

decodeMulticastRequest

public MulticastRequest decodeMulticastRequest(DatagramPacket packet,
                                               InvocationConstraints constraints,
                                               ClientSubjectChecker checker)
                                        throws IOException
Description copied from class: Discovery
Decodes the multicast request data contained in the given datagram in a manner that satisfies the specified constraints and client subject checker (if any), returning a MulticastRequest instance that contains the decoded data. null constraints are considered equivalent to empty constraints. All the specified constraints are checked before this method returns.

Specified by:
decodeMulticastRequest in class Discovery
Parameters:
packet - the packet to decode
constraints - the constraints to apply when decoding the packet, or null
checker - the object to use to check the client subject, or null
Returns:
the decoded multicast request data
Throws:
IOException - if an error occurs in interpreting the data
UnsupportedConstraintException - if unable to satisfy the specified constraints

encodeMulticastAnnouncement

public EncodeIterator encodeMulticastAnnouncement(MulticastAnnouncement announcement,
                                                  int maxPacketSize,
                                                  InvocationConstraints constraints)
Description copied from class: Discovery
Returns an iterator which can be used to encode the given multicast announcement data into sets of DatagramPackets, each bounded in length by the specified maximum packet size, in a manner that satisfies the given constraints. null constraints are considered equivalent to empty constraints. The destination of each DatagramPacket produced by the returned iterator is set to the address returned by Constants.getAnnouncementAddress(), with the value of Constants.discoveryPort used as the destination port.

Specified by:
encodeMulticastAnnouncement in class Discovery
Parameters:
announcement - the announcement data to encode
maxPacketSize - the maximum size of packets to produce
constraints - the constraints to apply when encoding the data, or null
Returns:
an iterator to use for encoding the data

encode

private static DatagramPacket[] encode(MulticastAnnouncement announcement,
                                       int maxPacketSize,
                                       InvocationConstraints constraints)
                                throws IOException
Throws:
IOException

decodeMulticastAnnouncement

public MulticastAnnouncement decodeMulticastAnnouncement(DatagramPacket packet,
                                                         InvocationConstraints constraints)
                                                  throws IOException
Description copied from class: Discovery
Decodes the multicast announcement data contained in the given datagram in a manner that satisfies the specified constraints, returning a MulticastAnnouncement instance that contains the decoded data. null constraints are considered equivalent to empty constraints. All the specified constraints are checked before this method returns.

Specified by:
decodeMulticastAnnouncement in class Discovery
Parameters:
packet - the packet to decode
constraints - the constraints to apply when decoding the packet, or null
Returns:
the decoded multicast announcement data
Throws:
IOException - if an error occurs in interpreting the data
UnsupportedConstraintException - if unable to satisfy the specified constraints

doUnicastDiscovery

public UnicastResponse doUnicastDiscovery(Socket socket,
                                          InvocationConstraints constraints,
                                          ClassLoader defaultLoader,
                                          ClassLoader verifierLoader,
                                          Collection context)
                                   throws IOException,
                                          ClassNotFoundException
Description copied from class: Discovery
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 constraints. null constraints are considered equivalent to empty constraints.

Specified by:
doUnicastDiscovery in class Discovery
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
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

handleUnicastDiscovery

public void handleUnicastDiscovery(UnicastResponse response,
                                   Socket socket,
                                   InvocationConstraints constraints,
                                   ClientSubjectChecker checker,
                                   Collection context)
                            throws IOException
Description copied from class: Discovery
Handles the server side of unicast discovery, transmitting the given response data over the provided socket using the given collection of object stream context objects in a manner that satisfies the specified constraints and client subject checker (if any). This method assumes that the protocol version number has already been consumed from the socket, but that no further processing of the connection has occurred. null constraints are considered equivalent to empty constraints.

Specified by:
handleUnicastDiscovery in class Discovery
Parameters:
response - the unicast response data to transmit
socket - the socket on which to handle unicast discovery
constraints - the constraints to apply to unicast discovery, or null
checker - the object to use to check the client subject, or null
context - the collection of context information objects to use when marshalling the registrar proxy
Throws:
IOException - if the protocol handshake fails, or if an error occurs in interpreting received data or in formatting data to send
UnsupportedConstraintException - if unable to satisfy the specified constraints

toString

public String toString()
Overrides:
toString in class Object

checkConstraints

private static void checkConstraints(InvocationConstraints constraints)
                              throws UnsupportedConstraintException
Throws:
UnsupportedConstraintException


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