Class Discovery
Logging
This implementation uses the Loggers named
com.sun.jini.discovery.DiscoveryV1 and com.sun.jini.discovery.DiscoveryV2
to log information at the following logging levels:
| Level | Description |
|---|---|
FINEST | Encoding and decoding of discovery protocol version 1 multicast requests, multicast announcements, and unicast responses |
| Level | Description |
|---|---|
WARNING | Truncation of unicast request format ID list due to length; discovery format providers that are unusable or have conflicting discovery format IDs |
FINE | Constraint check failures encountered during the unicast discovery handshake when determining a suitable discovery format to use |
FINEST | Encoding and decoding of discovery
protocol version 2 multicast requests, multicast announcements, and unicast responses; also,
access of Discovery instances implementing protocol version 2
|
- Since:
- 2.0
- Author:
- Sun Microsystems, Inc.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe version number for discovery protocol version 1.static final intThe version number for discovery protocol version 2. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract MulticastAnnouncementdecodeMulticastAnnouncement(DatagramPacket packet, InvocationConstraints constraints) Decodes the multicast announcement data contained in the given datagram in a manner that satisfies the specified constraints, returning aMulticastAnnouncementinstance that contains the decoded data.decodeMulticastAnnouncement(DatagramPacket packet, InvocationConstraints constraints, boolean delayConstraintCheck) Decodes the multicast announcement data contained in the given datagram in a manner that satisfies the specified constraints, returning aMulticastAnnouncementinstance that contains the decoded data, with constraint checking optionally delayed.abstract MulticastRequestdecodeMulticastRequest(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 aMulticastRequestinstance that contains the decoded data.decodeMulticastRequest(DatagramPacket packet, InvocationConstraints constraints, ClientSubjectChecker checker, boolean delayConstraintCheck) 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 aMulticastRequestinstance that contains the decoded data, with constraint checking optionally delayed.abstract UnicastResponsedoUnicastDiscovery(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.abstract EncodeIteratorencodeMulticastAnnouncement(MulticastAnnouncement announcement, int maxPacketSize, InvocationConstraints constraints) Returns an iterator which can be used to encode the given multicast announcement data into sets ofDatagramPackets, each bounded in length by the specified maximum packet size, in a manner that satisfies the given constraints.abstract EncodeIteratorencodeMulticastRequest(MulticastRequest request, int maxPacketSize, InvocationConstraints constraints) Returns an iterator which can be used to encode the given multicast request data into sets ofDatagramPackets, each bounded in length by the specified maximum packet size, in a manner that satisfies the given constraints.static DiscoveryReturns an instance implementing protocol version 1.static DiscoverygetProtocol2(MulticastRequestEncoder[] mre, MulticastRequestDecoder[] mrd, MulticastAnnouncementEncoder[] mae, MulticastAnnouncementDecoder[] mad, UnicastDiscoveryClient[] udc, UnicastDiscoveryServer[] uds) Returns an instance implementing protocol version 2 which uses the given providers.static DiscoverygetProtocol2(ClassLoader loader) Returns an instance implementing protocol version 2 which uses providers loaded from the given class loader, or the current context class loader if the given loader isnull.abstract voidhandleUnicastDiscovery(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).
-
Field Details
-
PROTOCOL_VERSION_1
public static final int PROTOCOL_VERSION_1The version number for discovery protocol version 1.- See Also:
-
PROTOCOL_VERSION_2
public static final int PROTOCOL_VERSION_2The version number for discovery protocol version 2.- See Also:
-
-
Constructor Details
-
Discovery
public Discovery()
-
-
Method Details
-
getProtocol1
Returns an instance implementing protocol version 1.- Returns:
- an instance implementing protocol version 1
-
getProtocol2
Returns an instance implementing protocol version 2 which uses providers loaded from the given class loader, or the current context class loader if the given loader isnull. Available providers are determined by interpreting any resources of the indicated class loader named"META-INF/services/com.sun.jini.discovery.DiscoveryFormatProvider"as files containing names of provider classes, with one name per line.- Parameters:
loader- class loader from which to load providers, ornullto indicate the current context class loader- Returns:
- an instance implementing protocol version 2
-
getProtocol2
public static Discovery getProtocol2(MulticastRequestEncoder[] mre, MulticastRequestDecoder[] mrd, MulticastAnnouncementEncoder[] mae, MulticastAnnouncementDecoder[] mad, UnicastDiscoveryClient[] udc, UnicastDiscoveryServer[] uds) Returns an instance implementing protocol version 2 which uses the given providers. Contents of arrays are copied;nullarray values are equivalent to empty arrays.- Parameters:
mre- providers for encoding multicast requestsmrd- providers for decoding multicast requestsmae- providers for encoding multicast announcementsmad- providers for decoding multicast announcementsudc- providers for performing the client side of unicast discoveryuds- providers for performing the server side of unicast discovery- Returns:
- an instance implementing protocol version 2
-
encodeMulticastRequest
public abstract EncodeIterator encodeMulticastRequest(MulticastRequest request, int maxPacketSize, InvocationConstraints constraints) Returns an iterator which can be used to encode the given multicast request data into sets ofDatagramPackets, each bounded in length by the specified maximum packet size, in a manner that satisfies the given constraints.nullconstraints are considered equivalent to empty constraints. The destination of eachDatagramPacketproduced by the returned iterator is set to the address returned byConstants.getRequestAddress(), with the value ofConstants.multicastDiscoveryPortused as the destination port.- Parameters:
request- the request data to encodemaxPacketSize- the maximum size of packets to produceconstraints- the constraints to apply when encoding the data, ornull- Returns:
- an iterator to use for encoding the data
- Throws:
NullPointerException- ifrequestisnull
-
decodeMulticastRequest
public abstract MulticastRequest decodeMulticastRequest(DatagramPacket packet, InvocationConstraints constraints, ClientSubjectChecker checker) throws IOException 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 aMulticastRequestinstance that contains the decoded data.nullconstraints are considered equivalent to empty constraints. All the specified constraints are checked before this method returns.- Parameters:
packet- the packet to decodeconstraints- the constraints to apply when decoding the packet, ornullchecker- the object to use to check the client subject, ornull- Returns:
- the decoded multicast request data
- Throws:
IOException- if an error occurs in interpreting the dataUnsupportedConstraintException- if unable to satisfy the specified constraintsSecurityException- if the given constraints cannot be satisfied due to insufficient caller permissions, or if the client subject check failsNullPointerException- ifpacketisnull
-
decodeMulticastRequest
public MulticastRequest decodeMulticastRequest(DatagramPacket packet, InvocationConstraints constraints, ClientSubjectChecker checker, boolean delayConstraintCheck) throws IOException 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 aMulticastRequestinstance that contains the decoded data, with constraint checking optionally delayed.nullconstraints are considered equivalent to empty constraints.The
delayConstraintCheckflag is used to control delayed constraint checking. Delayed constraint checking is useful for potentially delaying the expense of complete constraint checking, until other checks have been made on the returnedMulticastRequestfor preliminary validation. Implementations may ignore the flag, in which case, the behavior is equivalent to that ofdecodeMulticastRequest.If
delayConstraintCheckistrue, the method behaves as follows:- Some of the specified constraints may not be checked
before this method returns; the returned
MulticastRequest'scheckConstraintsmethod must be invoked to complete checking of all the constraints. - Constraints which must be checked before accessor
methods of the returned
MulticastRequestcan be invoked are always checked before this method returns.
If
delayConstraintCheckisfalse, all the specified constraints are checked before this method returns.Discoveryimplements this method to simply invokedecodeMulticastRequest, and thus checks all the specified constraints before returning.- Parameters:
packet- the packet to decodeconstraints- the constraints to apply when decoding the packet, ornullchecker- the object to use to check the client subject, ornulldelayConstraintCheck- flag to control delayed constraint checking- Returns:
- the decoded multicast request data.
- Throws:
IOException- if an error occurs in interpreting the dataSecurityException- if the given constraints cannot be satisfied due to insufficient caller permissions, or if the client subject check failsNullPointerException- ifpacketisnull- Since:
- 2.1
- Some of the specified constraints may not be checked
before this method returns; the returned
-
encodeMulticastAnnouncement
public abstract EncodeIterator encodeMulticastAnnouncement(MulticastAnnouncement announcement, int maxPacketSize, InvocationConstraints constraints) Returns an iterator which can be used to encode the given multicast announcement data into sets ofDatagramPackets, each bounded in length by the specified maximum packet size, in a manner that satisfies the given constraints.nullconstraints are considered equivalent to empty constraints. The destination of eachDatagramPacketproduced by the returned iterator is set to the address returned byConstants.getAnnouncementAddress(), with the value ofConstants.multicastDiscoveryPortused as the destination port.- Parameters:
announcement- the announcement data to encodemaxPacketSize- the maximum size of packets to produceconstraints- the constraints to apply when encoding the data, ornull- Returns:
- an iterator to use for encoding the data
- Throws:
NullPointerException- ifannouncementisnull
-
decodeMulticastAnnouncement
public abstract MulticastAnnouncement decodeMulticastAnnouncement(DatagramPacket packet, InvocationConstraints constraints) throws IOException Decodes the multicast announcement data contained in the given datagram in a manner that satisfies the specified constraints, returning aMulticastAnnouncementinstance that contains the decoded data.nullconstraints are considered equivalent to empty constraints. All the specified constraints are checked before this method returns.- Parameters:
packet- the packet to decodeconstraints- the constraints to apply when decoding the packet, ornull- Returns:
- the decoded multicast announcement data
- Throws:
IOException- if an error occurs in interpreting the dataUnsupportedConstraintException- if unable to satisfy the specified constraintsSecurityException- if the given constraints cannot be satisfied due to insufficient caller permissionsNullPointerException- ifpacketisnull
-
decodeMulticastAnnouncement
public MulticastAnnouncement decodeMulticastAnnouncement(DatagramPacket packet, InvocationConstraints constraints, boolean delayConstraintCheck) throws IOException Decodes the multicast announcement data contained in the given datagram in a manner that satisfies the specified constraints, returning aMulticastAnnouncementinstance that contains the decoded data, with constraint checking optionally delayed.nullconstraints are considered equivalent to empty constraints.The
delayConstraintCheckflag is used to control delayed constraint checking. Delayed constraint checking is useful for potentially delaying the expense of complete constraint checking, until other checks have been made on the returnedMulticastAnnouncementfor preliminary validation. Implementations may ignore the flag, in which case, the behavior is equivalent to that ofdecodeMulticastAnnouncement.If
delayConstraintCheckistrue, the method behaves as follows:- Some of the specified constraints may not be checked
before this method returns; the returned
MulticastAnnouncement'scheckConstraintsmethod must be invoked to complete checking of all the constraints. - Constraints which must be checked before accessor
methods of the returned
MulticastAnnouncementcan be invoked are always checked before this method returns.
If
delayConstraintCheckisfalse, all the specified constraints are checked before this method returns.Discoveryimplements this method to simply invokedecodeMulticastAnnouncement, and thus checks all the specified constraints before returning.- Parameters:
packet- the packet to decodeconstraints- the constraints to apply when decoding the packet, ornulldelayConstraintCheck- flag to control delayed constraint checking- Returns:
- the decoded multicast announcement data.
- Throws:
IOException- if an error occurs in interpreting the dataUnsupportedConstraintException- if unable to satisfy the specified constraintsSecurityException- if the given constraints cannot be satisfied due to insufficient caller permissions.NullPointerException- ifpacketisnull- Since:
- 2.1
- Some of the specified constraints may not be checked
before this method returns; the returned
-
doUnicastDiscovery
public abstract UnicastResponse doUnicastDiscovery(Socket socket, InvocationConstraints constraints, ClassLoader defaultLoader, ClassLoader verifierLoader, Collection context) throws IOException, ClassNotFoundException 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.nullconstraints are considered equivalent to empty constraints.- Parameters:
socket- the socket on which to perform unicast discoveryconstraints- the constraints to apply to unicast discovery, ornulldefaultLoader- the class loader value (possiblynull) to be passed as thedefaultLoaderargument toRMIClassLoadermethods when unmarshalling the registrar proxyverifierLoader- the class loader value (possiblynull) to pass toSecurity.verifyCodebaseIntegrity, if codebase integrity verification is used when unmarshalling the registrar proxycontext- the collection of context information objects (possiblynull) 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 sendUnsupportedConstraintException- if unable to satisfy the specified constraintsSecurityException- if the given constraints cannot be satisfied due to insufficient caller permissionsClassNotFoundException- if the class of the discovered registrar cannot be resolvedNullPointerException- ifsocketisnull
-
handleUnicastDiscovery
public abstract void handleUnicastDiscovery(UnicastResponse response, Socket socket, InvocationConstraints constraints, ClientSubjectChecker checker, Collection context) throws IOException 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.nullconstraints are considered equivalent to empty constraints.- Parameters:
response- the unicast response data to transmitsocket- the socket on which to handle unicast discoveryconstraints- the constraints to apply to unicast discovery, ornullchecker- the object to use to check the client subject, ornullcontext- 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 sendUnsupportedConstraintException- if unable to satisfy the specified constraintsSecurityException- if the given constraints cannot be satisfied due to insufficient caller permissions, or if the client subject check failsNullPointerException- ifresponse,socket, orcontextisnull
-