Package com.sun.jini.discovery
Class DiscoveryConstraints
java.lang.Object
com.sun.jini.discovery.DiscoveryConstraints
Class for processing constraints which apply to the discovery protocol:
DiscoveryProtocolVersion, MulticastMaxPacketSize, MulticastTimeToLive, UnicastSocketTimeout, ConnectionRelativeTime, ConnectionAbsoluteTime.- Since:
- 2.0
- Author:
- Sun Microsystems, Inc.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidcheckProtocolVersion(int version) Checks the protocol version of an incoming multicast request, announcement, or unicast discovery attempt, throwing anUnsupportedConstraintExceptionif handling of the given protocol does not satisfy the constraints of this instance.intReturns the protocol version to use for sending multicast requests or announcements, or initiating unicast discovery.longgetConnectionDeadline(long defaultValue) Returns the deadline by which a network connection must be established during unicast discovery, ordefaultValueif not constrained.intgetMulticastMaxPacketSize(int defaultValue) Returns the maximum multicast packet size to allow, or the specified default value if not constrained.intgetMulticastTimeToLive(int defaultValue) Returns the multicast time to live value to use, or the specified default value if not constrained.Returns the constraints for this instance which are not, or do not contain as alternatives, instances of the "fulfillable" (by this layer) constraint typesDiscoveryProtocolVersion,ConnectionRelativeTime,MulticastMaxPacketSize,MulticastTimeToLive, andUnicastSocketTimeout.intgetUnicastSocketTimeout(int defaultValue) Returns socket read timeout to use for unicast discovery, or the specified default value if not constrained.static voidEmpty method which serves as aMethodConstraintskey for looking upInvocationConstraintsthat apply to multicast announcements.static voidEmpty method which serves as aMethodConstraintskey for looking upInvocationConstraintsthat apply to multicast requests.static DiscoveryConstraintsprocess(InvocationConstraints constraints) Processes the discovery-related constraints in the given set of constraints, returning aDiscoveryConstraintsinstance from which the constraint results can be queried.static voidEmpty method which serves as aMethodConstraintskey for looking upInvocationConstraintsthat apply to unicast discovery.
-
Field Details
-
multicastRequestMethod
Method object for the multicastRequest method of this class. -
multicastAnnouncementMethod
Method object for the multicastAnnouncement method of this class. -
unicastDiscoveryMethod
Method object for the unicastDiscovery method of this class.
-
-
Method Details
-
multicastRequest
public static void multicastRequest()Empty method which serves as aMethodConstraintskey for looking upInvocationConstraintsthat apply to multicast requests. -
multicastAnnouncement
public static void multicastAnnouncement()Empty method which serves as aMethodConstraintskey for looking upInvocationConstraintsthat apply to multicast announcements. -
unicastDiscovery
public static void unicastDiscovery()Empty method which serves as aMethodConstraintskey for looking upInvocationConstraintsthat apply to unicast discovery. -
process
public static DiscoveryConstraints process(InvocationConstraints constraints) throws UnsupportedConstraintException Processes the discovery-related constraints in the given set of constraints, returning aDiscoveryConstraintsinstance from which the constraint results can be queried. Processing of timeout constraints is time dependent, and subsequent invocations of this method with the sameInvocationConstraintsmay result inDiscoveryConstraintinstances with different constraint results.- Parameters:
constraints- the constraints to process- Returns:
- an instance representing processed constraints
- Throws:
UnsupportedConstraintException- if the discovery-related constraints contain conflicts, or otherwise cannot be processedNullPointerException- ifconstraintsisnull
-
chooseProtocolVersion
public int chooseProtocolVersion()Returns the protocol version to use for sending multicast requests or announcements, or initiating unicast discovery.- Returns:
- the protocol version to use
-
checkProtocolVersion
Checks the protocol version of an incoming multicast request, announcement, or unicast discovery attempt, throwing anUnsupportedConstraintExceptionif handling of the given protocol does not satisfy the constraints of this instance.- Parameters:
version- protocol version to check- Throws:
UnsupportedConstraintException- if handling of the given protocol does not satisfy the constraints of this instance
-
getConnectionDeadline
public long getConnectionDeadline(long defaultValue) Returns the deadline by which a network connection must be established during unicast discovery, ordefaultValueif not constrained.- Parameters:
defaultValue- default timeout to return- Returns:
- the deadline for the network connection
- Since:
- 2.1
-
getMulticastMaxPacketSize
public int getMulticastMaxPacketSize(int defaultValue) Returns the maximum multicast packet size to allow, or the specified default value if not constrained.- Parameters:
defaultValue- the value to return if the multicast packet size is unconstrained- Returns:
- the maximum multicast packet size to allow
-
getMulticastTimeToLive
public int getMulticastTimeToLive(int defaultValue) Returns the multicast time to live value to use, or the specified default value if not constrained.- Parameters:
defaultValue- the value to return if the multicast time to live value is unconstrained- Returns:
- the multicast time to live value to use
-
getUnicastSocketTimeout
public int getUnicastSocketTimeout(int defaultValue) Returns socket read timeout to use for unicast discovery, or the specified default value if not constrained.- Parameters:
defaultValue- the value to return if the socket timeout is unconstrained- Returns:
- the socket timeout to use
-
getUnfulfilledConstraints
Returns the constraints for this instance which are not, or do not contain as alternatives, instances of the "fulfillable" (by this layer) constraint typesDiscoveryProtocolVersion,ConnectionRelativeTime,MulticastMaxPacketSize,MulticastTimeToLive, andUnicastSocketTimeout. Constraint alternatives containing both fulfillable and unfulfillable constraints are treated optimistically--it is assumed that the one of the fulfillable alternatives will be satisfied, so the unfulfillable alternatives are not included in the returned constraints.- Returns:
- the unfulfilled constraints for this instance
-