S - generic definition of the overall service type for this remote.ST - the corresponding state for the service type of this remote.public abstract class AbstractServiceRemote<S extends Service,ST extends com.google.protobuf.GeneratedMessage> extends Object implements Service, org.openbase.jul.iface.Manageable<rst.domotic.unit.UnitConfigType.UnitConfig>
| Modifier and Type | Field and Description |
|---|---|
protected org.slf4j.Logger |
logger |
protected org.openbase.jul.pattern.ObservableImpl<ST> |
serviceStateObservable |
SERVICE_LABEL| Constructor and Description |
|---|
AbstractServiceRemote(rst.domotic.service.ServiceTemplateType.ServiceTemplate.ServiceType serviceType)
AbstractServiceRemote constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
activate() |
void |
addDataObserver(org.openbase.jul.pattern.Observer<ST> observer)
Add an observer to get notifications when the service state changes.
|
Future<Void> |
applyAction(rst.domotic.action.ActionConfigType.ActionConfig actionConfig) |
protected abstract ST |
computeServiceState()
Compute the service state of this service collection if an underlying service changes.
|
void |
deactivate() |
UnitRemoteFactory |
getFactory()
Returns the internal service factory which is used for the instance creation.
|
Collection<UnitRemote> |
getInternalUnits()
Returns a collection of all internally used unit remotes.
|
Collection<S> |
getServices()
Returns a collection of all internally used unit remotes.
|
ST |
getServiceState() |
rst.domotic.service.ServiceTemplateType.ServiceTemplate.ServiceType |
getServiceType()
Returns the service type of this remote.
|
void |
init(Collection<rst.domotic.unit.UnitConfigType.UnitConfig> configs)
Initializes this service remote with a set of unit configurations.
|
void |
init(rst.domotic.unit.UnitConfigType.UnitConfig config) |
boolean |
isActive() |
boolean |
isConnected()
Checks if a server connection is established for every underlying remote.
|
boolean |
isDataAvailable()
Check if the data object is already available for every underlying remote.
|
void |
removeDataObserver(org.openbase.jul.pattern.Observer<ST> observer)
Remove an observer for the service state.
|
void |
setFactory(UnitRemoteFactory factory)
Set the internal service factory which will be used for the instance creation.
|
void |
shutdown() |
String |
toString()
Returns a short instance description.
|
static boolean |
verifyServiceCompatibility(rst.domotic.unit.UnitConfigType.UnitConfig unitConfig,
rst.domotic.service.ServiceTemplateType.ServiceTemplate.ServiceType serviceType) |
void |
waitForData()
Method blocks until an initial data message was dataObserverreceived from every remote controller.
|
void |
waitForData(long timeout,
TimeUnit timeUnit)
Method blocks until an initial data message was received from every remote controller or the given timeout is reached.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitdetectServiceMethod, getArgumentClasses, getServiceBaseName, getServicePrefix, getServiceStateName, invokeServiceMethodprotected final org.slf4j.Logger logger
protected final org.openbase.jul.pattern.ObservableImpl<ST extends com.google.protobuf.GeneratedMessage> serviceStateObservable
public AbstractServiceRemote(rst.domotic.service.ServiceTemplateType.ServiceTemplate.ServiceType serviceType)
serviceType - The remote service type.protected abstract ST computeServiceState() throws org.openbase.jul.exception.CouldNotPerformException
org.openbase.jul.exception.CouldNotPerformException - if an underlying service throws an exceptionpublic ST getServiceState() throws org.openbase.jul.exception.NotAvailableException
org.openbase.jul.exception.NotAvailableException - if the service state has not been set at least once.public void addDataObserver(org.openbase.jul.pattern.Observer<ST> observer)
observer - the observer which is notifiedpublic void removeDataObserver(org.openbase.jul.pattern.Observer<ST> observer)
observer - the observer which has been registeredpublic void init(rst.domotic.unit.UnitConfigType.UnitConfig config)
throws org.openbase.jul.exception.InitializationException,
InterruptedException
init in interface org.openbase.jul.iface.Initializable<rst.domotic.unit.UnitConfigType.UnitConfig>config - org.openbase.jul.exception.InitializationExceptionInterruptedExceptionpublic void init(Collection<rst.domotic.unit.UnitConfigType.UnitConfig> configs) throws org.openbase.jul.exception.InitializationException, InterruptedException
configs - a set of unit configurations.org.openbase.jul.exception.InitializationException - is thrown if the service remote could not be initialized.InterruptedException - is thrown if the current thread is externally interrupted.public void activate()
throws org.openbase.jul.exception.CouldNotPerformException,
InterruptedException
activate in interface org.openbase.jul.iface.Activatableorg.openbase.jul.exception.CouldNotPerformExceptionInterruptedExceptionpublic void deactivate()
throws org.openbase.jul.exception.CouldNotPerformException,
InterruptedException
deactivate in interface org.openbase.jul.iface.Activatableorg.openbase.jul.exception.CouldNotPerformExceptionInterruptedExceptionpublic void shutdown()
shutdown in interface org.openbase.jul.iface.Manageable<rst.domotic.unit.UnitConfigType.UnitConfig>shutdown in interface org.openbase.jul.iface.Shutdownablepublic boolean isActive()
isActive in interface org.openbase.jul.iface.Activatablepublic UnitRemoteFactory getFactory()
public void setFactory(UnitRemoteFactory factory)
factory - the service factory.public Collection<UnitRemote> getInternalUnits()
public Collection<S> getServices()
public rst.domotic.service.ServiceTemplateType.ServiceTemplate.ServiceType getServiceType()
public Future<Void> applyAction(rst.domotic.action.ActionConfigType.ActionConfig actionConfig) throws org.openbase.jul.exception.CouldNotPerformException, InterruptedException
applyAction in interface Serviceorg.openbase.jul.exception.CouldNotPerformExceptionInterruptedExceptionpublic void waitForData()
throws org.openbase.jul.exception.CouldNotPerformException,
InterruptedException
org.openbase.jul.exception.CouldNotPerformException - is thrown if any error occurs.InterruptedException - is thrown in case the thread is externally interrupted.public void waitForData(long timeout,
TimeUnit timeUnit)
throws org.openbase.jul.exception.CouldNotPerformException,
InterruptedException
timeout - maximal time to wait for the main controller data. After the timeout is reached a TimeoutException is thrown.timeUnit - the time unit of the timeout.org.openbase.jul.exception.CouldNotPerformException - is thrown in case the any error occurs, or if the given timeout is reached. In this case a TimeoutException is thrown.InterruptedException - is thrown in case the thread is externally interrupted.public boolean isConnected()
public boolean isDataAvailable()
public static boolean verifyServiceCompatibility(rst.domotic.unit.UnitConfigType.UnitConfig unitConfig,
rst.domotic.service.ServiceTemplateType.ServiceTemplate.ServiceType serviceType)
Copyright © 2014–2017 openbase.org. All rights reserved.