class DiscoveryV2 extends Discovery
Modifier and Type | Class and Description |
---|---|
private static class |
DiscoveryV2.DatagramBuffers
Buffer factory passed to multicast request and announcement encoders.
|
Modifier and Type | Field and Description |
---|---|
private static int |
FORMAT_ID_LEN |
private Map[] |
formatIdMaps |
private static WeakIdentityMap |
instances |
private static Logger |
logger |
private static byte |
MULTICAST_ANNOUNCEMENT |
private static int |
MULTICAST_ANNOUNCEMENT_DECODER |
private static int |
MULTICAST_ANNOUNCEMENT_ENCODER |
private static int |
MULTICAST_HEADER_LEN |
private static byte |
MULTICAST_REQUEST |
private static int |
MULTICAST_REQUEST_DECODER |
private static int |
MULTICAST_REQUEST_ENCODER |
private static long |
NULL_FORMAT_ID |
private static int |
NUM_PROVIDER_TYPES |
private static Class[] |
providerTypes |
private static int |
UNICAST_DISCOVERY_CLIENT |
private static int |
UNICAST_DISCOVERY_SERVER |
private static int |
UNICAST_REQUEST_HEADER_LEN |
private static int |
UNICAST_RESPONSE_HEADER_LEN |
MIN_MAX_PACKET_SIZE, PROTOCOL_VERSION_1, PROTOCOL_VERSION_2
Modifier | Constructor and Description |
---|---|
private |
DiscoveryV2(List[] providers) |
Modifier and Type | Method and Description |
---|---|
private static List |
asList(Object[] a) |
private static long |
computeFormatID(String format) |
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. |
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. |
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.
|
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. |
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. |
private static ClassLoader |
getContextClassLoader() |
(package private) static DiscoveryV2 |
getInstance(ClassLoader loader)
Returns DiscoveryV2 instance which uses providers loaded from the given
class loader, or the current context class loader if the given loader is
null.
|
(package private) static DiscoveryV2 |
getInstance(MulticastRequestEncoder[] mre,
MulticastRequestDecoder[] mrd,
MulticastAnnouncementEncoder[] mae,
MulticastAnnouncementDecoder[] mad,
UnicastDiscoveryClient[] udc,
UnicastDiscoveryServer[] uds)
Returns DiscoveryV2 instance which uses the given providers.
|
private static List[] |
getProviders(ClassLoader ldr) |
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).
|
private static Map |
makeFormatIdMap(List providers) |
String |
toString() |
getProtocol1, getProtocol2, getProtocol2
private static final byte MULTICAST_ANNOUNCEMENT
private static final byte MULTICAST_REQUEST
private static final long NULL_FORMAT_ID
private static final int FORMAT_ID_LEN
private static final int MULTICAST_HEADER_LEN
private static final int UNICAST_REQUEST_HEADER_LEN
private static final int UNICAST_RESPONSE_HEADER_LEN
private static final int MULTICAST_REQUEST_ENCODER
private static final int MULTICAST_REQUEST_DECODER
private static final int MULTICAST_ANNOUNCEMENT_ENCODER
private static final int MULTICAST_ANNOUNCEMENT_DECODER
private static final int UNICAST_DISCOVERY_CLIENT
private static final int UNICAST_DISCOVERY_SERVER
private static final int NUM_PROVIDER_TYPES
private static final Class[] providerTypes
private static final WeakIdentityMap instances
private static final Logger logger
private final Map[] formatIdMaps
private DiscoveryV2(List[] providers)
static DiscoveryV2 getInstance(ClassLoader loader)
static DiscoveryV2 getInstance(MulticastRequestEncoder[] mre, MulticastRequestDecoder[] mrd, MulticastAnnouncementEncoder[] mae, MulticastAnnouncementDecoder[] mad, UnicastDiscoveryClient[] udc, UnicastDiscoveryServer[] uds)
public EncodeIterator encodeMulticastRequest(MulticastRequest request, int maxPacketSize, InvocationConstraints constraints)
Discovery
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.encodeMulticastRequest
in class Discovery
request
- the request data to encodemaxPacketSize
- the maximum size of packets to produceconstraints
- the constraints to apply when encoding the data, or
null
public MulticastRequest decodeMulticastRequest(DatagramPacket packet, InvocationConstraints constraints, ClientSubjectChecker checker, boolean delayConstraintCheck) throws IOException
Discovery
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.
decodeMulticastRequest
in class Discovery
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 datapublic MulticastRequest decodeMulticastRequest(DatagramPacket packet, InvocationConstraints constraints, ClientSubjectChecker checker) throws IOException
Discovery
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.decodeMulticastRequest
in class Discovery
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 constraintspublic EncodeIterator encodeMulticastAnnouncement(MulticastAnnouncement announcement, int maxPacketSize, InvocationConstraints constraints)
Discovery
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.encodeMulticastAnnouncement
in class Discovery
announcement
- the announcement data to encodemaxPacketSize
- the maximum size of packets to produceconstraints
- the constraints to apply when encoding the data, or
null
public MulticastAnnouncement decodeMulticastAnnouncement(DatagramPacket packet, InvocationConstraints constraints, boolean delayConstraintCheck) throws IOException
Discovery
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.
decodeMulticastAnnouncement
in class Discovery
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 constraintspublic MulticastAnnouncement decodeMulticastAnnouncement(DatagramPacket packet, InvocationConstraints constraints) throws IOException
Discovery
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.decodeMulticastAnnouncement
in class Discovery
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 constraintspublic UnicastResponse doUnicastDiscovery(Socket socket, InvocationConstraints constraints, ClassLoader defaultLoader, ClassLoader verifierLoader, Collection context) throws IOException, ClassNotFoundException
Discovery
null
constraints are considered equivalent to empty
constraints.doUnicastDiscovery
in class Discovery
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 constraintsClassNotFoundException
- if the class of the discovered registrar
cannot be resolvedpublic void handleUnicastDiscovery(UnicastResponse response, Socket socket, InvocationConstraints constraints, ClientSubjectChecker checker, Collection context) throws IOException
Discovery
null
constraints are considered equivalent to empty
constraints.handleUnicastDiscovery
in class Discovery
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 constraintsprivate static ClassLoader getContextClassLoader()
private static List[] getProviders(ClassLoader ldr)
private static long computeFormatID(String format)
Copyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.