use of org.apache.axis2.util.CommandLineOptionParser in project wso2-synapse by wso2.
the class SampleAxis2ServerManager method start.
public void start(String[] args) throws Exception {
String repoLocation = null;
String confLocation = null;
CommandLineOptionParser optionsParser = new CommandLineOptionParser(args);
List invalidOptionsList = optionsParser.getInvalidOptions(new OptionsValidator() {
public boolean isInvalid(CommandLineOption option) {
String optionType = option.getOptionType();
return !("repo".equalsIgnoreCase(optionType) || "conf".equalsIgnoreCase(optionType));
}
});
if ((invalidOptionsList.size() > 0) || (args.length > 4)) {
printUsage();
}
Map optionsMap = optionsParser.getAllOptions();
CommandLineOption repoOption = (CommandLineOption) optionsMap.get("repo");
CommandLineOption confOption = (CommandLineOption) optionsMap.get("conf");
log.info("[SimpleAxisServer] Starting");
if (repoOption != null) {
repoLocation = repoOption.getOptionValue();
System.out.println("[SimpleAxisServer] Using the Axis2 Repository : " + new File(repoLocation).getAbsolutePath());
}
if (confOption != null) {
confLocation = confOption.getOptionValue();
System.out.println("[SimpleAxisServer] Using the Axis2 Configuration File : " + new File(confLocation).getAbsolutePath());
}
try {
configctx = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoLocation, confLocation);
configurePort(configctx);
// Need to initialize the cluster manager at last since we are changing the servers
// HTTP/S ports above. In the axis2.xml file, we need to set the "AvoidInitiation" param
// to "true"
ClusteringAgent clusteringAgent = configctx.getAxisConfiguration().getClusteringAgent();
if (clusteringAgent != null) {
clusteringAgent.setConfigurationContext(configctx);
clusteringAgent.init();
}
// Finally start the transport listeners
listenerManager = new ListenerManager();
listenerManager.init(configctx);
listenerManager.start();
log.info("[SimpleAxisServer] Started");
} catch (Throwable t) {
log.fatal("[SimpleAxisServer] Shutting down. Error starting SimpleAxisServer", t);
// must stop application
System.exit(1);
}
}
Aggregations