Class AbstractServiceDescriptor<A extends ArtifactDescriptor>
java.lang.Object
de.iip_ecosphere.platform.services.AbstractServiceDescriptor<A>
- Type Parameters:
A- the type of artifact descriptor
- All Implemented Interfaces:
ServiceDescriptor
public abstract class AbstractServiceDescriptor<A extends ArtifactDescriptor>
extends Object
implements ServiceDescriptor
Abstract
ServiceDescriptor implementation, e.g., including a representation of the ServiceState
statemachine. We do not protect the setters here explicitly, e.g., through a builder pattern as we assume that
the respective messages will only be called within the package of the implementing manager.
Holds a ServiceStub while the underlying service instance is operational. Must be set by the service manager,
will be released when state goes to ServiceState.STOPPING.- Author:
- Holger Eichelberger, SSE
-
Nested Class Summary
Nested classes/interfaces inherited from interface de.iip_ecosphere.platform.services.ServiceDescriptor
ServiceDescriptor.Action -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Map<ServiceDescriptor.Action, Runnable> private Stringprivate Aprivate Stringprivate Stringprivate List<TypedDataConnectorDescriptor> private booleanprivate booleanprivate de.iip_ecosphere.platform.services.environment.ServiceKindprivate Stringprivate List<TypedDataConnectorDescriptor> private List<TypedDataDescriptor> private de.iip_ecosphere.platform.services.environment.ServiceStateprivate de.iip_ecosphere.platform.services.environment.ServiceStubprivate de.iip_ecosphere.platform.support.Version -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractServiceDescriptor(String id, String applicationId, String name, String description, de.iip_ecosphere.platform.support.Version version) Creates an instance. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidAdds an input descriptor.protected voidAdds an output descriptor.protected voidaddParameter(TypedDataDescriptor parameter) Adds a parameter descriptor.voidattachAction(ServiceDescriptor.Action action, Runnable run) Attaches a runnable to an action.Returns all connector ids for the connectors incons.static Set<ServiceDescriptor> ensemble(ServiceDescriptor service) Returns all services in the same ensemble.ensembleConnectorNames(ServiceDescriptor service) Returns the names of all channel names of connectors within the ensemble ofservice.protected voidIf there is a registered runnable foraction, execute it.Returns the additional arguments to be passed on during service start.Returns the application id this service is assigned to (withoutapplication instance id).Returns the containing artifact.Returns the utilized artifact descriptor class.Returns all (asynchronous) connectors from this service.The description of the service.Returns the ensemble leader service, i.e., if multiple services are packaged together and shall be executed in the same process, it is important to synchronize aspects (via the ensemble leader service).getId()Returns the unique id of the service.Returns all (asynchronous) input connectors into this service.de.iip_ecosphere.platform.services.environment.ServiceKindgetKind()Returns the service kind.getName()The name of the service.Returns all (asynchronous) output connectors from this service.Returns all information about parameter forServiceOperations.reconfigureService(String, Map).de.iip_ecosphere.platform.services.environment.ServiceStategetState()Returns the state the service is currently in.protected de.iip_ecosphere.platform.services.environment.ServiceStubgetStub()Returns a service stub to control the service when it is running.de.iip_ecosphere.platform.support.VersionThe version of the service.protected voidinstantiateFrom(AbstractServiceDescriptor<A> template) Does further initialization afterAbstractServiceDescriptor(String, String, String, String, Version)to instantiate an instance fromtemplate.protected voidinstantiateFrom(AbstractServiceDescriptor<A> template, boolean addParameters, boolean addConnectors) Does further initialization afterAbstractServiceDescriptor(String, String, String, String, Version)to instantiate an instance fromtemplate.internalConnectorNames(Collection<? extends ServiceDescriptor> services) Returns the ids of all connectors withinservices.booleanReturns whether the service is deployable in distributable manner or fixed in deployment location.booleanReturns whether the service is top-level or nested, e.g., as family member.voidsetAdditionalArguments(List<String> additionalArgs) Defines additional arguments to be passed on during service start.protected voidsetArtifact(ArtifactDescriptor artifact) Defines an artifact.protected voidsetClassification(de.iip_ecosphere.platform.services.environment.ServiceKind kind, boolean isDeployable, boolean isTopLevel) Sets the classification of this service.voidsetState(de.iip_ecosphere.platform.services.environment.ServiceState state) Changes the state.protected voidsetStub(de.iip_ecosphere.platform.services.environment.ServiceStub stub) Defines the actual service stub.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.iip_ecosphere.platform.services.ServiceDescriptor
getApplicationInstanceId, getInvocablesCreator, getServiceId
-
Field Details
-
id
-
applicationId
-
name
-
description
-
version
private de.iip_ecosphere.platform.support.Version version -
artifact
-
state
private de.iip_ecosphere.platform.services.environment.ServiceState state -
kind
private de.iip_ecosphere.platform.services.environment.ServiceKind kind -
isDeployable
private boolean isDeployable -
isTopLevel
private boolean isTopLevel -
parameters
-
input
-
output
-
stub
private de.iip_ecosphere.platform.services.environment.ServiceStub stub -
additionalArgs
-
actions
-
-
Constructor Details
-
AbstractServiceDescriptor
protected AbstractServiceDescriptor(String id, String applicationId, String name, String description, de.iip_ecosphere.platform.support.Version version) Creates an instance. CallsetClassification(ServiceKind, boolean, boolean)afterwards.- Parameters:
id- the service idapplicationId- the application id, may be empty for default application/legacyname- the name of this servicedescription- the description of the serviceversion- the version
-
-
Method Details
-
instantiateFrom
Does further initialization afterAbstractServiceDescriptor(String, String, String, String, Version)to instantiate an instance fromtemplate. By default, adds parameters and connectors.- Parameters:
template- the descriptor being used as template- See Also:
-
instantiateFrom
protected void instantiateFrom(AbstractServiceDescriptor<A> template, boolean addParameters, boolean addConnectors) Does further initialization afterAbstractServiceDescriptor(String, String, String, String, Version)to instantiate an instance fromtemplate.- Parameters:
template- the descriptor being used as templateaddParameters- add the parameters fromtemplateaddConnectors- add the input/output connectors fromtemplate
-
getArtifactDescriptorClass
Returns the utilized artifact descriptor class.- Returns:
- the class
-
setArtifact
Defines an artifact.- Parameters:
artifact- the containing artifact descriptor
-
setClassification
protected void setClassification(de.iip_ecosphere.platform.services.environment.ServiceKind kind, boolean isDeployable, boolean isTopLevel) Sets the classification of this service. If not called, default values will be used.- Parameters:
kind- the service kindisDeployable- whether the service can be deployed in distributed manner or not (fixed, centralized)isTopLevel- whether the service is a top-level service or whether it is nested, e.g., family member
-
getEnsembleLeader
Description copied from interface:ServiceDescriptorReturns the ensemble leader service, i.e., if multiple services are packaged together and shall be executed in the same process, it is important to synchronize aspects (via the ensemble leader service).- Specified by:
getEnsembleLeaderin interfaceServiceDescriptor- Returns:
- the ensemble leader, may be null if there is none
-
getId
Description copied from interface:ServiceDescriptorReturns the unique id of the service.- Specified by:
getIdin interfaceServiceDescriptor- Returns:
- the id (may contain the
application idand theapplication instance idif specified)
-
getApplicationId
Description copied from interface:ServiceDescriptorReturns the application id this service is assigned to (withoutapplication instance id).- Specified by:
getApplicationIdin interfaceServiceDescriptor- Returns:
- the application id
-
getName
Description copied from interface:ServiceDescriptorThe name of the service.- Specified by:
getNamein interfaceServiceDescriptor- Returns:
- the name
-
getVersion
public de.iip_ecosphere.platform.support.Version getVersion()Description copied from interface:ServiceDescriptorThe version of the service.- Specified by:
getVersionin interfaceServiceDescriptor- Returns:
- the version
-
getDescription
Description copied from interface:ServiceDescriptorThe description of the service.- Specified by:
getDescriptionin interfaceServiceDescriptor- Returns:
- the description, may be empty
-
getState
public de.iip_ecosphere.platform.services.environment.ServiceState getState()Description copied from interface:ServiceDescriptorReturns the state the service is currently in. [R4c]- Specified by:
getStatein interfaceServiceDescriptor- Returns:
- the state
-
setState
public void setState(de.iip_ecosphere.platform.services.environment.ServiceState state) throws ExecutionException Description copied from interface:ServiceDescriptorChanges the state. [R133c]- Specified by:
setStatein interfaceServiceDescriptor- Parameters:
state- the new state- Throws:
ExecutionException- if changing the state fails for some reason
-
isDeployable
public boolean isDeployable()Description copied from interface:ServiceDescriptorReturns whether the service is deployable in distributable manner or fixed in deployment location.- Specified by:
isDeployablein interfaceServiceDescriptor- Returns:
truefor deployable,falsefor fixed
-
isTopLevel
public boolean isTopLevel()Description copied from interface:ServiceDescriptorReturns whether the service is top-level or nested, e.g., as family member.- Specified by:
isTopLevelin interfaceServiceDescriptor- Returns:
truefor top-level,falseelse
-
getKind
public de.iip_ecosphere.platform.services.environment.ServiceKind getKind()Description copied from interface:ServiceDescriptorReturns the service kind.- Specified by:
getKindin interfaceServiceDescriptor- Returns:
- the service kind
-
getArtifact
Description copied from interface:ServiceDescriptorReturns the containing artifact.- Specified by:
getArtifactin interfaceServiceDescriptor- Returns:
- the containing artifact (descriptor)
-
getParameters
Description copied from interface:ServiceDescriptorReturns all information about parameter forServiceOperations.reconfigureService(String, Map).- Specified by:
getParametersin interfaceServiceDescriptor- Returns:
- the name-descriptor mapping for all supported parameters
-
getInputDataConnectors
Description copied from interface:ServiceDescriptorReturns all (asynchronous) input connectors into this service.- Specified by:
getInputDataConnectorsin interfaceServiceDescriptor- Returns:
- all input channels, may contain other-sided connectors where
TypedDataConnectorDescriptor.getService()is notServiceDescriptor.getId()
-
getOutputDataConnectors
Description copied from interface:ServiceDescriptorReturns all (asynchronous) output connectors from this service.- Specified by:
getOutputDataConnectorsin interfaceServiceDescriptor- Returns:
- all input channels, may contain other-sided connectors where
TypedDataConnectorDescriptor.getService()is notServiceDescriptor.getId()
-
getDataConnectors
Description copied from interface:ServiceDescriptorReturns all (asynchronous) connectors from this service.- Specified by:
getDataConnectorsin interfaceServiceDescriptor- Returns:
- all channels, may contain other-sided connectors where
TypedDataConnectorDescriptor.getService()is notServiceDescriptor.getId() - See Also:
-
getStub
protected de.iip_ecosphere.platform.services.environment.ServiceStub getStub()Returns a service stub to control the service when it is running.- Returns:
- the service stub (may be null if the service is only available or about to be removed)
-
setStub
protected void setStub(de.iip_ecosphere.platform.services.environment.ServiceStub stub) Defines the actual service stub.- Parameters:
stub- the stub
-
addParameter
Adds a parameter descriptor.- Parameters:
parameter- the descriptor
-
addInputDataConnector
Adds an input descriptor.- Parameters:
input- the descriptor
-
addOutputDataConnector
Adds an output descriptor.- Parameters:
output- the descriptor
-
setAdditionalArguments
Description copied from interface:ServiceDescriptorDefines additional arguments to be passed on during service start.- Specified by:
setAdditionalArgumentsin interfaceServiceDescriptor- Parameters:
additionalArgs- the arguments, may be empty or null for none
-
getAdditionalArguments
Description copied from interface:ServiceDescriptorReturns the additional arguments to be passed on during service start.- Specified by:
getAdditionalArgumentsin interfaceServiceDescriptor- Returns:
- the arguments, may be empty or null for none
-
ensemble
Returns all services in the same ensemble. [public, static for testing]- Parameters:
service- the service to return the ensemble (in the same artifact) for- Returns:
- all services in the same ensemble
-
ensembleConnectorNames
Returns the names of all channel names of connectors within the ensemble ofservice.- Parameters:
service- the service to return the channel names for- Returns:
- all channel names of connectors within the ensemble of
service
-
internalConnectorNames
Returns the ids of all connectors withinservices.- Parameters:
services- the services to return the internal channel names for- Returns:
- all ids of connectors within the ensemble of
service
-
connectorIds
Returns all connector ids for the connectors incons.- Parameters:
cons- the connectors- Returns:
- the connector ids
-
attachAction
Description copied from interface:ServiceDescriptorAttaches a runnable to an action.- Specified by:
attachActionin interfaceServiceDescriptor- Parameters:
action- the actionrun- the runnable
-
executeAction
If there is a registered runnable foraction, execute it.- Parameters:
action- the action to look for
-