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 ServiceRemote<S,ST>
| Modifier and Type | Field and Description |
|---|---|
protected org.slf4j.Logger |
logger |
protected Object |
maintainer |
protected org.openbase.jul.pattern.ObservableImpl<ST> |
serviceStateObservable |
RESPONSIBLE_ACTION_FIELD_NAME, SERVICE_LABEL, SERVICE_MODE_PACKAGE, SERVICE_STATE_PACKAGE| Constructor and Description |
|---|
AbstractServiceRemote(rst.domotic.service.ServiceTemplateType.ServiceTemplate.ServiceType serviceType,
Class<ST> serviceDataClass)
AbstractServiceRemote constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
activate() |
void |
activate(Object maintainer) |
void |
addDataObserver(org.openbase.jul.pattern.Observer<ST> observer)
Add an observer to get notifications when the service state changes.
|
void |
addServiceStateObserver(rst.domotic.service.ServiceTemplateType.ServiceTemplate.ServiceType serviceType,
org.openbase.jul.pattern.Observer observer) |
Future<rst.domotic.action.ActionFutureType.ActionFuture> |
applyAction(rst.domotic.action.ActionDescriptionType.ActionDescription actionDescription) |
protected abstract ST |
computeServiceState()
Compute the service state of this service collection if an underlying
service changes.
|
void |
deactivate() |
ST |
getData() |
Class<ST> |
getDataClass() |
Collection<UnitRemote> |
getInternalUnits()
Returns a collection of all internally used unit remotes.
|
Collection<UnitRemote> |
getInternalUnits(rst.domotic.unit.UnitTemplateType.UnitTemplate.UnitType unitType) |
Long |
getPing() |
Collection<S> |
getServices()
Returns a collection of all internally used unit remotes.
|
Collection<S> |
getServices(rst.domotic.unit.UnitTemplateType.UnitTemplate.UnitType unitType)
Returns a collection of all internally used unit remotes filtered by the
given unit type.
|
ST |
getServiceState()
Deprecated.
please use getData instead.
|
rst.domotic.service.ServiceTemplateType.ServiceTemplate.ServiceType |
getServiceType()
Returns the service type of this remote.
|
boolean |
hasInternalRemotes() |
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.
|
boolean |
isLocked() |
void |
lock(Object maintainer) |
Future<Long> |
ping() |
void |
removeDataObserver(org.openbase.jul.pattern.Observer<ST> observer)
Remove an observer for the service state.
|
void |
removeServiceStateObserver(rst.domotic.service.ServiceTemplateType.ServiceTemplate.ServiceType serviceType,
org.openbase.jul.pattern.Observer observer) |
void |
removeUnit(rst.domotic.unit.UnitConfigType.UnitConfig unitConfig) |
CompletableFuture<ST> |
requestData(boolean failOnError)
Method request the data of all internal unit remotes.
|
void |
setInfrastructureFilter(boolean enabled)
Deprecated.
|
void |
shutdown() |
String |
toString()
Returns a short instance description.
|
void |
unlock(Object maintainer)
Method unlocks this instance.
|
void |
verifyMaintainability() |
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, waitactivate, addConnectionStateObserver, getConnectionState, removeConnectionStateObserver, requestDatabuildServiceState, detectServiceDataClass, detectServiceMethod, detectServiceMethod, getArgumentClasses, getServiceBaseName, getServicePrefix, getServiceStateClass, getServiceStateName, getServiceStateName, getServiceStateValues, getServiceType, invokeOperationServiceMethod, invokeProviderServiceMethod, invokeServiceMethod, invokeServiceMethod, upateActionDescription, upateActionDescriptionprotected final org.slf4j.Logger logger
protected final org.openbase.jul.pattern.ObservableImpl<ST extends com.google.protobuf.GeneratedMessage> serviceStateObservable
protected Object maintainer
protected abstract ST computeServiceState() throws org.openbase.jul.exception.CouldNotPerformException
org.openbase.jul.exception.CouldNotPerformException - if an underlying service throws an
exception@Deprecated public ST getServiceState() throws org.openbase.jul.exception.NotAvailableException
getServiceState in interface ServiceRemote<S extends Service,ST extends com.google.protobuf.GeneratedMessage>org.openbase.jul.exception.NotAvailableException - if the service state has not been set at
least once.public ST getData() throws org.openbase.jul.exception.NotAvailableException
getData in interface org.openbase.jul.pattern.provider.DataProvider<ST extends com.google.protobuf.GeneratedMessage>getData in interface org.openbase.jul.pattern.Remote<ST extends com.google.protobuf.GeneratedMessage>org.openbase.jul.exception.NotAvailableException - if the service state data has not been set at
least once.public void addDataObserver(org.openbase.jul.pattern.Observer<ST> observer)
addDataObserver in interface ServiceRemote<S extends Service,ST extends com.google.protobuf.GeneratedMessage>addDataObserver in interface org.openbase.jul.pattern.provider.DataProvider<ST extends com.google.protobuf.GeneratedMessage>observer - the observer which is notifiedpublic void removeDataObserver(org.openbase.jul.pattern.Observer<ST> observer)
removeDataObserver in interface ServiceRemote<S extends Service,ST extends com.google.protobuf.GeneratedMessage>removeDataObserver in interface org.openbase.jul.pattern.provider.DataProvider<ST extends com.google.protobuf.GeneratedMessage>observer - the observer which has been registeredpublic void addServiceStateObserver(rst.domotic.service.ServiceTemplateType.ServiceTemplate.ServiceType serviceType,
org.openbase.jul.pattern.Observer observer)
addServiceStateObserver in interface ServiceProviderpublic void removeServiceStateObserver(rst.domotic.service.ServiceTemplateType.ServiceTemplate.ServiceType serviceType,
org.openbase.jul.pattern.Observer observer)
removeServiceStateObserver in interface ServiceProviderpublic CompletableFuture<ST> requestData(boolean failOnError) throws org.openbase.jul.exception.CouldNotPerformException
requestData in interface ServiceRemote<S extends Service,ST extends com.google.protobuf.GeneratedMessage>failOnError - flag decides if an exception should be thrown in case one data request fails.org.openbase.jul.exception.CouldNotPerformException - is thrown if non of the request was successful. In case the failOnError is set to true any request error throws an CouldNotPerformException.public 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
init in interface ServiceRemote<S extends Service,ST extends com.google.protobuf.GeneratedMessage>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 activate(Object maintainer) throws InterruptedException, org.openbase.jul.exception.CouldNotPerformException
activate in interface org.openbase.jul.pattern.Remote<ST extends com.google.protobuf.GeneratedMessage>org.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 void removeUnit(rst.domotic.unit.UnitConfigType.UnitConfig unitConfig)
throws org.openbase.jul.exception.CouldNotPerformException,
InterruptedException
removeUnit in interface ServiceRemote<S extends Service,ST extends com.google.protobuf.GeneratedMessage>org.openbase.jul.exception.CouldNotPerformExceptionInterruptedExceptionpublic Collection<UnitRemote> getInternalUnits()
getInternalUnits in interface ServiceRemote<S extends Service,ST extends com.google.protobuf.GeneratedMessage>public Collection<UnitRemote> getInternalUnits(rst.domotic.unit.UnitTemplateType.UnitTemplate.UnitType unitType) throws org.openbase.jul.exception.CouldNotPerformException, InterruptedException
getInternalUnits in interface ServiceRemote<S extends Service,ST extends com.google.protobuf.GeneratedMessage>org.openbase.jul.exception.CouldNotPerformExceptionInterruptedExceptionpublic boolean hasInternalRemotes()
hasInternalRemotes in interface ServiceRemote<S extends Service,ST extends com.google.protobuf.GeneratedMessage>public Collection<S> getServices()
getServices in interface ServiceRemote<S extends Service,ST extends com.google.protobuf.GeneratedMessage>public Collection<S> getServices(rst.domotic.unit.UnitTemplateType.UnitTemplate.UnitType unitType)
getServices in interface ServiceRemote<S extends Service,ST extends com.google.protobuf.GeneratedMessage>public rst.domotic.service.ServiceTemplateType.ServiceTemplate.ServiceType getServiceType()
getServiceType in interface ServiceRemote<S extends Service,ST extends com.google.protobuf.GeneratedMessage>public Future<rst.domotic.action.ActionFutureType.ActionFuture> applyAction(rst.domotic.action.ActionDescriptionType.ActionDescription actionDescription) throws org.openbase.jul.exception.CouldNotPerformException, InterruptedException
applyAction in interface ServiceProviderorg.openbase.jul.exception.CouldNotPerformExceptionInterruptedExceptionpublic void waitForData()
throws org.openbase.jul.exception.CouldNotPerformException,
InterruptedException
waitForData in interface ServiceRemote<S extends Service,ST extends com.google.protobuf.GeneratedMessage>waitForData in interface org.openbase.jul.pattern.provider.DataProvider<ST extends com.google.protobuf.GeneratedMessage>waitForData in interface org.openbase.jul.pattern.Remote<ST extends com.google.protobuf.GeneratedMessage>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
waitForData in interface ServiceRemote<S extends Service,ST extends com.google.protobuf.GeneratedMessage>waitForData in interface org.openbase.jul.pattern.provider.DataProvider<ST extends com.google.protobuf.GeneratedMessage>waitForData in interface org.openbase.jul.pattern.Remote<ST extends com.google.protobuf.GeneratedMessage>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()
isConnected in interface ServiceRemote<S extends Service,ST extends com.google.protobuf.GeneratedMessage>isConnected in interface org.openbase.jul.pattern.Remote<ST extends com.google.protobuf.GeneratedMessage>public boolean isDataAvailable()
isDataAvailable in interface ServiceRemote<S extends Service,ST extends com.google.protobuf.GeneratedMessage>isDataAvailable in interface org.openbase.jul.pattern.provider.DataProvider<ST extends com.google.protobuf.GeneratedMessage>public static boolean verifyServiceCompatibility(rst.domotic.unit.UnitConfigType.UnitConfig unitConfig,
rst.domotic.service.ServiceTemplateType.ServiceTemplate.ServiceType serviceType)
public void verifyMaintainability()
throws org.openbase.jul.exception.VerificationFailedException
verifyMaintainability in interface org.openbase.jul.iface.Lockableorg.openbase.jul.exception.VerificationFailedExceptionpublic boolean isLocked()
isLocked in interface org.openbase.jul.iface.Lockablepublic void lock(Object maintainer) throws org.openbase.jul.exception.CouldNotPerformException
lock in interface org.openbase.jul.iface.Lockableorg.openbase.jul.exception.CouldNotPerformExceptionpublic void unlock(Object maintainer) throws org.openbase.jul.exception.CouldNotPerformException
unlock in interface org.openbase.jul.iface.Lockablemaintainer - the instance which currently holds the lock.org.openbase.jul.exception.CouldNotPerformException - is thrown if the instance could not be
unlocked.@Deprecated public void setInfrastructureFilter(boolean enabled)
public Future<Long> ping()
ping in interface org.openbase.jul.iface.provider.PingProviderping in interface org.openbase.jul.pattern.Remote<ST extends com.google.protobuf.GeneratedMessage>public Long getPing()
getPing in interface org.openbase.jul.iface.provider.PingProvidergetPing in interface org.openbase.jul.pattern.Remote<ST extends com.google.protobuf.GeneratedMessage>Copyright © 2014–2018 openbase.org. All rights reserved.