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 sc...@apache.org on 2005/10/04 17:08:54 UTC

svn commit: r294792 - in /webservices/wsrf/trunk/src/java/org/apache/ws/resource: handler/websphere/WASEjbResourceContext.java impl/ResourceContextImpl.java

Author: scamp
Date: Tue Oct  4 08:08:49 2005
New Revision: 294792

URL: http://svn.apache.org/viewcvs?rev=294792&view=rev
Log:
Added the new ResourceContextImpl

Added:
    webservices/wsrf/trunk/src/java/org/apache/ws/resource/handler/websphere/WASEjbResourceContext.java
Modified:
    webservices/wsrf/trunk/src/java/org/apache/ws/resource/impl/ResourceContextImpl.java

Added: webservices/wsrf/trunk/src/java/org/apache/ws/resource/handler/websphere/WASEjbResourceContext.java
URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/java/org/apache/ws/resource/handler/websphere/WASEjbResourceContext.java?rev=294792&view=auto
==============================================================================
--- webservices/wsrf/trunk/src/java/org/apache/ws/resource/handler/websphere/WASEjbResourceContext.java (added)
+++ webservices/wsrf/trunk/src/java/org/apache/ws/resource/handler/websphere/WASEjbResourceContext.java Tue Oct  4 08:08:49 2005
@@ -0,0 +1,65 @@
+package org.apache.ws.resource.handler.websphere;
+
+import org.apache.ws.resource.Resource;
+import org.apache.ws.resource.ResourceContext;
+import org.apache.ws.resource.ResourceException;
+import org.apache.ws.resource.WsrfRuntime;
+import org.apache.ws.resource.impl.ResourceContextImpl;
+import org.apache.ws.util.platform.JaxRpcPlatform;
+
+import javax.xml.soap.SOAPMessage;
+import java.net.URI;
+import java.net.URL;
+
+
+/**
+ * An implementation of ResourceContext for use when the endpoint is interacted with as an EJB.
+ *
+ * @author Sal Campana
+ */
+public class WASEjbResourceContext extends ResourceContextImpl
+{
+    private static final String UNSUPPORTED_INVOCATION = "This method is unsupported when invoked in the EJB context.";
+    private Object m_resourceID;
+
+    public WASEjbResourceContext(String serviceName, Object resourceID) throws Exception
+    {
+        m_resourceID = resourceID;
+        setServiceName(serviceName);
+        setServiceURL(new URL(JaxRpcPlatform.getJaxRpcPlatform().getEndpointUrl( WsrfRuntime.getRuntime().getBaseWebappUrl().toString(),serviceName )));
+        lookupHome();
+    }
+
+    /**
+     * @see ResourceContext#getRequestAction()
+     */
+    public String getRequestAction()
+    {
+        throw new UnsupportedOperationException(UNSUPPORTED_INVOCATION);
+    }
+
+    /**
+     * @see ResourceContext#getResource()
+     */
+    public Resource getResource() throws ResourceException
+    {
+        return getResourceHome().find(m_resourceID);
+    }
+
+
+    /**
+     * @see ResourceContext#setResponseAction(URI)
+     */
+    public void setResponseAction(URI action)
+    {
+        throw new UnsupportedOperationException(UNSUPPORTED_INVOCATION);
+    }
+
+    /**
+     * @see ResourceContext#getSOAPMessage()
+     */
+    public SOAPMessage getSOAPMessage()
+    {
+        throw new UnsupportedOperationException(UNSUPPORTED_INVOCATION);
+    }
+}

Modified: webservices/wsrf/trunk/src/java/org/apache/ws/resource/impl/ResourceContextImpl.java
URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/java/org/apache/ws/resource/impl/ResourceContextImpl.java?rev=294792&r1=294791&r2=294792&view=diff
==============================================================================
--- webservices/wsrf/trunk/src/java/org/apache/ws/resource/impl/ResourceContextImpl.java (original)
+++ webservices/wsrf/trunk/src/java/org/apache/ws/resource/impl/ResourceContextImpl.java Tue Oct  4 08:08:49 2005
@@ -64,6 +64,10 @@
     private String m_action;
     private SOAPMessageContext m_msgContext;
 
+    protected ResourceContextImpl() throws Exception
+    {
+    }
+
     /**
      * Creates a new {@link ResourceContextImpl} object.
      *
@@ -80,13 +84,23 @@
         m_msgContext = soapMsgContext;
         m_msg = soapMsgContext.getMessage();
         extractFields(soapMsgContext);
+        lookupHome();
+    }
+
+    /**
+     * Look up the ResourceHome by first calling {@see ResourceContextImpl#getResourceHomeLocation}
+     * @throws Exception
+     */
+    protected void lookupHome()
+            throws Exception
+    {
         try
         {
             m_home = (ResourceHome) new InitialContext().lookup(getResourceHomeLocation());
         }
         catch (NamingException ne)
         {
-            ne.printStackTrace();
+            LOG.debug("A NamingException Occurred.",ne);
             throw new ResourceContextException(ne);
         }
 
@@ -224,6 +238,11 @@
         return m_serviceURL;
     }
 
+    protected void setServiceURL(URL serviceURL)
+    {
+        m_serviceURL = serviceURL;
+    }
+
     /**
      * DOCUMENT_ME
      *
@@ -274,7 +293,7 @@
      */
     protected String getServiceName(MessageContext msgContext)
     {
-        URL serviceURL = (m_serviceURL != null) ? m_serviceURL : getServiceURL((SOAPMessageContext)msgContext);    
+        URL serviceURL = (m_serviceURL != null) ? m_serviceURL : getServiceURL((SOAPMessageContext)msgContext);
         //extract just the service name from the url
         String serviceName = serviceURL.toString();
         serviceName = serviceName.substring(serviceName.lastIndexOf("/") + 1);