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/02/03 19:49:22 UTC
svn commit: r151205 - in
incubator/hermes/trunk/src/java/org/apache/ws/notification/topics:
TopicExpressionEvaluator.java impl/ConcreteTopicExpressionEvaluator.java
impl/SimpleTopicExpressionEvaluator.java impl/TopicSpaceImpl.java
Author: ips
Date: Thu Feb 3 10:49:21 2005
New Revision: 151205
URL: http://svn.apache.org/viewcvs?view=rev&rev=151205
Log:
implemented
Added:
incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/ConcreteTopicExpressionEvaluator.java
Modified:
incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/TopicExpressionEvaluator.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/TopicSpaceImpl.java
Modified: incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/TopicExpressionEvaluator.java
URL: http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/TopicExpressionEvaluator.java?view=diff&r1=151204&r2=151205
==============================================================================
--- incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/TopicExpressionEvaluator.java (original)
+++ incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/TopicExpressionEvaluator.java Thu Feb 3 10:49:21 2005
@@ -64,8 +64,9 @@
public String[] getDialects();
/**
- * Converts the expression from dialect specific form to a ordered list of QNames. This method throws an exception
- * if the expression does not evaluate to a concrete topic path.
+ * Converts the expression from dialect specific form to a ordered list of QNames.
+ * This method throws an exception if the expression does not evaluate to a concrete
+ * topic path.
*
* @param expression object passed by client representing the topic expression
*
Added: 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=auto&rev=151205
==============================================================================
--- incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/ConcreteTopicExpressionEvaluator.java (added)
+++ incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/ConcreteTopicExpressionEvaluator.java Thu Feb 3 10:49:21 2005
@@ -0,0 +1,114 @@
+/*=============================================================================*
+ * 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.ws.notification.topics.TopicExpressionEvaluator;
+import org.apache.ws.notification.topics.TopicExpression;
+import org.apache.ws.notification.topics.TopicSpace;
+import org.apache.ws.notification.topics.Topic;
+import org.apache.ws.notification.topics.topicexpression.impl.UnsupportedTopicExpressionDialectException;
+import org.apache.ws.notification.topics.topicexpression.impl.TopicExpressionResolutionException;
+import org.apache.ws.notification.topics.topicexpression.impl.InvalidTopicExpressionException;
+import org.apache.ws.notification.topics.topicexpression.impl.TopicExpressionException;
+import org.apache.ws.notification.topics.v1_2.Topics1_2Constants;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.w3c.dom.Text;
+
+import java.util.Collection;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+/**
+ * Topic expression evalutor for the "Concrete" topic dialect.
+ *
+ * @see TopicExpressionEvaluator
+ */
+public class ConcreteTopicExpressionEvaluator implements TopicExpressionEvaluator
+{
+
+ private static final Log LOG =
+ LogFactory.getLog(SimpleTopicExpressionEvaluator.class.getName());
+
+ private static final String[] SUPPORTED_DIALECTS = {Topics1_2Constants.TOPIC_EXPR_DIALECT_CONCRETE};
+
+ public Collection resolve(TopicExpression expr,
+ TopicSpace topicSpace)
+ throws UnsupportedTopicExpressionDialectException,
+ TopicExpressionResolutionException,
+ InvalidTopicExpressionException,
+ TopicExpressionException
+ {
+ List topicPath = getConcreteTopicPath( expr );
+ LOG.debug("Looking for topic with namespace: " +
+ topicSpace.getNamespaceURI() + " and local part " +
+ topicPath);
+ Collection result = new ArrayList();
+ Topic topic = topicSpace.getTopic(topicPath);
+ if(topic != null)
+ {
+ result.add(topic);
+ }
+ return result;
+ }
+
+ public String[] getDialects()
+ {
+ return SUPPORTED_DIALECTS;
+ }
+
+ /**
+ * @see TopicExpressionEvaluator#getConcreteTopicPath(org.apache.ws.notification.topics.TopicExpression)
+ */
+ public List getConcreteTopicPath(TopicExpression expr) throws UnsupportedTopicExpressionDialectException, InvalidTopicExpressionException, TopicExpressionException
+ {
+ List result = new ArrayList();
+ Text exprText = (Text) expr.getContent();
+ String exprValue = exprText.getNodeValue();
+ exprValue = exprValue.substring(exprValue.indexOf(':') + 1);
+ StringTokenizer tokenizer = new StringTokenizer( exprValue, "/" );
+ if ( tokenizer.countTokens() == 0 )
+ {
+ throw new InvalidTopicExpressionException( "Topic expression must contain at least one path element." );
+ }
+ while ( tokenizer.hasMoreTokens() )
+ {
+ result.add( tokenizer.nextToken() );
+ }
+ return result;
+ }
+
+ public TopicExpression toTopicExpression(List topicPath)
+ throws InvalidTopicExpressionException,
+ TopicExpressionException
+ {
+ if(topicPath == null || topicPath.size() != 1)
+ {
+ throw new InvalidTopicExpressionException(
+ "invalidSimpleTopicPath");
+ }
+
+ TopicExpression result = null;
+
+ /* result = new XmlBeansTopicExpression(); (
+ Topics1_2Constants.TOPIC_EXPR_DIALECT_SIMPLE,
+ (QName) topicPath.get(0));*/
+
+ return result;
+ }
+
+}
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=151204&r2=151205
==============================================================================
--- 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 Feb 3 10:49:21 2005
@@ -26,13 +26,11 @@
import org.apache.ws.notification.topics.topicexpression.impl.TopicExpressionResolutionException;
import org.apache.ws.notification.topics.topicexpression.impl.UnsupportedTopicExpressionDialectException;
import org.apache.ws.notification.topics.v1_2.Topics1_2Constants;
-import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.TopicExpressionType;
import org.w3c.dom.Text;
+import java.util.ArrayList;
import java.util.Collection;
-import java.util.LinkedList;
import java.util.List;
-import java.util.Vector;
/**
* Topic expression evalutor for the "Simple" topic dialect.
@@ -53,25 +51,16 @@
InvalidTopicExpressionException,
TopicExpressionException
{
-
- Text exprValue = (Text) expr.getContent();
- String topicName = exprValue.getNodeValue();
- topicName = topicName.substring(topicName.indexOf(":") + 1);//todo not sure if got index correct here!
+ List topicPath = getConcreteTopicPath( expr );
LOG.debug("Looking for topic with namespace: " +
topicSpace.getNamespaceURI() + " and local part " +
- topicName);
-
- Collection result = new Vector();
- List topicPath = new LinkedList();
- topicPath.add(topicName);
-
+ ((Topic)topicPath.get( 0 )).getName() );
+ Collection result = new ArrayList();
Topic topic = topicSpace.getTopic(topicPath);
-
if(topic != null)
{
result.add(topic);
}
-
return result;
}
@@ -81,29 +70,19 @@
}
/**
- * Converts the expression from dialect specific form to a ordered list of QNames. This method throws an exception
- * if the expression does not evaluate to a concrete topic path.
- *
- * @param expression object passed by client representing the topic expression
- * @return a list of QNames describing the concrete topic path
- * @throws UnsupportedTopicExpressionDialectException
- * if the topic expression dialect is not supported
- * @throws InvalidTopicExpressionException
- * if the topic expression is invalid
- * @throws TopicExpressionException if any other error occurs
+ * @see TopicExpressionEvaluator#getConcreteTopicPath(org.apache.ws.notification.topics.TopicExpression)
*/
- public List getConcreteTopicPath(TopicExpression expression) throws UnsupportedTopicExpressionDialectException, InvalidTopicExpressionException, TopicExpressionException
+ public List getConcreteTopicPath(TopicExpression expr) throws UnsupportedTopicExpressionDialectException, InvalidTopicExpressionException, TopicExpressionException
{
- return null;
- }
-
- public List getConcreteTopicPath(TopicExpressionType expression)
- throws UnsupportedTopicExpressionDialectException,
- InvalidTopicExpressionException,
- TopicExpressionException
- {
- List result = new LinkedList();
- // result.add(((TopicExpressionType) expression).getValue());
+ List result = new ArrayList();
+ Text exprText = (Text) expr.getContent();
+ String exprValue = exprText.getNodeValue();
+ if ( exprValue.indexOf( '/' ) != -1 )
+ {
+ throw new InvalidTopicExpressionException( "Simple topic expressions must not contain slashes." );
+ }
+ exprValue = exprValue.substring(exprValue.indexOf(':') + 1);
+ result.add( exprValue );
return result;
}
Modified: incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/TopicSpaceImpl.java
URL: http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/TopicSpaceImpl.java?view=diff&r1=151204&r2=151205
==============================================================================
--- incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/TopicSpaceImpl.java (original)
+++ incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/TopicSpaceImpl.java Thu Feb 3 10:49:21 2005
@@ -17,20 +17,17 @@
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.TopicListener;
import org.apache.ws.notification.topics.TopicExpressionEngine;
-import org.apache.ws.notification.topics.topicexpression.impl.InvalidTopicExpressionException;
-import org.apache.ws.notification.topics.topicexpression.impl.UnsupportedTopicExpressionDialectException;
-import org.apache.ws.notification.topics.topicexpression.impl.TopicExpressionResolutionException;
+import org.apache.ws.notification.topics.TopicListener;
+import org.apache.ws.notification.topics.TopicSpace;
import org.apache.ws.notification.topics.topicexpression.impl.TopicExpressionException;
+import org.apache.ws.notification.topics.topicexpression.impl.TopicExpressionResolutionException;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.net.URI;
/**
* TODO
@@ -40,7 +37,7 @@
private String m_namespaceURI;
private Map m_rootTopicMap = new HashMap();
private static TopicExpressionEngine m_topicExpressionEngine =
- TopicExpressionEngineImpl.getInstance();
+ TopicExpressionEngineImpl.getInstance();
public TopicSpaceImpl( String namespaceURI )
{
@@ -62,9 +59,10 @@
m_rootTopicMap.remove( topic.getName() );
}
- public Collection getTopics( TopicExpression topicExpression ) throws TopicExpressionException, TopicExpressionResolutionException
+ public Collection getTopics( TopicExpression topicExpression ) throws TopicExpressionException,
+ TopicExpressionResolutionException
{
- return m_topicExpressionEngine.resolveTopicExpression(topicExpression, this);
+ return m_topicExpressionEngine.resolveTopicExpression( topicExpression, this );
}
public Topic getTopic( List topicPath )
@@ -98,16 +96,16 @@
public void addTopicListener( TopicListener listener )
{
- //To change body of implemented methods use File | Settings | File Templates.
+ // TODO: either remove, or implement
}
public void removeTopicListener( TopicListener listener )
{
- //To change body of implemented methods use File | Settings | File Templates.
+ // TODO: either remove, or implement
}
public Iterator topicListenerIterator()
{
- return null; //To change body of implemented methods use File | Settings | File Templates.
+ return null; // TODO: either remove, or implement
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: hermes-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: hermes-dev-help@ws.apache.org