|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.teleal.cling.model.DefaultServiceManager<T>
public class DefaultServiceManager<T>
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.
Nested Class Summary | |
---|---|
protected class |
DefaultServiceManager.DefaultPropertyChangeListener
|
Field Summary | |
---|---|
protected ReentrantLock |
lock
|
protected PropertyChangeSupport |
propertyChangeSupport
|
protected LocalService<T> |
service
|
protected Class<T> |
serviceClass
|
protected T |
serviceImpl
|
Fields inherited from interface org.teleal.cling.model.ServiceManager |
---|
EVENTED_STATE_VARIABLES |
Constructor Summary | |
---|---|
protected |
DefaultServiceManager(LocalService<T> service)
|
|
DefaultServiceManager(LocalService<T> service,
Class<T> serviceClass)
|
Method Summary | |
---|---|
protected PropertyChangeListener |
createPropertyChangeListener(T serviceImpl)
|
protected PropertyChangeSupport |
createPropertyChangeSupport(T serviceImpl)
|
protected T |
createServiceInstance()
|
void |
execute(Command<T> cmd)
Double-dispatch of arbitrary commands, used by action executors and state variable accessors. |
T |
getImplementation()
|
protected int |
getLockTimeoutMillis()
|
PropertyChangeSupport |
getPropertyChangeSupport()
Provides the capability to monitor the service for state changes. |
LocalService<T> |
getService()
|
protected void |
init()
|
protected void |
lock()
|
Collection<StateVariableValue> |
readEventedStateVariableValues()
Reading the state of a service manually. |
String |
toString()
|
protected void |
unlock()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected final LocalService<T> service
protected final Class<T> serviceClass
protected final ReentrantLock lock
protected T serviceImpl
protected PropertyChangeSupport propertyChangeSupport
Constructor Detail |
---|
protected DefaultServiceManager(LocalService<T> service)
public DefaultServiceManager(LocalService<T> service, Class<T> serviceClass)
Method Detail |
---|
protected void lock()
protected void unlock()
protected int getLockTimeoutMillis()
public LocalService<T> getService()
getService
in interface ServiceManager<T>
public T getImplementation()
getImplementation
in interface ServiceManager<T>
ActionExecutor
s
and StateVariableAccessor
s.public PropertyChangeSupport getPropertyChangeSupport()
ServiceManager
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:
ServiceManager.EVENTED_STATE_VARIABLES
.null
, only the current state has to be included.Collection
of StateVariableValue
,
representing the current state of the service after the change.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).
getPropertyChangeSupport
in interface ServiceManager<T>
public void execute(Command<T> cmd) throws Exception
ServiceManager
The service manager will execute the given Command
and it
might decorate the execution, for example, by locking/unlocking access to a shared service
implementation before and after the execution.
execute
in interface ServiceManager<T>
cmd
- The command to execute.
Exception
- Any exception, without wrapping, as thrown by Command.execute(ServiceManager)
public Collection<StateVariableValue> readEventedStateVariableValues() throws Exception
ServiceManager
readEventedStateVariableValues
in interface ServiceManager<T>
Collection
of StateVariableValue
, representing
the current state of the service.
Exception
- Any error that occured when the service's state was accessed.protected void init()
protected T createServiceInstance() throws Exception
Exception
protected PropertyChangeSupport createPropertyChangeSupport(T serviceImpl) throws Exception
Exception
protected PropertyChangeListener createPropertyChangeListener(T serviceImpl) throws Exception
Exception
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |