How to add a Composite controller action

View: New views
4 Messages — Rating Filter:   Alert me  

How to add a Composite controller action

by Rajagopalan Srinivasan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

Hi,

I am trying to add a Composite Action into the controller tree. Understand from the Reference that these have to be specified in a plugin.xml file. I am new to the Java plugin framework. My questions are:

1.       Should the file name be plugin_jpf.xml or plugin.xml? Or is that irrelevant?

2.       In which directory should this xml file be placed?

3.       Would this xml file be discovered automatically or do I need to specify something in my Repast model (such as the Scenario.xml  file)

 

Thank you in advance for your clarifications.

 

Raj

 


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Repast-interest mailing list
Repast-interest@...
https://lists.sourceforge.net/lists/listinfo/repast-interest

Re: How to add a Composite controller action

by Nick Collier-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Raj,

An easier way to to add a controller action is using a repast.simphony.scenario.ModelInitializer. This is a bit of code that's run just after the scenario loads. You can use it to inject actions into the scenario tree. Here's an example:

public class Initializer implements ModelInitializer {

  public void initialize(Scenario scen, RunEnvironmentBuilder builder) {
    scen.addMasterControllerAction(new NullAbstractControllerAction() {
      @Override
      public void runInitialize(RunState runState, final Context context, Parameters params) {
// the code in here will be executed during run initialization.
        
        }
      }

      public String toString() {
// This name will show up in the action tree
        return "Action Name";
      }
    });

}

You need to add the ModelInitializer to the scenario.xml file. 

<Scenario>
...
<model.initializer class="fully qualified name of the initializer class" />
</Scenario>

If you really want to go the plugin_jpf.xml route, I can explain that more fully as well.

Nick

On Nov 3, 2009, at 2:25 AM, Rajagopalan Srinivasan wrote:

Hi,
I am trying to add a Composite Action into the controller tree. Understand from the Reference that these have to be specified in a plugin.xml file. I am new to the Java plugin framework. My questions are:
1.       Should the file name be plugin_jpf.xml or plugin.xml? Or is that irrelevant?
2.       In which directory should this xml file be placed?
3.       Would this xml file be discovered automatically or do I need to specify something in my Repast model (such as the Scenario.xml  file)
 
Thank you in advance for your clarifications.
 
Raj
 
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference_______________________________________________
Repast-interest mailing list
Repast-interest@...
https://lists.sourceforge.net/lists/listinfo/repast-interest


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Repast-interest mailing list
Repast-interest@...
https://lists.sourceforge.net/lists/listinfo/repast-interest

Re: How to add a Composite controller action

by Rajagopalan Srinivasan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Nick,
Thanks for the tip. I am currently using that approach for adding Controller Actions. My question was more about specifying a "composite.action" for adding a parent controller action. (I realize now that the subject in my previous mail was a bit ambiguous.) Can a composite action also be added from the ModelInitializer? Thanks again.
 
Raj

From: Nick Collier [mailto:nick.collier@...]
Sent: Tue 11/3/2009 10:11 PM
To: Rajagopalan Srinivasan
Cc: repast-interest@...
Subject: Re: [Repast-interest] How to add a Composite controller action

Raj,

An easier way to to add a controller action is using a repast.simphony.scenario.ModelInitializer. This is a bit of code that's run just after the scenario loads. You can use it to inject actions into the scenario tree. Here's an example:

public class Initializer implements ModelInitializer {

  public void initialize(Scenario scen, RunEnvironmentBuilder builder) {
    scen.addMasterControllerAction(new NullAbstractControllerAction() {
      @Override
      public void runInitialize(RunState runState, final Context context, Parameters params) {
// the code in here will be executed during run initialization.
        
        }
      }

      public String toString() {
// This name will show up in the action tree
        return "Action Name";
      }
    });

}

You need to add the ModelInitializer to the scenario.xml file. 

<Scenario>
...
<model.initializer class="fully qualified name of the initializer class" />
</Scenario>

If you really want to go the plugin_jpf.xml route, I can explain that more fully as well.

Nick

On Nov 3, 2009, at 2:25 AM, Rajagopalan Srinivasan wrote:

Hi,
I am trying to add a Composite Action into the controller tree. Understand from the Reference that these have to be specified in a plugin.xml file. I am new to the Java plugin framework. My questions are:
1.       Should the file name be plugin_jpf.xml or plugin.xml? Or is that irrelevant?
2.       In which directory should this xml file be placed?
3.       Would this xml file be discovered automatically or do I need to specify something in my Repast model (such as the Scenario.xml  file)
 
Thank you in advance for your clarifications.
 
Raj
 
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference_______________________________________________
Repast-interest mailing list
Repast-interest@...
https://lists.sourceforge.net/lists/listinfo/repast-interest


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Repast-interest mailing list
Repast-interest@...
https://lists.sourceforge.net/lists/listinfo/repast-interest

Re: How to add a Composite controller action

by Nick Collier-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ah, I see. In this case, the plugin_jpf.xml is better. As for where to put it etc. I think the following should work although I haven't tested it in a long time. 

1. Put the plugin_jpf.xml in the scenario directory.
2. Add the following to your scenario.xml file:

<model.plugin_jpf file="plugin_jpf.xml" />

If that doesn't work then you need to make sure that the plugin_jpf.xml file is found by the plugin mechanism. It may search your model code classpath, but I can't remember for sure. At any rate, the boot.properties file in repast.simphony.runtime contains a property that specifies where to look for the jpf plugin files, so you can add to that so that your plugin jpf is included.

Nick

On Nov 3, 2009, at 9:47 AM, Rajagopalan Srinivasan wrote:

Nick,
Thanks for the tip. I am currently using that approach for adding Controller Actions. My question was more about specifying a "composite.action" for adding a parent controller action. (I realize now that the subject in my previous mail was a bit ambiguous.) Can a composite action also be added from the ModelInitializer? Thanks again.
 
Raj

From: Nick Collier [nick.collier@...]
Sent: Tue 11/3/2009 10:11 PM
To: Rajagopalan Srinivasan
Cc: repast-interest@...
Subject: Re: [Repast-interest] How to add a Composite controller action

Raj,

An easier way to to add a controller action is using a repast.simphony.scenario.ModelInitializer. This is a bit of code that's run just after the scenario loads. You can use it to inject actions into the scenario tree. Here's an example:

public class Initializer implements ModelInitializer {

  public void initialize(Scenario scen, RunEnvironmentBuilder builder) {
    scen.addMasterControllerAction(new NullAbstractControllerAction() {
      @Override
      public void runInitialize(RunState runState, final Context context, Parameters params) {
// the code in here will be executed during run initialization.
        
        }
      }

      public String toString() {
// This name will show up in the action tree
        return "Action Name";
      }
    });

}

You need to add the ModelInitializer to the scenario.xml file. 

<Scenario>
...
<model.initializer class="fully qualified name of the initializer class" />
</Scenario>

If you really want to go the plugin_jpf.xml route, I can explain that more fully as well.

Nick

On Nov 3, 2009, at 2:25 AM, Rajagopalan Srinivasan wrote:

Hi,
I am trying to add a Composite Action into the controller tree. Understand from the Reference that these have to be specified in a plugin.xml file. I am new to the Java plugin framework. My questions are:
1.       Should the file name be plugin_jpf.xml or plugin.xml? Or is that irrelevant?
2.       In which directory should this xml file be placed?
3.       Would this xml file be discovered automatically or do I need to specify something in my Repast model (such as the Scenario.xml  file)
 
Thank you in advance for your clarifications.
 
Raj
 
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference_______________________________________________
Repast-interest mailing list
Repast-interest@...
https://lists.sourceforge.net/lists/listinfo/repast-interest



------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Repast-interest mailing list
Repast-interest@...
https://lists.sourceforge.net/lists/listinfo/repast-interest