Hi Ronak,
I'm unaware of anyway to force initialization via
configuration. I do it with a startup servlet that calls the services
constructor using reflection based on parameters passed in as
init-params.
If anyone knows a better way please share, this seems hacky
to me.
- Doug
import java.util.List;
import java.util.Arrays; import java.util.Iterator; import
java.lang.reflect.InvocationTargetException;
import java.io.IOException;
import javax.servlet.Servlet;
import javax.servlet.ServletConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import org.apache.log4j.Logger;
/**
* <p>Title: StartAxisEngine.java</p><br> * <p>Description: Configured to 'load-on-startup' in the axis server's web.xml, * StartAxisEngine calls the constructor for the SOAP service * to initialize the axis engine. An init-param 'serviceName' with * a comma separated list of service names to start is required to * be in the web.xml: * <init-param> * <param-name>serviceName</param-name> * <param-value>your.package.name.YourSoapService, another.package.name.AnotherSoapService</param-value> * </init-param> * note: since this servlet is not meant to answer http requests * only the Servlet interface is used (not HttpServlet) by design. * </p><br> * * $Date: 2005/04/26 17:16:37 $ * $Author: dbell $ * $Revision: 1.6 $ * * */ public class StartAxisEngine implements Servlet { /** ServletConfig servletConfig */ private ServletConfig servletConfig; /** Logger log */ private static Logger log = Logger.getLogger(StartAxisEngine.class); /** * Default Constructor */ public StartAxisEngine() { super(); } /* * (non-Javadoc) * @see javax.servlet.Servlet#init(javax.servlet.ServletConfig) */ public void init(ServletConfig config) throws ServletException { //Set servletConfig this.servletConfig = config; //get the list of service to start for this webapp context List<String> list = Arrays.asList(config.getInitParameter("serviceName").split(",")); //Iterate over the list of service using Reflection to instantiate each service for(Iterator<String> itr = list.iterator(); itr.hasNext();) { String c = itr.next().trim(); try { if (c != null) { Object service = Class.forName(c).getConstructor( (Class[])null).newInstance((Object[])null); } } catch(ClassNotFoundException e) { log.error(e); continue; } catch(NoSuchMethodException e) { log.error(e); continue; } catch(InstantiationException e) { log.error(e); continue; } catch(IllegalAccessException e) { log.error(e); continue; } catch(InvocationTargetException e) { log.error(e); continue; } } } /* * (non-Javadoc) * @see javax.servlet.Servlet#getServletConfig() */ public ServletConfig getServletConfig() { return this.servletConfig; } /* * (non-Javadoc) * @see javax.servlet.Servlet#service(javax.servlet.ServletRequest, javax.servlet.ServletResponse) */ public void service(ServletRequest arg0, ServletResponse arg1) throws ServletException, IOException { } /* * (non-Javadoc) * @see javax.servlet.Servlet#getServletInfo() */ public String getServletInfo() { return this.servletConfig.getServletContext().getServletContextName(); } /* * (non-Javadoc) * @see javax.servlet.Servlet#destroy() */ public void destroy() { } From: Patel, Ronak (US SSA) [mailto:[EMAIL PROTECTED] Sent: Thursday, July 27, 2006 11:56 AM To: axis-user@ws.apache.org Subject: RE: [Axis] Load Web Service on Startup Hello All,
I am interested in finding out how I can force Apache Axis to load and run my Web Service (by calling it’s init() method) when the Web Server starts.
Is there a configuration parameter that I need to set somewhere?
I am interested in finding this out in both Axis2 and Axis1.x.
Any help would be greatly appreciated.
Ronak Patel Software Engineer BAE Systems CNIR 450 Pulaski Road Greenlawn, NY 11740 (631) 262 - 8230
|
- RE: [Axis] Load Web Service on Startup Ted Jones
- RE: [Axis] Load Web Service on Startup Bell, Douglas
- RE: [Axis] Load Web Service on Startup Guo, Jeffrey
- RE: [Axis] Load Web Service on Startup Patel, Ronak \(US SSA\)
- RE: [Axis] Load Web Service on Startup Guo, Jeffrey
- Re: [Axis] Load Web Service on Startup Deepal Jayasinghe
- Re: [Axis] Load Web Service on Startup Davanum Srinivas
- Re: [Axis] Load Web Service on Startu... Deepal Jayasinghe
- RE: [Axis] Load Web Service on Startup Tony Dean
- Re: [Axis] Load Web Service on Startup Davanum Srinivas
- RE: [Axis] Load Web Service on Startup Bell, Douglas