If you do not have to call the custom initialization before the webservice constructor , this could help:
- call custom environment initialization in a ServletContextListener
- Get servletContext from injected webServiceContext like:
@WebService
public class HelloServletImpl implements HelloServlet {
@Resource
public WebServiceContext wsContext;
public HelloServletImpl() {
System.out.println("HelloServlet is instantiated!");
}
@Override
public String newOperation(final String in) {
// TODO Auto-generated method stub
ServletContext servletContext =
(ServletContext) wsContext.getMessageContext().get(MessageContext.SERVLET_CONTEXT);
System.out.println(servletContext.getAttribute("TEST"));
return (String)servletContext.getAttribute("TEST");
}
}