|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.ws4d.java.client.SearchManager
public final class SearchManager
This class provides tools for searching local and remote devices and services
given a set of search criteria (see SearchParameter
) and obtaining
references to devices/services with known endpoint addresses.
A typical usage of the search functionality states that the caller provides
an implementation of the SearchCallback
interface which will receive
asynchronous notifications about matching services/devices found during the
search. Given this SearchCallback
implementation and a
SearchParameter
instance describing what kind of
devices/services to look for, the actual search can be started as depicted in
the following sample code:
SearchCallback callback = ...; // provide a receiver for search matches SearchParameter search = ...; // specify what to search for SearchManager.searchDevice(parameter, callback, null);
This example starts a search for a device, as the name of the called method
#searchDevice(SearchParameter, SearchCallback, null)
suggests. If a device
fulfilling the given search parameter criteria is found, this will be
indicated asynchronously by a call to
SearchCallback.deviceFound(DeviceReference, SearchParameter)
.
Similarly, if a search for services was issued (by means of
searchService(SearchParameter, SearchCallback)
), then matches would
result in a call to
SearchCallback.serviceFound(ServiceReference, SearchParameter)
.
The second purpose of this class is to enable the obtaining of a reference to
a (local or remote) device/service when knowing its endpoint address (i.e.
one of its endpoint references). This process differs somehow from the
aforementioned search as it doesn't involve probing the network to assert the
existence of the specified device or service (as its endpoint reference is
already known). Thus, it is possible that calling
DeviceReference.getDevice()
or ServiceReference.getService()
on the returned reference object results in a TimeoutException
being
thrown because the specified device/service is for some reason currently not
reachable (e.g. it is not running at the moment or there is no network path
connecting it with the local machine). In contrast, using the search
abilities will provide notifications only about devices/services which are
currently running and reachable.
Method Summary | |
---|---|
static ServiceReference |
createServiceReference(EndpointReference epr,
QNameSet portTypes,
java.lang.String comManId)
Gets service reference of service with specified endpoint reference. |
static DeviceReference |
getDeviceReference(EndpointReference epr,
DeviceListener listener,
DiscoveryBinding binding)
Gets device reference of device with specified endpoint reference. |
static DeviceReference |
getDeviceReference(EndpointReference epr,
URI address,
DeviceListener listener,
DiscoveryBinding binding)
Gets device reference of device specified by an endpoint reference and an address. |
static DeviceReference |
getDeviceReference(EndpointReference epr,
URI address,
DeviceListener listener,
java.lang.String comManId)
Gets device reference of device specified by an endpoint reference and an address. |
static DeviceReference |
getDeviceReference(HelloData helloData,
DeviceListener listener)
Gets device reference of device with specified endpoint reference. |
static DataStructure |
getLocalDevices()
Returns a data structure containing all the local devices within the current DPWS framework. |
static ServiceReference |
getServiceReference(EndpointReference epr,
java.lang.String comManId)
Gets service reference of service with specified endpoint reference. |
static void |
searchDevice(SearchParameter search,
SearchCallback callback,
DeviceListener listener)
Initiates a search for devices. |
static void |
searchService(SearchParameter search,
SearchCallback callback)
Searches for services. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static DeviceReference getDeviceReference(EndpointReference epr, URI address, DeviceListener listener, java.lang.String comManId)
listener
is not null
, it will be used as
callback for device changes of the corresponding device.
This method will NOT try to discover (resolve/probe) the device. If the
address is unreachable or wrong this method will return null
.
A DeviceReference that was created by this method has not DiscoveryBinding and will therefore not receive hello or bye messages form its referenced device.
epr
- endpoint reference of device for which to get device referenceaddress
- the address of the devicelistener
- optional; will be informed on changes of device' statecomManId
- ID of the communication manager to use when interacting
with supplied endpoint reference
public static DeviceReference getDeviceReference(EndpointReference epr, URI address, DeviceListener listener, DiscoveryBinding binding)
listener
is not null
, it will be used as
callback for device changes of the corresponding device.
This method will NOT try to discover (resolve/probe) the device. If the
address is unreachable or wrong this method will return null
.
epr
- endpoint reference of device for which to get device referenceaddress
- the address of the devicelistener
- optional; will be informed on changes of device' statebinding
- a DiscoveryBinding that specifies how to receive hello and bye messages for the DeviceReference
public static DeviceReference getDeviceReference(EndpointReference epr, DeviceListener listener, DiscoveryBinding binding)
listener
is not null
, it will be used as
callback for device changes of the corresponding device.
epr
- endpoint reference of device for which to get device referencelistener
- optional; will be informed on changes of device' statebinding
- a DiscoveryBinding that specifies how to receive hello and bye messages for the DeviceReference
public static DeviceReference getDeviceReference(HelloData helloData, DeviceListener listener)
listener
is not null
, it will be used as
callback for device changes of the corresponding device.
helloData
- hello data of device for which to get device referencelistener
- optional; will be informed about changes of the device's
state
public static ServiceReference getServiceReference(EndpointReference epr, java.lang.String comManId)
The returned @link ServiceReference
instance can be used to
obtain the actual service by calling
ServiceReference.getService()
.
epr
- endpoint reference of service to get service reference forcomManId
- ID of the communication manager to use when interacting
with supplied endpoint reference
public static ServiceReference createServiceReference(EndpointReference epr, QNameSet portTypes, java.lang.String comManId) throws DuplicateServiceReferenceException
The returned @link ServiceReference
instance can be used to
obtain the actual service by calling
ServiceReference.getService()
.
epr
- endpoint reference of service to get service reference forcomManId
- ID of the communication manager to use when interacting
with supplied endpoint reference
DuplicateServiceReferenceException
- in case a service reference
with the same endpoint reference is already presentpublic static void searchService(SearchParameter search, SearchCallback callback)
callback
by means of the method
SearchCallback.serviceFound(ServiceReference, SearchParameter)
.
search
- search parameter to specify the criteria that matching
services must fulfillcallback
- recipient of notifications about found matching servicespublic static void searchDevice(SearchParameter search, SearchCallback callback, DeviceListener listener)
search
.
When a matching device is found, it is passed to the method
SearchCallback.deviceFound(DeviceReference, SearchParameter)
of
the specified callback
argument. Should
listener
not be null
, it will be registered for
tracking device changes on each matching device.
search
- the search criteria for matching devicescallback
- where search results are to be delivered to; must not be
null
listener
- if not null
, the listener is used for
asynchronous callbacks each time the state of a device
matching the search criteria changes (i.e. when it goes
online, etc.)public static DataStructure getLocalDevices()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |