Package jadex.bridge.service.types.cms
Class PlatformComponent
- java.lang.Object
-
- jadex.bridge.service.types.cms.PlatformComponent
-
- All Implemented Interfaces:
IPlatformComponentAccess
public class PlatformComponent extends java.lang.Object implements IPlatformComponentAccess
Standalone platform component implementation.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classPlatformComponent.ExternalAccessInvocationHandlerNested class for service annotation.
-
Field Summary
Fields Modifier and Type Field Description static java.util.Set<java.lang.String>_BROKENbooleandebugHeisenbug debug flag cached for speed.protected java.lang.ExceptionexceptionThe failure reason (if any).protected java.util.Map<java.lang.Class<?>,IComponentFeature>featuresThe features.protected IValueFetcherfetcherThe combined value fetcher (cached for speed).protected IInternalAccessiaThe internal access.protected java.util.List<IComponentFeature>ifeaturesThe inited feature instances as list (for shutdown after failed init).protected ComponentCreationInfoinfoThe creation info.protected java.util.List<IComponentFeature>lfeaturesThe feature instances as list (for reverse execution, cached for speed).protected java.util.logging.LoggerloggerThe logger.static java.lang.StringPROPERTY_TERMINATION_TIMEOUTProperty name for timeout after which component long running cleanup is forcefully aborted.protected booleanshutdownThe shutdown flag (set on start of shutdown).static java.util.Set<java.lang.String>SUSPEND_METHOD_EXEMPTIONSExternal access method exempt from component suspension.
-
Constructor Summary
Constructors Constructor Description PlatformComponent()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description IFuture<java.lang.Void>body()Perform the main execution of the component (if any).IFuture<java.lang.Void>childTerminated(IComponentDescription desc, java.lang.Exception exception)Called when a child had an exception and was terminated.voidcreate(ComponentCreationInfo info, java.util.Collection<IComponentFeatureFactory> facs)Create the component, i.e.ITuple2Future<IComponentIdentifier,java.util.Map<java.lang.String,java.lang.Object>>createComponent(CreationInfo info)Create a new component on the platform.IFuture<IExternalAccess>createComponent(CreationInfo info, IResultListener<java.util.Collection<Tuple2<java.lang.String,java.lang.Object>>> resultlistener)Add a new component as subcomponent of this component.ISubscriptionIntermediateFuture<CMSStatusEvent>createComponentWithResults(CreationInfo info)Add a new component as subcomponent of this component.protected IFuture<java.lang.Void>executeBodyOnFeatures(java.util.Iterator<IComponentFeature> features)Execute feature bodies in parallel.protected IFuture<java.lang.Void>executeInitOnFeatures(java.util.Iterator<IComponentFeature> features)Recursively init the features.protected voidexecuteKillOnFeatures(java.util.List<IComponentFeature> features)Kill the features in inverse order.protected IFuture<java.lang.Void>executeShutdownOnFeatures(java.util.List<IComponentFeature> features)Recursively shutdown the features in inverse order.java.lang.ObjectgetArgument(java.lang.String name)Deprecated.From 3.0.IFuture<IComponentIdentifier[]>getChildren(java.lang.String type, IComponentIdentifier parent)Get the children (if any).java.lang.ClassLoadergetClassLoader()Get the class loader of the component.java.lang.StringgetComponentFilename(java.lang.String type)Get the file name for a logical type name of a subcomponent of this application.java.lang.StringgetConfiguration()Get the start configuration or the default configuration if any.IComponentDescriptiongetDescription()Get the component description.IFuture<IComponentDescription>getDescription(IComponentIdentifier cid)Get the component description.IFuture<IComponentDescription[]>getDescriptions()Get the component description.intgetEndstateStart()Get the step number when endstate began.java.lang.ExceptiongetException()Get the exception, if any.IExternalAccessgetExternalAccess()Get the external access.IExternalAccessgetExternalAccess(IComponentIdentifier cid)Get the external access for a component id.static <T> TgetExternalFeature(java.lang.Class<T> iface, java.lang.ClassLoader cl, java.lang.Object original)Get external feature wrapper.<T> TgetFeature(java.lang.Class<? extends T> type)Get a feature of the component.<T> TgetFeature0(java.lang.Class<? extends T> type)Get a feature of the component.IValueFetchergetFetcher()Get the fetcher.IComponentIdentifiergetId()Get the id of the component.IInternalAccessgetInternalAccess()Get the user view of this platform component.java.util.logging.LoggergetLogger()Get the logger.static java.lang.StringgetLoggerName(IComponentIdentifier cid)Get the logger name.IModelInfogetModel()Get the model of the component.IFuture<IModelInfo>getModelAsync()Get the model of the component.IParameterGuessergetParameterGuesser()Get the parameter guesser.PlatformComponentgetPlatformComponent()Get the platform component.IFuture<java.lang.Void>init()Perform the initialization of the component.protected voidinitLogger(java.util.logging.Logger logger)Init the logger with capability settings.IFuture<java.util.Map<java.lang.String,java.lang.Object>>killComponent()Kill the component.IFuture<java.util.Map<java.lang.String,java.lang.Object>>killComponent(IComponentIdentifier cid)Kill the component.IFuture<java.util.Map<java.lang.String,java.lang.Object>>killComponent(java.lang.Exception e)Kill the component.ISubscriptionIntermediateFuture<CMSStatusEvent>listenToComponent(IComponentIdentifier cid)Add a component listener for a specific component.static CreationInfoprepare(CreationInfo info)Helper method for preparing the creation info.IFuture<java.lang.Void>resumeComponent(IComponentIdentifier componentid)Resume the execution of an component.IFuture<IComponentDescription[]>searchComponents(IComponentDescription adesc, ISearchConstraints con)Search for components matching the given description.IFuture<java.lang.Void>setComponentBreakpoints(IComponentIdentifier cid, java.lang.String[] breakpoints)Set breakpoints for a component.protected voidsetInternalAccess(IInternalAccess ia)Set the internal access (proxy).IFuture<java.lang.Void>shutdown()Perform the shutdown of the component (if any).IFuture<java.lang.Void>stepComponent(IComponentIdentifier cid, java.lang.String stepinfo)Execute a step of a suspended component.IFuture<java.lang.Void>suspendComponent(IComponentIdentifier componentid)Suspend the execution of an component.java.lang.StringtoString()Get a string representation.
-
-
-
Field Detail
-
PROPERTY_TERMINATION_TIMEOUT
public static final java.lang.String PROPERTY_TERMINATION_TIMEOUT
Property name for timeout after which component long running cleanup is forcefully aborted.- See Also:
- Constant Field Values
-
SUSPEND_METHOD_EXEMPTIONS
public static final java.util.Set<java.lang.String> SUSPEND_METHOD_EXEMPTIONS
External access method exempt from component suspension.
-
_BROKEN
public static final java.util.Set<java.lang.String> _BROKEN
-
ia
protected IInternalAccess ia
The internal access.
-
info
protected ComponentCreationInfo info
The creation info.
-
features
protected java.util.Map<java.lang.Class<?>,IComponentFeature> features
The features.
-
lfeatures
protected java.util.List<IComponentFeature> lfeatures
The feature instances as list (for reverse execution, cached for speed).
-
ifeatures
protected java.util.List<IComponentFeature> ifeatures
The inited feature instances as list (for shutdown after failed init).
-
logger
protected java.util.logging.Logger logger
The logger.
-
exception
protected java.lang.Exception exception
The failure reason (if any).
-
fetcher
protected IValueFetcher fetcher
The combined value fetcher (cached for speed).
-
shutdown
protected boolean shutdown
The shutdown flag (set on start of shutdown).
-
debug
public boolean debug
Heisenbug debug flag cached for speed.
-
-
Method Detail
-
create
public void create(ComponentCreationInfo info, java.util.Collection<IComponentFeatureFactory> facs)
Create the component, i.e. instantiate its features. This is the first method that is called by the platform.- Specified by:
createin interfaceIPlatformComponentAccess- Parameters:
info- The component creation info.platformdata- The shared objects for all components of the same platform (registry etc.). See starter for available data.facs- The factories for component features to be instantiated for this component.
-
setInternalAccess
protected void setInternalAccess(IInternalAccess ia)
Set the internal access (proxy).- Parameters:
ia- The internal access.
-
init
public IFuture<java.lang.Void> init()
Perform the initialization of the component. Tries to switch to a separate thread for the component as soon as possible.- Specified by:
initin interfaceIPlatformComponentAccess- Returns:
- A future to indicate when the initialization is done.
-
body
public IFuture<java.lang.Void> body()
Perform the main execution of the component (if any).- Specified by:
bodyin interfaceIPlatformComponentAccess- Returns:
- A future to indicate when the body is done.
-
shutdown
public IFuture<java.lang.Void> shutdown()
Perform the shutdown of the component (if any).- Specified by:
shutdownin interfaceIPlatformComponentAccess- Returns:
- A future to indicate when the shutdown is done.
-
childTerminated
public IFuture<java.lang.Void> childTerminated(IComponentDescription desc, java.lang.Exception exception)
Called when a child had an exception and was terminated.- Specified by:
childTerminatedin interfaceIPlatformComponentAccess
-
executeInitOnFeatures
protected IFuture<java.lang.Void> executeInitOnFeatures(java.util.Iterator<IComponentFeature> features)
Recursively init the features.
-
executeBodyOnFeatures
protected IFuture<java.lang.Void> executeBodyOnFeatures(java.util.Iterator<IComponentFeature> features)
Execute feature bodies in parallel.
-
executeShutdownOnFeatures
protected IFuture<java.lang.Void> executeShutdownOnFeatures(java.util.List<IComponentFeature> features)
Recursively shutdown the features in inverse order.
-
executeKillOnFeatures
protected void executeKillOnFeatures(java.util.List<IComponentFeature> features)
Kill the features in inverse order. Kill is invoked, when shutdown does not return due to timeout.
-
getInternalAccess
public IInternalAccess getInternalAccess()
Get the user view of this platform component.- Specified by:
getInternalAccessin interfaceIPlatformComponentAccess- Returns:
- An internal access exposing user operations of the component.
-
getException
public java.lang.Exception getException()
Get the exception, if any.- Returns:
- The failure reason for use during cleanup, if any.
-
getArgument
public java.lang.Object getArgument(java.lang.String name)
Deprecated.From 3.0. Use getComponentFeature(IArgumentsResultsFeature.class).getArguments() Get an argument value per name.- Parameters:
name- The argument name.- Returns:
- The argument value.
-
getModel
public IModelInfo getModel()
Get the model of the component.- Returns:
- The model.
-
getModelAsync
public IFuture<IModelInfo> getModelAsync()
Get the model of the component.- Returns:
- The model.
-
getConfiguration
public java.lang.String getConfiguration()
Get the start configuration or the default configuration if any.- Returns:
- The configuration.
-
getId
public IComponentIdentifier getId()
Get the id of the component.- Returns:
- The component id.
-
getDescription
public IComponentDescription getDescription()
Get the component description.- Returns:
- The component description.
-
getDescription
public IFuture<IComponentDescription> getDescription(IComponentIdentifier cid)
Get the component description.- Returns:
- The component description.
-
getDescriptions
public IFuture<IComponentDescription[]> getDescriptions()
Get the component description.- Returns:
- The component description.
-
getFeature
public <T> T getFeature(java.lang.Class<? extends T> type)
Get a feature of the component.- Parameters:
feature- The type of the feature.- Returns:
- The feature instance.
-
getFeature0
public <T> T getFeature0(java.lang.Class<? extends T> type)
Get a feature of the component.- Parameters:
feature- The type of the feature.- Returns:
- The feature instance.
-
killComponent
public IFuture<java.util.Map<java.lang.String,java.lang.Object>> killComponent()
Kill the component.
-
killComponent
public IFuture<java.util.Map<java.lang.String,java.lang.Object>> killComponent(java.lang.Exception e)
Kill the component.- Parameters:
e- The failure reason, if any.
-
killComponent
public IFuture<java.util.Map<java.lang.String,java.lang.Object>> killComponent(IComponentIdentifier cid)
Kill the component.- Parameters:
e- The failure reason, if any.
-
getExternalAccess
public IExternalAccess getExternalAccess()
Get the external access.- Returns:
- The external access.
-
getExternalFeature
public static <T> T getExternalFeature(java.lang.Class<T> iface, java.lang.ClassLoader cl, java.lang.Object original)Get external feature wrapper.- Parameters:
iface-args-- Returns:
- The proxy.
-
getLogger
public java.util.logging.Logger getLogger()
Get the logger.- Returns:
- The logger.
-
getLoggerName
public static java.lang.String getLoggerName(IComponentIdentifier cid)
Get the logger name.- Parameters:
cid- The component identifier.- Returns:
- The name.
-
initLogger
protected void initLogger(java.util.logging.Logger logger)
Init the logger with capability settings.- Parameters:
logger- The logger.
-
getFetcher
public IValueFetcher getFetcher()
Get the fetcher.- Returns:
- The fetcher.
-
getParameterGuesser
public IParameterGuesser getParameterGuesser()
Get the parameter guesser.- Returns:
- The parameter guesser.
-
getClassLoader
public java.lang.ClassLoader getClassLoader()
Get the class loader of the component.
-
getChildren
public IFuture<IComponentIdentifier[]> getChildren(java.lang.String type, IComponentIdentifier parent)
Get the children (if any).- Returns:
- The children.
-
getComponentFilename
public java.lang.String getComponentFilename(java.lang.String type)
Get the file name for a logical type name of a subcomponent of this application.
-
getEndstateStart
public int getEndstateStart()
Get the step number when endstate began.- Returns:
- The step cnt.
-
getExternalAccess
public IExternalAccess getExternalAccess(IComponentIdentifier cid)
Get the external access for a component id.- Parameters:
cid- The component id.- Returns:
- The external access.
-
createComponent
public IFuture<IExternalAccess> createComponent(CreationInfo info, IResultListener<java.util.Collection<Tuple2<java.lang.String,java.lang.Object>>> resultlistener)
Add a new component as subcomponent of this component.- Parameters:
component- The model or pojo of the component.
-
createComponentWithResults
public ISubscriptionIntermediateFuture<CMSStatusEvent> createComponentWithResults(CreationInfo info)
Add a new component as subcomponent of this component.- Parameters:
component- The model or pojo of the component.
-
createComponent
public ITuple2Future<IComponentIdentifier,java.util.Map<java.lang.String,java.lang.Object>> createComponent(CreationInfo info)
Create a new component on the platform.- Parameters:
name- The component name or null for automatic generation.model- The model identifier (e.g. file name).info- Additional start information such as parent component or arguments (optional).- Returns:
- The id of the component and the results after the component has been killed.
-
prepare
public static CreationInfo prepare(CreationInfo info) throws java.lang.Exception
Helper method for preparing the creation info.- Parameters:
component- The pojo or filenameinfo- The creation info.- Returns:
- The creation info.
- Throws:
java.lang.Exception
-
suspendComponent
public IFuture<java.lang.Void> suspendComponent(IComponentIdentifier componentid)
Suspend the execution of an component.- Parameters:
componentid- The component identifier.
-
resumeComponent
public IFuture<java.lang.Void> resumeComponent(IComponentIdentifier componentid)
Resume the execution of an component.- Parameters:
componentid- The component identifier.
-
stepComponent
public IFuture<java.lang.Void> stepComponent(IComponentIdentifier cid, java.lang.String stepinfo)
Execute a step of a suspended component.- Parameters:
componentid- The component identifier.listener- Called when the step is finished (result will be the component description).
-
setComponentBreakpoints
public IFuture<java.lang.Void> setComponentBreakpoints(IComponentIdentifier cid, java.lang.String[] breakpoints)
Set breakpoints for a component. Replaces existing breakpoints. To add/remove breakpoints, use current breakpoints from component description as a base.- Parameters:
componentid- The component identifier.breakpoints- The new breakpoints (if any).
-
listenToComponent
public ISubscriptionIntermediateFuture<CMSStatusEvent> listenToComponent(IComponentIdentifier cid)
Add a component listener for a specific component. The listener is registered for component changes.- Parameters:
cid- The component to be listened.
-
searchComponents
public IFuture<IComponentDescription[]> searchComponents(IComponentDescription adesc, ISearchConstraints con)
Search for components matching the given description.- Returns:
- An array of matching component descriptions.
-
getPlatformComponent
public PlatformComponent getPlatformComponent()
Get the platform component.- Specified by:
getPlatformComponentin interfaceIPlatformComponentAccess- Returns:
- The platform component.
-
toString
public java.lang.String toString()
Get a string representation.- Overrides:
toStringin classjava.lang.Object
-
-