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 ip...@apache.org on 2005/04/28 01:31:29 UTC
svn commit: r165067 - in /incubator/hermes/trunk: ./
src/java/org/apache/ws/notification/base/
src/java/org/apache/ws/notification/base/impl/
src/java/org/apache/ws/notification/base/v2004_6/porttype/impl/
src/java/org/apache/ws/notification/topics/
src/java/org/apache/ws/notification/topics/impl/
src/java/org/apache/ws/notification/topics/util/ src/site/content/tutorial/
src/test/org/apache/ws/notification/topics/
Author: ips
Date: Wed Apr 27 16:31:27 2005
New Revision: 165067
URL: http://svn.apache.org/viewcvs?rev=165067&view=rev
Log:
beginning of impl of Full topic expressions
Added:
incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/TopicSet.java
incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/FullTopicExpressionEvaluator.java
incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/TopicSetImpl.java
Removed:
incubator/hermes/trunk/src/java/org/apache/ws/notification/base/impl/XmlBeansQueryExpression.java
incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/TopicSpaceSet.java
incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/TopicSpaceSetImpl.java
Modified:
incubator/hermes/trunk/project.xml
incubator/hermes/trunk/src/java/org/apache/ws/notification/base/NotificationProducerResource.java
incubator/hermes/trunk/src/java/org/apache/ws/notification/base/impl/AbstractSubscription.java
incubator/hermes/trunk/src/java/org/apache/ws/notification/base/impl/XmlBeansTopicExpression.java
incubator/hermes/trunk/src/java/org/apache/ws/notification/base/v2004_6/porttype/impl/NotificationProducerPortTypeImpl.java
incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/TopicExpression.java
incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/TopicExpressionEngineImpl.java
incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/util/TopicUtils.java
incubator/hermes/trunk/src/site/content/tutorial/FileSystem.wsdl
incubator/hermes/trunk/src/test/org/apache/ws/notification/topics/NotifProducer.java
Modified: incubator/hermes/trunk/project.xml
URL: http://svn.apache.org/viewcvs/incubator/hermes/trunk/project.xml?rev=165067&r1=165066&r2=165067&view=diff
==============================================================================
--- incubator/hermes/trunk/project.xml (original)
+++ incubator/hermes/trunk/project.xml Wed Apr 27 16:31:27 2005
@@ -194,13 +194,13 @@
</dependency>
<dependency>
- <groupId>commonj</groupId>
- <artifactId>commonj-twm</artifactId>
- <version>1.0</version>
+ <groupId>apollo</groupId>
+ <artifactId>commonj-twm-api</artifactId>
+ <version>1.1</version>
<url>http://dev2dev.bea.com/technologies/commonj/twm/</url>
<properties>
- <license>CommonjTwmLicense.txt</license>
- <usage>Needed for timer apis.</usage>
+ <license>ApacheLicense-2.0.txt</license>
+ <usage>Timer APIs used for scheduled resource termination</usage>
<war.bundle>true</war.bundle>
</properties>
</dependency>
Modified: incubator/hermes/trunk/src/java/org/apache/ws/notification/base/NotificationProducerResource.java
URL: http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/notification/base/NotificationProducerResource.java?rev=165067&r1=165066&r2=165067&view=diff
==============================================================================
--- incubator/hermes/trunk/src/java/org/apache/ws/notification/base/NotificationProducerResource.java (original)
+++ incubator/hermes/trunk/src/java/org/apache/ws/notification/base/NotificationProducerResource.java Wed Apr 27 16:31:27 2005
@@ -15,7 +15,7 @@
*=============================================================================*/
package org.apache.ws.notification.base;
-import org.apache.ws.notification.topics.TopicSpaceSet;
+import org.apache.ws.notification.topics.TopicSet;
import org.apache.ws.resource.Resource;
/**
@@ -27,6 +27,6 @@
public interface NotificationProducerResource extends Resource
{
- TopicSpaceSet getTopicSpaceSet();
+ TopicSet getTopicSpaceSet();
}
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?rev=165067&r1=165066&r2=165067&view=diff
==============================================================================
--- 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 Wed Apr 27 16:31:27 2005
@@ -23,7 +23,7 @@
import org.apache.ws.notification.topics.TopicExpression;
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.TopicSet;
import org.apache.ws.notification.topics.impl.SimpleSubscriptionTopicListener;
import org.apache.ws.notification.topics.topicexpression.impl.TopicExpressionException;
import org.apache.ws.pubsub.Filter;
@@ -244,7 +244,7 @@
return;
}
- TopicSpaceSet topicSpaceSet = ( (NotificationProducerResource) producerResource ).getTopicSpaceSet();
+ TopicSet topicSet = ( (NotificationProducerResource) producerResource ).getTopicSpaceSet();
Collection topics = null;
try
{ //todo fix!
@@ -290,12 +290,12 @@
private Collection evaluateTopicExpression() throws Exception
{
NotificationProducerResource resource = (NotificationProducerResource) getResource();
- TopicSpaceSet topicSpaceSet = resource.getTopicSpaceSet();
+ TopicSet topicSet = resource.getTopicSpaceSet();
Collection collection = null;
try
{
- collection = topicSpaceSet.evaluateExpression(m_topicExpression);
+ collection = topicSet.evaluateExpression(m_topicExpression);
}
catch (TopicExpressionException e)
{
Modified: incubator/hermes/trunk/src/java/org/apache/ws/notification/base/impl/XmlBeansTopicExpression.java
URL: http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/notification/base/impl/XmlBeansTopicExpression.java?rev=165067&r1=165066&r2=165067&view=diff
==============================================================================
--- incubator/hermes/trunk/src/java/org/apache/ws/notification/base/impl/XmlBeansTopicExpression.java (original)
+++ incubator/hermes/trunk/src/java/org/apache/ws/notification/base/impl/XmlBeansTopicExpression.java Wed Apr 27 16:31:27 2005
@@ -18,27 +18,17 @@
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.ws.XmlObjectWrapper;
import org.apache.ws.notification.topics.TopicExpression;
-import org.apache.ws.notification.topics.TopicExpression;
-import org.apache.ws.notification.topics.TopicExpressionEngine;
-import org.apache.ws.notification.topics.impl.TopicExpressionEngineImpl;
-import org.apache.ws.notification.topics.impl.faults.TopicPathDialectUnknownFaultException;
-import org.apache.ws.notification.base.v2004_6.impl.WsnNamespaceVersionHolderImpl;
import org.apache.ws.resource.i18n.Keys;
import org.apache.ws.resource.i18n.MessagesImpl;
import org.apache.ws.resource.properties.query.impl.XmlBeansQueryExpression;
-import org.apache.ws.util.JaxpUtils;
import org.apache.ws.util.XmlBeanUtils;
import org.apache.ws.util.i18n.Messages;
-import org.apache.ws.XmlObjectWrapper;
+import org.apache.ws.util.xml.impl.XmlBeansNamespaceContext;
import org.apache.xmlbeans.XmlObject;
-import org.apache.xmlbeans.XmlOptions;
import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.TopicExpressionType;
-import org.w3c.dom.DocumentFragment;
-import org.w3c.dom.Node;
-import org.w3c.dom.Text;
-import javax.naming.directory.SchemaViolationException;
import javax.xml.rpc.JAXRPCException;
import java.net.URI;
@@ -52,80 +42,59 @@
private static final Log LOG = LogFactory.getLog( XmlBeansQueryExpression.class );
public static final Messages MSG = MessagesImpl.getInstance();
+
+ private XmlObject m_queryExprXBean;
private URI m_dialect;
- private Node m_content;
- private TopicExpressionType m_topicExprXBean;
+ private Object m_content;
+ private Object m_nsContext;
/**
- * Creates a new {@link XmlBeansQueryExpression} object.
+ * Creates a new {@link XmlBeansTopicExpression} object.
*
* @param topicExprXBean DOCUMENT_ME
*
- * @throws javax.naming.directory.SchemaViolationException
- * DOCUMENT_ME
- * @throws javax.xml.rpc.JAXRPCException DOCUMENT_ME
+ * @throws JAXRPCException DOCUMENT_ME
*/
public XmlBeansTopicExpression( TopicExpressionType topicExprXBean )
- throws SchemaViolationException
{
- m_topicExprXBean = topicExprXBean;
-
- if( !isSupportedDialect(topicExprXBean.getDialect()))
- {
- throw new TopicPathDialectUnknownFaultException(new WsnNamespaceVersionHolderImpl(),"The dialect: " + topicExprXBean.getDialect() + " is unsupported.");
- }
-
- try
- {
- m_dialect = new URI( topicExprXBean.getDialect() );
- }
- catch ( Exception e )
- {
- throw new JAXRPCException( MSG.getMessage( Keys.FAILED_INIT_DIALECT, e ) );
- }
+ this( topicExprXBean, getDialect( topicExprXBean ) );
+ }
- XmlObject[] childElems = XmlBeanUtils.getChildElements( topicExprXBean );
+ protected XmlBeansTopicExpression( XmlObject xBean, URI dialect )
+ {
+ m_queryExprXBean = xBean;
+ m_dialect = dialect;
+ XmlObject[] childElems = XmlBeanUtils.getChildElements( m_queryExprXBean );
if ( childElems.length > 1 )
{
- throw new SchemaViolationException( MSG.getMessage( Keys.QUERY_ONLY_ONE_NODE ) );
+ throw new JAXRPCException( MSG.getMessage( Keys.QUERY_ONLY_ONE_NODE ) );
}
-
if ( childElems.length == 1 )
{
- m_content = ( (DocumentFragment) childElems[0].newDomNode() ).getFirstChild();
+ m_content = childElems[0];
}
else
{
- Node queryExprNode = ( (DocumentFragment) topicExprXBean.newDomNode( new XmlOptions().setSaveOuter() ) ).getFirstChild();
- m_content = queryExprNode.getFirstChild();
- if ( ( m_content == null ) || !( m_content instanceof Text ) )
- {
- throw new SchemaViolationException( MSG.getMessage( Keys.QUERY_MUST_HAVE_ELEM_OR_TXT ) );
- }
+ m_content = XmlBeanUtils.getValue( m_queryExprXBean );
}
+ m_nsContext = new XmlBeansNamespaceContext( m_queryExprXBean );
if ( LOG.isDebugEnabled() )
{
LOG.debug( MSG.getMessage( Keys.QUERY_EXPR, toString() ) );
}
}
- /**
- * Determines if the given dialect is supported
- *
- * @param dialect
- * @return
- */
- private boolean isSupportedDialect(String dialect)
+ private static URI getDialect(
+ TopicExpressionType topicExprElem )
{
- String[] supportedDialects = TopicExpressionEngineImpl.getInstance().getSupportedDialects();
- for (int i = 0; i < supportedDialects.length; i++)
+ try
+ {
+ return new URI( topicExprElem.getDialect() );
+ }
+ catch ( Exception e )
{
- if(dialect.equals(supportedDialects[i]))
- {
- return true;
- }
+ throw new JAXRPCException( MSG.getMessage( Keys.FAILED_INIT_DIALECT, e ) );
}
- return false;
}
/**
@@ -148,19 +117,14 @@
return m_dialect;
}
- public URI getURI()
+ public Object getNamespaceContext()
{
- return getDialect();
+ return m_nsContext;
}
- public Object getExpression()
+ public void setNamespaceContext( Object nsContext )
{
- return getContent();
- }
-
- public XmlObject getXmlObject()
- {
- return m_topicExprXBean;
+ m_nsContext = nsContext;
}
/**
@@ -170,21 +134,14 @@
*/
public String toString()
{
- String contentString;
- try
- {
- contentString = JaxpUtils.toString( m_content );
- }
- catch ( Exception e )
- {
- contentString = MSG.getMessage( Keys.NAME ) + "=" + m_content.getNodeName() + ", " +
- MSG.getMessage( Keys.VALUE ) +
- "=" +
- m_content.getNodeValue();
- }
-
return new ToStringBuilder( this ).append( MSG.getMessage( Keys.DIALECT ), m_dialect ).append(
- MSG.getMessage( Keys.CONTENT ), contentString )
+ MSG.getMessage( Keys.CONTENT ), m_content )
.toString();
}
+
+ public XmlObject getXmlObject()
+ {
+ return m_queryExprXBean;
+ }
+
}
Modified: incubator/hermes/trunk/src/java/org/apache/ws/notification/base/v2004_6/porttype/impl/NotificationProducerPortTypeImpl.java
URL: http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/notification/base/v2004_6/porttype/impl/NotificationProducerPortTypeImpl.java?rev=165067&r1=165066&r2=165067&view=diff
==============================================================================
--- incubator/hermes/trunk/src/java/org/apache/ws/notification/base/v2004_6/porttype/impl/NotificationProducerPortTypeImpl.java (original)
+++ incubator/hermes/trunk/src/java/org/apache/ws/notification/base/v2004_6/porttype/impl/NotificationProducerPortTypeImpl.java Wed Apr 27 16:31:27 2005
@@ -29,7 +29,7 @@
import org.apache.ws.notification.base.v2004_6.porttype.NotificationProducerPortType;
import org.apache.ws.notification.topics.Topic;
import org.apache.ws.notification.topics.TopicExpression;
-import org.apache.ws.notification.topics.TopicSpaceSet;
+import org.apache.ws.notification.topics.TopicSet;
import org.apache.ws.notification.topics.impl.SimpleSubscriptionTopicListener;
import org.apache.ws.notification.topics.impl.faults.NoCurrentMessageOnTopicFaultException;
import org.apache.ws.notification.topics.topicexpression.impl.TopicExpressionException;
@@ -149,12 +149,12 @@
private Collection evaluateTopicExpression(TopicExpression topicExpr)
{
NotificationProducerResource resource = (NotificationProducerResource) getResource();
- TopicSpaceSet topicSpaceSet = resource.getTopicSpaceSet();
+ TopicSet topicSet = resource.getTopicSpaceSet();
Collection collection = null;
try
{
- collection = topicSpaceSet.evaluateExpression(topicExpr);
+ collection = topicSet.evaluateExpression(topicExpr);
}
catch (TopicExpressionException e)
{
Modified: incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/TopicExpression.java
URL: http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/TopicExpression.java?rev=165067&r1=165066&r2=165067&view=diff
==============================================================================
--- incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/TopicExpression.java (original)
+++ incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/TopicExpression.java Wed Apr 27 16:31:27 2005
@@ -27,16 +27,18 @@
/**
* Returns the dialect of this topic expression.
- *
- * @return DOCUMENT_ME
*/
URI getDialect();
/**
- * Returns the actual expression (typically a String).
- *
- * @return DOCUMENT_ME
+ * Returns the content of this topic expression (typically a String).
*/
Object getContent();
+
+ /**
+ * Returns a namespace context that can be used to resolve prefixes within this
+ * query expression's content.
+ */
+ Object getNamespaceContext();
}
Added: incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/TopicSet.java
URL: http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/TopicSet.java?rev=165067&view=auto
==============================================================================
--- incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/TopicSet.java (added)
+++ incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/TopicSet.java Wed Apr 27 16:31:27 2005
@@ -0,0 +1,46 @@
+/*=============================================================================*
+ * 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.topics;
+
+import org.apache.ws.notification.topics.topicexpression.impl.TopicExpressionException;
+
+import java.util.Collection;
+
+/**
+ * The set of topics that a particular NotificationProducer supports.
+ *
+ * @author Ian Springer (ian DOT springer AT hp DOT com)
+ */
+public interface TopicSet
+{
+
+ void addTopicSpace( TopicSpace topicSpace );
+
+ void removeTopicSpace( String namespaceURI );
+
+ TopicSpace getTopicSpace( String namespaceURI );
+
+ TopicSpace[] getTopicSpaces();
+
+ Collection evaluateExpression(TopicExpression topicExpr) throws TopicExpressionException;
+
+ /**
+ * Returns a boolean that indicates if this topic set is fixed as defined by
+ * the WS-BaseNotification specification.
+ */
+ boolean isFixed();
+
+}
Added: incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/FullTopicExpressionEvaluator.java
URL: http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/FullTopicExpressionEvaluator.java?rev=165067&view=auto
==============================================================================
--- incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/FullTopicExpressionEvaluator.java (added)
+++ incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/FullTopicExpressionEvaluator.java Wed Apr 27 16:31:27 2005
@@ -0,0 +1,139 @@
+/*=============================================================================*
+ * 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.topics.impl;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.notification.topics.Topic;
+import org.apache.ws.notification.topics.TopicExpression;
+import org.apache.ws.notification.topics.TopicSet;
+import org.apache.ws.notification.topics.TopicSpace;
+import org.apache.ws.notification.topics.topicexpression.impl.InvalidTopicExpressionException;
+import org.apache.ws.notification.topics.topicexpression.impl.TopicExpressionException;
+import org.apache.ws.notification.topics.topicexpression.impl.TopicExpressionResolutionException;
+import org.apache.ws.notification.topics.topicexpression.impl.UnsupportedTopicExpressionDialectException;
+import org.apache.ws.notification.topics.v2004_06.Topics1_2Constants;
+import org.apache.ws.util.xml.NamespaceContext;
+
+import javax.xml.namespace.QName;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+/**
+ * Topic expression evalutor for the "Concrete" topic dialect.
+ *
+ * @see org.apache.ws.notification.topics.TopicExpressionEvaluator
+ */
+public class FullTopicExpressionEvaluator // implements TopicExpressionEvaluator
+{
+
+ private static final Log LOG =
+ LogFactory.getLog( FullTopicExpressionEvaluator.class.getName() );
+
+ private static final String[] SUPPORTED_DIALECTS = {Topics1_2Constants.TOPIC_EXPR_DIALECT_FULL};
+
+ public Topic[] resolve( TopicExpression topicExpr,
+ TopicSet topicSet )
+ throws UnsupportedTopicExpressionDialectException,
+ TopicExpressionResolutionException,
+ InvalidTopicExpressionException,
+ TopicExpressionException
+ {
+ if ( !( topicExpr.getContent() instanceof String ) )
+ {
+ throw new TopicExpressionException( "This evaluator requires the TopicExpression content to be a String." );
+ }
+ if ( !( topicExpr.getNamespaceContext() instanceof NamespaceContext ) )
+ {
+ throw new TopicExpressionException(
+ "This evaluator requires the TopicExpression namespaceContext to be a NamespaceContext." );
+ }
+ String expr = (String) topicExpr.getContent();
+ if ( StringUtils.isEmpty( expr ) || !StringUtils.containsNone( expr, " \t\n\r\f" ) )
+ {
+ throw new InvalidTopicExpressionException( "Full topic expression contains whitespace." );
+ }
+ StringTokenizer exprTokenizer = new StringTokenizer( expr, "|" );
+ Set allTopics = new HashSet();
+ NamespaceContext nsContext = (NamespaceContext) topicExpr.getNamespaceContext();
+ while ( exprTokenizer.hasMoreTokens() )
+ {
+ QName topicPath = toQName( exprTokenizer.nextToken(), nsContext );
+ List topics = evaluateTopicPath( topicPath, topicSet );
+ allTopics.addAll( topics );
+ }
+ if ( topicSet.isFixed() && allTopics.isEmpty() )
+ {
+ throw new InvalidTopicExpressionException( "Full topic expression '" + expr +
+ "' does not match any topics, and the target topic set is fixed." );
+ }
+ return (Topic[]) allTopics.toArray( new Topic[0] );
+ }
+
+ private List evaluateTopicPath( QName topicPath, TopicSet topicSet )
+ throws TopicExpressionResolutionException
+ {
+ List matchedTopics = new ArrayList();
+ TopicSpace topicSpace = topicSet.getTopicSpace( topicPath.getNamespaceURI() );
+ if ( topicSpace == null )
+ {
+ throw new TopicExpressionResolutionException(
+ "Topic path '" + topicPath.getPrefix() + ":" + topicPath.getLocalPart() +
+ "' references an unknown TopicSpace with namespace URI '" +
+ topicSpace.getNamespaceURI() +
+ "'." );
+ }
+ // TODO: parse and resolve localPart of topicPath and build up matchedTopics
+ return matchedTopics;
+ }
+
+ private QName toQName( String topicPath, NamespaceContext nsContext )
+ throws InvalidTopicExpressionException
+ {
+ StringTokenizer topicPathTokenizer = new StringTokenizer( topicPath, ":" );
+ if ( topicPathTokenizer.countTokens() == 0 )
+ {
+ throw new InvalidTopicExpressionException( "Topic path '" + topicPath + "' contains no local part." );
+ }
+ if ( topicPathTokenizer.countTokens() > 2 )
+ {
+ throw new InvalidTopicExpressionException( "Topic path '" + topicPath + "' contains more than one colon." );
+ }
+ String prefix, localPart;
+ if ( topicPathTokenizer.countTokens() == 1 )
+ {
+ prefix = "";
+ localPart = topicPathTokenizer.nextToken();
+ }
+ else
+ {
+ prefix = topicPathTokenizer.nextToken();
+ localPart = topicPathTokenizer.nextToken();
+ }
+ String nsURI = nsContext.getNamespaceURI( prefix );
+ return new QName( localPart, nsURI, prefix );
+ }
+
+ public String[] getDialects()
+ {
+ return SUPPORTED_DIALECTS;
+ }
+
+}
Modified: incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/TopicExpressionEngineImpl.java
URL: http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/TopicExpressionEngineImpl.java?rev=165067&r1=165066&r2=165067&view=diff
==============================================================================
--- incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/TopicExpressionEngineImpl.java (original)
+++ incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/TopicExpressionEngineImpl.java Wed Apr 27 16:31:27 2005
@@ -45,7 +45,7 @@
* Resolves topic expressions over topic lists. The engine looks for topic expression evaluators under
* "wsrf/topic/eval" context.
*
- * @see org.apache.ws.notification.topics.TopicSpaceSet
+ * @see org.apache.ws.notification.topics.TopicSet
*/
public class TopicExpressionEngineImpl implements TopicExpressionEngine
{
Added: incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/TopicSetImpl.java
URL: http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/TopicSetImpl.java?rev=165067&view=auto
==============================================================================
--- incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/TopicSetImpl.java (added)
+++ incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/TopicSetImpl.java Wed Apr 27 16:31:27 2005
@@ -0,0 +1,106 @@
+package org.apache.ws.notification.topics.impl;
+
+import org.apache.ws.XmlObjectWrapper;
+import org.apache.ws.notification.topics.Topic;
+import org.apache.ws.notification.topics.TopicExpression;
+import org.apache.ws.notification.topics.TopicSpace;
+import org.apache.ws.notification.topics.TopicSet;
+import org.apache.ws.notification.topics.topicexpression.impl.TopicExpressionException;
+import org.apache.xmlbeans.XmlCursor;
+import org.apache.xmlbeans.XmlObject;
+import org.w3c.dom.Text;
+
+import javax.xml.rpc.JAXRPCException;
+import java.util.Collection;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
+
+
+/**
+ * @author Sal Campana
+ */
+public class TopicSetImpl implements TopicSet
+{
+ private Map m_topicSpaces = new Hashtable();
+ private boolean m_fixed;
+
+ public TopicSetImpl( boolean fixed )
+ {
+ m_fixed = fixed;
+ }
+
+ /**
+ * 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();
+ //if topicSpace exists, simply add all topics to topicspace
+ if(m_topicSpaces.containsKey(namespaceURI))
+ {
+ TopicSpace topicSpc = (TopicSpace) m_topicSpaces.get(namespaceURI);
+ Iterator iterator = topicSpc.topicIterator();
+ while (iterator.hasNext())
+ {
+ Topic topic = (Topic) iterator.next();
+ topicSpace.addTopic(topic);
+ }
+ }
+
+ m_topicSpaces.put(namespaceURI, topicSpace);
+
+ }
+
+ public void removeTopicSpace(String namespaceURI)
+ {
+ m_topicSpaces.remove(namespaceURI);
+ }
+
+ public TopicSpace getTopicSpace(String namespaceURI)
+ {
+ return (TopicSpace) m_topicSpaces.get(namespaceURI);
+ }
+
+ public TopicSpace[] getTopicSpaces()
+ {
+ return (TopicSpace[]) m_topicSpaces.values().toArray(new TopicSpace[0]);
+ }
+
+ public Collection evaluateExpression(TopicExpression topicExpr)
+ throws TopicExpressionException
+ {
+
+ XmlObject xmlObjectTopicExpr = ((XmlObjectWrapper)topicExpr).getXmlObject();
+ Text content = (Text) topicExpr.getContent();
+ String nodeValue = content.getNodeValue();
+ String prefix = nodeValue.substring(0, nodeValue.indexOf(":"));
+ if(prefix == null || prefix.equals(""))
+ {
+ throw new JAXRPCException("Unable to determine namespace prefix for: " + nodeValue);
+ }
+
+ XmlCursor xmlCursor = xmlObjectTopicExpr.newCursor();
+ String namespaceForPrefix = xmlCursor.namespaceForPrefix(prefix);
+ xmlCursor.dispose();
+
+ if(namespaceForPrefix == null || namespaceForPrefix.equals(""))
+ {
+ throw new JAXRPCException("Unable to determine namespace for prefix: " + prefix);
+ }
+
+ TopicSpace topicSpace = getTopicSpace(namespaceForPrefix);
+ return topicSpace.getTopics(topicExpr);
+ }
+
+ public boolean isFixed()
+ {
+ return m_fixed;
+ }
+}
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=165067&r1=165066&r2=165067&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 Apr 27 16:31:27 2005
@@ -15,7 +15,7 @@
*=============================================================================*/
package org.apache.ws.notification.topics.util;
-import org.apache.ws.notification.topics.TopicSpaceSet;
+import org.apache.ws.notification.topics.TopicSet;
import org.apache.ws.notification.topics.ResourcePropertyValueChangeTopic;
import org.apache.ws.notification.topics.Topic;
import org.apache.ws.notification.topics.TopicSpace;
@@ -44,7 +44,7 @@
* @param topicSet
* @return
*/
- public static Topic addResourceTerminationTopic(TopicSpaceSet topicSet, Resource resource, NamespaceVersionHolder namespaces)
+ public static Topic addResourceTerminationTopic(TopicSet topicSet, Resource resource, NamespaceVersionHolder namespaces)
{
//there can be only 1 !
String namespace = namespaces.getLifetimeXsdNamespace();
@@ -77,7 +77,7 @@
* @param topicSet
* @return
*/
- public static Topic addResourcePropertyValueChangeTopic( ResourceProperty prop, TopicSpaceSet topicSet )
+ public static Topic addResourcePropertyValueChangeTopic( ResourceProperty prop, TopicSet topicSet )
{
if ( prop.getMetaData().isReadOnly() )
{
@@ -103,7 +103,7 @@
* @param topicSet
* @return
*/
- public static Topic[] addResourcePropertyValueChangeTopics( ResourcePropertySet propSet, TopicSpaceSet topicSet )
+ public static Topic[] addResourcePropertyValueChangeTopics( ResourcePropertySet propSet, TopicSet topicSet )
{
List topicList = new ArrayList();
Iterator propIter = propSet.iterator();
Modified: incubator/hermes/trunk/src/site/content/tutorial/FileSystem.wsdl
URL: http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/site/content/tutorial/FileSystem.wsdl?rev=165067&r1=165066&r2=165067&view=diff
==============================================================================
--- incubator/hermes/trunk/src/site/content/tutorial/FileSystem.wsdl (original)
+++ incubator/hermes/trunk/src/site/content/tutorial/FileSystem.wsdl Wed Apr 27 16:31:27 2005
@@ -12,10 +12,10 @@
xmlns:wsntw="http://docs.oasis-open.org/wsn/2004/06/wsn-WS-BaseNotification-1.2-draft-01.wsdl">
<import namespace="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceProperties-1.2-draft-01.wsdl"
- location="../spec/wsrf/WS-ResourceProperties-1_2.wsdl"/>
+ location="../spec/wsrf/WS-ResourceProperties-1_2-Draft_01.wsdl"/>
<import namespace="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceLifetime-1.2-draft-01.wsdl"
- location="../spec/wsrf/WS-ResourceLifetime-1_2.wsdl"/>
+ location="../spec/wsrf/WS-ResourceLifetime-1_2-Draft_01.wsdl"/>
<import namespace="http://docs.oasis-open.org/wsn/2004/06/wsn-WS-BaseNotification-1.2-draft-01.wsdl"
location="../spec/wsn/WS-BaseNotification-1_2-Draft_01.wsdl"/>
@@ -30,10 +30,10 @@
xmlns:wsnt="http://docs.oasis-open.org/wsn/2004/06/wsn-WS-BaseNotification-1.2-draft-01.xsd">
<xsd:import namespace="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-BaseFaults-1.2-draft-01.xsd"
- schemaLocation="../spec/wsrf/WS-BaseFaults-1_2.xsd"/>
+ schemaLocation="../spec/wsrf/WS-BaseFaults-1_2-Draft_01.xsd"/>
<xsd:import namespace="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceLifetime-1.2-draft-01.xsd"
- schemaLocation="../spec/wsrf/WS-ResourceLifetime-1_2.xsd"/>
+ schemaLocation="../spec/wsrf/WS-ResourceLifetime-1_2-Draft_01.xsd"/>
<xsd:import namespace="http://docs.oasis-open.org/wsn/2004/06/wsn-WS-BaseNotification-1.2-draft-01.xsd"
schemaLocation="../spec/wsn/WS-BaseNotification-1_2-Draft_01.xsd"/>
Modified: incubator/hermes/trunk/src/test/org/apache/ws/notification/topics/NotifProducer.java
URL: http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/test/org/apache/ws/notification/topics/NotifProducer.java?rev=165067&r1=165066&r2=165067&view=diff
==============================================================================
--- incubator/hermes/trunk/src/test/org/apache/ws/notification/topics/NotifProducer.java (original)
+++ incubator/hermes/trunk/src/test/org/apache/ws/notification/topics/NotifProducer.java Wed Apr 27 16:31:27 2005
@@ -14,6 +14,7 @@
import org.xmlsoap.schemas.ws.x2003.x03.addressing.AttributedURI;
import java.util.Calendar;
+import java.util.StringTokenizer;
/**
@@ -77,4 +78,14 @@
{
return null;
}
+
+ public static void main( String[] args )
+ {
+ StringTokenizer tok = new StringTokenizer( " / " );
+ while ( tok.hasMoreElements() )
+ {
+ System.out.println( "[" + tok.nextElement() + "]" );
+ }
+ }
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: hermes-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: hermes-dev-help@ws.apache.org