Search in sources :

Example 1 with OptionsValidator

use of org.apache.axis2.util.OptionsValidator 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);
    }
}
Also used : OptionsValidator(org.apache.axis2.util.OptionsValidator) CommandLineOption(org.apache.axis2.util.CommandLineOption) List(java.util.List) ClusteringAgent(org.apache.axis2.clustering.ClusteringAgent) Map(java.util.Map) File(java.io.File) CommandLineOptionParser(org.apache.axis2.util.CommandLineOptionParser) ListenerManager(org.apache.axis2.engine.ListenerManager)

Aggregations

File (java.io.File)1 List (java.util.List)1 Map (java.util.Map)1 ClusteringAgent (org.apache.axis2.clustering.ClusteringAgent)1 ListenerManager (org.apache.axis2.engine.ListenerManager)1 CommandLineOption (org.apache.axis2.util.CommandLineOption)1 CommandLineOptionParser (org.apache.axis2.util.CommandLineOptionParser)1 OptionsValidator (org.apache.axis2.util.OptionsValidator)1