Package cmion.level2

Class Competency

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected boolean available
      this boolean indicates whether the competency is available or not
      protected java.lang.String competencyName
      the name of the competency, what is it called
      protected java.lang.String competencyType
      the type of the competency, what does it do (competency Execution plans refer to the type not the name)
      protected CompetencyExecutionPlan plan
      the competency execution plan as part of which this competency was started
      protected boolean running
      this boolean indicates whether the competency is running or not
    • Constructor Summary

      Constructors 
      Constructor Description
      Competency​(IArchitecture architecture)
      create a competency object
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void cancel()
      Competencies can (and should) override this method to allow the execution system to cancel them.
      protected abstract boolean competencyCode​(java.util.HashMap<java.lang.String,​java.lang.String> parameters)
      every competency sub class must implement this method and in it perform the competency code.
      java.lang.String getCompetencyName()
      returns the name of the competency
      java.lang.String getCompetencyType()
      returns the type of the competency
      abstract void initialize()
      custom competency initialisation code should go in here
      boolean isAvailable()
      returns whether the competency is available (i.e.
      boolean isRunning()
      returns whether the competency is currently running or not
      void registerHandlers()
      registers request and event handlers of the competency execution system, if overridden, remember to call super.registerHandlers(); from within
      void requestStartCompetency​(java.util.HashMap<java.lang.String,​java.lang.String> parameters, CompetencyExecutionPlan cep, long executionID)
      convenience method to schedule a request for starting this competency
      void run()
      this is the thread main method, do not call it directly
      abstract boolean runsInBackground()
      every competency must provide information of whether it will run in the background permanently (returns true) or whether it will be invoked through the competency execution system (returns false)
      void setAdditionalData​(java.lang.Object data)
      a convenience function (i.e.
      • Methods inherited from class ion.Meta.Element

        destroy, getEventFilters, getEventHandlers, getRequestFilters, getRequestHandlers, getSimulation, getUID, schedule, wasDestroyed
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • competencyName

        protected java.lang.String competencyName
        the name of the competency, what is it called
      • competencyType

        protected java.lang.String competencyType
        the type of the competency, what does it do (competency Execution plans refer to the type not the name)
      • running

        protected boolean running
        this boolean indicates whether the competency is running or not
      • available

        protected boolean available
        this boolean indicates whether the competency is available or not
      • plan

        protected CompetencyExecutionPlan plan
        the competency execution plan as part of which this competency was started
    • Constructor Detail

      • Competency

        public Competency​(IArchitecture architecture)
        create a competency object
    • Method Detail

      • getCompetencyName

        public java.lang.String getCompetencyName()
        returns the name of the competency
      • getCompetencyType

        public java.lang.String getCompetencyType()
        returns the type of the competency
      • isRunning

        public boolean isRunning()
        returns whether the competency is currently running or not
      • isAvailable

        public boolean isAvailable()
        returns whether the competency is available (i.e. able to run), check isRunning to find out whether it is running or not
      • runsInBackground

        public abstract boolean runsInBackground()
        every competency must provide information of whether it will run in the background permanently (returns true) or whether it will be invoked through the competency execution system (returns false)
      • competencyCode

        protected abstract boolean competencyCode​(java.util.HashMap<java.lang.String,​java.lang.String> parameters)
                                           throws CompetencyCancelledException
        every competency sub class must implement this method and in it perform the competency code. This method will run in a seperate thread, so can take its time. It should not be called from outside, instead a request should be scheduled or the convenience function requestStartComptency of this class should be used
        Parameters:
        parameters - a map including running parameters and their values
        Returns:
        the return value of this method should indicate, whether the competency execution was a success (true) or failure (false)
        Throws:
        CompetencyCancelledException
      • initialize

        public abstract void initialize()
        custom competency initialisation code should go in here
      • run

        public final void run()
        this is the thread main method, do not call it directly
        Specified by:
        run in interface java.lang.Runnable
      • requestStartCompetency

        public void requestStartCompetency​(java.util.HashMap<java.lang.String,​java.lang.String> parameters,
                                           CompetencyExecutionPlan cep,
                                           long executionID)
        convenience method to schedule a request for starting this competency
        Parameters:
        parameters - a map including the parameters that this competence should work with
        cep - the competency execution plan, as part of which this competency was started, or null if the competency was not started by the execution system
        executionID -
      • cancel

        public void cancel()
        Competencies can (and should) override this method to allow the execution system to cancel them. When this method is called the competency should stop its execution as quickly as possible by throwing a CompetencyCancelledException in the comptencyCode method
      • registerHandlers

        public void registerHandlers()
        registers request and event handlers of the competency execution system, if overridden, remember to call super.registerHandlers(); from within
        Specified by:
        registerHandlers in class CmionComponent
      • setAdditionalData

        public void setAdditionalData​(java.lang.Object data)
        a convenience function (i.e. dirty hack) to allow samgar competency construction Please ignore this and don't call it :)