You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pubscribe-commits@ws.apache.org by ip...@apache.org on 2005/07/22 01:37:40 UTC

svn commit: r220209 - in /webservices/pubscribe/trunk/src: examples/pubsubclient/ java/org/apache/ws/eventing/ java/org/apache/ws/eventing/pubsub/ java/org/apache/ws/notification/base/v2004_06/impl/ java/org/apache/ws/notification/pubsub/ test/org/apac...

Author: ips
Date: Thu Jul 21 16:37:38 2005
New Revision: 220209

URL: http://svn.apache.org/viewcvs?rev=220209&view=rev
Log:
finished necessary updates due to refactoring of resource home

Removed:
    webservices/pubscribe/trunk/src/test/org/apache/ws/notification/base/impl/AbstractUnitExampleHome.java
Modified:
    webservices/pubscribe/trunk/src/examples/pubsubclient/JettyAxisServer.java
    webservices/pubscribe/trunk/src/java/org/apache/ws/eventing/SubscriptionHome.java
    webservices/pubscribe/trunk/src/java/org/apache/ws/eventing/pubsub/SubscriptionHome.java
    webservices/pubscribe/trunk/src/java/org/apache/ws/notification/base/v2004_06/impl/SubscriptionHome.java
    webservices/pubscribe/trunk/src/java/org/apache/ws/notification/pubsub/SubscriptionHome.java
    webservices/pubscribe/trunk/src/test/org/apache/ws/notification/base/impl/UnitExampleHome.java
    webservices/pubscribe/trunk/src/test/org/apache/ws/notification/base/impl/UnitResourceContext.java
    webservices/pubscribe/trunk/src/test/org/apache/ws/notification/base/v2004_06/porttype/impl/NotificationProducerPortTypeImplTest.java

Modified: webservices/pubscribe/trunk/src/examples/pubsubclient/JettyAxisServer.java
URL: http://svn.apache.org/viewcvs/webservices/pubscribe/trunk/src/examples/pubsubclient/JettyAxisServer.java?rev=220209&r1=220208&r2=220209&view=diff
==============================================================================
--- webservices/pubscribe/trunk/src/examples/pubsubclient/JettyAxisServer.java (original)
+++ webservices/pubscribe/trunk/src/examples/pubsubclient/JettyAxisServer.java Thu Jul 21 16:37:38 2005
@@ -16,7 +16,6 @@
 
 import org.apache.axis.components.logger.LogFactory;
 import org.apache.axis.utils.Messages;
-import org.apache.axis.utils.Options;
 import org.apache.commons.logging.Log;
 import org.mortbay.http.HttpContext;
 import org.mortbay.http.HttpServer;
@@ -24,11 +23,10 @@
 import org.mortbay.http.handler.ResourceHandler;
 import org.mortbay.jetty.servlet.ServletHandler;
 
-import java.net.MalformedURLException;
-
-public class JettyAxisServer {
+public class JettyAxisServer
+{
     public static Log log =
-            LogFactory.getLog(JettyAxisServer.class.getName());
+            LogFactory.getLog( JettyAxisServer.class.getName() );
 
     /**
      * Jetty HTTP Server *
@@ -45,25 +43,26 @@
      */
     HttpContext context = new HttpContext();
 
-    public JettyAxisServer() {
-        // Create a context 
-        context.setContextPath("/axis/*");
-        server.addContext(context);
-      
+    public JettyAxisServer()
+    {
+        // Create a context
+        context.setContextPath( "/axis/*" );
+        server.addContext( context );
+
         // Create a servlet container
         ServletHandler servlets = new ServletHandler();
-        context.addHandler(servlets);
+        context.addHandler( servlets );
 
         // Map a servlet onto the container
-        servlets.addServlet("AdminServlet", "/servlet/AdminServlet",
-                "org.apache.axis.transport.http.AdminServlet");
-        servlets.addServlet("AxisServlet", "/servlet/AxisServlet",
-                "org.apache.ws.resource.handler.axis.WsrfAxisServlet");
-        servlets.addServlet("AxisServlet", "/services/*",
-                "org.apache.ws.resource.handler.axis.WsrfAxisServlet");
+        servlets.addServlet( "AdminServlet", "/servlet/AdminServlet",
+                "org.apache.axis.transport.http.AdminServlet" );
+        servlets.addServlet( "AxisServlet", "/servlet/AxisServlet",
+                "org.apache.ws.resource.handler.axis.WsrfAxisServlet" );
+        servlets.addServlet( "AxisServlet", "/services/*",
+                "org.apache.ws.resource.handler.axis.WsrfAxisServlet" );
         //servlets.addServlet("AxisServlet", "*.jws",
         //        "org.apache.axis.transport.http.AxisServlet");
-        context.addHandler(new ResourceHandler());
+        context.addHandler( new ResourceHandler() );
     }
 
     /**
@@ -71,9 +70,10 @@
      *
      * @param port
      */
-    public void setPort(int port) {
-        listener.setPort(port);
-        server.addListener(listener);
+    public void setPort( int port )
+    {
+        listener.setPort( port );
+        server.addListener( listener );
     }
 
     /**
@@ -81,8 +81,9 @@
      *
      * @param dir
      */
-    public void setResourceBase(String dir) {
-        context.setResourceBase(dir);
+    public void setResourceBase( String dir )
+    {
+        context.setResourceBase( dir );
     }
 
     /**
@@ -90,11 +91,11 @@
      *
      * @throws Exception
      */
-    public void start() throws Exception {
+    public void start() throws Exception
+    {
         server.start();
-        log.info(
-                Messages.getMessage("start00", "JettyAxisServer",
-                        new Integer(listener.getServerSocket().getLocalPort()).toString()));
+        log.info( Messages.getMessage( "start00", "JettyAxisServer",
+                new Integer( listener.getServerSocket().getLocalPort() ).toString() ) );
     }
 
     /*

Modified: webservices/pubscribe/trunk/src/java/org/apache/ws/eventing/SubscriptionHome.java
URL: http://svn.apache.org/viewcvs/webservices/pubscribe/trunk/src/java/org/apache/ws/eventing/SubscriptionHome.java?rev=220209&r1=220208&r2=220209&view=diff
==============================================================================
--- webservices/pubscribe/trunk/src/java/org/apache/ws/eventing/SubscriptionHome.java (original)
+++ webservices/pubscribe/trunk/src/java/org/apache/ws/eventing/SubscriptionHome.java Thu Jul 21 16:37:38 2005
@@ -26,7 +26,6 @@
 import org.apache.ws.pubsub.Filter;
 import org.apache.ws.resource.InvalidResourceKeyException;
 import org.apache.ws.resource.JndiConstants;
-import org.apache.ws.resource.RemoveNotSupportedException;
 import org.apache.ws.resource.ResourceException;
 import org.apache.ws.resource.ResourceUnknownException;
 import org.apache.ws.resource.impl.AbstractResourceHome;
@@ -93,7 +92,7 @@
             Query query = XPQuery.parseQuery((String)s.getFilter().getExpression(),c);
             LOG.info("addSubscription "+s.getID()+" query :"+query);
             yfilter.addQuery(query);
-            add(s.getID(),s);
+            add(s);
             queriesBack.put(s.getID(),query);
             queries[c]=(String)s.getID();
         }catch(Exception e){
@@ -114,8 +113,6 @@
      * Removes a resource.
      *
      * @throws ResourceUnknownException    if no resource exists with the given key
-     * @throws InvalidResourceKeyException if the resource key is invalid.
-     * @throws RemoveNotSupportedException if remove operation is not supported.
      * @throws ResourceException           if any other error occurs.
      */
     public void remove( Object id ) throws ResourceException {
@@ -183,7 +180,7 @@
         return RESOURCE_KEY_NAME;
     }
 
-        /**
+    /**
      * Map containing all FilesystemResource instances - this map <em>must</em> be static for
      * compatibility with certain JNDI providers.
      */

Modified: webservices/pubscribe/trunk/src/java/org/apache/ws/eventing/pubsub/SubscriptionHome.java
URL: http://svn.apache.org/viewcvs/webservices/pubscribe/trunk/src/java/org/apache/ws/eventing/pubsub/SubscriptionHome.java?rev=220209&r1=220208&r2=220209&view=diff
==============================================================================
--- webservices/pubscribe/trunk/src/java/org/apache/ws/eventing/pubsub/SubscriptionHome.java (original)
+++ webservices/pubscribe/trunk/src/java/org/apache/ws/eventing/pubsub/SubscriptionHome.java Thu Jul 21 16:37:38 2005
@@ -19,6 +19,7 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.ws.resource.JndiConstants;
+import org.apache.ws.resource.IllegalResourceTypeException;
 import org.apache.ws.resource.impl.AbstractResourceHome;
 
 import javax.xml.namespace.QName;
@@ -52,13 +53,19 @@
         num++;
         LOG.info("create SubscriptionHome number : "+num);
     }
-    
-    
+
     public Subscription create(){        
-        Subscription s = new Subscription(); 
+        Subscription s = new Subscription();        
         s.setResourceHome(this);
-        LOG.info("before add "+ m_resources.size()+" instance "+this);        
-        add(s.getID(),s);
+        LOG.info("before add "+ m_resources.size()+" instance "+this);
+        try
+        {
+            add(s);
+        }
+        catch ( IllegalResourceTypeException irte )
+        {
+            throw new RuntimeException( irte );
+        }
         LOG.info("after add "+ m_resources.size());        
         return s;
     }

Modified: webservices/pubscribe/trunk/src/java/org/apache/ws/notification/base/v2004_06/impl/SubscriptionHome.java
URL: http://svn.apache.org/viewcvs/webservices/pubscribe/trunk/src/java/org/apache/ws/notification/base/v2004_06/impl/SubscriptionHome.java?rev=220209&r1=220208&r2=220209&view=diff
==============================================================================
--- webservices/pubscribe/trunk/src/java/org/apache/ws/notification/base/v2004_06/impl/SubscriptionHome.java (original)
+++ webservices/pubscribe/trunk/src/java/org/apache/ws/notification/base/v2004_06/impl/SubscriptionHome.java Thu Jul 21 16:37:38 2005
@@ -122,7 +122,7 @@
             EndpointReference subscriptionEPR = getEndpointReference( getSubscriptionAddress( producerReference ),
                     id, nsSet.getAddressingNamespace() );
             subscription.setEndpointReference( subscriptionEPR );
-            add( id, subscription );
+            add( subscription );
             return subscription;
         }
         catch ( Exception e )

Modified: webservices/pubscribe/trunk/src/java/org/apache/ws/notification/pubsub/SubscriptionHome.java
URL: http://svn.apache.org/viewcvs/webservices/pubscribe/trunk/src/java/org/apache/ws/notification/pubsub/SubscriptionHome.java?rev=220209&r1=220208&r2=220209&view=diff
==============================================================================
--- webservices/pubscribe/trunk/src/java/org/apache/ws/notification/pubsub/SubscriptionHome.java (original)
+++ webservices/pubscribe/trunk/src/java/org/apache/ws/notification/pubsub/SubscriptionHome.java Thu Jul 21 16:37:38 2005
@@ -18,6 +18,7 @@
 package org.apache.ws.notification.pubsub;
 
 import org.apache.ws.resource.JndiConstants;
+import org.apache.ws.resource.IllegalResourceTypeException;
 import org.apache.ws.resource.impl.AbstractResourceHome;
 
 import javax.xml.namespace.QName;
@@ -47,7 +48,14 @@
     
     public Subscription create(){
         Subscription s = new Subscription();
-        add(s.getID(),s);
+        try
+        {
+            add(s);
+        }
+        catch ( IllegalResourceTypeException irte )
+        {
+            throw new RuntimeException( irte );
+        }
         return s;
     }
 

Modified: webservices/pubscribe/trunk/src/test/org/apache/ws/notification/base/impl/UnitExampleHome.java
URL: http://svn.apache.org/viewcvs/webservices/pubscribe/trunk/src/test/org/apache/ws/notification/base/impl/UnitExampleHome.java?rev=220209&r1=220208&r2=220209&view=diff
==============================================================================
--- webservices/pubscribe/trunk/src/test/org/apache/ws/notification/base/impl/UnitExampleHome.java (original)
+++ webservices/pubscribe/trunk/src/test/org/apache/ws/notification/base/impl/UnitExampleHome.java Thu Jul 21 16:37:38 2005
@@ -6,34 +6,33 @@
 import org.apache.ws.resource.ResourceContextException;
 import org.apache.ws.resource.ResourceException;
 import org.apache.ws.resource.ResourceUnknownException;
-import org.apache.ws.resource.ResourceKey;
 import org.apache.ws.resource.impl.AbstractResourceHome;
-import org.apache.ws.resource.impl.SimpleTypeResourceKey;
 import org.apache.ws.notification.base.WsnNamespaceVersionHolder;
-import org.apache.ws.notification.base.impl.UnitResource;
 import org.apache.ws.notification.base.v2004_06.impl.WsnNamespaceVersionHolderImpl;
 
 import javax.xml.namespace.QName;
+import java.util.Map;
 
 /**
  * @author Sal Campana
  */
-public class UnitExampleHome extends AbstractUnitExampleHome
+public class UnitExampleHome extends AbstractResourceHome
 {
+
     public static final String SERVICE_NAME = "UnitHome";
     public static final String TARGET_NAMESPACE = "http://unittest";
     public static final QName SERVICE_QNAME = new QName(TARGET_NAMESPACE, SERVICE_NAME);
     public static final String TARGET_NSPREFIX = "unit";
+    public static final String RESOURCE_ID = "123";
     public static final QName PORT_TYPE = new QName(TARGET_NAMESPACE, "UnitTestExamples");
     public static final String SERVICE_PORT_NAME = SERVICE_NAME;
     public static final QName RESOURCE_KEY_NAME = new QName(TARGET_NAMESPACE, "ResourceIdentifier", TARGET_NSPREFIX);
     private Resource m_resource;
-    public static final ResourceKey RESOURCE_KEY = new SimpleTypeResourceKey(RESOURCE_KEY_NAME, "unit_key");
     public WsnNamespaceVersionHolder m_namespaceSet = new WsnNamespaceVersionHolderImpl();
 
     public UnitExampleHome()
     {
-        setResourceKeyName( SimpleTypeResourceKey.class.getName() );
+        setResourceIdentifierReferenceParameterName( RESOURCE_KEY_NAME.toString() );
         setResourceClassName( UnitResource.class.getName() );
         try
         {
@@ -71,14 +70,13 @@
           {
             try
             {
-                UnitResource myresource = new UnitResource(); //this will create the resource IF it is has default constructor
-                myresource.setID("123");
-                m_resource = myresource;
-                myresource.init();
-                //the next line will create an EPR
-                EndpointReference epr = getEndpointReference(resourceContext.getBaseURL() + "/" + getServiceName().getLocalPart(), RESOURCE_KEY, m_namespaceSet.getAddressingNamespace());
-                myresource.setEndpointReference(epr); //make sure to set the EPR on your new instance
-                add(RESOURCE_KEY, myresource);
+                UnitResource myResource = new UnitResource(); //this will create the resource IF it is has default constructor
+                myResource.setID(RESOURCE_ID);
+                m_resource = myResource;
+                myResource.init();
+                EndpointReference epr = getEndpointReference(resourceContext.getBaseURL() + "/" + getServiceName().getLocalPart(), RESOURCE_ID, m_namespaceSet.getAddressingNamespace());
+                myResource.setEndpointReference(epr); //make sure to set the EPR on your new instance
+                add(myResource);
             }
             catch (Exception e)
             {
@@ -87,4 +85,24 @@
           }
         return m_resource;
     }
+
+    /**
+     * Map containing all FilesystemResource instances - this map <em>must</em> be static for
+     * compatibility with certain JNDI providers.
+     */
+    private static Map s_resources;
+
+    /**
+     * Returns a map of all FilesystemResource instances. Used by the {@link org.apache.ws.resource.impl.AbstractResourceHome}
+     * superclass.
+     */
+    protected synchronized final Map getResourceMap()
+    {
+        if ( s_resources == null )
+        {
+            s_resources = AbstractResourceHome.createResourceMap( m_resourceIsPersistent );
+        }
+        return s_resources;
+    }
+
 }

Modified: webservices/pubscribe/trunk/src/test/org/apache/ws/notification/base/impl/UnitResourceContext.java
URL: http://svn.apache.org/viewcvs/webservices/pubscribe/trunk/src/test/org/apache/ws/notification/base/impl/UnitResourceContext.java?rev=220209&r1=220208&r2=220209&view=diff
==============================================================================
--- webservices/pubscribe/trunk/src/test/org/apache/ws/notification/base/impl/UnitResourceContext.java (original)
+++ webservices/pubscribe/trunk/src/test/org/apache/ws/notification/base/impl/UnitResourceContext.java Thu Jul 21 16:37:38 2005
@@ -1,61 +1,35 @@
 package org.apache.ws.notification.base.impl;
 
-import org.apache.ws.resource.ResourceContext;
 import org.apache.ws.resource.Resource;
-import org.apache.ws.resource.ResourceContextException;
+import org.apache.ws.resource.ResourceContext;
 import org.apache.ws.resource.ResourceException;
 import org.apache.ws.resource.ResourceHome;
-import org.apache.ws.resource.ResourceKey;
-import org.apache.ws.resource.InvalidResourceKeyException;
-import org.apache.ws.resource.impl.SimpleTypeResourceKey;
-import org.apache.ws.resource.faults.ResourceKeyHeaderNotFoundFaultException;
-import org.apache.ws.util.NameUtils;
 
-import javax.xml.namespace.QName;
-import javax.xml.soap.SOAPHeaderElement;
-import javax.xml.soap.SOAPMessage;
 import javax.xml.soap.MessageFactory;
 import javax.xml.soap.SOAPException;
-import javax.xml.soap.SOAPHeader;
-import java.util.Iterator;
-import java.net.URL;
+import javax.xml.soap.SOAPMessage;
 import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Iterator;
 
 
 /**
  * @author Sal Campana
  */
-public class UnitResourceContext extends ResourceContext
+public class UnitResourceContext implements ResourceContext
 {
+    
     ResourceHome m_home = new UnitExampleHome();
     private Resource m_resource = null;
-    private SimpleTypeResourceKey m_key = null;
     public static final String ID_KEY = "1212";
     private String m_serviceName = UnitExampleHome.SERVICE_NAME;
-    private static final String TARGET_NSURI = UnitExampleHome.TARGET_NAMESPACE;
     public static final String TARGET_NSPREFIX = UnitExampleHome.TARGET_NSPREFIX;
 
-
-    public synchronized ResourceHome getResourceHome() throws ResourceContextException
+    public synchronized ResourceHome getResourceHome()
     {
         return m_home;
     }
 
-    public ResourceKey getResourceKey( QName keyName, Class keyClass ) throws ResourceContextException, ResourceKeyHeaderNotFoundFaultException
-    {
-        return m_key;
-    }
-
-    public SOAPHeaderElement getResourceKeyHeader() throws ResourceContextException
-    {
-        return (SOAPHeaderElement) m_key.toSOAPElement();
-    }
-
-    public SOAPHeaderElement getResourceKeyHeader( QName keyName ) throws ResourceContextException
-    {
-        return (SOAPHeaderElement) m_key.toSOAPElement();
-    }
-
     public SOAPMessage getSOAPMessage()
     {
         try
@@ -69,31 +43,6 @@
         return null;
     }
 
-    public ResourceKey getResourceKey() throws ResourceContextException
-    {
-        if ( m_key == null )
-        {
-            try
-            {
-                MessageFactory messageFactory = MessageFactory.newInstance();
-                SOAPMessage message = messageFactory.createMessage();
-                SOAPHeader soapHeader = message.getSOAPHeader();
-                SOAPHeaderElement soapHeaderElement = soapHeader.addHeaderElement( NameUtils.toName( new QName( TARGET_NSURI, "ResourceIdentifier", TARGET_NSPREFIX ) ) );
-                soapHeaderElement.addTextNode( ID_KEY );
-                m_key = new SimpleTypeResourceKey( soapHeaderElement );
-            }
-            catch ( SOAPException e )
-            {
-                e.printStackTrace();
-            }
-            catch ( InvalidResourceKeyException e )
-            {
-                e.printStackTrace();
-            }
-        }
-        return m_key;
-    }
-
     public String getServiceName()
     {
         return m_serviceName;
@@ -157,7 +106,7 @@
         return null;
     }
 
-    public Resource getResource() throws ResourceContextException, ResourceException
+    public Resource getResource() throws ResourceException
     {
         return m_resource;
     }

Modified: webservices/pubscribe/trunk/src/test/org/apache/ws/notification/base/v2004_06/porttype/impl/NotificationProducerPortTypeImplTest.java
URL: http://svn.apache.org/viewcvs/webservices/pubscribe/trunk/src/test/org/apache/ws/notification/base/v2004_06/porttype/impl/NotificationProducerPortTypeImplTest.java?rev=220209&r1=220208&r2=220209&view=diff
==============================================================================
--- webservices/pubscribe/trunk/src/test/org/apache/ws/notification/base/v2004_06/porttype/impl/NotificationProducerPortTypeImplTest.java (original)
+++ webservices/pubscribe/trunk/src/test/org/apache/ws/notification/base/v2004_06/porttype/impl/NotificationProducerPortTypeImplTest.java Thu Jul 21 16:37:38 2005
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2004 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.notification.base.v2004_06.porttype.impl;
 
 import junit.framework.Test;
@@ -31,12 +46,13 @@
 import java.util.Calendar;
 
 /**
- * NotificationProducerPortTypeImpl Tester.
+ * Test case for {@link NotificationProducerPortTypeImpl}.
  *
  * @author Sal Campana
  */
 public class NotificationProducerPortTypeImplTest extends TestCase
 {
+
     ResourceContext m_resourceContext;
     private NotificationProducerPortTypeImpl m_portTypeImpl;
     protected static final int NOTIF_LISTENER_TIMEOUT = 20000;
@@ -81,7 +97,7 @@
 
     private void triggerChangeEvent() throws ResourceContextException, ResourceException
     {
-        PropertiesResource resource = (PropertiesResource) m_resourceContext.getResourceHome().find(UnitExampleHome.RESOURCE_KEY);
+        PropertiesResource resource = (PropertiesResource) m_resourceContext.getResourceHome().find(UnitExampleHome.RESOURCE_ID);
         ResourceProperty resourceProperty = resource.getResourcePropertySet().get(NotificationProducerPortType.PROP_QNAME_TOPIC_EXPRESSION_DIALECTS);
         TopicExpressionDialectsDocument topicExpressionDialectsDocument = TopicExpressionDialectsDocument.Factory.newInstance();
         topicExpressionDialectsDocument.setTopicExpressionDialects("foo-dialect");