You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pubscribe-dev@ws.apache.org by sc...@apache.org on 2005/03/31 20:55:59 UTC

svn commit: r159622 - in incubator/hermes/trunk/src/java/org/apache/ws: notification/base/impl/ notification/base/v1_2/porttype/impl/ notification/topics/impl/ util/test/

Author: scamp
Date: Thu Mar 31 10:55:57 2005
New Revision: 159622

URL: http://svn.apache.org/viewcvs?view=rev&rev=159622
Log: (empty)


Added:
    incubator/hermes/trunk/src/java/org/apache/ws/util/test/
Modified:
    incubator/hermes/trunk/src/java/org/apache/ws/notification/base/impl/AbstractSubscription.java
    incubator/hermes/trunk/src/java/org/apache/ws/notification/base/v1_2/porttype/impl/NotificationProducerPortTypeImpl.java
    incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/ConcreteTopicExpressionEvaluator.java
    incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/SimpleSubscriptionTopicListener.java
    incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/SimpleTopicExpressionEvaluator.java
    incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/TopicSpaceSetImpl.java

Modified: incubator/hermes/trunk/src/java/org/apache/ws/notification/base/impl/AbstractSubscription.java
URL: http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/notification/base/impl/AbstractSubscription.java?view=diff&r1=159621&r2=159622
==============================================================================
--- incubator/hermes/trunk/src/java/org/apache/ws/notification/base/impl/AbstractSubscription.java (original)
+++ incubator/hermes/trunk/src/java/org/apache/ws/notification/base/impl/AbstractSubscription.java Thu Mar 31 10:55:57 2005
@@ -24,8 +24,8 @@
 import org.apache.ws.notification.topics.TopicListener;
 import org.apache.ws.notification.topics.TopicListenerList;
 import org.apache.ws.notification.topics.TopicSpaceSet;
-import org.apache.ws.notification.topics.TopicSpace;
 import org.apache.ws.notification.topics.impl.SimpleSubscriptionTopicListener;
+import org.apache.ws.notification.topics.topicexpression.impl.TopicExpressionException;
 import org.apache.ws.pubsub.Filter;
 import org.apache.ws.pubsub.NotificationConsumer;
 import org.apache.ws.pubsub.NotificationProducer;
@@ -44,6 +44,7 @@
 
 import javax.naming.Context;
 import javax.naming.InitialContext;
+import javax.xml.rpc.JAXRPCException;
 import java.net.URI;
 import java.util.ArrayList;
 import java.util.Calendar;
@@ -248,6 +249,8 @@
         {                      //todo fix!
             //TopicSpace topicSpace = topicSpaceSet.getTopicSpace();
             //topics = topicSpace.getTopics( m_topicExpression );
+            topics = evaluateTopicExpression();
+
         }
         catch ( Exception e )
         {
@@ -281,6 +284,23 @@
             resourceTerminationListener.terminationOccurred(rte);
         }
 
+    }
+
+    private Collection evaluateTopicExpression() throws Exception
+    {
+        NotificationProducerResource resource = (NotificationProducerResource) getResource();
+        TopicSpaceSet topicSpaceSet = resource.getTopicSpaceSet();
+
+        Collection collection = null;
+        try
+        {
+            collection = topicSpaceSet.evaluateExpression(m_topicExpression);
+        }
+        catch (TopicExpressionException e)
+        {
+            throw new JAXRPCException("An exception occurred during subscription. ", e);
+        }
+        return collection;
     }
 
     private boolean removeListener( Collection topics )

Modified: incubator/hermes/trunk/src/java/org/apache/ws/notification/base/v1_2/porttype/impl/NotificationProducerPortTypeImpl.java
URL: http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/notification/base/v1_2/porttype/impl/NotificationProducerPortTypeImpl.java?view=diff&r1=159621&r2=159622
==============================================================================
--- incubator/hermes/trunk/src/java/org/apache/ws/notification/base/v1_2/porttype/impl/NotificationProducerPortTypeImpl.java (original)
+++ incubator/hermes/trunk/src/java/org/apache/ws/notification/base/v1_2/porttype/impl/NotificationProducerPortTypeImpl.java Thu Mar 31 10:55:57 2005
@@ -112,7 +112,7 @@
         {
             TopicExpression topicExpr = new XmlBeansTopicExpression( request.getTopicExpression() );
             //this prop has default values in schema..it "should" get a value either way if not explicitly set in request
-            boolean useNotify = request.getUseNotify();
+            boolean useNotify = request.isSetUseNotify() ? request.getUseNotify() : true;
             EndpointReference producerEPR = buildEPR( getResourceContext() );
 
             Context initialContext = new InitialContext(  );

Modified: incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/ConcreteTopicExpressionEvaluator.java
URL: http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/ConcreteTopicExpressionEvaluator.java?view=diff&r1=159621&r2=159622
==============================================================================
--- incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/ConcreteTopicExpressionEvaluator.java (original)
+++ incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/ConcreteTopicExpressionEvaluator.java Thu Mar 31 10:55:57 2005
@@ -56,7 +56,7 @@
         List topicPath = getConcreteTopicPath( expr );
         LOG.debug("Looking for topic with namespace: " +
                      topicSpace.getNamespaceURI() + " and local part " +
-                     topicPath);
+                     topicPath.get(0));
         Collection result = new ArrayList();
         Topic topic = topicSpace.getTopic(topicPath);
         if(topic != null)

Modified: incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/SimpleSubscriptionTopicListener.java
URL: http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/SimpleSubscriptionTopicListener.java?view=diff&r1=159621&r2=159622
==============================================================================
--- incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/SimpleSubscriptionTopicListener.java (original)
+++ incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/SimpleSubscriptionTopicListener.java Thu Mar 31 10:55:57 2005
@@ -25,14 +25,11 @@
 import org.apache.ws.notification.base.v1_2.BaseNotification1_2Constants;
 import org.apache.ws.notification.topics.Topic;
 import org.apache.ws.notification.topics.TopicExpression;
-import org.apache.ws.notification.topics.TopicExpressionEngine;
-import org.apache.ws.notification.topics.TopicExpressionEvaluator;
 import org.apache.ws.notification.topics.TopicListener;
-import org.apache.ws.notification.topics.topicexpression.impl.TopicExpressionException;
 import org.apache.ws.pubsub.NotificationConsumer;
 import org.apache.ws.pubsub.emitter.EmitterTask;
-import org.apache.ws.util.XmlBeanUtils;
 import org.apache.ws.util.JaxpUtils;
+import org.apache.ws.util.XmlBeanUtils;
 import org.apache.ws.util.thread.NamedThread;
 import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlObject;
@@ -41,12 +38,11 @@
 import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.NotifyDocument;
 import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.TopicExpressionType;
 import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.DOMException;
+import org.xml.sax.SAXException;
 import org.xmlsoap.schemas.ws.x2003.x03.addressing.EndpointReferenceType;
 import org.xmlsoap.schemas.ws.x2003.x03.addressing.ReferencePropertiesType;
-import org.xml.sax.SAXException;
 
+import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.soap.MessageFactory;
 import javax.xml.soap.SOAPBody;
 import javax.xml.soap.SOAPElement;
@@ -55,13 +51,10 @@
 import javax.xml.soap.SOAPHeader;
 import javax.xml.soap.SOAPHeaderElement;
 import javax.xml.soap.SOAPMessage;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import java.io.Serializable;
 import java.io.IOException;
+import java.io.Serializable;
 import java.net.URI;
 import java.net.URL;
-import java.util.List;
 
 /**
  * Topic listener implementation that will trigger notifications when a topic
@@ -166,28 +159,31 @@
     * Send a notification
     *
     * @param subscription The subscription for which to send the notification
-    * @param msg     The new value of the topic
+    * @param rawMsg     The new value of the topic
     * @throws Exception
     */
    public void notify( Subscription subscription,
-                       Object       msg )
+                       Object       rawMsg )
    throws Exception
    {
+       XmlObject message = null;
       synchronized ( subscription )
       {
          if ( !subscription.isPaused(  ) )
          {
             System.out.println( "Notification received for subscription with Id " + subscription.getID(  )
-                                + "; value: " + msg );
-
-            EndpointReference             epr                           =
+                                + "; value: " + rawMsg );
+              EndpointReference             epr                           =
                subscription.getNotificationConsumer(  ).getEPR(  );
+             if(subscription.getUseNotify())
+             {
+
             NotifyDocument                notifyDoc                     = NotifyDocument.Factory.newInstance(  );
             NotifyDocument.Notify         notify                        = notifyDoc.addNewNotify(  );
             NotificationMessageHolderType notificationMessageHolderType = notify.addNewNotificationMessage(  );
 
-            //assumes xmlobject for msg...this needs to change
-            notificationMessageHolderType.setMessage( (XmlObject) msg );
+            //assumes xmlobject for rawMsg...this needs to change
+            notificationMessageHolderType.setMessage( (XmlObject) rawMsg );
 
             //set the producer ref
             notificationMessageHolderType.setProducerReference( (EndpointReferenceType) ( (XmlObjectWrapper) subscription.getNotificationProducer(  )
@@ -198,7 +194,13 @@
             TopicExpressionType tp =
                (TopicExpressionType) ( (XmlObjectWrapper) topicExpressionIntf ).getXmlObject(  );
             notificationMessageHolderType.setTopic( tp );
-            Document document = toDocument(subscription, notifyDoc);
+                 message = notifyDoc;
+            }
+            else
+             {
+                 message = XmlBeanUtils.toXmlObject(rawMsg);
+             }
+            Document document = toDocument(message);
 
              SOAPMessage soapMessage =
                   buildSOAPMessage( document, (EndpointReferenceType) ( (XmlObjectWrapper) epr ).getXmlObject(  ) );
@@ -209,19 +211,19 @@
       }
    }
 
-    private Document toDocument(Subscription subscription, NotifyDocument notifyDoc)
+    private Document toDocument(XmlObject notifyDoc)
             throws ParserConfigurationException, SAXException, IOException
     {
         Document document = null;
         //notify is now populated
-        if (subscription.getUseNotify(  ))
+
+        if (XmlBeanUtils.isDocument(notifyDoc))
         {
             document = (Document) notifyDoc.newDomNode();
         }
         else
-        {
-            NotificationMessageHolderType notificationMessageArray = notifyDoc.getNotify().getNotificationMessageArray(0);
-            String s = notificationMessageArray.xmlText(new XmlOptions().setSaveOuter());
+        {           
+            String s = notifyDoc.xmlText(new XmlOptions().setSaveOuter());
             document = JaxpUtils.toDocument( s );
         }
         return document;

Modified: incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/SimpleTopicExpressionEvaluator.java
URL: http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/SimpleTopicExpressionEvaluator.java?view=diff&r1=159621&r2=159622
==============================================================================
--- incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/SimpleTopicExpressionEvaluator.java (original)
+++ incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/SimpleTopicExpressionEvaluator.java Thu Mar 31 10:55:57 2005
@@ -54,7 +54,7 @@
         List topicPath = getConcreteTopicPath( expr );
         LOG.debug("Looking for topic with namespace: " +
                      topicSpace.getNamespaceURI() + " and local part " +
-                     ((Topic)topicPath.get( 0 )).getName() );
+                     topicPath.get( 0 ) );
         Collection result = new ArrayList();
         Topic topic = topicSpace.getTopic(topicPath);
         if(topic != null)

Modified: incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/TopicSpaceSetImpl.java
URL: http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/TopicSpaceSetImpl.java?view=diff&r1=159621&r2=159622
==============================================================================
--- incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/TopicSpaceSetImpl.java (original)
+++ incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/TopicSpaceSetImpl.java Thu Mar 31 10:55:57 2005
@@ -24,6 +24,15 @@
 {
     Map m_topicSpaces = new Hashtable();
 
+    /**
+     * Adds the TopicSpace to the TopicSpaceSet.
+     *
+     * Note. If the TopiSpace already exists, this method will add all the known Topics
+     * to the passed-in TopicSpace and set it as the current TopicSpace in the TopicSpaceSet.
+     * This will ensure there is only 1 TopicSpace in the set and it is complete...
+     *
+     * @param topicSpace
+     */
     public void addTopicSpace(TopicSpace topicSpace)
     {
         String namespaceURI = topicSpace.getNamespaceURI();
@@ -38,10 +47,9 @@
                 topicSpace.addTopic(topic);
             }
         }
-        else
-        {
-            m_topicSpaces.put(namespaceURI, topicSpace);
-        }
+
+        m_topicSpaces.put(namespaceURI, topicSpace);
+
     }
 
     public void removeTopicSpace(String namespaceURI)
@@ -71,7 +79,7 @@
         {
             throw new JAXRPCException("Unable to determine namespace prefix for: " + nodeValue);
         }
-        
+
         XmlCursor xmlCursor = xmlObjectTopicExpr.newCursor();
         String namespaceForPrefix = xmlCursor.namespaceForPrefix(prefix);
         xmlCursor.dispose();



---------------------------------------------------------------------
To unsubscribe, e-mail: hermes-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: hermes-dev-help@ws.apache.org