Class PlatformComponent

    • 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.
      • 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).
    • Constructor Detail

      • PlatformComponent

        public PlatformComponent()
    • 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:
        create in interface IPlatformComponentAccess
        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:
        init in interface IPlatformComponentAccess
        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:
        body in interface IPlatformComponentAccess
        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:
        shutdown in interface IPlatformComponentAccess
        Returns:
        A future to indicate when the shutdown is done.
      • 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.
      • 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.
      • 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.
      • 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.
      • 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 CreationInfo prepare​(CreationInfo info)
        Helper method for preparing the creation info.
        Parameters:
        component - The pojo or filename
        info - The creation info.
        Returns:
        The creation info.
      • 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).
      • toString

        public java.lang.String toString()
        Get a string representation.
        Overrides:
        toString in class java.lang.Object