You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wsrf-commits@ws.apache.org by ip...@apache.org on 2005/07/13 23:48:16 UTC

svn commit: r216272 - in /webservices/wsrf/trunk/src: java/org/apache/ws/resource/handler/ java/org/apache/ws/resource/handler/axis/ java/org/apache/ws/resource/i18n/ java/org/apache/ws/resource/webapp/ webapp/WEB-INF/

Author: ips
Date: Wed Jul 13 14:48:15 2005
New Revision: 216272

URL: http://svn.apache.org/viewcvs?rev=216272&view=rev
Log:
use servlet context listener callback method instead of servlet init method to init WSRF JNDI context

Added:
    webservices/wsrf/trunk/src/java/org/apache/ws/resource/webapp/
    webservices/wsrf/trunk/src/java/org/apache/ws/resource/webapp/WsrfServletContextListener.java
Removed:
    webservices/wsrf/trunk/src/java/org/apache/ws/resource/handler/axis/WsrfAxisServlet.java
Modified:
    webservices/wsrf/trunk/src/java/org/apache/ws/resource/handler/ResourceHandler.java
    webservices/wsrf/trunk/src/java/org/apache/ws/resource/i18n/Keys.java
    webservices/wsrf/trunk/src/webapp/WEB-INF/web.xml

Modified: webservices/wsrf/trunk/src/java/org/apache/ws/resource/handler/ResourceHandler.java
URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/java/org/apache/ws/resource/handler/ResourceHandler.java?rev=216272&r1=216271&r2=216272&view=diff
==============================================================================
--- webservices/wsrf/trunk/src/java/org/apache/ws/resource/handler/ResourceHandler.java (original)
+++ webservices/wsrf/trunk/src/java/org/apache/ws/resource/handler/ResourceHandler.java Wed Jul 13 14:48:15 2005
@@ -30,7 +30,6 @@
 import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.XmlOptions;
 import org.apache.xmlbeans.impl.values.XmlAnyTypeImpl;
-import org.apache.axis.soap.SOAP11Constants;
 
 import javax.xml.namespace.QName;
 import javax.xml.rpc.JAXRPCException;

Modified: webservices/wsrf/trunk/src/java/org/apache/ws/resource/i18n/Keys.java
URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/java/org/apache/ws/resource/i18n/Keys.java?rev=216272&r1=216271&r2=216272&view=diff
==============================================================================
--- webservices/wsrf/trunk/src/java/org/apache/ws/resource/i18n/Keys.java (original)
+++ webservices/wsrf/trunk/src/java/org/apache/ws/resource/i18n/Keys.java Wed Jul 13 14:48:15 2005
@@ -145,9 +145,9 @@
     String RECEIVED_WSDL_REQUEST = "RECEIVED_WSDL_REQUEST";
 
     /**
-     * @msg Initializing the {0} and the JNDI context from {1}
+     * @msg Populating WSRF JNDI context - reading JNDI configuration off classpath from {0}...
      */
-    String INIT_SERVLET_AND_JNDI = "INIT_SERVLET_AND_JNDI";
+    String POPULATING_JNDI = "POPULATING_JNDI";
 
     /**
      * @msg {0} is initialized.

Added: webservices/wsrf/trunk/src/java/org/apache/ws/resource/webapp/WsrfServletContextListener.java
URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/java/org/apache/ws/resource/webapp/WsrfServletContextListener.java?rev=216272&view=auto
==============================================================================
--- webservices/wsrf/trunk/src/java/org/apache/ws/resource/webapp/WsrfServletContextListener.java (added)
+++ webservices/wsrf/trunk/src/java/org/apache/ws/resource/webapp/WsrfServletContextListener.java Wed Jul 13 14:48:15 2005
@@ -0,0 +1,68 @@
+/*=============================================================================*
+ *  Copyright 2005 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+package org.apache.ws.resource.webapp;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.resource.i18n.Keys;
+import org.apache.ws.resource.i18n.MessagesImpl;
+import org.apache.ws.util.i18n.Messages;
+import org.apache.ws.util.jndi.XmlBeanJndiUtils;
+
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+import java.io.InputStream;
+
+/**
+ * A servlet context listener for the WSRF webapp that provides the hook for
+ * initializing the WSRF JNDI context. Note, to configure this listener, add
+ * the following lines to web.xml:
+ *
+ *   <listener>
+ *     <listener-class>org.apache.ws.resource.webapp.WsrfWebAppContextListener</listener-class>
+ *   </listener>
+ *
+ * @author Ian Springer
+ */
+public class WsrfServletContextListener implements ServletContextListener
+{
+
+    private static final Log LOG = LogFactory.getLog( WsrfServletContextListener.class );
+    private static final Messages MSG = MessagesImpl.getInstance();
+
+    public void contextInitialized( ServletContextEvent contextEvent )
+    {
+        String contextName = contextEvent.getServletContext().getServletContextName();
+        LOG.info( "Initializing the " + contextName + " webapp..." );
+        LOG.info( MSG.getMessage( Keys.POPULATING_JNDI, XmlBeanJndiUtils.JNDI_CONFIG_FILENAME ) );
+        try
+        {
+            InputStream jndiConfigStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(
+                                        XmlBeanJndiUtils.JNDI_CONFIG_FILENAME );
+            XmlBeanJndiUtils.initializeFromInputStream( jndiConfigStream );
+        }
+        catch ( Exception e )
+        {
+            throw new RuntimeException( "Fatal error! Failed to initialize WSRF JNDI context.", e );
+        }
+    }
+
+    public void contextDestroyed( ServletContextEvent contextEvent )
+    {
+        // intentionally empty
+    }
+
+}

Modified: webservices/wsrf/trunk/src/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/webapp/WEB-INF/web.xml?rev=216272&r1=216271&r2=216272&view=diff
==============================================================================
--- webservices/wsrf/trunk/src/webapp/WEB-INF/web.xml (original)
+++ webservices/wsrf/trunk/src/webapp/WEB-INF/web.xml Wed Jul 13 14:48:15 2005
@@ -1,26 +1,23 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
+<?xml version="1.0"?>
 
 <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web
 Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
 
 <web-app>
-  <display-name>Apache-Axis</display-name>
+  <display-name>Apache WSRF</display-name>
     
     <listener>
-        <listener-class>org.apache.axis.transport.http.AxisHTTPSessionListener</listener-class>
+      <listener-class>org.apache.ws.resource.webapp.WsrfServletContextListener</listener-class> 
+      <listener-class>org.apache.axis.transport.http.AxisHTTPSessionListener</listener-class>
     </listener>
     
-<!-- Wsrf Servlet -->
   <servlet>
     <servlet-name>AxisServlet</servlet-name>
     <display-name>Apache-Axis Servlet</display-name>
-    <servlet-class>
-        org.apache.ws.resource.handler.axis.WsrfAxisServlet
-    </servlet-class>
-    <load-on-startup>100</load-on-startup>
+    <servlet-class>org.apache.axis.transport.http.AxisServlet</servlet-class>    
   </servlet>
   
- <!-- uncomment this if you want the admin servlet -->
+ <!-- uncomment this if you want the Axis admin servlet -->
  <!--
   <servlet>
     <servlet-name>AdminServlet</servlet-name>
@@ -36,10 +33,8 @@
     <servlet-name>AxisServlet</servlet-name>
     <url-pattern>/services/*</url-pattern>
   </servlet-mapping>
-
   
-
- <!-- uncomment this if you want the admin servlet -->
+ <!-- uncomment this if you want the Axis admin servlet -->
  <!--
   <servlet-mapping>
     <servlet-name>AdminServlet</servlet-name>