Class SComponentManagementService


  • public class SComponentManagementService
    extends java.lang.Object
    Static CMS methods.
    • Constructor Detail

      • SComponentManagementService

        public SComponentManagementService()
    • 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.
      • 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.
      • 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.
      • getComponentFactory

        protected static 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.
      • 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
      • 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.
      • getComponentIdentifiers

        public static 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...?
      • getComponentDescription

        public static 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.
      • getChildCount

        public static IFuture<java.lang.Integer> getChildCount​(IComponentIdentifier cid,
                                                               IInternalAccess agent)
        Get the children count.
        Parameters:
        cid - The component identifier.
        Returns:
        The child count
      • 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 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.
      • setComponentBreakpoints

        public static 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 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.
      • resumeComponent

        public static 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 IFuture<java.lang.Void> suspendComponent​(IComponentIdentifier cid,
                                                               IInternalAccess agent)
        Suspend the execution of an component.
        Parameters:
        cid - The component identifier.
      • destroyComponent

        protected static void destroyComponent​(IComponentIdentifier cid,
                                               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 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.
      • loadModel

        public static IFuture<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
      • createComponent

        public static IFuture<IComponentIdentifier> createComponent​(java.lang.String oname,
                                                                    java.lang.String modelname,
                                                                    CreationInfo info,
                                                                    IResultListener<java.util.Collection<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.
        listener - The result listener (if any). Will receive the id of the component as result, when the component has been created.
        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 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 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)
      • scheduleStep

        public static <T> 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.