Klasse DefaultServiceManager<T>

java.lang.Object
org.jupnp.model.DefaultServiceManager<T>
Alle implementierten Schnittstellen:
ServiceManager<T>

public class DefaultServiceManager<T> extends Object implements ServiceManager<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.

Autor:
Christian Bauer, Jochen Hiller - Changed to use Compact2 compliant Java Beans
  • Felddetails

  • Konstruktordetails

    • DefaultServiceManager

      protected DefaultServiceManager(LocalService<T> service)
    • DefaultServiceManager

      public DefaultServiceManager(LocalService<T> service, Class<T> serviceClass)
  • Methodendetails

    • lock

      protected void lock()
    • unlock

      protected void unlock()
    • getLockTimeoutMillis

      protected int getLockTimeoutMillis()
    • getService

      public LocalService<T> getService()
      Angegeben von:
      getService in Schnittstelle ServiceManager<T>
      Gibt zurück:
      The metadata of the service to which this manager is assigned.
    • getImplementation

      public T getImplementation()
      Angegeben von:
      getImplementation in Schnittstelle ServiceManager<T>
      Gibt zurück:
      An instance with the interface expected by the bound ActionExecutors and StateVariableAccessors.
    • getPropertyChangeSupport

      public PropertyChangeSupport getPropertyChangeSupport()
      Beschreibung aus Schnittstelle kopiert: ServiceManager
      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).

      Angegeben von:
      getPropertyChangeSupport in Schnittstelle ServiceManager<T>
      Gibt zurück:
      An adapter that will notify its listeners whenever any evented state variable changes.
    • execute

      public void execute(Command<T> cmd) throws Exception
      Beschreibung aus Schnittstelle kopiert: ServiceManager
      Double-dispatch of arbitrary commands, used by action executors and state variable accessors.

      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.

      Angegeben von:
      execute in Schnittstelle ServiceManager<T>
      Parameter:
      cmd - The command to execute.
      Löst aus:
      Exception - Any exception, without wrapping, as thrown by Command.execute(ServiceManager)
    • getCurrentState

      public Collection<StateVariableValue> getCurrentState() throws Exception
      Beschreibung aus Schnittstelle kopiert: ServiceManager
      Reading the state of a service manually.
      Angegeben von:
      getCurrentState in Schnittstelle ServiceManager<T>
      Gibt zurück:
      A Collection of StateVariableValue, representing the current state of the service, that is, all evented state variable values.
      Löst aus:
      Exception - Any error that occurred when the service's state was accessed.
    • getCurrentState

      protected Collection<StateVariableValue> getCurrentState(String[] variableNames) throws Exception
      Löst aus:
      Exception
    • init

      protected void init()
    • createServiceInstance

      protected T createServiceInstance() throws Exception
      Löst aus:
      Exception
    • createPropertyChangeSupport

      protected PropertyChangeSupport createPropertyChangeSupport(T serviceImpl) throws Exception
      Löst aus:
      Exception
    • createPropertyChangeListener

      protected PropertyChangeListener createPropertyChangeListener(T serviceImpl) throws Exception
      Löst aus:
      Exception
    • readInitialEventedStateVariableValues

      protected Collection<StateVariableValue> readInitialEventedStateVariableValues() throws Exception
      Löst aus:
      Exception
    • toString

      public String toString()
      Setzt außer Kraft:
      toString in Klasse Object