Package jadex.bridge.service.types.cms
Class SComponentManagementService
- java.lang.Object
-
- jadex.bridge.service.types.cms.SComponentManagementService
-
public class SComponentManagementService extends java.lang.Object
Static CMS methods.
-
-
Constructor Summary
Constructors Constructor Description SComponentManagementService()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static void
addParentLocking(CreationInfo cinfo, IInternalAccess agent, jadex.commons.future.Future<IComponentIdentifier> inited)
Add the locking of the parent while subcomponent is created.protected static jadex.commons.future.IFuture<java.lang.Void>
addSubcomponent(IInternalAccess pad, IComponentDescription ad, IModelInfo lmodel, IInternalAccess agent)
Add a new component to its parent.protected static void
cleanup(IComponentIdentifier cid, java.lang.Exception exception)
static jadex.commons.future.ISubscriptionIntermediateFuture<CMSStatusEvent>
createComponent(CreationInfo info, java.lang.String name, java.lang.String model, IInternalAccess agent)
Create a new component on the platform.static jadex.commons.future.ITuple2Future<IComponentIdentifier,java.util.Map<java.lang.String,java.lang.Object>>
createComponent(java.lang.String name, java.lang.String model, CreationInfo info, IInternalAccess agent)
Create a new component on the platform.static jadex.commons.future.IFuture<IComponentIdentifier>
createComponent(java.lang.String oname, java.lang.String modelname, CreationInfo info, jadex.commons.future.IResultListener<java.util.Collection<jadex.commons.Tuple2<java.lang.String,java.lang.Object>>> resultlistener, IInternalAccess agent)
Create a new component on the platform.static IPlatformComponentAccess
createPlatformComponent(java.lang.ClassLoader classloader)
Create a platform component.static IPlatformComponentAccess
createPlatformComponent(java.lang.ClassLoader classloader, PlatformComponent comp)
Create a platform component.protected static <T> jadex.commons.future.IResultListener<T>
createResultListener(IInternalAccess agent, jadex.commons.future.IResultListener<T> listener)
Create result listener that tolerates when agent is null at shutdown.protected static boolean
debug(IInternalAccess agent)
Check if heisenbug debugging is requested for the agent.static jadex.commons.future.IFuture<java.util.Map<java.lang.String,java.lang.Object>>
destroyComponent(IComponentIdentifier cid, IInternalAccess agent)
Destroy (forcefully terminate) an component on the platform.protected static void
destroyComponent(IComponentIdentifier cid, jadex.commons.future.Future<java.util.Map<java.lang.String,java.lang.Object>> ret, IInternalAccess agent)
This method is guaranteed to be called exactly ONCE and represents the internal destroy method that performs the actual cleanup work.protected static jadex.commons.future.IFuture<java.util.List<java.lang.Exception>>
destroyComponentLoop(IComponentIdentifier cid, IComponentIdentifier[] achildren, int i, IInternalAccess agent)
Loop for destroying subcomponents.static void
exitDestroy(IComponentIdentifier cid, IComponentDescription desc, java.lang.Exception ex, java.util.Map<java.lang.String,java.lang.Object> results)
Exit the destroy method by setting description state and resetting maps.static IComponentIdentifier
generateComponentIdentifier(java.lang.String localname, java.lang.String platformname, IInternalAccess agent, boolean uniqueids)
Create a component identifier that is allowed on the platform.static jadex.commons.future.IFuture<java.lang.Integer>
getChildCount(IComponentIdentifier cid, IInternalAccess agent)
Get the children count.static jadex.commons.future.IFuture<IComponentIdentifier[]>
getChildren(IComponentIdentifier cid, IInternalAccess agent)
Get the children components of a component.static jadex.commons.future.IFuture<IComponentDescription[]>
getChildrenDescriptions(IComponentIdentifier cid, IInternalAccess agent)
Get the children components of a component.protected static jadex.commons.future.IFuture<java.lang.ClassLoader>
getClassLoader(ILibraryService libser, IResourceIdentifier rid)
Gets the classloader from libservice.protected static IPlatformComponentAccess
getComponent(IComponentIdentifier cid)
Helper to get a component from components or init infos.static jadex.commons.future.IFuture<IComponentDescription>
getComponentDescription(IComponentIdentifier cid)
Get the component description of a single component.static jadex.commons.future.IFuture<IComponentDescription[]>
getComponentDescriptions(IComponentIdentifier cid)
Get the component descriptions.static IComponentFactory
getComponentFactory(IComponentIdentifier cid)
Get the bootstrap factoryprotected static jadex.commons.future.IFuture<IComponentFactory>
getComponentFactory(java.lang.String model, CreationInfo cinfo, IResourceIdentifier rid, boolean searched, boolean cachemiss, IInternalAccess agent)
Get a fitting component factory for a specific model.static jadex.commons.future.IFuture<IComponentIdentifier[]>
getComponentIdentifiers(IInternalAccess agent)
Get the component identifiers.static IComponentDescription
getDescription(IComponentIdentifier cid)
Get the description for a component (if any).static IExternalAccess
getExternalAccess(IComponentIdentifier cid, IInternalAccess agent)
Get the external access of a component.static java.lang.ClassLoader
getLocalClassLoader(IComponentIdentifier cid)
Gets the classloader of a local component.static IExternalAccess
getLocalExternalAccess(IComponentIdentifier cid)
Gets the external access of a local component.protected static IInternalAccess
getParentComponent(CreationInfo cinfo, IInternalAccess agent)
Get the parent component.static IComponentIdentifier
getParentIdentifier(IInternalAccess agent)
Get the parent component of a component.protected static InitInfo
getParentInfo(CreationInfo cinfo, IInternalAccess agent)
Get the info of the parent component.static java.lang.String
getPojoComponentType(java.lang.Object pojo)
todo: introduce non-kernel specific annotation @Component(type=x).static jadex.commons.future.IFuture<IResourceIdentifier>
getResourceIdentifier(java.lang.String filename, IResourceIdentifier rid, IInternalAccess agent)
Find the class loader for a new (local) component.static CmsState
getState(IComponentIdentifier cid)
Get the CMS state for the platform.protected static IComponentIdentifier[]
internalGetChildren(IComponentIdentifier cid)
Get the children of a component.static IComponentDescription
internalGetComponentDescription(IComponentIdentifier cid)
Get the component description of a single component.protected static boolean
isInitSuspend(CreationInfo cinfo, IModelInfo lmodel, IInternalAccess agent)
Test if a component should be suspended after init is done.protected static boolean
isMultiFactory(IComponentFactory fac)
Test if factory is a multi factory.static boolean
isRemoteComponent(IComponentIdentifier cid, IInternalAccess agent)
Test if a component identifier is a remote component.static boolean
isSystemComponent(IModelInfo lmodel, CreationInfo cinfo, IComponentIdentifier pacid)
static void
linkResults(jadex.commons.future.IResultListener<java.util.Collection<jadex.commons.Tuple2<java.lang.String,java.lang.Object>>> resultlistener, IPlatformComponentAccess component, IInternalAccess agent)
static jadex.commons.future.ISubscriptionIntermediateFuture<CMSStatusEvent>
listenToAll(IExternalAccess agent)
Add a component listener for all components.static jadex.commons.future.ISubscriptionIntermediateFuture<CMSStatusEvent>
listenToAll(IInternalAccess agent)
Add a component listener for all components.static jadex.commons.future.ISubscriptionIntermediateFuture<CMSStatusEvent>
listenToComponent(IComponentIdentifier cid, IExternalAccess agent)
Add a component listener for a specific component.static jadex.commons.future.ISubscriptionIntermediateFuture<CMSStatusEvent>
listenToComponent(IComponentIdentifier cid, IInternalAccess agent)
Add a component listener for a specific component.static jadex.commons.future.IFuture<jadex.commons.Tuple3<IModelInfo,java.lang.ClassLoader,java.util.Collection<IComponentFeatureFactory>>>
loadModel(java.lang.String modelname, CreationInfo cinfo, IInternalAccess agent)
Load a model with the following steps: - get the resource identifier for the model - resolve the filename (local types of subcomponents -> filenames) - get a suitable component factory - load the model with that factory - check if the model has errors and convert to exceptionstatic void
notifyListenersAdded(IComponentDescription desc)
Notify the cms listeners of an addition.static void
notifyListenersChanged(IComponentDescription desc)
Notify the cms listeners of a change.static void
notifyListenersRemoved(IComponentDescription desc, java.lang.Exception ex, java.util.Map<java.lang.String,java.lang.Object> results)
Notify the cms listeners of a removal.static void
removeComponentFactory(IComponentIdentifier cid)
Remove the bootstrap factoryprotected static jadex.commons.future.IFuture<jadex.commons.Tuple2<java.lang.String,java.lang.ClassLoader>>
resolveFilename(java.lang.String modelname, CreationInfo cinfo, IResourceIdentifier rid, IInternalAccess agent)
Find the file name and local component type name for a component to be started.static jadex.commons.future.IFuture<java.lang.Void>
resumeComponent(IComponentIdentifier cid, boolean initresume, IInternalAccess agent)
Resume the execution of an component.static <T> jadex.commons.future.IFuture<T>
scheduleStep(IComponentIdentifier cid, IComponentStep<T> step)
Schedule a step without getting external access.static jadex.commons.future.IFuture<IComponentDescription[]>
searchComponents(IComponentDescription adesc, ISearchConstraints con, IInternalAccess agent)
Search for components matching the given description.static jadex.commons.future.IFuture<java.lang.Void>
setComponentBreakpoints(IComponentIdentifier cid, java.lang.String[] breakpoints, IInternalAccess agent)
Set breakpoints for a component.void
setComponentState(IComponentIdentifier comp, java.lang.String state)
Set the state of a component (i.e.static jadex.commons.future.IFuture<java.lang.Void>
stepComponent(IComponentIdentifier cid, java.lang.String stepinfo, IInternalAccess agent)
Execute a step of a suspended component.static jadex.commons.future.IFuture<java.lang.Void>
suspendComponent(IComponentIdentifier cid, IInternalAccess agent)
Suspend the execution of an component.
-
-
-
Method Detail
-
getLocalExternalAccess
public static final IExternalAccess getLocalExternalAccess(IComponentIdentifier cid)
Gets the external access of a local component.- Parameters:
cid
- The component id.- Returns:
- External Access.
-
getLocalClassLoader
public static final java.lang.ClassLoader getLocalClassLoader(IComponentIdentifier cid)
Gets the classloader of a local component.- Parameters:
cid
- The component id.- Returns:
- ClassLoader.
-
getState
public static final CmsState getState(IComponentIdentifier cid)
Get the CMS state for the platform.- Parameters:
cid
- The platform id.- Returns:
- The CMS state.
-
getComponentFactory
public static IComponentFactory getComponentFactory(IComponentIdentifier cid)
Get the bootstrap factory- Parameters:
cid
- The platform id.- Returns:
- The bootstrap factory.
-
removeComponentFactory
public static void removeComponentFactory(IComponentIdentifier cid)
Remove the bootstrap factory- Parameters:
cid
- The platform id.
-
getDescription
public static IComponentDescription getDescription(IComponentIdentifier cid)
Get the description for a component (if any).
-
exitDestroy
public static void exitDestroy(IComponentIdentifier cid, IComponentDescription desc, java.lang.Exception ex, java.util.Map<java.lang.String,java.lang.Object> results)
Exit the destroy method by setting description state and resetting maps.
-
listenToAll
public static jadex.commons.future.ISubscriptionIntermediateFuture<CMSStatusEvent> listenToAll(IInternalAccess agent)
Add a component listener for all components. The listener is registered for component changes.
-
listenToAll
public static jadex.commons.future.ISubscriptionIntermediateFuture<CMSStatusEvent> listenToAll(IExternalAccess agent)
Add a component listener for all components. The listener is registered for component changes.
-
listenToComponent
public static jadex.commons.future.ISubscriptionIntermediateFuture<CMSStatusEvent> listenToComponent(IComponentIdentifier cid, IInternalAccess agent)
Add a component listener for a specific component. The listener is registered for component changes.- Parameters:
cid
- The component to be listened.- Throws:
java.lang.IllegalStateException
- when the component is not found.
-
listenToComponent
public static jadex.commons.future.ISubscriptionIntermediateFuture<CMSStatusEvent> listenToComponent(IComponentIdentifier cid, IExternalAccess agent)
Add a component listener for a specific component. The listener is registered for component changes.- Parameters:
cid
- The component to be listened.- Throws:
java.lang.IllegalStateException
- when the component is not found.
-
notifyListenersAdded
public static void notifyListenersAdded(IComponentDescription desc)
Notify the cms listeners of an addition.
-
notifyListenersChanged
public static void notifyListenersChanged(IComponentDescription desc)
Notify the cms listeners of a change.
-
notifyListenersRemoved
public static void notifyListenersRemoved(IComponentDescription desc, java.lang.Exception ex, java.util.Map<java.lang.String,java.lang.Object> results)
Notify the cms listeners of a removal.
-
resolveFilename
protected static jadex.commons.future.IFuture<jadex.commons.Tuple2<java.lang.String,java.lang.ClassLoader>> resolveFilename(java.lang.String modelname, CreationInfo cinfo, IResourceIdentifier rid, IInternalAccess agent)
Find the file name and local component type name for a component to be started.
-
getPojoComponentType
public static java.lang.String getPojoComponentType(java.lang.Object pojo)
todo: introduce non-kernel specific annotation @Component(type=x). would be best if @Agent could inherit from @Component
-
getComponentFactory
protected static jadex.commons.future.IFuture<IComponentFactory> getComponentFactory(java.lang.String model, CreationInfo cinfo, IResourceIdentifier rid, boolean searched, boolean cachemiss, IInternalAccess agent)
Get a fitting component factory for a specific model. Searches the cached factories for the one that fits the model and returns it. Possibly reevaluates the cache when no factory was found.- Parameters:
model
- The model file name.cinfo
- The creaion info.rid
- The resource identifier.searched
- True, when a search has already been done.- Returns:
- The component factory.
-
isMultiFactory
protected static boolean isMultiFactory(IComponentFactory fac)
Test if factory is a multi factory.
-
getParentInfo
protected static InitInfo getParentInfo(CreationInfo cinfo, IInternalAccess agent)
Get the info of the parent component.
-
getParentComponent
protected static IInternalAccess getParentComponent(CreationInfo cinfo, IInternalAccess agent)
Get the parent component.
-
isRemoteComponent
public static boolean isRemoteComponent(IComponentIdentifier cid, IInternalAccess agent)
Test if a component identifier is a remote component.
-
createResultListener
protected static <T> jadex.commons.future.IResultListener<T> createResultListener(IInternalAccess agent, jadex.commons.future.IResultListener<T> listener)
Create result listener that tolerates when agent is null at shutdown.
-
isInitSuspend
protected static boolean isInitSuspend(CreationInfo cinfo, IModelInfo lmodel, IInternalAccess agent)
Test if a component should be suspended after init is done.- Parameters:
cinfo
- The creation info.lmodel
- The model of the component.- Returns:
- True, if the component should be suspended
-
internalGetChildren
protected static IComponentIdentifier[] internalGetChildren(IComponentIdentifier cid)
Get the children of a component.
-
setComponentState
public void setComponentState(IComponentIdentifier comp, java.lang.String state)
Set the state of a component (i.e. update the component description). Currently only switching between suspended/waiting is allowed.
-
generateComponentIdentifier
public static IComponentIdentifier generateComponentIdentifier(java.lang.String localname, java.lang.String platformname, IInternalAccess agent, boolean uniqueids)
Create a component identifier that is allowed on the platform.- Parameters:
name
- The base name.- Returns:
- The component identifier.
-
searchComponents
public static jadex.commons.future.IFuture<IComponentDescription[]> searchComponents(IComponentDescription adesc, ISearchConstraints con, IInternalAccess agent)
Search for components matching the given description.- Returns:
- An array of matching component descriptions.
-
getComponentIdentifiers
public static jadex.commons.future.IFuture<IComponentIdentifier[]> getComponentIdentifiers(IInternalAccess agent)
Get the component identifiers.- Returns:
- The component identifiers. This method should be used with caution when the agent population is large. <- TODO and the reason is...?
-
getComponentDescriptions
public static jadex.commons.future.IFuture<IComponentDescription[]> getComponentDescriptions(IComponentIdentifier cid)
Get the component descriptions.- Returns:
- The component descriptions.
-
getComponentDescription
public static jadex.commons.future.IFuture<IComponentDescription> getComponentDescription(IComponentIdentifier cid)
Get the component description of a single component.- Parameters:
cid
- The component identifier.- Returns:
- The component description of this component.
-
internalGetComponentDescription
public static IComponentDescription internalGetComponentDescription(IComponentIdentifier cid)
Get the component description of a single component.- Parameters:
cid
- The component identifier.- Returns:
- The component description of this component.
-
getChildrenDescriptions
public static jadex.commons.future.IFuture<IComponentDescription[]> getChildrenDescriptions(IComponentIdentifier cid, IInternalAccess agent)
Get the children components of a component.- Parameters:
cid
- The component identifier.- Returns:
- The children component descriptions.
-
getChildCount
public static jadex.commons.future.IFuture<java.lang.Integer> getChildCount(IComponentIdentifier cid, IInternalAccess agent)
Get the children count.- Parameters:
cid
- The component identifier.- Returns:
- The child count
-
getChildren
public static jadex.commons.future.IFuture<IComponentIdentifier[]> getChildren(IComponentIdentifier cid, IInternalAccess agent)
Get the children components of a component.- Parameters:
cid
- The component identifier.- Returns:
- The children component identifiers.
-
getParentIdentifier
public static IComponentIdentifier getParentIdentifier(IInternalAccess agent)
Get the parent component of a component.- Parameters:
platform
- The component identifier.- Returns:
- The parent component identifier.
-
getResourceIdentifier
public static jadex.commons.future.IFuture<IResourceIdentifier> getResourceIdentifier(java.lang.String filename, IResourceIdentifier rid, IInternalAccess agent)
Find the class loader for a new (local) component. Use parent component class loader for local parents and current platform class loader for remote or no parents.- Parameters:
platform
- The component id.- Returns:
- The class loader.
-
getExternalAccess
public static IExternalAccess getExternalAccess(IComponentIdentifier cid, IInternalAccess agent)
Get the external access of a component.- Parameters:
cid
- The component identifier.
-
setComponentBreakpoints
public static jadex.commons.future.IFuture<java.lang.Void> setComponentBreakpoints(IComponentIdentifier cid, java.lang.String[] breakpoints, IInternalAccess agent)
Set breakpoints for a component. Replaces existing breakpoints. To add/remove breakpoints, use current breakpoints from component description as a base.- Parameters:
cid
- The component identifier.breakpoints
- The new breakpoints (if any).
-
stepComponent
public static jadex.commons.future.IFuture<java.lang.Void> stepComponent(IComponentIdentifier cid, java.lang.String stepinfo, IInternalAccess agent)
Execute a step of a suspended component.- Parameters:
componentid
- The component identifier.
-
addSubcomponent
protected static jadex.commons.future.IFuture<java.lang.Void> addSubcomponent(IInternalAccess pad, IComponentDescription ad, IModelInfo lmodel, IInternalAccess agent)
Add a new component to its parent.
-
resumeComponent
public static jadex.commons.future.IFuture<java.lang.Void> resumeComponent(IComponentIdentifier cid, boolean initresume, IInternalAccess agent)
Resume the execution of an component.- Parameters:
componentid
- The component identifier.
-
suspendComponent
public static jadex.commons.future.IFuture<java.lang.Void> suspendComponent(IComponentIdentifier cid, IInternalAccess agent)
Suspend the execution of an component.- Parameters:
cid
- The component identifier.
-
destroyComponentLoop
protected static jadex.commons.future.IFuture<java.util.List<java.lang.Exception>> destroyComponentLoop(IComponentIdentifier cid, IComponentIdentifier[] achildren, int i, IInternalAccess agent)
Loop for destroying subcomponents.
-
destroyComponent
protected static void destroyComponent(IComponentIdentifier cid, jadex.commons.future.Future<java.util.Map<java.lang.String,java.lang.Object>> ret, IInternalAccess agent)
This method is guaranteed to be called exactly ONCE and represents the internal destroy method that performs the actual cleanup work.- Parameters:
cid
- The component to destroy.ret
- The future to be informed.
-
destroyComponent
public static jadex.commons.future.IFuture<java.util.Map<java.lang.String,java.lang.Object>> destroyComponent(IComponentIdentifier cid, IInternalAccess agent)
Destroy (forcefully terminate) an component on the platform.- Parameters:
cid
- The component to destroy.- Throws:
java.lang.IllegalStateException
- when the component is not found.
-
loadModel
public static jadex.commons.future.IFuture<jadex.commons.Tuple3<IModelInfo,java.lang.ClassLoader,java.util.Collection<IComponentFeatureFactory>>> loadModel(java.lang.String modelname, CreationInfo cinfo, IInternalAccess agent)
Load a model with the following steps: - get the resource identifier for the model - resolve the filename (local types of subcomponents -> filenames) - get a suitable component factory - load the model with that factory - check if the model has errors and convert to exception
-
isSystemComponent
public static boolean isSystemComponent(IModelInfo lmodel, CreationInfo cinfo, IComponentIdentifier pacid)
- Parameters:
name
-- Returns:
-
addParentLocking
protected static void addParentLocking(CreationInfo cinfo, IInternalAccess agent, jadex.commons.future.Future<IComponentIdentifier> inited)
Add the locking of the parent while subcomponent is created.
-
linkResults
public static void linkResults(jadex.commons.future.IResultListener<java.util.Collection<jadex.commons.Tuple2<java.lang.String,java.lang.Object>>> resultlistener, IPlatformComponentAccess component, IInternalAccess agent)
-
createComponent
public static jadex.commons.future.IFuture<IComponentIdentifier> createComponent(java.lang.String oname, java.lang.String modelname, CreationInfo info, jadex.commons.future.IResultListener<java.util.Collection<jadex.commons.Tuple2<java.lang.String,java.lang.Object>>> resultlistener, IInternalAccess agent)
Create a new component on the platform.- Parameters:
name
- The component name.model
- The model identifier (e.g. file name).info
- The creation info, if any.resultlistener
- The kill listener (if any). Will receive the results of the component execution, after the component has terminated.
-
createPlatformComponent
public static IPlatformComponentAccess createPlatformComponent(java.lang.ClassLoader classloader)
Create a platform component. It creates a proxy around the platform component to autoimplement the feature methods of internal access.
-
createPlatformComponent
public static IPlatformComponentAccess createPlatformComponent(java.lang.ClassLoader classloader, PlatformComponent comp)
Create a platform component. It creates a proxy around the platform component to autoimplement the feature methods of internal access.
-
createComponent
public static jadex.commons.future.ISubscriptionIntermediateFuture<CMSStatusEvent> createComponent(CreationInfo info, java.lang.String name, java.lang.String model, IInternalAccess agent)
Create a new component on the platform. This method allows for retrieving intermediate results of the component via status events.- 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 status events of the components. Consists of CMSCreatedEvent, (CMSIntermediateResultEvent)*, CMSTerminatedEvent
-
createComponent
public static jadex.commons.future.ITuple2Future<IComponentIdentifier,java.util.Map<java.lang.String,java.lang.Object>> createComponent(java.lang.String name, java.lang.String model, CreationInfo info, IInternalAccess agent)
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.
-
cleanup
protected static void cleanup(IComponentIdentifier cid, java.lang.Exception exception)
-
getComponent
protected static IPlatformComponentAccess getComponent(IComponentIdentifier cid)
Helper to get a component from components or init infos.- Parameters:
cid
- The component id.- Returns:
- The component.
-
getClassLoader
protected static final jadex.commons.future.IFuture<java.lang.ClassLoader> getClassLoader(ILibraryService libser, IResourceIdentifier rid)
Gets the classloader from libservice.
-
scheduleStep
public static <T> jadex.commons.future.IFuture<T> scheduleStep(IComponentIdentifier cid, IComponentStep<T> step)
Schedule a step without getting external access.- Parameters:
cid
- The component id.step
- The step.- Returns:
- result of the step or runtime exception when component not found.
-
debug
protected static boolean debug(IInternalAccess agent)
Check if heisenbug debugging is requested for the agent.
-
-