Changeset 263


Ignore:
Timestamp:
01/07/2010 05:34:44 PM (11 years ago)
Author:
michael.kriegel
Message:

changed the way of how we specify whether a competency runs in background or is invoked by the execution system. Previously this was determined in the competency library xml file, now it is specified directly in the competency code. This change is in preparation for dynamic competency loading when cmion interfaces with samgar (to be implemented soon)

Location:
libs/cmion
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • libs/cmion/cmionLauncher/CompetencyLibrary.dtd

    r181 r263  
    11<!--Top Element of the competency library file --> 
    2 <!ELEMENT CompetencyLibrary (Competency*)> 
     2<!ELEMENT CompetencyLibrary (Competency*,Samgar?)> 
    33 
    44<!--A competency to load dynamically when the architecture is started up--> 
     
    1515<!ATTLIST Competency ConstructorParameters CDATA #IMPLIED> 
    1616 
    17 <!--Specifies whether this competency should started immediately and run permanently in the background, 
    18  or whether it will be available for execution through the competency execution system. If omitted, the 
    19  competency will not run in the background.--> 
    20 <!ATTLIST Competency RunInBackground (true|false) #IMPLIED> 
     17<!--An optional element to specify Samgar related information. If specified, CMION will attempt to contact 
     18the Samgar name server and dynamically add competencies which represent compatible running Samgar modules  
     19within cmion. Omit this element if you do not want to use Samgar. --> 
     20<!ELEMENT SAMGAR EMPTY> 
  • libs/cmion/cmionLauncher/CompetencyLibraryTest.xml

    r243 r263  
    99b) optional parameters that should be passed to the competency during  
    1010construction (assumed parameter type is String, parameters are seperated by comma). 
    11 c) if you include the attribute runInBackground and set it to "true" the competency 
    12 will be started and run in background as soon as it is initialised, it will then however 
    13 not be available to include in competency execution plans, since it will be already 
    14 running in the background. --> 
     11--> 
    1512 
    1613<Competency ClassName="cmion.level2.competencies.test.TestCompetency1"  
     
    2118<Competency ClassName="cmion.level2.competencies.test.TestCompetency5" 
    2219                        ConstructorParameters="Pizza,Pasta" />  
    23 <Competency ClassName="cmion.level2.competencies.test.TestCompetency6" RunInBackground="true" /> 
     20<Competency ClassName="cmion.level2.competencies.test.TestCompetency6" /> 
    2421                         
    2522</CompetencyLibrary> 
  • libs/cmion/cmionMain/src/cmion/level2/Competency.java

    r248 r263  
    9292                return available; 
    9393        } 
     94         
     95        /** every competency must provide information of whether it will run in the background 
     96         *  permanently (returns true) or whether it will be invoked through the competency  
     97         *  execution system (returns false) */ 
     98        public abstract boolean runsInBackground(); 
    9499         
    95100        /** every competency sub class must implement this method and in it perform  
  • libs/cmion/cmionMain/src/cmion/level2/CompetencyLibrary.java

    r248 r263  
    128128                                else 
    129129                                        throw new Exception("No class name specified for an architecture component in architecture configuration file."); 
    130  
    131                                 // read attribute RunInBackground default: false 
    132                                 boolean runInBackground = false; 
    133                                 Node atrRunInBg = attribs.getNamedItem("RunInBackground"); 
    134                                 if (atrRunInBg!=null) 
    135                                         if (atrRunInBg.getNodeValue().trim().equalsIgnoreCase("True")) 
    136                                                 runInBackground = true; 
    137130                                 
    138131                                // read attribute ConstructorParameters: default none 
     
    142135                                        constructorParametersStr= atrConstrPars.getNodeValue(); 
    143136                                 
    144                                 // create array to store values of contrucotr parameters 
     137                                // create array to store values of constructor parameters 
    145138                                ArrayList<Object> constructorParameters = new ArrayList<Object>(); 
    146139                                // create array that specifies the classes of the parameters of the constructor 
     
    177170                                // check if instance is of the right type 
    178171                                if (!(instance instanceof Competency)) throw new Exception("Competency could not be loaded because "+ className+ " is not a subclass of Competency"); 
    179                  
     172                                Competency competency = (Competency) instance; 
     173                                 
    180174                                // add to our list of competencies 
    181                                 if (runInBackground) 
    182                                         backgroundCompetencies.add((Competency)instance); 
     175                                if (competency.runsInBackground()) 
     176                                        backgroundCompetencies.add(competency); 
    183177                                else     
    184                                         competencies.add((Competency)instance);                  
     178                                        competencies.add(competency);                    
    185179                        } 
    186180                } 
  • libs/cmion/cmionMain/src/cmion/level2/competencies/ExampleCompetency.java

    r248 r263  
    6767        } 
    6868 
     69        /** this competency is invoked directly (does not run in background) */ 
     70        @Override 
     71        public boolean runsInBackground()  
     72        { 
     73                //note: if we return true here, competencyCode (below) will be called only once 
     74                // directly at cmion start up and should be written as an endless loop 
     75 
     76                return false; 
     77        }        
     78 
    6979         
    7080        /** the custom code of the competence, this is already running in a thread */ 
  • libs/cmion/cmionMain/src/cmion/level2/competencies/ExampleTCPCompetency.java

    r248 r263  
    6161        } 
    6262 
     63        /** this competency is invoked directly (does not run in background) */ 
     64        @Override 
     65        public boolean runsInBackground()  
     66        { 
     67                // note: if we return true here, startExecution (below) will be called only once 
     68                // directly at cmion start up and calling returnSuccess should be avoided as this 
     69                // will terminate the competency and background competencies usually don't terminate. 
     70 
     71                return false; 
     72        }        
     73         
    6374        /** we must implement this method. It will be invoked whenever the  
    6475         * competency is started. */ 
  • libs/cmion/cmionMain/src/cmion/level2/competencies/test/TestCompetency1.java

    r248 r263  
    5858        } 
    5959 
     60        /** this competency is invoked directly (does not run in background) */ 
     61        @Override 
     62        public boolean runsInBackground()  
     63        { 
     64                return false; 
     65        }        
     66         
    6067        /** competency code */ 
    6168        @Override 
     
    6875                // test competency 1 always fails 
    6976                return false; 
    70         }        
     77        } 
    7178         
    7279} 
  • libs/cmion/cmionMain/src/cmion/level2/competencies/test/TestCompetency2.java

    r248 r263  
    5858                available = true; 
    5959        } 
     60         
     61        /** this competency is invoked directly (does not run in background) */ 
     62        @Override 
     63        public boolean runsInBackground()  
     64        { 
     65                return false; 
     66        }        
    6067 
    6168        /** competency code */ 
  • libs/cmion/cmionMain/src/cmion/level2/competencies/test/TestCompetency3.java

    r248 r263  
    5858        } 
    5959 
     60        /** this competency is invoked directly (does not run in background) */ 
     61        @Override 
     62        public boolean runsInBackground()  
     63        { 
     64                return false; 
     65        }        
     66         
    6067        /** competency code */ 
    6168        @Override 
  • libs/cmion/cmionMain/src/cmion/level2/competencies/test/TestCompetency4.java

    r248 r263  
    5757        } 
    5858 
     59        /** this competency is invoked directly (does not run in background) */ 
     60        @Override 
     61        public boolean runsInBackground()  
     62        { 
     63                return false; 
     64        }        
     65         
    5966        /** competency code */ 
    6067        @Override 
  • libs/cmion/cmionMain/src/cmion/level2/competencies/test/TestCompetency5.java

    r248 r263  
    6868                available = true; 
    6969        } 
     70         
     71        /** this competency is invoked directly (does not run in background) */ 
     72        @Override 
     73        public boolean runsInBackground()  
     74        { 
     75                return false; 
     76        }        
    7077 
    7178        /** competency code */ 
  • libs/cmion/cmionMain/src/cmion/level2/competencies/test/TestCompetency6.java

    r248 r263  
    5151        } 
    5252 
     53        /** this competency runs in background and is not invoked directly */ 
     54        @Override 
     55        public boolean runsInBackground()  
     56        { 
     57                return true; 
     58        } 
     59         
    5360         
    5461        @Override 
Note: See TracChangeset for help on using the changeset viewer.