Package javax.jmdns.impl
Class DNSStatefulObject.DefaultImplementation
java.lang.Object
java.util.concurrent.locks.ReentrantLock
javax.jmdns.impl.DNSStatefulObject.DefaultImplementation
- All Implemented Interfaces:
Serializable
,Lock
,DNSStatefulObject
- Direct Known Subclasses:
HostInfo.HostInfoState
,ServiceInfoImpl.ServiceInfoState
- Enclosing interface:
DNSStatefulObject
public static class DNSStatefulObject.DefaultImplementation
extends ReentrantLock
implements DNSStatefulObject
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface javax.jmdns.impl.DNSStatefulObject
DNSStatefulObject.DefaultImplementation, DNSStatefulObject.DNSStatefulObjectSemaphore
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final DNSStatefulObject.DNSStatefulObjectSemaphore
private final DNSStatefulObject.DNSStatefulObjectSemaphore
private JmDNSImpl
protected DNSState
protected DNSTask
private static org.slf4j.Logger
private static final long
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
advanceState
(DNSTask task) Sets the state and notifies all objects that wait on the ServiceInfo.void
associateWithTask
(DNSTask task, DNSState state) Sets the task associated with this Object.boolean
Sets the state and notifies all objects that wait on the ServiceInfo.boolean
Sets the state and notifies all objects that wait on the ServiceInfo.getDns()
Returns the DNS associated with this object.boolean
Returns true, if this is an announced state.boolean
Returns true, if this is an announcing state.boolean
isAssociatedWithTask
(DNSTask task, DNSState state) Checks if this object is associated with the task and in the same state.boolean
Returns true, if this is a canceled state.boolean
Returns true, if this is a canceling state.boolean
isClosed()
Returns true, if this is a closed state.boolean
Returns true, if this is a closing state.boolean
Returns true, if this is a probing state.boolean
Sets the state and notifies all objects that wait on the ServiceInfo.void
Remove the association of the task with this Object.boolean
Sets the state and notifies all objects that wait on the ServiceInfo.protected void
protected void
protected void
toString()
boolean
waitForAnnounced
(long timeout) Waits for the object to be announced.boolean
waitForCanceled
(long timeout) Waits for the object to be canceled.private boolean
private boolean
Methods inherited from class java.util.concurrent.locks.ReentrantLock
getHoldCount, getOwner, getQueuedThreads, getQueueLength, getWaitingThreads, getWaitQueueLength, hasQueuedThread, hasQueuedThreads, hasWaiters, isFair, isHeldByCurrentThread, isLocked, lock, lockInterruptibly, newCondition, tryLock, tryLock, unlock
-
Field Details
-
logger
private static org.slf4j.Logger logger -
serialVersionUID
private static final long serialVersionUID- See Also:
-
_dns
-
_task
-
_state
-
_announcing
-
_canceling
-
-
Constructor Details
-
DefaultImplementation
public DefaultImplementation()
-
-
Method Details
-
getDns
Returns the DNS associated with this object.- Specified by:
getDns
in interfaceDNSStatefulObject
- Returns:
- DNS resolver
-
setDns
-
associateWithTask
Sets the task associated with this Object.- Specified by:
associateWithTask
in interfaceDNSStatefulObject
- Parameters:
task
- associated taskstate
- state of the task
-
removeAssociationWithTask
Remove the association of the task with this Object.- Specified by:
removeAssociationWithTask
in interfaceDNSStatefulObject
- Parameters:
task
- associated task
-
isAssociatedWithTask
Checks if this object is associated with the task and in the same state.- Specified by:
isAssociatedWithTask
in interfaceDNSStatefulObject
- Parameters:
task
- associated taskstate
- state of the task- Returns:
true
is the task is associated with this object,false
otherwise.
-
setTask
-
setState
- Parameters:
state
- the state to set
-
advanceState
Sets the state and notifies all objects that wait on the ServiceInfo.- Specified by:
advanceState
in interfaceDNSStatefulObject
- Parameters:
task
- associated task- Returns:
true
if the state was changed by this thread,false
otherwise.- See Also:
-
revertState
public boolean revertState()Sets the state and notifies all objects that wait on the ServiceInfo.- Specified by:
revertState
in interfaceDNSStatefulObject
- Returns:
true
if the state was changed by this thread,false
otherwise.- See Also:
-
cancelState
public boolean cancelState()Sets the state and notifies all objects that wait on the ServiceInfo.- Specified by:
cancelState
in interfaceDNSStatefulObject
- Returns:
true
if the state was changed by this thread,false
otherwise.
-
closeState
public boolean closeState()Sets the state and notifies all objects that wait on the ServiceInfo.- Specified by:
closeState
in interfaceDNSStatefulObject
- Returns:
true
if the state was changed by this thread,false
otherwise.
-
recoverState
public boolean recoverState()Sets the state and notifies all objects that wait on the ServiceInfo.- Specified by:
recoverState
in interfaceDNSStatefulObject
- Returns:
true
if the state was changed by this thread,false
otherwise.
-
isProbing
public boolean isProbing()Returns true, if this is a probing state.- Specified by:
isProbing
in interfaceDNSStatefulObject
- Returns:
true
if probing state,false
otherwise
-
isAnnouncing
public boolean isAnnouncing()Returns true, if this is an announcing state.- Specified by:
isAnnouncing
in interfaceDNSStatefulObject
- Returns:
true
if announcing state,false
otherwise
-
isAnnounced
public boolean isAnnounced()Returns true, if this is an announced state.- Specified by:
isAnnounced
in interfaceDNSStatefulObject
- Returns:
true
if announced state,false
otherwise
-
isCanceling
public boolean isCanceling()Returns true, if this is a canceling state.- Specified by:
isCanceling
in interfaceDNSStatefulObject
- Returns:
true
if canceling state,false
otherwise
-
isCanceled
public boolean isCanceled()Returns true, if this is a canceled state.- Specified by:
isCanceled
in interfaceDNSStatefulObject
- Returns:
true
if canceled state,false
otherwise
-
isClosing
public boolean isClosing()Returns true, if this is a closing state.- Specified by:
isClosing
in interfaceDNSStatefulObject
- Returns:
true
if closing state,false
otherwise
-
isClosed
public boolean isClosed()Returns true, if this is a closed state.- Specified by:
isClosed
in interfaceDNSStatefulObject
- Returns:
true
if closed state,false
otherwise
-
willCancel
private boolean willCancel() -
willClose
private boolean willClose() -
waitForAnnounced
public boolean waitForAnnounced(long timeout) Waits for the object to be announced.- Specified by:
waitForAnnounced
in interfaceDNSStatefulObject
- Parameters:
timeout
- the maximum time to wait in milliseconds.- Returns:
true
if the object is announced,false
otherwise
-
waitForCanceled
public boolean waitForCanceled(long timeout) Waits for the object to be canceled.- Specified by:
waitForCanceled
in interfaceDNSStatefulObject
- Parameters:
timeout
- the maximum time to wait in milliseconds.- Returns:
true
if the object is canceled,false
otherwise
-
toString
- Overrides:
toString
in classReentrantLock
-