Dynamic agent creation & service-blackboard communication
Matt Abrams
abramsm at gmail.com
Wed Aug 10 11:08:05 EDT 2005
Another option is to use the CCM project from cougaar.org. The
project provides basic functionality for creating new agents
dynamically and adding components to new agents after they are
created.
http://cougaar.org/projects/ccm/
Matt
On 8/10/05, Michael Jarrett <msjarret at engmail.uwaterloo.ca> wrote:
> This is acutally a fair bit harder than it should be, unless Cougaar 12
> corrected some of the issues.
>
> Each node has a node agent with the same name as the node. If you wish to
> replace the Node agent's actual agent definition, you can do so using a
> custom XSL template. For your purposes, this will not be necessary. I would
> suggest just loading a regular PLUGIN into the node agent, which you can do
> easily as follows:
> <node name="name">
> <component class="blah.class."/>
> ...
>
> Note, the default insertion point for components under nodes are to be
> plugins, so you don't even have to specify it.
>
> Your plugin into the node agent, lets call it X, can then create agents
> directly with the node control service.
>
> AgentContainer ac= ncs.getRootContainer();
> MessageAddress addy= MessageAddress.getMessageAddress(agentName);
> ac.addAgent(addy, new org.cougaar.core.component.StateTuple(
> new ComponentDescription(
> "org.cougaar.core.agent.AgentImpl"/*agentName*/,
> org.cougaar.core.agent.Agent.INSERTION_POINT,
> "org.cougaar.core.agent.AgentImpl",
> null,
> java.util.Collections.singletonList(addy.getAddress()),
> null, null, null,
> ComponentDescription.PRIORITY_COMPONENT)
> , null));
>
> You can do something similar with the MobilityService if you're so inclined.
>
> The BIG problem comes from how you can get components into your new agent. I
> belive as of recent Cougaar versions, the ComponentInitializerService will
> look for AgentName.xml in your config dir for a specification of your new
> agent. The problem in your case is that you can't give multiple agents with
> the same definition a unique name. Sadly, the only solution to this that
> I've found is to create your own custom ComponentInitializerService.
>
> Now, given that you've created your new agent successfully, getting stuff on
> the blackboard is trivial. Just have the same plugin that created the agent
> create a relay to that agent.
>
> Cheers,
> Mike
>
>
> > -----Original Message-----
> > From: cougaar-developers-bounces at cougaar.org
> > [mailto:cougaar-developers-bounces at cougaar.org] On Behalf Of
> > Xingzhi Pan
> > Sent: August 10, 2005 9:54 AM
> > To: cougaar-developers at cougaar.org
> > Subject: Dynamic agent creation & service-blackboard communication
> >
> > Greetings,
> > The title of my last post is misleading, sorry for that.
> >
> > I try to make it clear ;-)
> >
> > Question 1. dynamic agent creation
> >
> > I need to know how to create an agent dynamically and put something
> > on it's blackboard after that.
> >
> > In fact I'm writing an Instant Messaging server on Cougaar.
> > So I use a NodeAgent's plugin to start a thread that keep
> > listening some port.
> > If there comes a connection, the listening thread create an
> > agent and pass the
> > connection to it. ie, the new agent represent the session between
> > server and client.
> > I've read the CDG and mail archive but can't find an exact
> > way to do that.
> >
> > Should I write an XML in advance for the new agent? Or just
> > instantiate a ComponentDescription,
> > pass it to a StateTuple instance, then call addAgent? I need some
> > concrete examples.
> >
> > Question 2. service-blackboard communication
> >
> > I published a node-level service. All I want to know is how can this
> > service "put" some object on
> > a specified agent's blackboard so some "subscribed" plugin
> > can do my stuff.
> >
> > I'll be most grateful for any helping hand :-)
> > Pan Xingzhi
> >
> > _______________________________________________
> > Cougaar-developers mailing list
> > Cougaar-developers at cougaar.org
> > http://cougaar.org/mailman/listinfo/cougaar-developers
> >
>
> _______________________________________________
> Cougaar-developers mailing list
> Cougaar-developers at cougaar.org
> http://cougaar.org/mailman/listinfo/cougaar-developers
>
More information about the Cougaar-developers
mailing list