|
From: <to...@us...> - 2008-01-17 12:06:06
|
Revision: 100
http://xoperator.svn.sourceforge.net/xoperator/?rev=100&view=rev
Author: tomatop
Date: 2008-01-17 03:51:28 -0800 (Thu, 17 Jan 2008)
Log Message:
-----------
agent exits only on ctrl+c from the command line
Modified Paths:
--------------
trunk/xOperator/src/net/sf/xoperator/startup/CommandLineMain.java
Modified: trunk/xOperator/src/net/sf/xoperator/startup/CommandLineMain.java
===================================================================
--- trunk/xOperator/src/net/sf/xoperator/startup/CommandLineMain.java 2008-01-11 01:36:53 UTC (rev 99)
+++ trunk/xOperator/src/net/sf/xoperator/startup/CommandLineMain.java 2008-01-17 11:51:28 UTC (rev 100)
@@ -70,9 +70,10 @@
*/
public class CommandLineMain {
{
- //PropertyConfigurator.configure();
- //new PropertyConfigurator();
+ // PropertyConfigurator.configure();
+ // new PropertyConfigurator();
}
+
Options options = new Options();
private Log log = LogFactory.getLog(CommandLineMain.class);
@@ -131,117 +132,115 @@
.withDescription(
"The port of the server to connect to for the roxy account, defaults to 5222")
.create("proxy_port"));
- options
- .addOption(OptionBuilder
- .withArgName("group_agent")
- .hasArg()
- .isRequired(false)
- .withDescription(
+ options.addOption(OptionBuilder.withArgName("group_agent").hasArg()
+ .isRequired(false).withDescription(
"if set to to true, no proxy account will be used")
.create("group_agent"));
- options
- .addOption(OptionBuilder
- .withArgName("p2penabled")
- .hasArg()
- .isRequired(false)
- .withDescription(
+ options.addOption(OptionBuilder.withArgName("p2penabled").hasArg()
+ .isRequired(false).withDescription(
"if set to to true, p2p communication is activated")
.create("p2penabled"));
}
- public void startUp(String[] args){
- log.debug("Starting the application, got the following paramters by the commandline:");
+ public void startUp(String[] args) {
+ log
+ .debug("Starting the application, got the following paramters by the commandline:");
for (String arg : args) {
log.debug(arg);
}
log.debug("End of the argument list");
- System.out.println("Starting the client");
- CommandLineParser parser = new GnuParser();
- AccountInfo main = new AccountInfo();
- AccountInfo proxy = new AccountInfo();
- try {
- CommandLine cl = parser.parse(options, args);
-
- main.setUsername(cl.getOptionValue("main_username"));
- main.setPassword(cl.getOptionValue("main_password"));
- main.setServer(cl.getOptionValue("main_server"));
- main.setPort(cl.getOptionValue("main_port")!=null?Integer.parseInt(cl.getOptionValue("main_port")):null);
-
- main.setStandalone(cl.getOptionValue("group_agent")!=null?Boolean.parseBoolean(cl.getOptionValue("group_agent")):false);
- main.setP2penabled(cl.getOptionValue("p2penabled")!=null?Boolean.getBoolean(cl.getOptionValue("p2penabled")):false);
- main.setMainAccount(true);
-
- if(main.isStandalone()){
- proxy=null;
- }else{
- proxy.setUsername(cl.getOptionValue("proxy_username"));
- proxy.setPassword(cl.getOptionValue("proxy_password"));
- proxy.setServer(cl.getOptionValue("proxy_server"));
- proxy.setPort(cl.getOptionValue("proxy_port")!=null?Integer.parseInt(cl.getOptionValue("proxy_port")):null);
- proxy.setMainAccount(false);
- }
-
-
-
-
- } catch (ParseException e) {
- System.out.println(e.getMessage());
- HelpFormatter hform = new HelpFormatter();
- hform.printHelp("Parameters are: ", options);
- System.exit(0);
- }
-
- Blackboard bboard = new ThreadsafeObjectBlackboard(new NoCloningCloneStrategy());
- NoPlanBlackBoardControl control = new NoPlanBlackBoardControl(bboard);
-
- control.registerKnowledgeSource(new RDFStoreHTTPAdaptor());
- control.registerKnowledgeSource(new XMPPManager(control));
- control.registerKnowledgeSource(new SPARQL2TextTransformer());
- control.registerKnowledgeSource(new LoggingKS(control));
- control.registerKnowledgeSource(new NamespaceKS());
-
- //Constructing the userinterface
-
- List<Interaction> interactions = new ArrayList<Interaction>();
- interactions.add(new QueryCommand());
- interactions.add(new HelpCommand());
- interactions.add(new ListDatastoresCommand());
- interactions.add(new AddDatastoreCommand());
- interactions.add(new RemoveDatastoreCommand());
-
-
- interactions.add(new AddAimlTemplate());
- interactions.add(new ListAimlTemplates());
- interactions.add(new RemoveAimlTemplate());
-
- interactions.add(new AddNamespaceCommand());
- interactions.add(new RemoveNamespaceCommand());
- interactions.add(new ListNamespacesCommand());
-
-
- Interactor interact = new Interactor(interactions,control);
- control.registerKnowledgeSource(new UIDelegate(interact,control));
-
-
- //starting the system by intializing the data store, which loads the configuration
- SerializingPersonalDataStore store = new SerializingPersonalDataStore(control);
- control.registerKnowledgeSource(store);
- store.initialize(main, proxy);
-
-
-
+ System.out.println("Starting the client");
+ CommandLineParser parser = new GnuParser();
+ AccountInfo main = new AccountInfo();
+ AccountInfo proxy = new AccountInfo();
+ try {
+ CommandLine cl = parser.parse(options, args);
- }
+ main.setUsername(cl.getOptionValue("main_username"));
+ main.setPassword(cl.getOptionValue("main_password"));
+ main.setServer(cl.getOptionValue("main_server"));
+ main.setPort(cl.getOptionValue("main_port") != null ? Integer
+ .parseInt(cl.getOptionValue("main_port")) : null);
+ main
+ .setStandalone(cl.getOptionValue("group_agent") != null ? Boolean
+ .parseBoolean(cl.getOptionValue("group_agent"))
+ : false);
+ main
+ .setP2penabled(cl.getOptionValue("p2penabled") != null ? Boolean
+ .getBoolean(cl.getOptionValue("p2penabled"))
+ : false);
+ main.setMainAccount(true);
+
+ if (main.isStandalone()) {
+ proxy = null;
+ } else {
+ proxy.setUsername(cl.getOptionValue("proxy_username"));
+ proxy.setPassword(cl.getOptionValue("proxy_password"));
+ proxy.setServer(cl.getOptionValue("proxy_server"));
+ proxy.setPort(cl.getOptionValue("proxy_port") != null ? Integer
+ .parseInt(cl.getOptionValue("proxy_port")) : null);
+ proxy.setMainAccount(false);
+ }
+
+ } catch (ParseException e) {
+ System.out.println(e.getMessage());
+ HelpFormatter hform = new HelpFormatter();
+ hform.printHelp("Parameters are: ", options);
+ System.exit(0);
+ }
+
+ Blackboard bboard = new ThreadsafeObjectBlackboard(
+ new NoCloningCloneStrategy());
+ NoPlanBlackBoardControl control = new NoPlanBlackBoardControl(bboard);
+
+ control.registerKnowledgeSource(new RDFStoreHTTPAdaptor());
+ control.registerKnowledgeSource(new XMPPManager(control));
+ control.registerKnowledgeSource(new SPARQL2TextTransformer());
+ control.registerKnowledgeSource(new LoggingKS(control));
+ control.registerKnowledgeSource(new NamespaceKS());
+
+ // Constructing the userinterface
+
+ List<Interaction> interactions = new ArrayList<Interaction>();
+ interactions.add(new QueryCommand());
+ interactions.add(new HelpCommand());
+ interactions.add(new ListDatastoresCommand());
+ interactions.add(new AddDatastoreCommand());
+ interactions.add(new RemoveDatastoreCommand());
+
+ interactions.add(new AddAimlTemplate());
+ interactions.add(new ListAimlTemplates());
+ interactions.add(new RemoveAimlTemplate());
+
+ interactions.add(new AddNamespaceCommand());
+ interactions.add(new RemoveNamespaceCommand());
+ interactions.add(new ListNamespacesCommand());
+
+ Interactor interact = new Interactor(interactions, control);
+ control.registerKnowledgeSource(new UIDelegate(interact, control));
+
+ // starting the system by intializing the data store, which loads the
+ // configuration
+ SerializingPersonalDataStore store = new SerializingPersonalDataStore(
+ control);
+ control.registerKnowledgeSource(store);
+ store.initialize(main, proxy);
+
+ }
+
public static void main(String[] args) {
CommandLineMain main = new CommandLineMain();
main.startUp(args);
-
+ int exit = 0;
try {
- System.in.read();
+ while (exit!=-1) {
+ exit = System.in.read();
+ }
+
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|