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();
}
}
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);
}
}
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");
}
}
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);
}
}
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);
}
}
Aggregations