org.ow2.petals.binding.soap.listener.incoming.SoapExternalServer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of petals-bc-soap Show documentation
Show all versions of petals-bc-soap Show documentation
The PEtALS SOAP JBI binding component based on Axis2 and Jetty.
The newest version!
/**
* Copyright (c) 2006-2012 EBM WebSourcing, 2012-2023 Linagora
*
* This program/library is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 2.1 of the License, or (at your
* option) any later version.
*
* This program/library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program/library; If not, see http://www.gnu.org/licenses/
* for the GNU Lesser General Public License version 2.1.
*/
package org.ow2.petals.binding.soap.listener.incoming;
import java.util.MissingResourceException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.jbi.JBIException;
import org.apache.axis2.AxisFault;
import org.ow2.petals.binding.soap.SoapComponentContext;
import org.ow2.petals.binding.soap.listener.incoming.jetty.AxisServletServer;
/**
* This class is used to manage listeners for external WS addresses registered during SU deployment.
* @author Adrien Louis - EBM WebSourcing
* @author Christophe Hhamerling - EBM WebSourcing
*/
public class SoapExternalServer {
protected final AxisServletServer httpServer;
protected final SoapComponentContext soapContext;
/**
* Creates a new instance of {@link SoapExternalServer}
*
* @param soapContext
*
* @throws JBIException
* if the specified host in the component extension is not a
* valid address
* @throws AxisFault
*/
public SoapExternalServer(final SoapComponentContext soapContext) throws JBIException, AxisFault {
this.soapContext = soapContext;
// Get a specific logger for the HTTP server
final Logger jettyLogger = soapContext.getComponent().getContext().getLogger("jetty", null);
/*
* Init the HTTP server which will handle external SOAP request (only if the specified host is valid). The
* axis2.xml defines a Petals dispatcher that will catch incoming requests.
*/
this.httpServer = new AxisServletServer(jettyLogger, this.soapContext.getSoapServerConfig(),
this.soapContext.getAxis2ConfigurationContext(), this.soapContext.getIncomingProbes(),
this.soapContext.isPublicStacktracesEnabled());
}
/**
* Start the embedded HTTP server and initialize the dispatcher.
*
*
* Note: it will also start the ListenerManager
*
* @throws AxisFault
* @throws JBIException
* @throws MissingResourceException
*/
public void start() throws AxisFault, MissingResourceException, JBIException {
/*
* Starts the HTTP server which will handle external SOAP request (only
* if the specified host is valid). The axis2.xml defines a Petals
* dispatcher that will catch incoming requests.
*/
if (this.soapContext.getSoapServerConfig().isValidHostName()) {
this.httpServer.start();
} else if (this.soapContext.getLogger().isLoggable(Level.WARNING)) {
this.soapContext.getLogger().log(Level.WARNING,
"Specified host name in component isn't valid, consequently "
+ "the HTTP server is not started");
}
if (this.soapContext.getSoapServerConfig().isValidHostName()
&& this.soapContext.getLogger().isLoggable(Level.INFO)) {
this.soapContext.getLogger().log(Level.INFO,
"Component Information is available at " + this.soapContext.getSoapServerConfig().getBaseURL());
}
}
/**
* Stop the embedded HTTP server that handles incoming requests.
*
* Note: it will also stop the ListenerManager
*/
public void stop() throws AxisFault {
this.httpServer.stop();
}
/**
* Shutdown the embedded HTTP(S)/SOAP server that handles incoming requests.
*
* Note: it will also shutdown the ListenerManager
*
*/
public void shutdown() throws AxisFault {
this.httpServer.shutdown();
}
public AxisServletServer getHttpServer() {
return this.httpServer;
}
}