axis spring 集成(2)

2008-02-23 09:35:33来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折

一.SpringAxisConstans

package com.skysuite.axis.spring;

import org.apache.axis.deployment.wsdd.WSDDConstants;

import Javax.XML.namespace.QName;

public class SpringAxisConstans {


public static final String PROVIDER_SPRINGRPC = "SPRINGRPC";
public static final String PROVIDER_SPRINGMSG = "SPRINGMSG";

public static final QName QNAME_JAVARPC_SPRINGPROVIDER = new QName(WSDDConstants.URI_WSDD_JAVA, PROVIDER_SPRINGRPC);
public static final QName QNAME_JAVAMSG_SPRINGPROVIDER = new QName(WSDDConstants.URI_WSDD_JAVA, PROVIDER_SPRINGMSG);


}

2.AxisServlet

package com.skysuite.axis.spring;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;

import org.apache.axis.transport.http.AxisServlet;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springFramework.beans.BeanUtils;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContextException;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.util.StringUtils;
import org.springframework.Web.context.ConfigurableWebApplicationContext;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import org.springframework.web.context.support.XmlWebApplicationContext;


public class SpringAxisServlet extends AxisServlet {

private static final Log LOG = LogFactory.getLog(SpringAxisServlet.class);

/**
* Suffix for WebApplicationContext namespaces. If a SpringAxisServlet is
* given the name "axis" in a context, the namespace used by this instance will
* resolve to "axis-servlet".
*/
public static final String DEFAULT_NAMESPACE_SUFFIX = "-servlet";

/**
* Default context class for SpringAxisServlet.
*
* @see org.springframework.web.context.support.XmlWebApplicationContext
*/
public static final Class DEFAULT_CONTEXT_CLASS = XmlWebApplicationContext.class;

/** Name of the ServletContext attribute for the WebApplicationContext */
public static final String SERVLET_CONTEXT_ATTRIBUTE = SpringAxisServlet.class.getName()
".CONTEXT";

/** Custom WebApplicationContext class */
private Class contextClass = DEFAULT_CONTEXT_CLASS;

/** Namespace for this servlet */
private String namespace;

/** Explicit context config location */
private String contextConfigLocation;

/** WebApplicationContext for the SpringAxisServlet */
private WebApplicationContext webApplicationContext;

/**
* Initialise the WebApplicationContext of the SpringAxisServlet.
*
* @see org.apache.axis.transport.http.AxisServlet#init()
*/
public void init() throws ServletException {
super.init();

long startTime = System.currentTimeMillis();
if (LOG.isDebugEnabled()) {
LOG.debug("Servlet '" getServletName() "' init");
}

setContextClassName(getServletConfig().getInitParameter("contextClassName"));
setContextConfigLocation(getServletConfig().getInitParameter("contextConfigLocation"));
setNamespace(getServletConfig().getInitParameter("namespace"));

try {
this.webApplicationContext = initWebApplicationContext();
} catch (BeansException ex) {
LOG.error("Context initialization failed", ex);
throw ex;
}

if (LOG.isDebugEnabled()) {
long elapsedTime = System.currentTimeMillis() - startTime;
LOG.debug("Servlet '"
this.getServletName()
"' init completed in "
elapsedTime
" ms");
}
}

/**
* Close the WebApplicationContext of the SpringAxisServlet.
*
* @see org.apache.axis.transport.http.AxisServletBase#destroy()
*/
public void destroy() {
super.destroy();

log("Closing WebApplicationContext of servlet '" getServletName() "'");
if (this.webApplicationContext instanceof ConfigurableApplicationContext) {
((ConfigurableApplicationContext) this.webApplicationContext).close();
}
}

/**
* Set a custom context class by name. This class must be of type WebApplicationContext,

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:东软SMIAS Java API移动短信接入JUnit TestCase

下一篇:JSP与JavaMail (六)