Search in sources :

Example 1 with ServerManager

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);
}
Also used : ServerManager(org.apache.synapse.ServerManager) ServletConfig(javax.servlet.ServletConfig) ServletContext(javax.servlet.ServletContext) ServerConfigurationInformation(org.apache.synapse.ServerConfigurationInformation)

Example 2 with 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);
}
Also used : ServerManager(org.apache.synapse.ServerManager) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) MessageReceiver(org.apache.axis2.engine.MessageReceiver) HashMap(java.util.HashMap) AxisService(org.apache.axis2.description.AxisService) ServerConfigurationInformation(org.apache.synapse.ServerConfigurationInformation) TransportInDescription(org.apache.axis2.description.TransportInDescription) Services(org.apache.synapse.util.Services) ServerContextInformation(org.apache.synapse.ServerContextInformation) MessageReceiver(org.apache.axis2.engine.MessageReceiver)

Example 3 with ServerManager

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();
    }
}
Also used : ServerManager(org.apache.synapse.ServerManager) ServletContext(javax.servlet.ServletContext) ListingAgent(org.apache.axis2.transport.http.ListingAgent)

Example 4 with ServerManager

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);
    }
}
Also used : ServerManager(org.apache.synapse.ServerManager) ServletException(javax.servlet.ServletException) IOException(java.io.IOException)

Example 5 with ServerManager

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();
}
Also used : ServerManager(org.apache.synapse.ServerManager) SampleAxis2ServerManager(samples.util.SampleAxis2ServerManager) ServerConfigurationInformation(org.apache.synapse.ServerConfigurationInformation)

Aggregations

ServerManager (org.apache.synapse.ServerManager)5 ServerConfigurationInformation (org.apache.synapse.ServerConfigurationInformation)3 ServletContext (javax.servlet.ServletContext)2 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 ServletConfig (javax.servlet.ServletConfig)1 ServletException (javax.servlet.ServletException)1 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)1 AxisService (org.apache.axis2.description.AxisService)1 TransportInDescription (org.apache.axis2.description.TransportInDescription)1 MessageReceiver (org.apache.axis2.engine.MessageReceiver)1 ListingAgent (org.apache.axis2.transport.http.ListingAgent)1 ServerContextInformation (org.apache.synapse.ServerContextInformation)1 Services (org.apache.synapse.util.Services)1 SampleAxis2ServerManager (samples.util.SampleAxis2ServerManager)1