public class DefaultDeviceReference extends TimedEntry implements DeviceReference
| Modifier and Type | Field and Description |
|---|---|
static AppSequence |
APP_SEQUENCE_ZERO
This sequence number should only be used to compare the first incoming message to proxy devices
|
static int |
EVENT_DEVICE_BYE |
static int |
EVENT_DEVICE_CHANGED |
static int |
EVENT_DEVICE_COMPLETELY_DISCOVERED |
static int |
EVENT_DEVICE_FAULT_RESET |
static int |
EVENT_DEVICE_GET_RSP |
static int |
EVENT_DEVICE_SEEN |
protected HashMap |
outgoingDiscoveryInfosDown |
protected HashMap |
outgoingDiscoveryInfosUp |
STATE_BUILD_UP, STATE_RUNNING, STATE_STOPPED, STATE_UNKNOWNLOCATION_LOCAL, LOCATION_REMOTE, LOCATION_UNKNOWN| Modifier and Type | Method and Description |
|---|---|
void |
addListener(DeviceListener listener)
Register listener (callback) for device reference changes.
|
void |
addOutgoingDiscoveryInfo(OutgoingDiscoveryInfo info)
Adds the specified outgoing discovery info to this device.
|
void |
announceDeviceBye()
Informs listeners on this device reference in separate thread about stop.
|
void |
announceDeviceChangedAndBuildUp()
Clones device listeners and informs everyone in separate thread about change.
|
void |
announceDeviceRunningAndBuildUp()
Clones device listeners and informs everyone in separate thread about change.
|
void |
buildUpDevice()
Instructs this device reference to asynchronously send a Get message to the device and create a new proxy, if
required.
|
protected int |
changeProxyReferenceState(int event) |
protected boolean |
checkAppSequence(AppSequence appSeq)
Checks if the specified application sequence is newer than the latest.
|
void |
dispose() |
void |
fetchCompleteDiscoveryDataAsync()
Fetches all discovery data of device reference by sending a directed probe to the remote
device.
|
void |
fetchCompleteDiscoveryDataSync()
Uses directed Probe to refresh discovery data.
|
Iterator |
getChildren(boolean doDiscovery)
Returns the embedded device references, if any exist.
|
java.lang.String |
getComManId()
Returns the ID of the communication protocol to use when communicating with this reference's
target over the current
preferred transport address. |
Device |
getDevice()
Get device.
|
protected Device |
getDevice(boolean doBuildUp)
Returns device.
|
Iterator |
getDevicePortTypes(boolean doDiscovery)
Gets port types implemented by device.
|
QName[] |
getDevicePortTypesAsArray(boolean doDiscovery)
Gets port types implemented by device.
|
DiscoveryData |
getDiscoveryData() |
Iterator |
getDiscoveryXAddressInfos(boolean doDiscovery) |
EndpointReference |
getEndpointReference()
Gets endpoint reference of device.
|
int |
getLocation()
Returns the location of the device or service, which may be - LOCATION_UNKNOWN, -
LOCATION_REMOTE, - LOCATION_LOCAL.
|
long |
getMetadataVersion(boolean doDiscovery)
Returns the metadata version of the device.
|
Set |
getOutgoingDiscoveryInfos() |
XAddressInfo |
getPreferredDiscoveryXAddressInfo() |
URI |
getPreferredXAddress()
Returns the preferred transport address for communication with this reference.
|
XAddressInfo |
getPreferredXAddressInfo() |
Iterator |
getScopes(boolean doDiscovery)
Gets scopes the device resides in.
|
URI[] |
getScopesAsArray(boolean doDiscovery)
Gets scopes the device resides in.
|
SecurityKey |
getSecurityKey() |
int |
getState()
Gets state of device / device reference.
|
Iterator |
getTransportAndDiscoveryXAddressInfos(boolean doDiscovery) |
Iterator |
getXAddressInfos(boolean doDiscovery)
Get the transport addresses of the device.
|
boolean |
isAutoUpdateDevice() |
boolean |
isCompleteDiscovered()
Case remote: Did we receive the answer to a directed probe for the current version of the
device? Case local: Always true.
|
boolean |
isDeviceObjectExisting()
Case remote: Did a proxy device object exist for the current version of the remote device?
Case local: Always true. |
boolean |
isDiscovered()
Case remote: Did we receive a resolve message for the current version of the device.
|
void |
probeDeviceDirectly(ResponseCallback callback) |
Device |
rebuildDevice()
Rebuilds device.
|
void |
removeListener(DeviceListener listener)
Unregisters listener for this device reference.
|
boolean |
removeOutgoingDiscoveryInfo(OutgoingDiscoveryInfo info)
Removes a previously
added outgoing discovery info from
this device. |
void |
reset()
Resets all state information of the device reference except the endpoint reference.
|
void |
reset(boolean recurse)
Resets all state information of the device reference except the endpoint reference.
|
XAddressInfo |
resolveRemoteDevice()
Sends Resolve message to remote device.
|
void |
setAutoUpdateDevice(boolean autoUpdateDevice)
When set to
true, the device reference will attempt to rebuild the device proxy
automatically each time a a change in the device's metadata version is detected. |
void |
setDiscoveryData(DiscoveryData newDiscoveryData) |
Device |
setLocalDevice(LocalDevice device)
Sets device, replaces present device.
|
void |
setSecurityKey(SecurityKey newKey) |
protected int |
sizeOfListeners()
Returns amount of listeners for this reference.
|
boolean |
supportsSecurity() |
protected void |
timedOut()
Runs what should be done at time out.
|
java.lang.String |
toString() |
boolean |
updateFromBye(ConnectionInfo info) |
isDisabledpublic static final AppSequence APP_SEQUENCE_ZERO
public static final int EVENT_DEVICE_SEEN
public static final int EVENT_DEVICE_BYE
public static final int EVENT_DEVICE_GET_RSP
public static final int EVENT_DEVICE_CHANGED
public static final int EVENT_DEVICE_COMPLETELY_DISCOVERED
public static final int EVENT_DEVICE_FAULT_RESET
protected HashMap outgoingDiscoveryInfosUp
protected HashMap outgoingDiscoveryInfosDown
public void dispose()
public void addOutgoingDiscoveryInfo(OutgoingDiscoveryInfo info)
info - the new protocol domain to add to this devicepublic boolean removeOutgoingDiscoveryInfo(OutgoingDiscoveryInfo info)
added outgoing discovery info from
this device.info - the output domain to removepublic Set getOutgoingDiscoveryInfos()
public java.lang.String toString()
toString in class TimedEntrypublic int getState()
DeviceReferenceDeviceReference.STATE_UNKNOWN, DeviceReference.STATE_RUNNING, DeviceReference.STATE_BUILD_UP and DeviceReference.STATE_STOPPED.getState in interface DeviceReferenceDeviceReference.STATE_UNKNOWN,
DeviceReference.STATE_RUNNING,
DeviceReference.STATE_BUILD_UP,
DeviceReference.STATE_STOPPEDpublic Device getDevice() throws CommunicationException
DeviceReference
A Proxy to a remote device is built up by sending resolve and get messages.
getDevice in interface DeviceReferenceCommunicationException - This exception is thrown, if the remote device doesn't answer to the messages, which tries to receive the
necessary data. The possible messages to be sent are resolve, and get messages. The timeout value can be
configured in the DispatchingProperties via the methods DispatchingProperties.setResponseWaitTime(int)
and DispatchingProperties.setResponseWaitTime(int).protected Device getDevice(boolean doBuildUp) throws CommunicationException
false, no proxy device will be created, i.e. no resolve and get
messages will be sent.doBuildUp - Specifies that a proxy device should be built up, if no device already exists.null, if build up was not requested.CommunicationExceptionpublic Device rebuildDevice() throws CommunicationException
rebuildDevice in interface DeviceReferenceCommunicationExceptionpublic void buildUpDevice()
DeviceListener.deviceBuiltUp(DeviceReference,
Device) method.
Note that in order to reduce network traffic a Get message will actually be sent only if it is detected that the device within this device reference instance is not up to date anymore.
public Device setLocalDevice(LocalDevice device)
device - Replacement device (local).public void reset()
reset(boolean) with an
argument of false.public void reset(boolean recurse)
recurse is set to true, than all service
references currently associated with this device reference will be reset prior to removing them, too.recurse - if service references associated with this device reference shell be reset, toopublic void fetchCompleteDiscoveryDataSync()
throws CommunicationException
fetchCompleteDiscoveryDataSync in interface DeviceReferenceCommunicationExceptionpublic void fetchCompleteDiscoveryDataAsync()
DeviceReferencefetchCompleteDiscoveryDataAsync in interface DeviceReferencepublic XAddressInfo resolveRemoteDevice() throws CommunicationException
CommunicationExceptionpublic void probeDeviceDirectly(ResponseCallback callback)
probeDeviceDirectly in interface DeviceReferencepublic int getLocation()
ReferencegetLocation in interface Referencepublic Iterator getDevicePortTypes(boolean doDiscovery) throws CommunicationException
DeviceReferencegetDevicePortTypes in interface DeviceReferencedoDiscovery - if true and no port types are known and device is remote located, a resolve message will be
sent to remote device to discover them.QName.CommunicationExceptionpublic QName[] getDevicePortTypesAsArray(boolean doDiscovery) throws CommunicationException
DeviceReferencegetDevicePortTypesAsArray in interface DeviceReferencedoDiscovery - if true and no port types are known and device is remote located, a resolve message will be
sent to remote device to discover them.QName.CommunicationExceptionpublic Iterator getScopes(boolean doDiscovery) throws CommunicationException
DeviceReferencegetScopes in interface DeviceReferencedoDiscovery - if true and no port types are known and device is remote located, a resolve message will be
sent to remote device to discover them.URI.CommunicationExceptionpublic URI[] getScopesAsArray(boolean doDiscovery) throws CommunicationException
DeviceReferencegetScopesAsArray in interface DeviceReferencedoDiscovery - if true and no port types are known and device is remote located, a resolve message will be
sent to remote device to discover them.URI.CommunicationExceptionpublic long getMetadataVersion(boolean doDiscovery)
throws CommunicationException
DeviceReferencegetMetadataVersion in interface DeviceReferencedoDiscovery - if true and no port types are known and device is remote located, a resolve message will be
sent to remote device to discover them.CommunicationExceptionpublic Iterator getXAddressInfos(boolean doDiscovery) throws CommunicationException
DeviceReferencegetXAddressInfos in interface DeviceReferencedoDiscovery - if true and no port types are known and device is remote located, a resolve message will be
sent to remote device to discover them.URI .CommunicationExceptionpublic Iterator getDiscoveryXAddressInfos(boolean doDiscovery) throws CommunicationException
getDiscoveryXAddressInfos in interface DeviceReferenceCommunicationExceptionpublic Iterator getTransportAndDiscoveryXAddressInfos(boolean doDiscovery) throws CommunicationException
getTransportAndDiscoveryXAddressInfos in interface DeviceReferenceCommunicationExceptionpublic URI getPreferredXAddress()
ReferencegetPreferredXAddress in interface Referencepublic java.lang.String getComManId()
Referencepreferred transport address. Will
return the framework-wide
default communication ID, if no preferred transport address has been explicitly set.getComManId in interface Referencepublic EndpointReference getEndpointReference()
DeviceReferencegetEndpointReference in interface DeviceReferencepublic XAddressInfo getPreferredDiscoveryXAddressInfo()
getPreferredDiscoveryXAddressInfo in interface DeviceReferencepublic DiscoveryData getDiscoveryData()
getDiscoveryData in interface DeviceReferencepublic void setDiscoveryData(DiscoveryData newDiscoveryData)
public SecurityKey getSecurityKey()
getSecurityKey in interface DeviceReferencepublic void setSecurityKey(SecurityKey newKey)
setSecurityKey in interface DeviceReferenceprotected boolean checkAppSequence(AppSequence appSeq)
true will be returned. If new sequence is
null, method returns true;newSequence - true, if the specified sequence is newer than the latest sequence or if new sequence is
null.protected int changeProxyReferenceState(int event)
protected void timedOut()
TimedEntrytimedOut in class TimedEntrypublic void addListener(DeviceListener listener)
DeviceReferenceaddListener in interface DeviceReferencelistener - listener (callback) to register.public void removeListener(DeviceListener listener)
DeviceReferenceremoveListener in interface DeviceReferencelistener - listener to remove.protected int sizeOfListeners()
public boolean isDeviceObjectExisting()
DeviceReferencetrue.isDeviceObjectExisting in interface DeviceReferencetrue.public boolean isDiscovered()
DeviceReferenceisDiscovered in interface DeviceReferencetrue.public boolean isCompleteDiscovered()
DeviceReferenceisCompleteDiscovered in interface DeviceReferencetrue.public boolean isAutoUpdateDevice()
isAutoUpdateDevice in interface DeviceReferencepublic void setAutoUpdateDevice(boolean autoUpdateDevice)
DeviceReferencetrue, the device reference will attempt to rebuild the device proxy
automatically each time a a change in the device's metadata version is detected.setAutoUpdateDevice in interface DeviceReferencepublic void announceDeviceBye()
public void announceDeviceChangedAndBuildUp()
public void announceDeviceRunningAndBuildUp()
public XAddressInfo getPreferredXAddressInfo()
getPreferredXAddressInfo in interface DeviceReferencepublic boolean updateFromBye(ConnectionInfo info)
public Iterator getChildren(boolean doDiscovery) throws CommunicationException
DeviceReferencegetChildren in interface DeviceReferencedoDiscovery - should be true if additional network communication is acceptable. This method will block until the
information has been obtained.CommunicationException - Can only be thrown when doDiscovery is set to truepublic boolean supportsSecurity()
supportsSecurity in interface DeviceReference