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/28 00:11:08 UTC
svn commit: r225643 - in
/webservices/pubscribe/trunk/src/java/org/apache/ws/notification/base:
FixedTopicSetResourcePropertyCallback.java
TopicExpressionDialectsResourcePropertyCallback.java
TopicResourcePropertyCallback.java
Author: ips
Date: Wed Jul 27 15:11:07 2005
New Revision: 225643
URL: http://svn.apache.org/viewcvs?rev=225643&view=rev
Log:
callbacks for WSN producer props
Added:
webservices/pubscribe/trunk/src/java/org/apache/ws/notification/base/FixedTopicSetResourcePropertyCallback.java
webservices/pubscribe/trunk/src/java/org/apache/ws/notification/base/TopicExpressionDialectsResourcePropertyCallback.java
webservices/pubscribe/trunk/src/java/org/apache/ws/notification/base/TopicResourcePropertyCallback.java
Added: webservices/pubscribe/trunk/src/java/org/apache/ws/notification/base/FixedTopicSetResourcePropertyCallback.java
URL: http://svn.apache.org/viewcvs/webservices/pubscribe/trunk/src/java/org/apache/ws/notification/base/FixedTopicSetResourcePropertyCallback.java?rev=225643&view=auto
==============================================================================
--- webservices/pubscribe/trunk/src/java/org/apache/ws/notification/base/FixedTopicSetResourcePropertyCallback.java (added)
+++ webservices/pubscribe/trunk/src/java/org/apache/ws/notification/base/FixedTopicSetResourcePropertyCallback.java Wed Jul 27 15:11:07 2005
@@ -0,0 +1,74 @@
+/*=============================================================================*
+ * 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.notification.base;
+
+import org.apache.ws.notification.base.v2004_06.porttype.NotificationProducerPortType;
+import org.apache.ws.resource.properties.ResourceProperty;
+import org.apache.ws.resource.properties.ResourcePropertyCallback;
+import org.apache.ws.resource.properties.impl.CallbackFailedException;
+import org.apache.xmlbeans.XmlBoolean;
+import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.FixedTopicSetDocument;
+
+import javax.xml.namespace.QName;
+
+/**
+ * A callback for the FixedTopicSet resource property from the WS-BaseNotification
+ * NotificationProducer portType.
+ */
+public class FixedTopicSetResourcePropertyCallback implements ResourcePropertyCallback
+{
+
+ private NotificationProducerResource m_resource;
+
+ /**
+ * Creates a new {@link FixedTopicSetResourcePropertyCallback} for the specified notification producer resource.
+ *
+ * @param resource a notification producer resource
+ */
+ public FixedTopicSetResourcePropertyCallback( NotificationProducerResource resource )
+ {
+ m_resource = resource;
+ }
+
+ /**
+ * @param prop the wsnt:FixedTopicSet resource property
+ *
+ * @return the wsnt:FixedTopicSet resource property
+ *
+ * @throws org.apache.ws.resource.properties.impl.CallbackFailedException
+ */
+ public ResourceProperty refreshProperty( ResourceProperty prop ) throws CallbackFailedException
+ {
+ QName propName = prop.getMetaData().getName();
+ if ( !propName.equals( NotificationProducerPortType.PROP_QNAME_FIXED_TOPIC_SET ) )
+ {
+ throw new IllegalArgumentException( "Unsupported property: " + propName );
+ }
+ if ( prop.isEmpty() )
+ {
+ FixedTopicSetDocument fixedTopicSetDoc = FixedTopicSetDocument.Factory.newInstance();
+ fixedTopicSetDoc.setFixedTopicSet(m_resource.getTopicSpaceSet().isFixed());
+ prop.add(fixedTopicSetDoc);
+ }
+ else
+ {
+ XmlBoolean fixedTopicSetPropElem = (XmlBoolean) prop.get( 0 );
+ fixedTopicSetPropElem.setBooleanValue( m_resource.getTopicSpaceSet().isFixed() );
+ }
+ return prop;
+ }
+
+}
Added: webservices/pubscribe/trunk/src/java/org/apache/ws/notification/base/TopicExpressionDialectsResourcePropertyCallback.java
URL: http://svn.apache.org/viewcvs/webservices/pubscribe/trunk/src/java/org/apache/ws/notification/base/TopicExpressionDialectsResourcePropertyCallback.java?rev=225643&view=auto
==============================================================================
--- webservices/pubscribe/trunk/src/java/org/apache/ws/notification/base/TopicExpressionDialectsResourcePropertyCallback.java (added)
+++ webservices/pubscribe/trunk/src/java/org/apache/ws/notification/base/TopicExpressionDialectsResourcePropertyCallback.java Wed Jul 27 15:11:07 2005
@@ -0,0 +1,62 @@
+/*=============================================================================*
+ * 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.notification.base;
+
+import org.apache.ws.notification.base.v2004_06.porttype.NotificationProducerPortType;
+import org.apache.ws.notification.topics.expression.impl.TopicExpressionEngineImpl;
+import org.apache.ws.resource.properties.ResourceProperty;
+import org.apache.ws.resource.properties.ResourcePropertyCallback;
+import org.apache.ws.resource.properties.impl.CallbackFailedException;
+import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.TopicExpressionDialectsDocument;
+
+import javax.xml.namespace.QName;
+
+/**
+ * A callback for the TopicExpressionDialects resource property from the WS-BaseNotification NotificationProducer
+ * portType.
+ */
+public class TopicExpressionDialectsResourcePropertyCallback implements ResourcePropertyCallback
+{
+
+ /**
+ * @param prop the wsnt:TopicExpressionDialects resource property
+ *
+ * @return the wsnt:TopicExpressionDialects resource property
+ *
+ * @throws org.apache.ws.resource.properties.impl.CallbackFailedException
+ */
+ public ResourceProperty refreshProperty( ResourceProperty prop ) throws CallbackFailedException
+ {
+ QName propName = prop.getMetaData().getName();
+ if ( !propName.equals( NotificationProducerPortType.PROP_QNAME_TOPIC_EXPRESSION_DIALECTS ) )
+ {
+ throw new IllegalArgumentException( "Unsupported property: " + propName );
+ }
+ if ( prop.isEmpty() )
+ {
+ 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] );
+ prop.add( topicExpressionDialectsDocument );
+ }
+ }
+ return prop;
+ }
+
+}
Added: webservices/pubscribe/trunk/src/java/org/apache/ws/notification/base/TopicResourcePropertyCallback.java
URL: http://svn.apache.org/viewcvs/webservices/pubscribe/trunk/src/java/org/apache/ws/notification/base/TopicResourcePropertyCallback.java?rev=225643&view=auto
==============================================================================
--- webservices/pubscribe/trunk/src/java/org/apache/ws/notification/base/TopicResourcePropertyCallback.java (added)
+++ webservices/pubscribe/trunk/src/java/org/apache/ws/notification/base/TopicResourcePropertyCallback.java Wed Jul 27 15:11:07 2005
@@ -0,0 +1,130 @@
+/*=============================================================================*
+ * 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.notification.base;
+
+import org.apache.ws.notification.base.v2004_06.porttype.NotificationProducerPortType;
+import org.apache.ws.notification.topics.Topic;
+import org.apache.ws.notification.topics.TopicSpace;
+import org.apache.ws.notification.topics.v2004_06.TopicsConstants;
+import org.apache.ws.resource.properties.ResourceProperty;
+import org.apache.ws.resource.properties.ResourcePropertyCallback;
+import org.apache.ws.resource.properties.impl.CallbackFailedException;
+import org.apache.ws.util.XmlBeanUtils;
+import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.TopicDocument;
+import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.TopicExpressionType;
+
+import javax.xml.namespace.QName;
+import java.util.Iterator;
+
+/**
+ * A callback for the Topic resource property from the WS-BaseNotification
+ * NotificationProducer portType.
+ */
+public class TopicResourcePropertyCallback implements ResourcePropertyCallback
+{
+
+ private NotificationProducerResource m_resource;
+
+ /**
+ * Creates a new {@link TopicResourcePropertyCallback} for the specified notification producer resource.
+ *
+ * @param resource a notification producer resource
+ */
+ public TopicResourcePropertyCallback( NotificationProducerResource resource )
+ {
+ m_resource = resource;
+ }
+
+ /**
+ * @param prop the wsnt:Topic resource property
+ *
+ * @return the wsnt:Topic resource property
+ *
+ * @throws org.apache.ws.resource.properties.impl.CallbackFailedException
+ */
+ public ResourceProperty refreshProperty( ResourceProperty prop ) throws CallbackFailedException
+ {
+ QName propName = prop.getMetaData().getName();
+ if ( !propName.equals( NotificationProducerPortType.PROP_QNAME_TOPIC ) )
+ {
+ throw new IllegalArgumentException( "Unsupported property: " + propName );
+ }
+ prop.clear();
+ TopicSpace[] topicSpaces = m_resource.getTopicSpaceSet().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 );
+
+ if ( topic.isVisible() )
+ {
+ addSimpleTopicExpression( rootTopicQName, prop );
+ }
+
+ Iterator subTopics = topic.topicIterator();
+ while ( subTopics.hasNext() )
+ {
+ Topic subTopic = (Topic) subTopics.next();
+ addConcreteTopicExpressions( rootTopicQName, subTopic, prop );
+ }
+ }
+ }
+ return prop;
+ }
+
+ private static void addSimpleTopicExpression(QName rootTopicName, ResourceProperty prop)
+ {
+ TopicDocument topicDocument = TopicDocument.Factory.newInstance();
+ TopicExpressionType topicExpressionType = topicDocument.addNewTopic();
+ topicExpressionType.setDialect(TopicsConstants.TOPIC_EXPR_DIALECT_SIMPLE);
+ XmlBeanUtils.setValueAsQName(topicExpressionType, rootTopicName);
+ prop.add(topicDocument);
+ }
+
+ /**
+ * Recursively adds Concrete Topics to the Topic Document
+ *
+ * @param rootTopicName The QName of the parent topic.
+ * @param subTopic The current topic being added.
+ * @param resourceProp The ResourceProperty associated with the Topic being added to.
+ */
+ private static void addConcreteTopicExpressions(QName rootTopicName, Topic subTopic, ResourceProperty resourceProp)
+ {
+ TopicDocument topicDocument = TopicDocument.Factory.newInstance();
+ String topicName = subTopic.getName();
+ QName concreteTopicName = new QName(rootTopicName.getNamespaceURI(), rootTopicName.getLocalPart() + "/" + topicName);
+ if (subTopic.isVisible())
+ {
+ TopicExpressionType topicExpressionType = topicDocument.addNewTopic();
+ topicExpressionType.setDialect(TopicsConstants.TOPIC_EXPR_DIALECT_CONCRETE);
+ XmlBeanUtils.setValueAsQName(topicExpressionType, concreteTopicName);
+ resourceProp.add(topicDocument);
+ }
+ Iterator iterator = subTopic.topicIterator();
+ while (iterator.hasNext())
+ {
+ Topic topic = (Topic) iterator.next();
+ addConcreteTopicExpressions(concreteTopicName, topic, resourceProp);
+ }
+ }
+
+}