Search in sources :

Example 1 with ListenerManager

use of org.apache.axis2.engine.ListenerManager in project wso2-axis2-transports by wso2.

the class AxisTestClientContext method setUp.

@Setup
@SuppressWarnings("unused")
private void setUp(TransportDescriptionFactory tdf, AxisTestClientContextConfigurator[] configurators) throws Exception {
    cfgCtx = ConfigurationContextFactory.createConfigurationContext(new CustomAxisConfigurator());
    AxisConfiguration axisCfg = cfgCtx.getAxisConfiguration();
    TransportOutDescription trpOutDesc = tdf.createTransportOutDescription();
    axisCfg.addTransportOut(trpOutDesc);
    sender = trpOutDesc.getSender();
    sender.init(cfgCtx, trpOutDesc);
    boolean useListener = false;
    for (AxisTestClientContextConfigurator configurator : configurators) {
        if (configurator.isTransportListenerRequired()) {
            useListener = true;
            break;
        }
    }
    TransportInDescription trpInDesc;
    if (useListener) {
        trpInDesc = tdf.createTransportInDescription();
    } else {
        trpInDesc = null;
    }
    for (AxisTestClientContextConfigurator configurator : configurators) {
        configurator.setupTransport(trpInDesc, trpOutDesc);
    }
    if (useListener) {
        listenerManager = new ListenerManager();
        listenerManager.init(cfgCtx);
        cfgCtx.setTransportManager(listenerManager);
        listenerManager.addListener(trpInDesc, false);
        listenerManager.start();
    }
}
Also used : AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) CustomAxisConfigurator(org.apache.axis2.transport.CustomAxisConfigurator) TransportInDescription(org.apache.axis2.description.TransportInDescription) TransportOutDescription(org.apache.axis2.description.TransportOutDescription) ListenerManager(org.apache.axis2.engine.ListenerManager) Setup(org.apache.axis2.transport.testkit.tests.Setup)

Example 2 with ListenerManager

use of org.apache.axis2.engine.ListenerManager 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)

Example 3 with ListenerManager

use of org.apache.axis2.engine.ListenerManager in project wso2-synapse by wso2.

the class Axis2SynapseController method stop.

/**
 * Cleanup the axis2 environment and stop the synapse environment.
 */
public void stop() {
    try {
        // stop tasks
        SynapseTaskManager synapseTaskManager = synapseEnvironment.getTaskManager();
        if (synapseTaskManager.isInitialized()) {
            synapseTaskManager.cleanup();
        }
        EnterpriseBeanstalkManager manager = (EnterpriseBeanstalkManager) serverContextInformation.getProperty(EnterpriseBeanstalkConstants.BEANSTALK_MANAGER_PROP_NAME);
        if (manager != null) {
            manager.destroy();
        }
        // stop the listener manager
        if (listenerManager != null) {
            listenerManager.stop();
        }
        // detach the synapse handlers
        if (configurationContext != null) {
            List<Phase> inflowPhases = configurationContext.getAxisConfiguration().getInFlowPhases();
            for (Phase inPhase : inflowPhases) {
                // we are interested about the Dispatch phase in the inflow
                if (PhaseMetadata.PHASE_DISPATCH.equals(inPhase.getPhaseName())) {
                    List<HandlerDescription> synapseHandlers = new ArrayList<HandlerDescription>();
                    for (Handler handler : inPhase.getHandlers()) {
                        if (SynapseDispatcher.NAME.equals(handler.getName()) || SynapseMustUnderstandHandler.NAME.equals(handler.getName())) {
                            synapseHandlers.add(handler.getHandlerDesc());
                        }
                    }
                    for (HandlerDescription handlerMD : synapseHandlers) {
                        inPhase.removeHandler(handlerMD);
                    }
                }
            }
        } else {
            handleException("Couldn't detach the Synapse handlers, " + "ConfigurationContext not found.");
        }
        // continue stopping the axis2 environment if we created it
        if (serverConfigurationInformation.isCreateNewInstance() && configurationContext != null && configurationContext.getAxisConfiguration() != null) {
            Map<String, AxisService> serviceMap = configurationContext.getAxisConfiguration().getServices();
            for (AxisService svc : serviceMap.values()) {
                svc.setActive(false);
            }
            // stop all modules
            Map<String, AxisModule> moduleMap = configurationContext.getAxisConfiguration().getModules();
            for (AxisModule mod : moduleMap.values()) {
                if (mod.getModule() != null && !"synapse".equals(mod.getName())) {
                    mod.getModule().shutdown(configurationContext);
                }
            }
        }
    } catch (AxisFault e) {
        log.error("Error stopping the Axis2 Environment");
    }
}
Also used : AxisFault(org.apache.axis2.AxisFault) EnterpriseBeanstalkManager(org.apache.synapse.commons.beanstalk.enterprise.EnterpriseBeanstalkManager) SecretCallbackHandler(org.wso2.securevault.secret.SecretCallbackHandler)

Example 4 with ListenerManager

use of org.apache.axis2.engine.ListenerManager in project wso2-synapse by wso2.

the class SynapseCommodityServiceTest method startServer.

private void startServer(ConfigurationContext configctx) throws AxisFault {
    ListenerManager listenerManager = configctx.getListenerManager();
    if (listenerManager == null) {
        listenerManager = new ListenerManager();
        listenerManager.init(configctx);
    }
    Iterator iter = configctx.getAxisConfiguration().getTransportsIn().keySet().iterator();
    while (iter.hasNext()) {
        String trp = (String) iter.next();
        TransportInDescription trsIn = configctx.getAxisConfiguration().getTransportsIn().get(trp);
        listenerManager.addListener(trsIn, false);
    }
}
Also used : Iterator(java.util.Iterator) TransportInDescription(org.apache.axis2.description.TransportInDescription) ListenerManager(org.apache.axis2.engine.ListenerManager)

Example 5 with ListenerManager

use of org.apache.axis2.engine.ListenerManager in project airavata by apache.

the class XBayaClientTest method axis2ServiceStarter.

private ListenerManager axis2ServiceStarter() throws AxisFault {
    try {
        ConfigurationContext configContext = ConfigurationContextFactory.createBasicConfigurationContext("axis2_default.xml");
        AxisService service = AxisService.createService(EchoService.class.getName(), configContext.getAxisConfiguration());
        configContext.deployService(service);
        ListenerManager manager = new ListenerManager();
        manager.init(configContext);
        manager.start();
        return manager;
    } catch (Exception e) {
        throw AxisFault.makeFault(e);
    }
}
Also used : ConfigurationContext(org.apache.axis2.context.ConfigurationContext) AxisService(org.apache.axis2.description.AxisService) ListenerManager(org.apache.axis2.engine.ListenerManager)

Aggregations

ListenerManager (org.apache.axis2.engine.ListenerManager)4 TransportInDescription (org.apache.axis2.description.TransportInDescription)2 File (java.io.File)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 AxisFault (org.apache.axis2.AxisFault)1 ClusteringAgent (org.apache.axis2.clustering.ClusteringAgent)1 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)1 AxisService (org.apache.axis2.description.AxisService)1 TransportOutDescription (org.apache.axis2.description.TransportOutDescription)1 AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)1 CustomAxisConfigurator (org.apache.axis2.transport.CustomAxisConfigurator)1 Setup (org.apache.axis2.transport.testkit.tests.Setup)1 CommandLineOption (org.apache.axis2.util.CommandLineOption)1 CommandLineOptionParser (org.apache.axis2.util.CommandLineOptionParser)1 OptionsValidator (org.apache.axis2.util.OptionsValidator)1 EnterpriseBeanstalkManager (org.apache.synapse.commons.beanstalk.enterprise.EnterpriseBeanstalkManager)1 SecretCallbackHandler (org.wso2.securevault.secret.SecretCallbackHandler)1