public abstract class Discovery extends Object
Logging
This implementation uses the Logger
s 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 |
HANDLED
| 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
|
Modifier and Type | Field and Description |
---|---|
static int |
PROTOCOL_VERSION_1
The version number for discovery protocol version 1.
|
static int |
PROTOCOL_VERSION_2
The version number for discovery protocol version 2.
|
Constructor and Description |
---|
Discovery() |
Modifier and Type | Method and Description |
---|---|
abstract 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. |
MulticastAnnouncement |
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 a
MulticastAnnouncement instance that contains the decoded data, with
constraint checking optionally delayed. |
abstract 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. |
MulticastRequest |
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 a
MulticastRequest instance that
contains the decoded data, with constraint checking optionally
delayed. |
abstract 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.
|
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 of
DatagramPacket s, each bounded in
length by the specified maximum packet size, in a manner that satisfies
the given constraints. |
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 of
DatagramPacket s, each bounded in
length by the specified maximum packet size, in a manner that satisfies
the given constraints. |
static Discovery |
getProtocol1()
Returns an instance implementing protocol version 1.
|
static Discovery |
getProtocol2(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 is
null . |
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.
|
abstract 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).
|
public static final int PROTOCOL_VERSION_1
public static final int PROTOCOL_VERSION_2
public static Discovery getProtocol1()
public static Discovery getProtocol2(ClassLoader loader)
null
. 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.loader
- class loader from which to load providers, or
null
to indicate the current context class loaderpublic static Discovery getProtocol2(MulticastRequestEncoder[] mre, MulticastRequestDecoder[] mrd, MulticastAnnouncementEncoder[] mae, MulticastAnnouncementDecoder[] mad, UnicastDiscoveryClient[] udc, UnicastDiscoveryServer[] uds)
null
array
values are equivalent to empty arrays.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 discoverypublic abstract EncodeIterator encodeMulticastRequest(MulticastRequest request, int maxPacketSize, InvocationConstraints constraints)
DatagramPacket
s, 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.request
- the request data to encodemaxPacketSize
- the maximum size of packets to produceconstraints
- the constraints to apply when encoding the data, or
null
NullPointerException
- if request
is
null
public abstract MulticastRequest decodeMulticastRequest(DatagramPacket packet, InvocationConstraints constraints, ClientSubjectChecker checker) throws IOException
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.packet
- the packet to decodeconstraints
- the constraints to apply when decoding the packet, or
null
checker
- the object to use to check the client subject, or
null
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
- if packet
is null
public MulticastRequest decodeMulticastRequest(DatagramPacket packet, InvocationConstraints constraints, ClientSubjectChecker checker, boolean delayConstraintCheck) throws IOException
MulticastRequest
instance that
contains the decoded data, with constraint checking optionally
delayed. null
constraints are considered
equivalent to empty constraints.
The delayConstraintCheck
flag 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 returned
MulticastRequest
for preliminary validation.
Implementations may ignore the flag, in which case, the behavior is
equivalent to that of decodeMulticastRequest
.
If delayConstraintCheck
is true
, the method
behaves as follows:
MulticastRequest
's
checkConstraints
method must be invoked to complete checking of all the constraints.
MulticastRequest
can be invoked are always
checked before this method returns.If delayConstraintCheck
is false
, all the
specified constraints are checked before this method returns.
Discovery
implements this method to simply invoke decodeMulticastRequest
, and thus checks all the
specified constraints before returning.
packet
- the packet to decodeconstraints
- the constraints to apply when decoding the packet, or
null
checker
- the object to use to check the client subject, or
null
delayConstraintCheck
- flag to control delayed constraint checkingIOException
- 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
- if packet
is null
public abstract EncodeIterator encodeMulticastAnnouncement(MulticastAnnouncement announcement, int maxPacketSize, InvocationConstraints constraints)
DatagramPacket
s, 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.announcement
- the announcement data to encodemaxPacketSize
- the maximum size of packets to produceconstraints
- the constraints to apply when encoding the data, or
null
NullPointerException
- if announcement
is
null
public abstract MulticastAnnouncement decodeMulticastAnnouncement(DatagramPacket packet, InvocationConstraints constraints) throws IOException
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.packet
- the packet to decodeconstraints
- the constraints to apply when decoding the packet, or
null
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
- if packet
is null
public MulticastAnnouncement decodeMulticastAnnouncement(DatagramPacket packet, InvocationConstraints constraints, boolean delayConstraintCheck) throws IOException
MulticastAnnouncement
instance that contains the decoded data, with
constraint checking optionally delayed. null
constraints
are considered equivalent to empty constraints.
The delayConstraintCheck
flag 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 returned
MulticastAnnouncement
for preliminary validation.
Implementations may ignore the flag, in which case, the behavior is
equivalent to that of decodeMulticastAnnouncement
.
If delayConstraintCheck
is true
, the method
behaves as follows:
MulticastAnnouncement
's
checkConstraints
method must be invoked to complete checking of all the constraints.
MulticastAnnouncement
can be invoked are always
checked before this method returns. If delayConstraintCheck
is false
,
all the specified constraints are checked before this method returns.
Discovery
implements this method to simply invoke decodeMulticastAnnouncement
, and thus checks
all the specified constraints before returning.
packet
- the packet to decodeconstraints
- the constraints to apply when decoding the packet, or
null
delayConstraintCheck
- flag to control delayed constraint checkingIOException
- 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
- if packet
is null
public abstract UnicastResponse doUnicastDiscovery(Socket socket, InvocationConstraints constraints, ClassLoader defaultLoader, ClassLoader verifierLoader, Collection context) throws IOException, ClassNotFoundException
null
constraints are considered equivalent to empty
constraints.socket
- the socket on which to perform unicast discoveryconstraints
- 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
proxyverifierLoader
- the class loader value (possibly
null
) to pass to Security.verifyCodebaseIntegrity
, if codebase integrity verification is
used when unmarshalling the registrar proxycontext
- the collection of context information objects (possibly
null
) to use when unmarshalling the registrar proxyIOException
- 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
- if socket
is null
public abstract void handleUnicastDiscovery(UnicastResponse response, Socket socket, InvocationConstraints constraints, ClientSubjectChecker checker, Collection context) throws IOException
null
constraints are considered equivalent to empty
constraints.response
- the unicast response data to transmitsocket
- the socket on which to handle unicast discoveryconstraints
- 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 proxyIOException
- 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
- if response
,
socket
, or context
is null
Copyright © GigaSpaces.