Changeset 172


Ignore:
Timestamp:
10/20/2009 12:19:11 PM (10 years ago)
Author:
michael.kriegel
Message:

Refactoring out of the class that holds the main method (Architecture) into a separate project (architectureLauncher). The reason for this is to avoid circular dependencies between the projects architectureMain and architectureAddOns. Due to this refactoring architectureMain is now turned into a class library (architecture is started from architecture launcher). Also some bugs fixed in this commit (added a flush() in RemoteTCPCompetency.sendMessage and changed order of constructor parameters for storage containers (architecture reference always has to come first))

Location:
architecture/architectureMain
Files:
1 added
7 deleted
20 edited

Legend:

Unmodified
Added
Removed
  • architecture/architectureMain/src/lirec/architecture/LirecComponent.java

    r143 r172  
    3434         
    3535/** reference to the architecture, through which references to other components can be obtained */ 
    36 protected Architecture architecture; 
     36protected IArchitecture architecture; 
    3737 
    3838/** create a new Lirec Component */ 
    39 protected LirecComponent(Architecture architecture) 
     39protected LirecComponent(IArchitecture architecture) 
    4040{ 
    4141        this.architecture = architecture; 
     
    4343 
    4444/** returns a reference to the Lire architecture object */ 
    45 public Architecture getArchitecture() { 
     45public IArchitecture getArchitecture() { 
    4646        return architecture; 
    4747} 
  • architecture/architectureMain/src/lirec/level2/Competency.java

    r143 r172  
    3535import java.util.HashMap; 
    3636 
    37 import lirec.architecture.Architecture; 
     37import lirec.architecture.IArchitecture; 
    3838import lirec.architecture.LirecComponent; 
    3939 
     
    5959         
    6060        /** create a competency object */ 
    61         public Competency(Architecture architecture) 
     61        public Competency(IArchitecture architecture) 
    6262        { 
    6363                super(architecture); 
  • architecture/architectureMain/src/lirec/level2/CompetencyExecution.java

    r143 r172  
    3939import java.util.HashMap; 
    4040 
    41 import lirec.architecture.Architecture; 
     41import lirec.architecture.IArchitecture; 
    4242import lirec.architecture.LirecComponent; 
    4343 
     
    5050         
    5151        /** create a new Competency Execution Component */ 
    52         public CompetencyExecution(Architecture architecture) 
     52        public CompetencyExecution(IArchitecture architecture) 
    5353        { 
    5454                super(architecture); 
  • architecture/architectureMain/src/lirec/level2/CompetencyLibrary.java

    r143 r172  
    4444import org.w3c.dom.NodeList; 
    4545 
    46 import lirec.architecture.Architecture; 
     46import lirec.architecture.IArchitecture; 
    4747import lirec.architecture.LirecComponent; 
    4848 
     
    5959 
    6060        /** Create a new competency library */ 
    61         public CompetencyLibrary(Architecture architecture, String competencyLibraryFile) throws Exception  
     61        public CompetencyLibrary(IArchitecture architecture, String competencyLibraryFile) throws Exception  
    6262        { 
    6363                super(architecture); 
     
    139139                                        constructorParametersStr= atrConstrPars.getNodeValue(); 
    140140                                 
    141                                 // the first parameter to the constructor is always a reference to the architecture for all lirec components 
     141                                // create array to store values of contrucotr parameters 
    142142                                ArrayList<Object> constructorParameters = new ArrayList<Object>(); 
     143                                // create array that specifies the classes of the parameters of the constructor 
     144                                ArrayList<Class<?>> constructorClasses = new ArrayList<Class<?>>(); 
     145                                 
     146                                // the first parameter to the constructor is always a reference to the architecture for all lirec components                             
    143147                                constructorParameters.add(architecture); 
     148                                // it's class is IArchitecture 
     149                                constructorClasses.add(IArchitecture.class); 
    144150                                 
    145151                                // di-sect constructor parameters (in the string all parameters are seperated by a comma) 
     
    148154                                { 
    149155                                        String token = st.nextToken().trim(); 
    150                                         if (!token.equals("")) constructorParameters.add(token); 
     156                                        if (!token.equals("")) 
     157                                        { 
     158                                                constructorParameters.add(token); 
     159                                                constructorClasses.add(String.class); 
     160                                        } 
    151161                                } 
    152162                                 
     
    155165                                // obtain class  
    156166                                Class<?> cls = Class.forName(className); 
    157                                  
    158                                 // create array that specifies the classes of the parameters of the constructor 
    159                                 ArrayList<Class<?>> constructorClasses = new ArrayList<Class<?>>(); 
    160                                 for (Object o: constructorParameters) 
    161                                         constructorClasses.add(o.getClass()); 
    162167                                 
    163168                                // obtain the constructor  
  • architecture/architectureMain/src/lirec/level2/RemoteCompetency.java

    r143 r172  
    3030import java.util.HashMap; 
    3131 
    32 import lirec.architecture.Architecture; 
     32import lirec.architecture.IArchitecture; 
    3333 
    3434/** an abstract class describing a competency, whose main execution is performed remotely, 
     
    4747         
    4848        /** call this constructor from subclasses */ 
    49         protected RemoteCompetency(Architecture architecture)  
     49        protected RemoteCompetency(IArchitecture architecture)  
    5050        { 
    5151                super(architecture); 
  • architecture/architectureMain/src/lirec/level2/RemoteTCPCompetency.java

    r143 r172  
    3636import java.net.Socket; 
    3737 
    38 import lirec.architecture.Architecture; 
     38import lirec.architecture.IArchitecture; 
    3939 
    4040/** A class encapsulating tcp communication we another process on the network. */ 
     
    7070         * to, if serverMode is true this parameter is not used (can be null)  
    7171         */ 
    72         protected RemoteTCPCompetency(Architecture architecture, int port, boolean serverMode, String serverAddress) { 
     72        protected RemoteTCPCompetency(IArchitecture architecture, int port, boolean serverMode, String serverAddress) { 
    7373                super(architecture); 
    7474                this.port = port; 
     
    9292                { 
    9393                        writer.write(message + "\n"); 
     94                        writer.flush(); 
    9495                }  
    9596                catch (IOException e) 
  • architecture/architectureMain/src/lirec/level2/competencies/ExampleCompetency.java

    r143 r172  
    3030import java.util.HashMap; 
    3131 
    32 import lirec.architecture.Architecture; 
     32import lirec.architecture.IArchitecture; 
    3333import lirec.level2.Competency; 
    3434 
     
    3939        /** constructor, every competency, should if possible have a constructor  
    4040         *  that receives the Architecture as an argument */ 
    41         public ExampleCompetency(Architecture architecture) 
     41        public ExampleCompetency(IArchitecture architecture) 
    4242        { 
    4343                // call parent class constructor, always do this first 
  • architecture/architectureMain/src/lirec/level2/competencies/ExampleTCPCompetency.java

    r143 r172  
    3030import java.util.HashMap; 
    3131 
    32 import lirec.architecture.Architecture; 
     32import lirec.architecture.IArchitecture; 
    3333import lirec.level2.RemoteTCPCompetency; 
    3434 
     
    3939        /** constructor, every competency, should if possible have a constructor  
    4040         *  that receives the Architecture as an argument */ 
    41         public ExampleTCPCompetency(Architecture architecture)  
     41        public ExampleTCPCompetency(IArchitecture architecture)  
    4242        { 
    4343                // call parent class constructor, always do this first 
  • architecture/architectureMain/src/lirec/level2/competencies/test/TestCompetency1.java

    r143 r172  
    3030import java.util.HashMap; 
    3131 
    32 import lirec.architecture.Architecture; 
     32import lirec.architecture.IArchitecture; 
    3333import lirec.level2.Competency; 
    3434 
     
    3838 
    3939        /** constructor of the test competency */ 
    40         public TestCompetency1(Architecture architecture) 
     40        public TestCompetency1(IArchitecture architecture) 
    4141        { 
    4242                // call parent class constructor, always do this first 
  • architecture/architectureMain/src/lirec/level2/competencies/test/TestCompetency2.java

    r143 r172  
    3131import java.util.Random; 
    3232 
    33 import lirec.architecture.Architecture; 
     33import lirec.architecture.IArchitecture; 
    3434import lirec.level2.Competency; 
    3535 
     
    3939 
    4040        /** constructor of the test competency */ 
    41         public TestCompetency2(Architecture architecture) 
     41        public TestCompetency2(IArchitecture architecture) 
    4242        { 
    4343                // call parent class constructor, always do this first 
  • architecture/architectureMain/src/lirec/level2/competencies/test/TestCompetency3.java

    r143 r172  
    3030import java.util.HashMap; 
    3131 
    32 import lirec.architecture.Architecture; 
     32import lirec.architecture.IArchitecture; 
    3333import lirec.level2.Competency; 
    3434 
     
    3838 
    3939        /** constructor of the test competency */ 
    40         public TestCompetency3(Architecture architecture) 
     40        public TestCompetency3(IArchitecture architecture) 
    4141        { 
    4242                // call parent class constructor, always do this first 
  • architecture/architectureMain/src/lirec/level2/competencies/test/TestCompetency4.java

    r143 r172  
    3030import java.util.HashMap; 
    3131 
    32 import lirec.architecture.Architecture; 
     32import lirec.architecture.IArchitecture; 
    3333import lirec.level2.Competency; 
    3434 
     
    3737 
    3838        /** constructor of the test competency */ 
    39         public TestCompetency4(Architecture architecture) 
     39        public TestCompetency4(IArchitecture architecture) 
    4040        { 
    4141                // call parent class constructor, always do this first 
  • architecture/architectureMain/src/lirec/level2/competencies/test/TestCompetency5.java

    r143 r172  
    3030import java.util.HashMap; 
    3131 
    32 import lirec.architecture.Architecture; 
     32import lirec.architecture.IArchitecture; 
    3333import lirec.level2.Competency; 
    3434 
     
    4444        /** constructor of the test competency, this one has an additional parameter, purely 
    4545         *  for the purpose whether the constructor is found and the parameter passed correctly */ 
    46         public TestCompetency5(Architecture architecture, String someParameter1, String someParameter2) 
     46        public TestCompetency5(IArchitecture architecture, String someParameter1, String someParameter2) 
    4747        { 
    4848                // call parent class constructor, always do this first 
  • architecture/architectureMain/src/lirec/level2/competencies/test/TestCompetency6.java

    r143 r172  
    3030import java.util.HashMap; 
    3131 
    32 import lirec.architecture.Architecture; 
     32import lirec.architecture.IArchitecture; 
    3333import lirec.level2.Competency; 
    3434 
     
    4040 
    4141        /** constructor of the test competency */ 
    42         public TestCompetency6(Architecture architecture) { 
     42        public TestCompetency6(IArchitecture architecture) { 
    4343                super(architecture); 
    4444 
  • architecture/architectureMain/src/lirec/level3/AgentMindConnector.java

    r143 r172  
    3131import ion.Meta.IEvent; 
    3232import ion.Meta.Simulation; 
    33 import lirec.architecture.Architecture; 
     33import lirec.architecture.IArchitecture; 
    3434import lirec.architecture.LirecComponent; 
    3535import lirec.storage.EventPropertyChanged; 
     
    5050         
    5151/** create a new Agent Mind Connector */         
    52 public AgentMindConnector(Architecture architecture) 
     52public AgentMindConnector(IArchitecture architecture) 
    5353{ 
    5454        super(architecture); 
  • architecture/architectureMain/src/lirec/level3/CompetencyManager.java

    r143 r172  
    4242import javax.xml.parsers.DocumentBuilderFactory; 
    4343 
    44 import lirec.architecture.Architecture; 
     44import lirec.architecture.IArchitecture; 
    4545import lirec.architecture.LirecComponent; 
    4646import lirec.level2.CompetencyExecutionPlan; 
     
    6969 
    7070         
    71         public CompetencyManager(Architecture architecture, String competencyManagerRulesFileName) throws Exception 
     71        public CompetencyManager(IArchitecture architecture, String competencyManagerRulesFileName) throws Exception 
    7272        { 
    7373                super(architecture); 
  • architecture/architectureMain/src/lirec/level3/fatima/FAtiMAConnector.java

    r143 r172  
    3333import java.util.HashMap; 
    3434 
    35 import lirec.architecture.Architecture; 
     35import lirec.architecture.IArchitecture; 
    3636import lirec.level3.AgentMindConnector; 
    3737import lirec.level3.MindAction; 
     
    5050         
    5151        /** create a new FAtiMA connector */ 
    52         public FAtiMAConnector(Architecture architecture)  
     52        public FAtiMAConnector(IArchitecture architecture)  
    5353        { 
    5454                super(architecture); 
  • architecture/architectureMain/src/lirec/level3/supersimplemind/SuperSimpleMindConnector.java

    r143 r172  
    2828package lirec.level3.supersimplemind; 
    2929 
    30 import lirec.architecture.Architecture; 
     30import lirec.architecture.IArchitecture; 
    3131import lirec.level3.AgentMindConnector; 
    3232import lirec.level3.MindAction; 
     
    4040         
    4141        /** creates a new connector for a SuperSimpleMind */  
    42         public SuperSimpleMindConnector(Architecture architecture) 
     42        public SuperSimpleMindConnector(IArchitecture architecture) 
    4343        {        
    4444                super(architecture); 
  • architecture/architectureMain/src/lirec/storage/LirecStorageContainer.java

    r143 r172  
    3838import java.util.HashMap; 
    3939 
    40 import lirec.architecture.Architecture; 
     40import lirec.architecture.IArchitecture; 
    4141import lirec.architecture.LirecComponent; 
    4242 
     
    8888         * @param architecture reference to the lirec architecture object 
    8989         */ 
    90         protected LirecStorageContainer(String name, String type, LirecStorageContainer parentContainer, Architecture architecture)  
     90        protected LirecStorageContainer(IArchitecture architecture, String name, String type, LirecStorageContainer parentContainer)  
    9191        { 
    9292                super(architecture); 
     
    104104         * @param architecture reference to the lirec architecture object 
    105105         */ 
    106         public LirecStorageContainer(String name, String type, Architecture architecture)  
    107         { 
    108                 this(name,type,null,architecture); 
     106        public LirecStorageContainer(IArchitecture architecture, String name, String type)  
     107        { 
     108                this(architecture,name,type,null); 
    109109        } 
    110110         
     
    289289                { 
    290290                        // ok we don't have such a sub container yet, create it then 
    291                         LirecStorageContainer container = new LirecStorageContainer(name,type,this,architecture); 
     291                        LirecStorageContainer container = new LirecStorageContainer(architecture,name,type,this); 
    292292                         
    293293                        // add it to our list of sub containers 
  • architecture/architectureMain/src/lirec/storage/WorldModel.java

    r143 r172  
    3131import java.util.HashMap; 
    3232 
    33 import lirec.architecture.Architecture; 
     33import lirec.architecture.IArchitecture; 
    3434 
    3535/** a specific subclass of lirec storage container with convenience methods added  
     
    4141         
    4242         
    43         public WorldModel(String name, Architecture architecture) { 
     43        public WorldModel(IArchitecture architecture, String name) { 
    4444                // this container is of the type "WorldModel" 
    45                 super(name, "WorldModel", null, architecture); 
     45                super(architecture,name, "WorldModel", null); 
    4646        } 
    4747 
Note: See TracChangeset for help on using the changeset viewer.