Package cmion.level2

Class Competency

java.lang.Object
ion.Meta.Element
cmion.architecture.CmionComponent
cmion.level2.Competency
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
ExampleCompetency, Migration, RemoteCompetency, TestCompetency1, TestCompetency2, TestCompetency3, TestCompetency4, TestCompetency5, TestCompetency6, TestCompetency7, TestCompetency8

public abstract class Competency extends CmionComponent implements Runnable
competencies are represented by objects of subclasses of this class
  • Field Summary

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

    Fields inherited from class cmion.architecture.CmionComponent

    architecture
  • Constructor Summary

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

    Modifier and Type
    Method
    Description
    void
    Competencies can (and should) override this method to allow the execution system to cancel them.
    protected abstract boolean
    every competency sub class must implement this method and in it perform the competency code.
    returns the name of the competency
    returns the type of the competency
    abstract void
    custom competency initialisation code should go in here
    boolean
    returns whether the competency is available (i.e.
    boolean
    returns whether the competency is currently running or not
    void
    registers request and event handlers of the competency execution system, if overridden, remember to call super.registerHandlers(); from within
    void
    requestStartCompetency(HashMap<String,String> parameters, CompetencyExecutionPlan cep, long executionID)
    convenience method to schedule a request for starting this competency
    final void
    run()
    this is the thread main method, do not call it directly
    abstract boolean
    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
    a convenience function (i.e.

    Methods inherited from class cmion.architecture.CmionComponent

    getArchitecture, isConnected, onDestroy, raise

    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 Details

    • competencyName

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

      protected 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 Details

    • Competency

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

    • getCompetencyName

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

      public 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(HashMap<String,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 Runnable
    • requestStartCompetency

      public void requestStartCompetency(HashMap<String,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(Object data)
      a convenience function (i.e. dirty hack) to allow samgar competency construction Please ignore this and don't call it :)