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/05/04 19:04:44 UTC

svn commit: r168145 - in /incubator/hermes/trunk: ./ src/java/org/apache/ws/notification/tool/WsnWsdl2Java.java src/java/org/apache/ws/notification/topics/util/TopicUtils.java src/templates/NotificationProducer-AbstractResource_init.txt

Author: scamp
Date: Wed May  4 10:04:42 2005
New Revision: 168145

URL: http://svn.apache.org/viewcvs?rev=168145&view=rev
Log:
updated to init the NotifProducer Topics

Modified:
    incubator/hermes/trunk/   (props changed)
    incubator/hermes/trunk/src/java/org/apache/ws/notification/tool/WsnWsdl2Java.java
    incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/util/TopicUtils.java
    incubator/hermes/trunk/src/templates/NotificationProducer-AbstractResource_init.txt

Propchange: incubator/hermes/trunk/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Wed May  4 10:04:42 2005
@@ -4,3 +4,4 @@
 junit*.properties
 *.log
 *.iml
+*.bak

Modified: incubator/hermes/trunk/src/java/org/apache/ws/notification/tool/WsnWsdl2Java.java
URL: http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/notification/tool/WsnWsdl2Java.java?rev=168145&r1=168144&r2=168145&view=diff
==============================================================================
--- incubator/hermes/trunk/src/java/org/apache/ws/notification/tool/WsnWsdl2Java.java (original)
+++ incubator/hermes/trunk/src/java/org/apache/ws/notification/tool/WsnWsdl2Java.java Wed May  4 10:04:42 2005
@@ -19,9 +19,11 @@
 import org.apache.ws.notification.tool.v2004_06.NotificationProducerPortType2JavaInfo;
 import org.apache.ws.notification.tool.v2004_06.SubscriptionManagerPortType2JavaInfo;
 import org.apache.ws.notification.base.v2004_6.impl.WsnNamespaceVersionHolderImpl;
+import org.apache.ws.notification.base.v2004_6.porttype.NotificationProducerPortType;
 import org.apache.ws.resource.tool.Wsdl2Java;
 import org.apache.ws.resource.tool.velocity.ServiceProperties;
 import org.apache.ws.resource.ResourceDefinition;
+import org.apache.ws.pubsub.NotificationProducer;
 import org.apache.velocity.VelocityContext;
 
 import java.io.File;
@@ -56,6 +58,11 @@
     {
         ServiceProperties serviceProperties = super.buildServiceProperties(resourceDefinition, file, file1);
         serviceProperties.setNamespaceVersionHolder(WsnNamespaceVersionHolderImpl.class);//make sure to add different ones as new versions comeout
+
+        //tell service props which properties we handle for the user...
+        serviceProperties.addImplementedProperty(NotificationProducerPortType.PROP_QNAME_FIXED_TOPIC_SET);
+        serviceProperties.addImplementedProperty(NotificationProducerPortType.PROP_QNAME_TOPIC);
+        serviceProperties.addImplementedProperty(NotificationProducerPortType.PROP_QNAME_TOPIC_EXPRESSION_DIALECTS);
         return serviceProperties;
     }
 

Modified: incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/util/TopicUtils.java
URL: http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/util/TopicUtils.java?rev=168145&r1=168144&r2=168145&view=diff
==============================================================================
--- incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/util/TopicUtils.java (original)
+++ incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/util/TopicUtils.java Wed May  4 10:04:42 2005
@@ -19,15 +19,25 @@
 import org.apache.ws.notification.topics.ResourcePropertyValueChangeTopic;
 import org.apache.ws.notification.topics.Topic;
 import org.apache.ws.notification.topics.TopicSpace;
+import org.apache.ws.notification.topics.TopicExpressionEngine;
+import org.apache.ws.notification.topics.v2004_06.TopicsConstants;
 import org.apache.ws.notification.topics.impl.ResourcePropertyValueChangeTopicImpl;
 import org.apache.ws.notification.topics.impl.TopicSpaceImpl;
 import org.apache.ws.notification.topics.impl.ResourceTerminationTopicImpl;
+import org.apache.ws.notification.topics.impl.TopicExpressionEngineImpl;
+import org.apache.ws.notification.base.v2004_6.porttype.NotificationProducerPortType;
 import org.apache.ws.resource.properties.ResourceProperty;
 import org.apache.ws.resource.properties.ResourcePropertySet;
 import org.apache.ws.resource.properties.NamespaceVersionHolder;
 import org.apache.ws.resource.Resource;
 import org.apache.ws.resource.lifetime.ResourceTerminationListener;
+import org.apache.ws.util.XmlBeanUtils;
+import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.FixedTopicSetDocument;
+import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.TopicDocument;
+import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.TopicExpressionType;
+import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.TopicExpressionDialectsDocument;
 
+import javax.xml.namespace.QName;
 import java.util.Iterator;
 import java.util.ArrayList;
 import java.util.List;
@@ -120,6 +130,94 @@
             }
         }
         return (Topic[]) topicList.toArray( new Topic[0] );
+    }
+
+    /**
+     * Initializes the Topic, TopicExpressionDialects and FixedTopicSet resource properties
+     * </br>
+     * FixedTopicSet will be set based on the value returned from the {@see TopicSpaceSet#isFixed()} method.
+     * </br>
+     * Topic will have all root topics in the TopicSpaceSet, set to Simple dialect AND all child topics set ot
+     * Concrete dialect.
+     * </br>
+     *
+     * TopicExpressionDialects will be set to the engine's known Topic Dialects acquired from the TopicExpressionEngine
+     *
+     * @param topicSpaceSet
+     * @param propSet
+     */
+    public static void initNotificationProducerProperties(TopicSpaceSet topicSpaceSet, ResourcePropertySet propSet)
+    {
+        //setup the FixedTopicSet property
+        ResourceProperty resourceProperty = propSet.get(NotificationProducerPortType.PROP_QNAME_FIXED_TOPIC_SET);
+        FixedTopicSetDocument fixedTopicSetDocument = FixedTopicSetDocument.Factory.newInstance();
+        fixedTopicSetDocument.setFixedTopicSet(topicSpaceSet.isFixed());
+        resourceProperty.add(fixedTopicSetDocument);
+
+        //setup the Topic property
+        resourceProperty = propSet.get(NotificationProducerPortType.PROP_QNAME_TOPIC);
+        TopicDocument topicDocument = TopicDocument.Factory.newInstance();
+        TopicSpace[] topicSpaces = topicSpaceSet.getTopicSpaces();
+        for (int i = 0; i < topicSpaces.length; i++)
+        {
+            TopicSpace topicSpace = topicSpaces[i];
+            String targetNamespace = topicSpace.getTargetNamespace();
+            Iterator iterator = topicSpace.topicIterator();
+            while (iterator.hasNext())
+            {
+                Topic topic =  (Topic)iterator.next();
+                String topicName = topic.getName();
+                QName rootTopicQName = new QName(targetNamespace, topicName);
+                addSimpleTopic(topicDocument, rootTopicQName);
+                Iterator subTopics = topic.topicIterator();
+                while (subTopics.hasNext())
+                {
+                    Topic subTopic = (Topic) subTopics.next();
+                    addConcreteTopics(rootTopicQName, subTopic, topicDocument);
+                }
+            }
+        }
+        resourceProperty.add(topicDocument);
+
+        //setup the TopicExpressionDialects property
+        resourceProperty = propSet.get(NotificationProducerPortType.PROP_QNAME_TOPIC_EXPRESSION_DIALECTS);
+        String[] supportedDialects = TopicExpressionEngineImpl.getInstance().getSupportedDialects();
+        //add a TopicExpressionDialectsDocument for each TopicExpressionDialect.
+        for (int i = 0; i < supportedDialects.length; i++)
+        {
+            TopicExpressionDialectsDocument topicExpressionDialectsDocument = TopicExpressionDialectsDocument.Factory.newInstance();
+            topicExpressionDialectsDocument.setTopicExpressionDialects(supportedDialects[i]);
+            resourceProperty.add(topicExpressionDialectsDocument);
+        }
+    }
+
+    private static void addSimpleTopic(TopicDocument topicDocument, QName rootTopicQName)
+    {
+        TopicExpressionType topicExpressionType = topicDocument.addNewTopic();
+        topicExpressionType.setDialect(TopicsConstants.TOPIC_EXPR_DIALECT_SIMPLE);
+        XmlBeanUtils.setValueAsQName(topicExpressionType, rootTopicQName);
+    }
+
+    /**
+     * Recursively adds Concrete Topics to the Topic Document
+     *
+     * @param rootTopicQName The QName of the parent topic.
+     * @param subTopic  The current topic being added.
+     * @param topicDocument  The TopicDocument being added to.
+     */
+    private static void addConcreteTopics(QName rootTopicQName, Topic subTopic, TopicDocument topicDocument)
+    {
+        String topicName = subTopic.getName();
+        QName concreteTopicName = new QName(rootTopicQName.getNamespaceURI(), rootTopicQName.getLocalPart() + "/" + topicName);
+        TopicExpressionType topicExpressionType = topicDocument.addNewTopic();
+        topicExpressionType.setDialect(TopicsConstants.TOPIC_EXPR_DIALECT_CONCRETE);
+        XmlBeanUtils.setValueAsQName(topicExpressionType, concreteTopicName);
+        Iterator iterator = subTopic.topicIterator();
+        while (iterator.hasNext())
+        {
+            Topic topic = (Topic) iterator.next();
+            addConcreteTopics(concreteTopicName, topic, topicDocument);
+        }
     }
 
 }

Modified: incubator/hermes/trunk/src/templates/NotificationProducer-AbstractResource_init.txt
URL: http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/templates/NotificationProducer-AbstractResource_init.txt?rev=168145&r1=168144&r2=168145&view=diff
==============================================================================
--- incubator/hermes/trunk/src/templates/NotificationProducer-AbstractResource_init.txt (original)
+++ incubator/hermes/trunk/src/templates/NotificationProducer-AbstractResource_init.txt Wed May  4 10:04:42 2005
@@ -1,10 +1 @@
 
-	// initialize wsrl:Topic property
-	// TODO
-
-	// initialize wsrl:FixedTopicSet property
-	// TODO
-
-	// initialize wsrl:TopicExpressionDialects property
-	// TODO
-	



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