use of org.apache.synapse.ServerManager in project wso2-synapse by wso2.
the class SynapseStartUpServlet method init.
public void init() throws ServletException {
ServletConfig servletConfig = getServletConfig();
ServletContext servletContext = servletConfig.getServletContext();
if (Boolean.TRUE.equals(servletContext.getAttribute(ALREADY_INITED))) {
return;
}
ServerManager serverManager = new ServerManager();
ServerConfigurationInformation information = ServerConfigurationInformationFactory.createServerConfigurationInformation(servletConfig);
serverManager.init(information, null);
serverManager.start();
servletContext.setAttribute(ALREADY_INITED, Boolean.TRUE);
servletContext.setAttribute(SYNAPSE_SERVER_MANAGER, serverManager);
}
use of org.apache.synapse.ServerManager in project wso2-synapse by wso2.
the class SynapseCommodityServiceTest method setUp.
protected void setUp() throws java.lang.Exception {
ServerConfigurationInformation information = new ServerConfigurationInformation();
information.setCreateNewInstance(false);
information.setSynapseHome(".");
// Initializing Synapse repository
information.setSynapseXMLLocation("./../../repository/conf/sample/resources/misc/synapse.xml");
information.setAxis2Xml("./../../repository/conf/axis2.xml");
findAndReplace(new File("./../../repository/conf/axis2_pt_server.xml"), new File("./target/test_repos/axis2.xml"), "lib/", "./../../modules/distribution/src/main/conf/");
findAndReplace(new File("./../../repository/conf/axis2_be_server.xml"), new File("./target/test_repos/axis2_be_server.xml"), "lib/", "./../../modules/distribution/src/main/conf/");
System.setProperty("jmx.agent.name", "synapse");
ConfigurationContext synapseConfigCtx = ConfigurationContextFactory.createConfigurationContextFromFileSystem("./target/test_repos/synapse", "./target/test_repos/axis2.xml");
TransportInDescription synTrsIn = synapseConfigCtx.getAxisConfiguration().getTransportsIn().get("http");
synTrsIn.getParameter("port").setValue("10100");
synTrsIn = synapseConfigCtx.getAxisConfiguration().getTransportsIn().get("https");
synTrsIn.getParameter("port").setValue("12100");
startServer(synapseConfigCtx);
ServerContextInformation contextInformation = new ServerContextInformation(synapseConfigCtx, information);
ServerManager serverManager = new ServerManager();
serverManager.init(information, contextInformation);
serverManager.start();
// Initializing Business Endpoint
// Set a different agent name to avoid collisions between the MBeans registered
// by the two servers.
System.setProperty("jmx.agent.name", "business");
ConfigurationContext businessConfigCtx = ConfigurationContextFactory.createConfigurationContextFromFileSystem("./target/test_repos/synapse", "./target/test_repos/axis2_be_server.xml");
HashMap messageReciverMap = new HashMap();
Class inOnlyMessageReceiver = org.apache.axis2.util.Loader.loadClass("org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver");
org.apache.axis2.engine.MessageReceiver messageReceiver = (org.apache.axis2.engine.MessageReceiver) inOnlyMessageReceiver.newInstance();
messageReciverMap.put(org.apache.axis2.description.WSDL2Constants.MEP_URI_IN_ONLY, messageReceiver);
Class inoutMessageReceiver = org.apache.axis2.util.Loader.loadClass("org.apache.axis2.rpc.receivers.RPCMessageReceiver");
MessageReceiver inOutmessageReceiver = (MessageReceiver) inoutMessageReceiver.newInstance();
messageReciverMap.put(org.apache.axis2.description.WSDL2Constants.MEP_URI_IN_OUT, inOutmessageReceiver);
messageReciverMap.put(org.apache.axis2.description.WSDL2Constants.MEP_URI_ROBUST_IN_ONLY, inOutmessageReceiver);
AxisService businessService = AxisService.createService(Services.class.getName(), businessConfigCtx.getAxisConfiguration(), messageReciverMap, "http://business.org", "http://business.org", Services.class.getClassLoader());
businessConfigCtx.getAxisConfiguration().addService(businessService);
TransportInDescription busTrsIn = businessConfigCtx.getAxisConfiguration().getTransportsIn().get("http");
busTrsIn.getParameter("port").setValue("10101");
busTrsIn = businessConfigCtx.getAxisConfiguration().getTransportsIn().get("https");
busTrsIn.getParameter("port").setValue("12101");
startServer(businessConfigCtx);
}
use of org.apache.synapse.ServerManager in project wso2-synapse by wso2.
the class SynapseAxisServlet method init.
/**
* Overrides init method so that avoid starting listeners again
*
* @param config the servlet configuration on which synapse initializes.
* @throws ServletException
*/
public void init(ServletConfig config) throws ServletException {
ServletContext servletContext = config.getServletContext();
ServerManager serverManager = (ServerManager) config.getServletContext().getAttribute(SynapseStartUpServlet.SYNAPSE_SERVER_MANAGER);
if (serverManager != null) {
this.configContext = (ConfigurationContext) serverManager.getServerContextInformation().getServerContext();
this.axisConfiguration = this.configContext.getAxisConfiguration();
servletContext.setAttribute(this.getClass().getName(), this);
this.servletConfig = config;
agent = new ListingAgent(configContext);
initParams();
}
}
use of org.apache.synapse.ServerManager in project wso2-synapse by wso2.
the class SynapseStartUpServlet method destroy.
public void destroy() {
try {
Object o = getServletConfig().getServletContext().getAttribute(SYNAPSE_SERVER_MANAGER);
if (o != null && o instanceof ServerManager) {
ServerManager serverManager = (ServerManager) o;
serverManager.stop();
getServletContext().removeAttribute(ALREADY_INITED);
}
} catch (Exception e) {
log.error("Error stopping the Synapse listener manager", e);
}
}
use of org.apache.synapse.ServerManager in project wso2-synapse by wso2.
the class AbstractAutomationTestCase method setUpSynapseEnv.
protected void setUpSynapseEnv() {
System.setProperty("port", "8280");
System.setProperty("org.apache.xerces.xni.parser.XMLParserConfiguration", "org.apache.xerces.parsers.XMLGrammarCachingConfiguration");
System.setProperty("axis2.xml", "modules/samples/target/test_repos/synapse/conf/axis2.xml");
ServerConfigurationInformation information = new ServerConfigurationInformation();
information.setAxis2RepoLocation(SYNAPSE_REPO);
serverManager = new ServerManager();
serverManager.init(information, null);
serverManager.start();
}
Aggregations