YAACC - UPNP Client and Server
Loading...
Searching...
No Matches
Public Member Functions | List of all members
org.fourthline.cling.registry.Registry Interface Reference

The core of the UPnP stack, keeping track of known devices and resources. More...

Inheritance diagram for org.fourthline.cling.registry.Registry:
Inheritance graph
Collaboration diagram for org.fourthline.cling.registry.Registry:
Collaboration graph

Public Member Functions

UpnpService getUpnpService ()
 
UpnpServiceConfiguration getConfiguration ()
 
ProtocolFactory getProtocolFactory ()
 
void shutdown ()
 Typically called internally when the UPnP stack is stopping.
 
void pause ()
 Stops background maintenance (thread) of registered items.
 
void resume ()
 Resumes background maintenance (thread) of registered items.
 
boolean isPaused ()
 
void addListener (RegistryListener listener)
 
void removeListener (RegistryListener listener)
 
Collection< RegistryListenergetListeners ()
 
boolean notifyDiscoveryStart (RemoteDevice device)
 Called internally by the UPnP stack when the discovery protocol starts.
 
void notifyDiscoveryFailure (RemoteDevice device, Exception ex)
 Called internally by the UPnP stack when the discovery protocol stopped abnormally.
 
void addDevice (LocalDevice localDevice) throws RegistrationException
 Call this method to add your local device metadata.
 
void addDevice (LocalDevice localDevice, DiscoveryOptions options) throws RegistrationException
 Call this method to add your local device metadata.
 
void setDiscoveryOptions (UDN udn, DiscoveryOptions options)
 Change the active DiscoveryOptions for the given (local device) UDN.
 
DiscoveryOptions getDiscoveryOptions (UDN udn)
 Get the currently active DiscoveryOptions for the given (local device) UDN.
 
void addDevice (RemoteDevice remoteDevice) throws RegistrationException
 Called internally by the UPnP discovery protocol.
 
boolean update (RemoteDeviceIdentity rdIdentity)
 Called internally by the UPnP discovery protocol.
 
boolean removeDevice (LocalDevice localDevice)
 Call this to remove your local device metadata.
 
boolean removeDevice (RemoteDevice remoteDevice)
 Called internally by the UPnP discovery protocol.
 
boolean removeDevice (UDN udn)
 Call this to remove any device metadata with the given UDN.
 
void removeAllLocalDevices ()
 Clear the registry of all locally registered device metadata.
 
void removeAllRemoteDevices ()
 Clear the registry of all discovered remote device metadata.
 
Device getDevice (UDN udn, boolean rootOnly)
 
LocalDevice getLocalDevice (UDN udn, boolean rootOnly)
 
RemoteDevice getRemoteDevice (UDN udn, boolean rootOnly)
 
Collection< LocalDevice > getLocalDevices ()
 
Collection< RemoteDevice > getRemoteDevices ()
 
Collection< Device<?, ?, ?> > getDevices ()
 
Collection< Device<?, ?, ?> > getDevices (DeviceType deviceType)
 
Collection< Device<?, ?, ?> > getDevices (ServiceType serviceType)
 
Service<?, ?> getService (ServiceReference serviceReference)
 
void addResource (Resource resource)
 Stores an arbitrary resource in the registry.
 
void addResource (Resource resource, int maxAgeSeconds)
 Stores an arbitrary resource in the registry.
 
boolean removeResource (Resource resource)
 Removes a resource from the registry.
 
Resource getResource (URI pathQuery) throws IllegalArgumentException
 
public< T extends Resource > T getResource (Class< T > resourceType, URI pathQuery) throws IllegalArgumentException
 
Collection< Resource > getResources ()
 
public< T extends Resource > Collection< T > getResources (Class< T > resourceType)
 
void addLocalSubscription (LocalGENASubscription subscription)
 Called internally by the UPnP stack, during GENA protocol execution.
 
LocalGENASubscription getLocalSubscription (String subscriptionId)
 Called internally by the UPnP stack, during GENA protocol execution.
 
boolean updateLocalSubscription (LocalGENASubscription subscription)
 Called internally by the UPnP stack, during GENA protocol execution.
 
boolean removeLocalSubscription (LocalGENASubscription subscription)
 Called internally by the UPnP stack, during GENA protocol execution.
 
void addRemoteSubscription (RemoteGENASubscription subscription)
 Called internally by the UPnP stack, during GENA protocol execution.
 
RemoteGENASubscription getRemoteSubscription (String subscriptionId)
 Called internally by the UPnP stack, during GENA protocol execution.
 
void updateRemoteSubscription (RemoteGENASubscription subscription)
 Called internally by the UPnP stack, during GENA protocol execution.
 
void removeRemoteSubscription (RemoteGENASubscription subscription)
 Called internally by the UPnP stack, during GENA protocol execution.
 
void registerPendingRemoteSubscription (RemoteGENASubscription subscription)
 Called internally by the UPnP stack, during GENA protocol execution.
 
void unregisterPendingRemoteSubscription (RemoteGENASubscription subscription)
 Called internally by the UPnP stack, during GENA protocol execution.
 
RemoteGENASubscription getWaitRemoteSubscription (String subscriptionId)
 Called internally by the UPnP stack, during GENA protocol execution.
 
void advertiseLocalDevices ()
 Manually trigger advertisement messages for all local devices.
 

Detailed Description

The core of the UPnP stack, keeping track of known devices and resources.

A running UPnP stack has one Registry. Any discovered device is added to this registry, as well as any exposed local device. The registry then maintains these devices continuously (see RegistryMaintainer) and when needed refreshes their announcements on the network or removes them when they have expired. The registry also keeps track of GENA event subscriptions.

UPnP client applications typically monitor activity of the registry via RegistryListener, they are inherently asynchronous.

The registry has to be shutdown() properly, so it can notify all participants on the network that local devices will no longer be available and cancel all GENA subscriptions.

An implementation has to be thread-safe.

Author
Christian Bauer

Member Function Documentation

◆ addDevice() [1/3]

void org.fourthline.cling.registry.Registry.addDevice ( LocalDevice  localDevice) throws RegistrationException

Call this method to add your local device metadata.

Parameters
localDeviceThe device to add and maintain.
Exceptions
RegistrationExceptionIf a conflict with an already registered device was detected.

Implemented in org.fourthline.cling.registry.RegistryImpl.

◆ addDevice() [2/3]

void org.fourthline.cling.registry.Registry.addDevice ( LocalDevice  localDevice,
DiscoveryOptions  options 
) throws RegistrationException

Call this method to add your local device metadata.

Parameters
localDeviceThe device to add and maintain.
optionsImmediately effective when this device is registered.
Exceptions
RegistrationExceptionIf a conflict with an already registered device was detected.

Implemented in org.fourthline.cling.registry.RegistryImpl.

◆ addDevice() [3/3]

void org.fourthline.cling.registry.Registry.addDevice ( RemoteDevice  remoteDevice) throws RegistrationException

Called internally by the UPnP discovery protocol.

Exceptions
RegistrationExceptionIf a conflict with an already registered device was detected.

Implemented in org.fourthline.cling.registry.RegistryImpl.

◆ addLocalSubscription()

void org.fourthline.cling.registry.Registry.addLocalSubscription ( LocalGENASubscription  subscription)

Called internally by the UPnP stack, during GENA protocol execution.

Implemented in org.fourthline.cling.registry.RegistryImpl.

◆ addRemoteSubscription()

void org.fourthline.cling.registry.Registry.addRemoteSubscription ( RemoteGENASubscription  subscription)

Called internally by the UPnP stack, during GENA protocol execution.

Implemented in org.fourthline.cling.registry.RegistryImpl.

◆ addResource() [1/2]

void org.fourthline.cling.registry.Registry.addResource ( Resource  resource)

Stores an arbitrary resource in the registry.

Parameters
resourceThe resource to maintain indefinitely (until it is manually removed).

Implemented in org.fourthline.cling.registry.RegistryImpl.

◆ addResource() [2/2]

void org.fourthline.cling.registry.Registry.addResource ( Resource  resource,
int  maxAgeSeconds 
)

Stores an arbitrary resource in the registry.

Call this method repeatedly to refresh and prevent expiration of the resource.

Parameters
resourceThe resource to maintain.
maxAgeSecondsThe time after which the registry will automatically remove the resource.

Implemented in org.fourthline.cling.registry.RegistryImpl.

◆ advertiseLocalDevices()

void org.fourthline.cling.registry.Registry.advertiseLocalDevices ( )

Manually trigger advertisement messages for all local devices.

No messages will be send for devices with disabled advertisements, see DiscoveryOptions!

Implemented in org.fourthline.cling.registry.RegistryImpl.

◆ getDevice()

Device org.fourthline.cling.registry.Registry.getDevice ( UDN  udn,
boolean  rootOnly 
)
Parameters
udnThe device name to lookup.
rootOnlyIf true, only matches of root devices are returned.
Returns
The registered root or embedded device metadata, or null.

Implemented in org.fourthline.cling.registry.RegistryImpl.

◆ getDevices() [1/3]

Collection< Device<?, ?, ?> > org.fourthline.cling.registry.Registry.getDevices ( )
Returns
All device metadata, in no particular order, or an empty collection.

Implemented in org.fourthline.cling.registry.RegistryImpl.

◆ getDevices() [2/3]

Collection< Device<?, ?, ?> > org.fourthline.cling.registry.Registry.getDevices ( DeviceType  deviceType)
Returns
All device metadata of devices which implement the given type, in no particular order, or an empty collection.

Implemented in org.fourthline.cling.registry.RegistryImpl.

◆ getDevices() [3/3]

Collection< Device<?, ?, ?> > org.fourthline.cling.registry.Registry.getDevices ( ServiceType  serviceType)
Returns
All device metadata of devices which have a service that implements the given type, in no particular order, or an empty collection.

Implemented in org.fourthline.cling.registry.RegistryImpl.

◆ getDiscoveryOptions()

DiscoveryOptions org.fourthline.cling.registry.Registry.getDiscoveryOptions ( UDN  udn)

Get the currently active DiscoveryOptions for the given (local device) UDN.

Returns
null if there are no active discovery options for the given UDN.

Implemented in org.fourthline.cling.registry.RegistryImpl.

◆ getLocalDevice()

LocalDevice org.fourthline.cling.registry.Registry.getLocalDevice ( UDN  udn,
boolean  rootOnly 
)
Parameters
udnThe device name to lookup.
rootOnlyIf true, only matches of root devices are returned.
Returns
The registered root or embedded device metadata, or null.

Implemented in org.fourthline.cling.registry.RegistryImpl.

◆ getLocalDevices()

Collection< LocalDevice > org.fourthline.cling.registry.Registry.getLocalDevices ( )
Returns
All locally registered device metadata, in no particular order, or an empty collection.

Implemented in org.fourthline.cling.registry.RegistryImpl.

◆ getLocalSubscription()

LocalGENASubscription org.fourthline.cling.registry.Registry.getLocalSubscription ( String  subscriptionId)

Called internally by the UPnP stack, during GENA protocol execution.

Implemented in org.fourthline.cling.registry.RegistryImpl.

◆ getRemoteDevice()

RemoteDevice org.fourthline.cling.registry.Registry.getRemoteDevice ( UDN  udn,
boolean  rootOnly 
)
Parameters
udnThe device name to lookup.
rootOnlyIf true, only matches of root devices are returned.
Returns
The registered root or embedded device metadata, or null.

Implemented in org.fourthline.cling.registry.RegistryImpl.

◆ getRemoteDevices()

Collection< RemoteDevice > org.fourthline.cling.registry.Registry.getRemoteDevices ( )
Returns
All discovered remote device metadata, in no particular order, or an empty collection.

Implemented in org.fourthline.cling.registry.RegistryImpl.

◆ getRemoteSubscription()

RemoteGENASubscription org.fourthline.cling.registry.Registry.getRemoteSubscription ( String  subscriptionId)

Called internally by the UPnP stack, during GENA protocol execution.

Implemented in org.fourthline.cling.registry.RegistryImpl.

◆ getResource() [1/2]

public< T extends Resource > T org.fourthline.cling.registry.Registry.getResource ( Class< T >  resourceType,
URI  pathQuery 
) throws IllegalArgumentException
Parameters
<T>The required subtype of the org.fourthline.cling.model.resource.Resource.
pathQueryThe path and optional query string of the resource's registration URI (e.g. /dev/somefile.xml?param=value)
resourceTypeThe required subtype of the org.fourthline.cling.model.resource.Resource.
Returns
Any registered resource that matches the given URI path and subtype.
Exceptions
IllegalArgumentExceptionIf the given URI was absolute, only path and query are allowed.

◆ getResource() [2/2]

Resource org.fourthline.cling.registry.Registry.getResource ( URI  pathQuery) throws IllegalArgumentException
Parameters
pathQueryThe path and optional query string of the resource's registration URI (e.g. /dev/somefile.xml?param=value)
Returns
Any registered resource that matches the given URI path.
Exceptions
IllegalArgumentExceptionIf the given URI was absolute, only path and query are allowed.

Implemented in org.fourthline.cling.registry.RegistryImpl.

◆ getResources() [1/2]

Collection< Resource > org.fourthline.cling.registry.Registry.getResources ( )
Returns
All registered resources, in no particular order, or an empty collection.

Implemented in org.fourthline.cling.registry.RegistryImpl.

◆ getResources() [2/2]

public< T extends Resource > Collection< T > org.fourthline.cling.registry.Registry.getResources ( Class< T >  resourceType)
Parameters
<T>The required subtype of the org.fourthline.cling.model.resource.Resource.
resourceTypeThe required subtype of the org.fourthline.cling.model.resource.Resource.
Returns
Any registered resource that matches the given subtype.

◆ getService()

Service<?, ?> org.fourthline.cling.registry.Registry.getService ( ServiceReference  serviceReference)
Returns
Complete service metadata for a service reference or null if no service for the given reference has been registered.

Implemented in org.fourthline.cling.registry.RegistryImpl.

◆ getWaitRemoteSubscription()

RemoteGENASubscription org.fourthline.cling.registry.Registry.getWaitRemoteSubscription ( String  subscriptionId)

Called internally by the UPnP stack, during GENA protocol execution.

Get a remote subscription from its subscriptionId. If the subscription can't be found, wait for one of the pending remote subscription procedures from the registry background maintainer to terminate, until the subscription has been found or until there are no more pending subscription procedures.

Implemented in org.fourthline.cling.registry.RegistryImpl.

◆ isPaused()

boolean org.fourthline.cling.registry.Registry.isPaused ( )
Returns
true if the registry has currently no running background maintenance (thread).

Implemented in org.fourthline.cling.registry.RegistryImpl.

◆ notifyDiscoveryFailure()

void org.fourthline.cling.registry.Registry.notifyDiscoveryFailure ( RemoteDevice  device,
Exception  ex 
)

Called internally by the UPnP stack when the discovery protocol stopped abnormally.

The registry will notify all registered listeners of this event.

Parameters
deviceThe half-hydrated (without services) metadata of the discovered device.
exThe cause for the interruption of the discovery protocol.

Implemented in org.fourthline.cling.registry.RegistryImpl.

◆ notifyDiscoveryStart()

boolean org.fourthline.cling.registry.Registry.notifyDiscoveryStart ( RemoteDevice  device)

Called internally by the UPnP stack when the discovery protocol starts.

The registry will notify all registered listeners of this event, unless the given device was already in the registry.

Parameters
deviceThe half-hydrated (without services) metadata of the discovered device.
Returns
false if the device was already registered.

Implemented in org.fourthline.cling.registry.RegistryImpl.

◆ pause()

void org.fourthline.cling.registry.Registry.pause ( )

Stops background maintenance (thread) of registered items.

When paused, the registry will no longer remove expired remote devices if their discovery announcements stop for some reason (device was turned off). Your local control point will now see potentially unavailable remote devices. Outbound GENA subscriptions from your local control point to remote services will not be renewed automatically anymore, a remote service might drop your subscriptions if you don't resume maintenance within the subscription's expiration timeout.

Local devices and services will not be announced periodically anymore to remote control points, only when they are manually added are removed from the registry. The registry will also no longer remove expired inbound GENA subscriptions to local service from remote control points, if that control point for some reason stops sending subscription renewal messages.

Implemented in org.fourthline.cling.registry.RegistryImpl.

◆ registerPendingRemoteSubscription()

void org.fourthline.cling.registry.Registry.registerPendingRemoteSubscription ( RemoteGENASubscription  subscription)

Called internally by the UPnP stack, during GENA protocol execution.

When subscribing with a remote host, the remote host might send the initial event message faster than the response for the subscription request. This method register that the subscription procedure is executing.

Implemented in org.fourthline.cling.registry.RegistryImpl.

◆ removeAllLocalDevices()

void org.fourthline.cling.registry.Registry.removeAllLocalDevices ( )

Clear the registry of all locally registered device metadata.

Implemented in org.fourthline.cling.registry.RegistryImpl.

◆ removeAllRemoteDevices()

void org.fourthline.cling.registry.Registry.removeAllRemoteDevices ( )

Clear the registry of all discovered remote device metadata.

Implemented in org.fourthline.cling.registry.RegistryImpl.

◆ removeDevice() [1/3]

boolean org.fourthline.cling.registry.Registry.removeDevice ( LocalDevice  localDevice)

Call this to remove your local device metadata.

Returns
true if the device was registered and has been removed.

Implemented in org.fourthline.cling.registry.RegistryImpl.

◆ removeDevice() [2/3]

boolean org.fourthline.cling.registry.Registry.removeDevice ( RemoteDevice  remoteDevice)

Called internally by the UPnP discovery protocol.

Implemented in org.fourthline.cling.registry.RegistryImpl.

◆ removeDevice() [3/3]

boolean org.fourthline.cling.registry.Registry.removeDevice ( UDN  udn)

Call this to remove any device metadata with the given UDN.

Returns
true if the device was registered and has been removed.

Implemented in org.fourthline.cling.registry.RegistryImpl.

◆ removeLocalSubscription()

boolean org.fourthline.cling.registry.Registry.removeLocalSubscription ( LocalGENASubscription  subscription)

Called internally by the UPnP stack, during GENA protocol execution.

Implemented in org.fourthline.cling.registry.RegistryImpl.

◆ removeRemoteSubscription()

void org.fourthline.cling.registry.Registry.removeRemoteSubscription ( RemoteGENASubscription  subscription)

Called internally by the UPnP stack, during GENA protocol execution.

Implemented in org.fourthline.cling.registry.RegistryImpl.

◆ removeResource()

boolean org.fourthline.cling.registry.Registry.removeResource ( Resource  resource)

Removes a resource from the registry.

Parameters
resourceThe resource to remove.
Returns
true if the resource was registered and has been removed.

Implemented in org.fourthline.cling.registry.RegistryImpl.

◆ resume()

void org.fourthline.cling.registry.Registry.resume ( )

Resumes background maintenance (thread) of registered items.

A local control point has to handle the following situations when resuming registry maintenance:

A remote device registration might have expired. This is the case when the remote device stopped sending announcements while the registry was paused (maybe because the device was switched off) and the registry was paused longer than the device advertisement's maximum age. The registry will not know if the device is still available when it resumes maintenance. However, it will simply assume that the remote device is still available and restart its expiration check cycle. That means a device will finally be removed from the registry, if no further announcements from the device are received, when the maximum age of the device has elapsed after the registry resumed operation.

Secondly, a remote device registration might not have expired but some of your outbound GENA subscriptions to its services have not been renewed within the expected renewal period. Therefore your outbound subscriptions might be invalid, because the remote service can drop subscriptions when you don't renew them. On resume, the registry will attempt to send renewals for all outbound GENA subscriptions that require renewal, on devices that still haven't expired. If renewal fails, your subscription will end with org.fourthline.cling.model.gena.CancelReason#RENEWAL_FAILED. Although you then might conclude that the remote device is no longer available, a GENA renewal can also fail for other reasons. The remote device will be kept and maintained in the registry until it announces itself or it expires, even after a failed GENA renewal.

If you are providing local devices and services, resuming registry maintenance has the following effects:

Local devices and their services are announced again immediately if the registry has been paused for longer than half of the device's maximum age. Remote control points will either see this as a new device advertisement (if they have dropped your device while you paused maintenance) or as a regular update if you didn't pause longer than the device's maximum age/expiration timeout.

Inbound GENA subscriptions to your local services are active, even in paused state - remote control points should continue renewing the subscription. If a remote control point stopped renewing a subscription without unsubscribing (hard power off), an outdated inbound subscription will be detected when you resume maintenance. This subscription will be cleaned up immediately on resume.

Implemented in org.fourthline.cling.registry.RegistryImpl.

◆ setDiscoveryOptions()

void org.fourthline.cling.registry.Registry.setDiscoveryOptions ( UDN  udn,
DiscoveryOptions  options 
)

Change the active DiscoveryOptions for the given (local device) UDN.

Parameters
optionsSet to null to disable any options.

Implemented in org.fourthline.cling.registry.RegistryImpl.

◆ shutdown()

void org.fourthline.cling.registry.Registry.shutdown ( )

Typically called internally when the UPnP stack is stopping.

Unsubscribe all local devices and GENA subscriptions.

Implemented in org.fourthline.cling.registry.RegistryImpl.

◆ unregisterPendingRemoteSubscription()

void org.fourthline.cling.registry.Registry.unregisterPendingRemoteSubscription ( RemoteGENASubscription  subscription)

Called internally by the UPnP stack, during GENA protocol execution.

Notify that the subscription procedure has terminated.

Implemented in org.fourthline.cling.registry.RegistryImpl.

◆ update()

boolean org.fourthline.cling.registry.Registry.update ( RemoteDeviceIdentity  rdIdentity)

Called internally by the UPnP discovery protocol.

Implemented in org.fourthline.cling.registry.RegistryImpl.

◆ updateLocalSubscription()

boolean org.fourthline.cling.registry.Registry.updateLocalSubscription ( LocalGENASubscription  subscription)

Called internally by the UPnP stack, during GENA protocol execution.

Implemented in org.fourthline.cling.registry.RegistryImpl.

◆ updateRemoteSubscription()

void org.fourthline.cling.registry.Registry.updateRemoteSubscription ( RemoteGENASubscription  subscription)

Called internally by the UPnP stack, during GENA protocol execution.

Implemented in org.fourthline.cling.registry.RegistryImpl.


The documentation for this interface was generated from the following file: