[Pogamut-list] How to bind parser?

jakub.gemrot pogamut-forum at diana.ms.mff.cuni.cz
Wed Apr 21 14:26:36 CEST 2010


Re: How to bind parser?

Author: jakub.gemrot

Hi!

See javadoc for SingleUT2004BotRunner :-) ... it says you can use it for single purpose only ... run single bot inside JVM ;-)

One by one...

JMX -> yes it is used by NetBeans plugin to manage bot inside different JVM - note that the biggest feature of Pogamut 3 is the option to directly debug the bot inside NetBeans (you could not do that in Pogamut 2). Currently bots are run in different JVM than the plugin therefore we needed the way to control the bot -> JMX.

MBeans server -> yes it is man handled, blame the Sun (Oracle) company :-( ... if you start up the registry for MBean server, start the agent and then stop it and expect the JVM to exit as well ... surprise! ... The registry are still running inside deamon thread and JVM will run forever ... additionally, there is some issue with stopping the registry when some mxbean are still registered - we needed the way to unregister automatically or MBeans of the single agent. We're recording which mxbeans are being published on MBeanServer level (manhandling as you're writing).

All in all - to let JVM be closed, you must call Pogamut.getPlatform().close() in order to shutdown registry. Therefore you must somehow now the time when that moment comes. This can be achieved by different means / approaches - one of them is SingleUT2004BotRunner and MultipleUT2004BotRunner. 

I advise you to check out the source of SingleUT2004BotRunner and see how the bot is being constructed and where it waits till the bot finishes. Cut these parts of the code into your main method and experiment. ... you will probably need to read javadoc for factory and modules.

We're using Guice IOC to assamble the agent - therefore you need to instantiate a module (see UT2004BotModule) that configures UT2004BotFactory (from ...guice... package). The factory can then construct a new agent for you that can be started via .start() method.

Note that the start() method has a nice behavior - even though the agent is multithreaded - start() method will finish when the bot is actually completely running. If any thread fails during start up - start() will throw an exception. (Thanks to "component design" and "ComponentBus" object that provides life-cycle for all agent components.).

Once the agent is started - you can observe its states via getState().getFlag() ... note that the stat is actually object of some class and the class is implementing various interfaces that serves as markers "what stat it is" ... there is a hierarchy between agent states ... see package cz.cuni.amis.pogamut.base.agent.state and see which interfaces are there ... if you want to check whether the agent is in particular state, you may use .inState() or .notInState() methods at Agent.

Phew - lot of infos ;-) 

Good luck!

Jimmy

-- 
Reply Link: <http://diana.ms.mff.cuni.cz/main/tiki-view_forum_thread.php?forumId=4&comments_reply_threadId=4&comments_parentId=55&post_reply=1#form>





More information about the Pogamut-list mailing list