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
competencies are represented by objects of subclasses of this class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanthis boolean indicates whether the competency is available or notprotected Stringthe name of the competency, what is it calledprotected Stringthe type of the competency, what does it do (competency Execution plans refer to the type not the name)protected CompetencyExecutionPlanthe competency execution plan as part of which this competency was startedprotected booleanthis boolean indicates whether the competency is running or notFields inherited from class cmion.architecture.CmionComponent
architecture -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcancel()Competencies can (and should) override this method to allow the execution system to cancel them.protected abstract booleancompetencyCode(HashMap<String, String> parameters) every competency sub class must implement this method and in it perform the competency code.returns the name of the competencyreturns the type of the competencyabstract voidcustom competency initialisation code should go in herebooleanreturns whether the competency is available (i.e.booleanreturns whether the competency is currently running or notvoidregisters request and event handlers of the competency execution system, if overridden, remember to call super.registerHandlers(); from withinvoidrequestStartCompetency(HashMap<String, String> parameters, CompetencyExecutionPlan cep, long executionID) convenience method to schedule a request for starting this competencyfinal voidrun()this is the thread main method, do not call it directlyabstract booleanevery 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)voidsetAdditionalData(Object data) a convenience function (i.e.Methods inherited from class cmion.architecture.CmionComponent
getArchitecture, isConnected, onDestroy, raiseMethods inherited from class ion.Meta.Element
destroy, getEventFilters, getEventHandlers, getRequestFilters, getRequestHandlers, getSimulation, getUID, schedule, wasDestroyed
-
Field Details
-
competencyName
the name of the competency, what is it called -
competencyType
the type of the competency, what does it do (competency Execution plans refer to the type not the name) -
running
protected boolean runningthis boolean indicates whether the competency is running or not -
available
protected boolean availablethis boolean indicates whether the competency is available or not -
plan
the competency execution plan as part of which this competency was started
-
-
Constructor Details
-
Competency
create a competency object
-
-
Method Details
-
getCompetencyName
returns the name of the competency -
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 CompetencyCancelledExceptionevery 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 -
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 withcep- the competency execution plan, as part of which this competency was started, or null if the competency was not started by the execution systemexecutionID-
-
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:
registerHandlersin classCmionComponent
-
setAdditionalData
a convenience function (i.e. dirty hack) to allow samgar competency construction Please ignore this and don't call it :)
-