Skip to content
This repository has been archived by the owner on Oct 4, 2021. It is now read-only.

Commit

Permalink
Wrote some more javadoc and fixed some doc gen errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
DivineThreepwood committed Jan 11, 2017
1 parent 5ec8754 commit 612ba0c
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,14 @@
import org.openbase.jul.schedule.SyncObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import rst.domotic.action.ActionConfigType;
import rst.domotic.action.ActionConfigType.ActionConfig;
import rst.domotic.service.ServiceTemplateType.ServiceTemplate.ServiceType;
import rst.domotic.unit.UnitConfigType.UnitConfig;

/**
*
* @author <a href="mailto:[email protected]">Divine Threepwood</a>
*
* @param <S> generic definition of the overall service type for this remote.
* @param <ST> the corresponding state for the service type of this remote.
*/
Expand All @@ -74,8 +75,9 @@ public abstract class AbstractServiceRemote<S extends Service, ST extends Genera
private final SyncObject syncObject = new SyncObject("ServiceStateComputationLock");

/**
* AbstractServiceRemote constructor.
*
* @param serviceType
* @param serviceType The remote service type.
*/
public AbstractServiceRemote(final ServiceType serviceType) {
this.serviceState = null;
Expand Down Expand Up @@ -124,7 +126,7 @@ public ST getServiceState() throws NotAvailableException {
*
* @param observer the observer which is notified
*/
public void addDataObserver(Observer<ST> observer) {
public void addDataObserver(final Observer<ST> observer) {
serviceStateObservable.addObserver(observer);
}

Expand All @@ -133,7 +135,7 @@ public void addDataObserver(Observer<ST> observer) {
*
* @param observer the observer which has been registered
*/
public void removeDataObserver(Observer<ST> observer) {
public void removeDataObserver(final Observer<ST> observer) {
serviceStateObservable.removeObserver(observer);
}

Expand Down Expand Up @@ -169,8 +171,8 @@ public void init(final UnitConfig config) throws InitializationException, Interr
* Each of the units referred by the given configurations should provide the service type of this service remote.
*
* @param configs a set of unit configurations.
* @throws InitializationException
* @throws InterruptedException
* @throws InitializationException is thrown if the service remote could not be initialized.
* @throws InterruptedException is thrown if the current thread is externally interrupted.
*/
public void init(final Collection<UnitConfig> configs) throws InitializationException, InterruptedException {
try {
Expand All @@ -192,6 +194,12 @@ public void init(final Collection<UnitConfig> configs) throws InitializationExce
}
}

/**
* {@inheritDoc}
*
* @throws CouldNotPerformException {@inheritDoc}
* @throws InterruptedException {@inheritDoc}
*/
@Override
public void activate() throws CouldNotPerformException, InterruptedException {
try {
Expand All @@ -210,6 +218,12 @@ public void activate() throws CouldNotPerformException, InterruptedException {
}
}

/**
* {@inheritDoc}
*
* @throws CouldNotPerformException {@inheritDoc}
* @throws InterruptedException {@inheritDoc}
*/
@Override
public void deactivate() throws CouldNotPerformException, InterruptedException {
MultiException.ExceptionStack exceptionStack = null;
Expand All @@ -224,6 +238,9 @@ public void deactivate() throws CouldNotPerformException, InterruptedException {
MultiException.checkAndThrow("Could not deactivate all service units!", exceptionStack);
}

/**
* {@inheritDoc}
*/
@Override
public void shutdown() {
try {
Expand All @@ -233,33 +250,63 @@ public void shutdown() {
}
}

/**
* {@inheritDoc}
*
* @return {@inheritDoc}
*/
@Override
public boolean isActive() {
return unitRemoteMap.values().stream().allMatch((remote) -> (remote.isActive()));
}

/**
* Returns the internal service factory which is used for the instance creation.
*
* @return the internal service factory.
*/
public UnitRemoteFactory getFactory() {
return factory;
}

public void setFactory(UnitRemoteFactory factory) {
/**
* Set the internal service factory which will be used for the instance creation.
*
* @param factory the service factory.
*/
public void setFactory(final UnitRemoteFactory factory) {
this.factory = factory;
}

/**
* Returns a collection of all internally used unit remotes.
*
* @return a collection of unit remotes limited to the service interface.
*/
public Collection<UnitRemote> getInternalUnits() {
return Collections.unmodifiableCollection(unitRemoteMap.values());
}

/**
* Returns a collection of all internally used unit remotes.
*
* @return a collection of unit remotes limited to the service interface.
*/
public Collection<S> getServices() {
return Collections.unmodifiableCollection(serviceMap.values());
}

/**
* Returns the service type of this remote.
*
* @return the remote service type.
*/
public ServiceType getServiceType() {
return serviceType;
}

@Override
public Future<Void> applyAction(final ActionConfigType.ActionConfig actionConfig) throws CouldNotPerformException, InterruptedException {
public Future<Void> applyAction(final ActionConfig actionConfig) throws CouldNotPerformException, InterruptedException {
try {
if (!actionConfig.getServiceType().equals(getServiceType())) {
throw new VerificationFailedException("Service type is not compatible to given action config!");
Expand Down Expand Up @@ -299,7 +346,7 @@ public void waitForData() throws CouldNotPerformException, InterruptedException
* @throws CouldNotPerformException is thrown in case the any error occurs, or if the given timeout is reached. In this case a TimeoutException is thrown.
* @throws InterruptedException is thrown in case the thread is externally interrupted.
*/
public void waitForData(long timeout, TimeUnit timeUnit) throws CouldNotPerformException, InterruptedException {
public void waitForData(final long timeout, final TimeUnit timeUnit) throws CouldNotPerformException, InterruptedException {
//todo reimplement with respect to the given timeout.
for (UnitRemote remote : unitRemoteMap.values()) {
waitForData(timeout, timeUnit);
Expand Down Expand Up @@ -329,6 +376,11 @@ public static boolean verifyServiceCompatibility(final UnitConfig unitConfig, fi
return unitConfig.getServiceConfigList().stream().anyMatch((serviceConfig) -> (serviceConfig.getServiceTemplate().getType() == serviceType));
}

/**
* Returns a short instance description.
*
* @return a description as string.
*/
@Override
public String toString() {
if (serviceType == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,32 +37,32 @@ public interface ServiceRemoteFactory {
* Creates and initializes a service remote out of the given service type
* and a collection of unitConfigs.
*
* @param serviceType
* @param unitConfigs
* @param serviceType The remote service type.
* @param unitConfigs The collection of units which are controlled by the new service remote instance.
* @return the new created service remote.
* @throws CouldNotPerformException
* @throws java.lang.InterruptedException
* @throws CouldNotPerformException is thrown if any error occurs during the creation.
* @throws InterruptedException is thrown if the current thread is externally interrupted.
*/
public AbstractServiceRemote createAndInitServiceRemote(final ServiceType serviceType, final Collection<UnitConfig> unitConfigs) throws CouldNotPerformException, InterruptedException;

/**
* Creates and initializes a service remote out of the given service type
* and unitConfig.
*
* @param serviceType
* @param unitConfig
* @param serviceType The remote service type.
* @param unitConfig The unit which is controlled by the new service remote instance.
* @return the new created service remote.
* @throws CouldNotPerformException
* @throws java.lang.InterruptedException
* @throws CouldNotPerformException is thrown if any error occurs during the creation.
* @throws InterruptedException is thrown if the current thread is externally interrupted.
*/
public AbstractServiceRemote createAndInitServiceRemote(final ServiceType serviceType, final UnitConfig unitConfig) throws CouldNotPerformException, InterruptedException;

/**
* Creates a service remote out of the given service type.
*
* @param serviceType
* @param serviceType The remote service type.
* @return the new created unit remote.
* @throws CouldNotPerformException
* @throws CouldNotPerformException is thrown if any error occurs during the creation.
*/
public AbstractServiceRemote createServiceRemote(final ServiceType serviceType) throws CouldNotPerformException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import rst.rsb.ScopeType;

/**
* TODO Release: remove unused @param <CONFIG> Configuration
* TODO Release: remove unused parameter CONFIG
*
* @author <a href="mailto:[email protected]">Divine Threepwood</a>
* @param <M> Message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@
import rst.rsb.ScopeType.Scope;

/**
*
* @author <a href="mailto:[email protected]">Divine Threepwood</a>
*
* The unit remote factory interface.
*/
public interface UnitRemoteFactory extends Factory<UnitRemote, UnitConfig> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.openbase.bco.registry.unit.remote.CachedUnitRegistryRemote;
import org.openbase.jul.exception.CouldNotPerformException;
import org.openbase.jul.exception.FatalImplementationErrorException;
import org.openbase.jul.exception.InitializationException;
import org.openbase.jul.exception.InvalidStateException;
import org.openbase.jul.exception.NotAvailableException;
import org.openbase.jul.exception.printer.ExceptionPrinter;
Expand Down Expand Up @@ -212,7 +211,7 @@ public static UnitRemote getUnit(final String unitId, final boolean waitForData)
* To force a resynchronization call {@link org.openbase.bco.dal.remote.unit.UnitRemote#requestData()} on the remote instance.
* Please avoid polling unit states! If you want to get informed about unit config or unit data state changes, please register new config or data observer on this remote instance.
*
* @param unitId the unit identifier.
* @param unitConfig the unit configuration.
* @param waitForData if this flag is set to true the current thread will block until the unit remote is fully synchronized with the unit controller.
* @return a new or cached unit remote which can be used to control the unit or request all current unit states.
* @throws NotAvailableException is thrown in case the unit is not available.
Expand Down Expand Up @@ -244,7 +243,7 @@ public static UnitRemote getUnit(final UnitConfig unitConfig, final boolean wait
*
* @see #getUnit(rst.domotic.unit.UnitConfigType.UnitConfig, boolean)
*/
public static <UR extends UnitRemote> UR getUnit(final UnitConfig unitConfig, boolean waitForData, final Class<UR> unitRemoteClass) throws NotAvailableException, InterruptedException {
public static <UR extends UnitRemote> UR getUnit(final UnitConfig unitConfig, final boolean waitForData, final Class<UR> unitRemoteClass) throws NotAvailableException, InterruptedException {
try {
return (UR) getUnit(unitConfig, waitForData);
} catch (ClassCastException ex) {
Expand Down

0 comments on commit 612ba0c

Please sign in to comment.