YAACC - UPNP Client and Server
Loading...
Searching...
No Matches
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
org.fourthline.cling.model.DefaultServiceManager< T > Class Template Reference

Default implementation, creates and manages a single instance of a plain Java bean. More...

Inheritance diagram for org.fourthline.cling.model.DefaultServiceManager< T >:
Inheritance graph
Collaboration diagram for org.fourthline.cling.model.DefaultServiceManager< T >:
Collaboration graph

Classes

class  DefaultPropertyChangeListener
 

Public Member Functions

 DefaultServiceManager (LocalService< T > service, Class< T > serviceClass)
 
LocalService< T > getService ()
 
getImplementation ()
 
PropertyChangeSupport getPropertyChangeSupport ()
 Provides the capability to monitor the service for state changes.
 
void execute (Command< T > cmd) throws Exception
 Double-dispatch of arbitrary commands, used by action executors and state variable accessors.
 
Collection< StateVariableValue > getCurrentState () throws Exception
 Reading the state of a service manually.
 
String toString ()
 

Protected Member Functions

 DefaultServiceManager (LocalService< T > service)
 
void lock ()
 
void unlock ()
 
int getLockTimeoutMillis ()
 
Collection< StateVariableValue > getCurrentState (String[] variableNames) throws Exception
 
void init ()
 
createServiceInstance () throws Exception
 
PropertyChangeSupport createPropertyChangeSupport (T serviceImpl) throws Exception
 
PropertyChangeListener createPropertyChangeListener (T serviceImpl) throws Exception
 
Collection< StateVariableValue > readInitialEventedStateVariableValues () throws Exception
 

Protected Attributes

final LocalService< T > service
 
final Class< T > serviceClass
 
final ReentrantLock lock = new ReentrantLock(true)
 
serviceImpl
 
PropertyChangeSupport propertyChangeSupport
 

Additional Inherited Members

- Static Public Attributes inherited from org.fourthline.cling.model.ServiceManager< T >
static final String EVENTED_STATE_VARIABLES = "_EventedStateVariables"
 Use this property name when propagating change events that affect any evented UPnP state variable.
 

Detailed Description

Default implementation, creates and manages a single instance of a plain Java bean.

Creates instance of the defined service class when it is first needed (acts as a factory), manages the instance in a field (it's shared), and synchronizes (locks) all multi-threaded access. A locking attempt will timeout after 500 milliseconds with a runtime exception if another operation is already in progress. Override getLockTimeoutMillis() to customize this behavior, e.g. if your service bean is slow and requires more time for typical action executions or state variable reading.

Author
Christian Bauer

Member Function Documentation

◆ execute()

void org.fourthline.cling.model.DefaultServiceManager< T >.execute ( Command< T >  cmd) throws Exception

Double-dispatch of arbitrary commands, used by action executors and state variable accessors.

The service manager will execute the given org.fourthline.cling.model.Command and it might decorate the execution, for example, by locking/unlocking access to a shared service implementation before and after the execution.

Parameters
cmdThe command to execute.
Exceptions
ExceptionAny exception, without wrapping, as thrown by org.fourthline.cling.model.Command#execute(ServiceManager)

Implements org.fourthline.cling.model.ServiceManager< T >.

◆ getCurrentState()

Collection< StateVariableValue > org.fourthline.cling.model.DefaultServiceManager< T >.getCurrentState ( ) throws Exception

Reading the state of a service manually.

Returns
A Collection of org.fourthline.cling.model.state.StateVariableValue, representing the current state of the service, that is, all evented state variable values.
Exceptions
ExceptionAny error that occurred when the service's state was accessed.

Implements org.fourthline.cling.model.ServiceManager< T >.

Here is the call graph for this function:

◆ getImplementation()

◆ getPropertyChangeSupport()

PropertyChangeSupport org.fourthline.cling.model.DefaultServiceManager< T >.getPropertyChangeSupport ( )

Provides the capability to monitor the service for state changes.

The GENA subsystem expects that this adapter will notify its listeners whenever any evented UPnP state variable of the service has changed its state. The following change event is expected:

The collection has to include values for all state variables, no matter what state variable was updated. Any other event is ignored (e.g. individual property changes).

Returns
An adapter that will notify its listeners whenever any evented state variable changes.

Implements org.fourthline.cling.model.ServiceManager< T >.

◆ getService()

LocalService< T > org.fourthline.cling.model.DefaultServiceManager< T >.getService ( )
Returns
The metadata of the service to which this manager is assigned.

Implements org.fourthline.cling.model.ServiceManager< T >.

Referenced by org.fourthline.cling.model.DefaultServiceManager< T >.getCurrentState().

Here is the caller graph for this function:

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