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/05/16 21:12:07 UTC

svn commit: r170431 - in /incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression: ./ impl/

Author: ips
Date: Mon May 16 12:12:04 2005
New Revision: 170431

URL: http://svn.apache.org/viewcvs?rev=170431&view=rev
Log:
moved to new package

Added:
    incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/
    incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/InvalidTopicExpressionException.java
    incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/TopicExpression.java
    incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/TopicExpressionEngine.java
    incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/TopicExpressionEvaluator.java
    incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/TopicExpressionException.java
    incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/TopicExpressionResolutionException.java
    incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/TopicPathDialectUnknownException.java
    incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/impl/
    incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/impl/AbstractTopicExpressionEvaluator.java
    incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/impl/ConcreteTopicExpressionEvaluator.java
    incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/impl/FullTopicExpressionEvaluator.java
    incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/impl/SimpleTopicExpressionEvaluator.java
    incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/impl/TopicExpressionEngineImpl.java

Added: incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/InvalidTopicExpressionException.java
URL: http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/InvalidTopicExpressionException.java?rev=170431&view=auto
==============================================================================
--- incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/InvalidTopicExpressionException.java (added)
+++ incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/InvalidTopicExpressionException.java Mon May 16 12:12:04 2005
@@ -0,0 +1,62 @@
+/*
+ *  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.expression;
+
+
+/**
+ * This exception is raised when the topic expression is invalid.
+ */
+public class InvalidTopicExpressionException extends TopicExpressionException
+{
+    /**
+     * Creates a InvalidTopicExpressionException without error message.
+     */
+    public InvalidTopicExpressionException()
+    {
+    }
+
+    /**
+     * Creates a InvalidTopicExpressionException with a given error message.
+     *
+     * @param message error message
+     */
+    public InvalidTopicExpressionException(String message)
+    {
+        super(message);
+    }
+
+    /**
+     * Creates a InvalidTopicExpressionException with a given error message
+     * and nested exception.
+     *
+     * @param message error message
+     * @param exception nested exception/
+     */
+    public InvalidTopicExpressionException(String message, Throwable exception)
+    {
+        super(message, exception);
+    }
+
+    /**
+     * Creates a InvalidTopicExpressionException from a nested exception.
+     *
+     * @param exception nested exception
+     */
+    public InvalidTopicExpressionException(Throwable exception)
+    {
+        super(exception);
+    }
+}

Added: incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/TopicExpression.java
URL: http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/TopicExpression.java?rev=170431&view=auto
==============================================================================
--- incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/TopicExpression.java (added)
+++ incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/TopicExpression.java Mon May 16 12:12:04 2005
@@ -0,0 +1,44 @@
+/*=============================================================================*
+ *  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.expression;
+
+import java.net.URI;
+
+/**
+ * Java representation of the wsnt:TopicExpressionType XML schema type.
+ *
+ * @author Ian Springer (ian DOT springer AT hp DOT com)
+ */
+public interface TopicExpression
+{
+
+    /**
+     * Returns the dialect of this topic expression.
+     */
+    URI getDialect();
+
+    /**
+     * 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/expression/TopicExpressionEngine.java
URL: http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/TopicExpressionEngine.java?rev=170431&view=auto
==============================================================================
--- incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/TopicExpressionEngine.java (added)
+++ incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/TopicExpressionEngine.java Mon May 16 12:12:04 2005
@@ -0,0 +1,85 @@
+/*
+ *  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.expression;
+
+import org.apache.ws.notification.topics.expression.InvalidTopicExpressionException;
+import org.apache.ws.notification.topics.expression.TopicExpressionException;
+import org.apache.ws.notification.topics.expression.TopicExpressionException;
+import org.apache.ws.notification.topics.expression.TopicExpressionResolutionException;
+import org.apache.ws.notification.topics.expression.TopicExpressionResolutionException;
+import org.apache.ws.notification.topics.expression.TopicPathDialectUnknownException;
+import org.apache.ws.notification.topics.expression.TopicExpression;
+import org.apache.ws.notification.topics.Topic;
+import org.apache.ws.notification.topics.TopicSpaceSet;
+
+/**
+ * The <code>TopicExpressionEngine</code> interface is used to map queries on a
+ * topic list to the appropriate <code>TopicExpressionEvaluators</code> and then
+ * return the result. <code>TopicExpressionEvaluators</code> can be
+ * preconfigured or dynamically added at runtime.
+ *
+ * @see TopicExpressionEvaluator
+ */
+public interface TopicExpressionEngine
+{
+    /**
+     * registers a new evaluator that can be used to evaluate topic expressions
+     *
+     * @param evaluator implementation of evaluator to be used for evaluating
+     *                  topic expressions
+     */
+    void registerEvaluator(TopicExpressionEvaluator evaluator);
+
+    /**
+     * Resolves a topic expression using the passed topic list. The appropraite
+     * TopicExpressionEvaluator is used based on the dialect element.
+     *
+     * @param topicSpaceSet       the topic list to apply the expression to
+     * @param topicExpression topic expression
+     * @return the set of topics the expression evaluated to
+     * @throws org.apache.ws.notification.topics.expression.TopicPathDialectUnknownException
+     *                                  if the topic expression dialect is not
+     *                                  supported
+     * @throws TopicExpressionResolutionException
+     *                                  if the expression could not be
+     *                                  evaluated
+     * @throws InvalidTopicExpressionException
+     *                                  if the topic expression is invalid
+     * @throws TopicExpressionException if any other error occurs
+     */
+    Topic[] evaluateTopicExpression( TopicSpaceSet topicSpaceSet, TopicExpression topicExpression ) throws TopicPathDialectUnknownException,
+            TopicExpressionResolutionException,
+                                    InvalidTopicExpressionException,
+            TopicExpressionException;
+
+    /**
+     * Gets the evaluator currently registered to handle a topic expression of
+     * the specified dialect.
+     *
+     * @return the matching topic expression evaluator or null if none was
+     *         found
+     */
+    TopicExpressionEvaluator getEvaluator(String dialect);
+
+    /**
+     * Returns a list of URIs representing the registered topic expression
+     * dialects
+     *
+     * @return the list of supported dialects
+     */
+    String[] getSupportedDialects();
+
+}

Added: incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/TopicExpressionEvaluator.java
URL: http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/TopicExpressionEvaluator.java?rev=170431&view=auto
==============================================================================
--- incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/TopicExpressionEvaluator.java (added)
+++ incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/TopicExpressionEvaluator.java Mon May 16 12:12:04 2005
@@ -0,0 +1,64 @@
+/*
+ *  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.expression;
+
+import org.apache.ws.notification.topics.expression.InvalidTopicExpressionException;
+import org.apache.ws.notification.topics.expression.TopicExpressionException;
+import org.apache.ws.notification.topics.expression.TopicExpressionResolutionException;
+import org.apache.ws.notification.topics.expression.TopicPathDialectUnknownException;
+import org.apache.ws.notification.topics.expression.InvalidTopicExpressionException;
+import org.apache.ws.notification.topics.expression.TopicExpressionResolutionException;
+import org.apache.ws.notification.topics.expression.TopicExpression;
+import org.apache.ws.notification.topics.Topic;
+import org.apache.ws.notification.topics.TopicSpaceSet;
+
+/**
+ * A <code>TopicExpressionEvaluator</code> is used to implement a topic expression evaluation against a
+ * <code>TopicSpaceSet</code>. An evaluator can be registered with a <code>TopicExpressionEngine</code>,
+ * which in turn calls the evaluator when a matching expression is found.
+ */
+public interface TopicExpressionEvaluator
+{
+
+    /**
+     * Evaluates the expression over a TopicSpace and returns the set of matching topics.
+     *
+     * @param topicSpaceSet topic list associated with the service/resource
+     * @param expression object passed by client representing the topic expression
+     * @return the set of topics that matched the specified expression
+     *
+     * @throws TopicPathDialectUnknownException
+     *                                  if the topic expression dialect is not supported
+     * @throws TopicExpressionResolutionException
+     *                                  if the expression could not be evaluated
+     * @throws org.apache.ws.notification.topics.expression.InvalidTopicExpressionException
+     *                                  if the topic expression is invalid
+     * @throws TopicExpressionException if any other error occurs
+     */
+    Topic[] evaluate( TopicSpaceSet topicSpaceSet, TopicExpression expression )
+            throws TopicPathDialectUnknownException,
+            TopicExpressionResolutionException,
+            InvalidTopicExpressionException,
+            TopicExpressionException;
+
+    /**
+     * Gets the URIs for the dialects that this evaluator can handle
+     *
+     * @return array of URIs supported by this evaluator
+     */
+    String[] getDialects();
+
+}

Added: incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/TopicExpressionException.java
URL: http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/TopicExpressionException.java?rev=170431&view=auto
==============================================================================
--- incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/TopicExpressionException.java (added)
+++ incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/TopicExpressionException.java Mon May 16 12:12:04 2005
@@ -0,0 +1,64 @@
+/*
+ *  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.expression;
+
+/**
+ * This is a basic exception raised by <code>TopicExpressionEngine</code> or
+ * <code>TopicExpressionEvaluator</code>.
+ */
+public class TopicExpressionException extends Exception
+{
+
+    /**
+     * Creates a TopicExpressionException without error message.
+     */
+    public TopicExpressionException()
+    {
+    }
+
+    /**
+     * Creates a TopicExpressionException with a given error message.
+     *
+     * @param message error message
+     */
+    public TopicExpressionException(String message)
+    {
+        super(message);
+    }
+
+    /**
+     * Creates a TopicExpressionException with a given error message and nested
+     * exception.
+     *
+     * @param message error message
+     * @param exception nested exception/
+     */
+    public TopicExpressionException(String message, Throwable exception)
+    {
+        super(message, exception);
+    }
+
+    /**
+     * Creates a TopicExpressionException from a nested exception.
+     *
+     * @param exception nested exception
+     */
+    public TopicExpressionException(Throwable exception)
+    {
+        super(exception);
+    }
+
+}

Added: incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/TopicExpressionResolutionException.java
URL: http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/TopicExpressionResolutionException.java?rev=170431&view=auto
==============================================================================
--- incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/TopicExpressionResolutionException.java (added)
+++ incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/TopicExpressionResolutionException.java Mon May 16 12:12:04 2005
@@ -0,0 +1,65 @@
+/*
+ *  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.expression;
+
+
+
+/**
+ * This exception is raised when resolution of a topic expression fails.
+ */
+public class TopicExpressionResolutionException extends org.apache.ws.notification.topics.expression.TopicExpressionException
+{
+    /**
+     * Creates a TopicExpressionResolutionException without error message.
+     */
+    public TopicExpressionResolutionException()
+    {
+    }
+
+    /**
+     * Creates a TopicExpressionResolutionException with a given error message.
+     *
+     * @param message error message
+     */
+    public TopicExpressionResolutionException(String message)
+    {
+        super(message);
+    }
+
+    /**
+     * Creates a TopicExpressionResolutionException with a given error message
+     * and nested exception.
+     *
+     * @param message   error message
+     * @param exception nested exception
+     */
+    public TopicExpressionResolutionException(
+        String message,
+        Throwable exception)
+    {
+        super(message, exception);
+    }
+
+    /**
+     * Creates a TopicExpressionResolutionException from a nested exception.
+     *
+     * @param exception nested exception
+     */
+    public TopicExpressionResolutionException(Throwable exception)
+    {
+        super(exception);
+    }
+}

Added: incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/TopicPathDialectUnknownException.java
URL: http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/TopicPathDialectUnknownException.java?rev=170431&view=auto
==============================================================================
--- incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/TopicPathDialectUnknownException.java (added)
+++ incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/TopicPathDialectUnknownException.java Mon May 16 12:12:04 2005
@@ -0,0 +1,67 @@
+/*
+ *  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.expression;
+
+
+
+/**
+ * This exception is raised if the given topic expression dialect is
+ * unsupported.
+ */
+public class TopicPathDialectUnknownException
+    extends TopicExpressionException
+{
+    /**
+     * Creates a UnsupportedQueryDialectException without error message.
+     */
+    public TopicPathDialectUnknownException()
+    {
+    }
+
+    /**
+     * Creates a UnsupportedQueryDialectException with a given error message.
+     *
+     * @param message error message
+     */
+    public TopicPathDialectUnknownException(String message)
+    {
+        super(message);
+    }
+
+    /**
+     * Creates a UnsupportedQueryDialectException with a given error message
+     * and nested exception.
+     *
+     * @param message error message
+     * @param exception nested exception/
+     */
+    public TopicPathDialectUnknownException(
+        String message,
+        Throwable exception)
+    {
+        super(message, exception);
+    }
+
+    /**
+     * Creates a UnsupportedQueryDialectException from a nested exception.
+     *
+     * @param exception nested exception
+     */
+    public TopicPathDialectUnknownException(Throwable exception)
+    {
+        super(exception);
+    }
+}

Added: incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/impl/AbstractTopicExpressionEvaluator.java
URL: http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/impl/AbstractTopicExpressionEvaluator.java?rev=170431&view=auto
==============================================================================
--- incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/impl/AbstractTopicExpressionEvaluator.java (added)
+++ incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/impl/AbstractTopicExpressionEvaluator.java Mon May 16 12:12:04 2005
@@ -0,0 +1,115 @@
+/*=============================================================================*
+ *  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.expression.impl;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.ws.notification.topics.expression.TopicExpression;
+import org.apache.ws.notification.topics.expression.TopicExpressionEvaluator;
+import org.apache.ws.notification.topics.TopicSpace;
+import org.apache.ws.notification.topics.TopicSpaceSet;
+import org.apache.ws.notification.topics.expression.InvalidTopicExpressionException;
+import org.apache.ws.notification.topics.expression.TopicExpressionException;
+import org.apache.ws.notification.topics.expression.TopicExpressionResolutionException;
+import org.apache.ws.notification.topics.expression.InvalidTopicExpressionException;
+import org.apache.ws.notification.topics.expression.TopicExpressionException;
+import org.apache.ws.notification.topics.expression.TopicExpressionResolutionException;
+import org.apache.ws.notification.topics.expression.TopicExpressionEvaluator;
+import org.apache.ws.util.xml.NamespaceContext;
+
+import javax.xml.namespace.QName;
+
+/**
+ * An abstract class that provides functionality that is shared by the
+ * {@link TopicExpressionEvaluator}s for all three WS-Topics topic expression
+ * dialects.
+ *
+ * @author Ian Springer (ian DOT springer AT hp DOT com)
+ */
+public abstract class AbstractTopicExpressionEvaluator implements TopicExpressionEvaluator
+{
+
+    protected NamespaceContext getNamespaceContext( TopicExpression topicExpr ) throws TopicExpressionException
+    {
+        if ( !( topicExpr.getNamespaceContext() instanceof NamespaceContext ) )
+        {
+            throw new TopicExpressionException(
+                    "This evaluator requires the TopicExpression namespaceContext to be a NamespaceContext." );
+        }
+        return (NamespaceContext) topicExpr.getNamespaceContext();
+    }
+
+    protected String getContent( TopicExpression topicExpr )
+            throws TopicExpressionException
+    {
+        if ( !( topicExpr.getContent() instanceof String ) )
+        {
+            throw new TopicExpressionException( "This evaluator requires the TopicExpression content to be a String." );
+        }
+        String expr = (String) topicExpr.getContent();
+        if ( StringUtils.isEmpty( expr ) || !StringUtils.containsNone( expr, " \t\n\r\f" ) )
+        {
+            throw new InvalidTopicExpressionException( "Full topic expression contains whitespace." );
+        }
+        return expr;
+    }
+
+    protected TopicSpace getTopicSpace( TopicSpaceSet topicSpaceSet, QName topicPath )
+            throws TopicExpressionResolutionException
+    {
+        TopicSpace topicSpace = topicSpaceSet.getTopicSpace( topicPath.getNamespaceURI() );
+        if ( topicSpace == null )
+        {
+            throw new TopicExpressionResolutionException( "Topic path '" + topicPath.getPrefix() + ":" +
+                    topicPath.getLocalPart() +
+                    "' references an unknown TopicSpace with namespace URI '" +
+                    topicPath.getNamespaceURI() +
+                    "'." );
+        }
+        return topicSpace;
+    }
+
+    protected QName toQName( String topicPath, NamespaceContext nsContext )
+            throws InvalidTopicExpressionException
+    {
+        String prefix, localPart;
+        int i = topicPath.indexOf( ':' );
+        if ( i == -1 )  // no prefix
+        {
+            prefix = "";
+            localPart = topicPath;
+        }
+        else if ( i == 0 )
+        {
+            throw new InvalidTopicExpressionException( "Topic path '" + topicPath + "' starts with a colon." );
+        }
+        else if ( i == topicPath.length() - 1 )
+        {
+            throw new InvalidTopicExpressionException( "Topic path '" + topicPath + "' ends with a colon." );
+        }
+        else
+        {
+            prefix = topicPath.substring( 0, i );
+            localPart = topicPath.substring( i + 1 );
+            if ( localPart.indexOf( ':' ) != -1 )
+            {
+                throw new InvalidTopicExpressionException( "Local part of topic path '" + topicPath + "' contains a colon." );
+            }
+        }
+        String nsURI = nsContext.getNamespaceURI( prefix );
+        return new QName( nsURI, localPart, prefix );
+    }
+
+}

Added: incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/impl/ConcreteTopicExpressionEvaluator.java
URL: http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/impl/ConcreteTopicExpressionEvaluator.java?rev=170431&view=auto
==============================================================================
--- incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/impl/ConcreteTopicExpressionEvaluator.java (added)
+++ incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/impl/ConcreteTopicExpressionEvaluator.java Mon May 16 12:12:04 2005
@@ -0,0 +1,103 @@
+/*=============================================================================*
+ *  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.expression.impl;
+
+import org.apache.ws.notification.topics.Topic;
+import org.apache.ws.notification.topics.expression.TopicExpression;
+import org.apache.ws.notification.topics.expression.TopicExpressionEvaluator;
+import org.apache.ws.notification.topics.TopicSet;
+import org.apache.ws.notification.topics.TopicSpace;
+import org.apache.ws.notification.topics.TopicSpaceSet;
+import org.apache.ws.notification.topics.expression.InvalidTopicExpressionException;
+import org.apache.ws.notification.topics.expression.TopicExpressionException;
+import org.apache.ws.notification.topics.expression.TopicExpressionResolutionException;
+import org.apache.ws.notification.topics.expression.TopicPathDialectUnknownException;
+import org.apache.ws.notification.topics.expression.InvalidTopicExpressionException;
+import org.apache.ws.notification.topics.expression.TopicExpressionException;
+import org.apache.ws.notification.topics.expression.TopicExpressionResolutionException;
+import org.apache.ws.notification.topics.expression.TopicExpression;
+import org.apache.ws.notification.topics.expression.impl.AbstractTopicExpressionEvaluator;
+import org.apache.ws.notification.topics.v2004_06.TopicsConstants;
+import org.apache.ws.util.xml.NamespaceContext;
+
+import javax.xml.namespace.QName;
+import java.util.StringTokenizer;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * Topic expression evalutor for the WS-Topics "Concrete" topic dialect.
+ *
+ * @see org.apache.ws.notification.topics.expression.TopicExpressionEvaluator
+ *
+ * @author Ian Springer (ian DOT springer AT hp DOT com)
+ */
+public class ConcreteTopicExpressionEvaluator extends AbstractTopicExpressionEvaluator
+{
+
+    //private static final Log LOG = LogFactory.getLog(ConcreteTopicExpressionEvaluator.class.getName());
+
+    private static final String[] SUPPORTED_DIALECTS = {TopicsConstants.TOPIC_EXPR_DIALECT_CONCRETE};
+
+    public Topic[] evaluate( TopicSpaceSet topicSpaceSet, TopicExpression topicExpr )
+        throws TopicPathDialectUnknownException,
+            TopicExpressionResolutionException,
+            InvalidTopicExpressionException,
+            TopicExpressionException
+    {
+        String expr = getContent( topicExpr );
+        NamespaceContext nsContext = getNamespaceContext( topicExpr );
+        QName topicPath = toQName( expr, nsContext );
+        List matchedTopics = evaluateTopicPath( topicSpaceSet, topicPath );
+        return (Topic[]) matchedTopics.toArray( new Topic[0] );
+    }
+
+    public String[] getDialects()
+    {
+        return SUPPORTED_DIALECTS;
+    }
+
+    private List evaluateTopicPath( TopicSpaceSet topicSpaceSet, QName topicPath )
+            throws TopicExpressionResolutionException, InvalidTopicExpressionException
+    {
+        List matchedTopics = new ArrayList();
+        TopicSpace topicSpace = getTopicSpace( topicSpaceSet, topicPath );
+        if ( topicPath.getLocalPart().indexOf( "//" ) != -1 ||
+             topicPath.getLocalPart().indexOf( "*" ) != -1 ||
+             topicPath.getLocalPart().indexOf( "|" ) != -1 ||
+             topicPath.getLocalPart().indexOf( "." ) != -1 )
+        {
+            throw new InvalidTopicExpressionException( "Topic path '" + topicPath +
+                    "' contains one or more illegal characters ('//', '*', '|' or '.')." );
+        }
+        StringTokenizer pathTokenizer = new StringTokenizer( topicPath.getLocalPart(), "/" );
+        TopicSet topicSet = topicSpace;
+        boolean resolvedPath = true;
+        while ( pathTokenizer.hasMoreTokens() )
+        {
+            String name = pathTokenizer.nextToken();
+            if ( ! topicSet.containsTopic( name ) )
+            {
+                resolvedPath = false;
+                break;
+            }
+            topicSet = topicSet.getTopic( name );
+        }
+        if ( resolvedPath ) { matchedTopics.add( topicSet ); }
+        return matchedTopics;
+    }
+
+}

Added: incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/impl/FullTopicExpressionEvaluator.java
URL: http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/impl/FullTopicExpressionEvaluator.java?rev=170431&view=auto
==============================================================================
--- incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/impl/FullTopicExpressionEvaluator.java (added)
+++ incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/impl/FullTopicExpressionEvaluator.java Mon May 16 12:12:04 2005
@@ -0,0 +1,233 @@
+/*=============================================================================*
+ *  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.expression.impl;
+
+import org.apache.ws.notification.topics.Topic;
+import org.apache.ws.notification.topics.expression.TopicExpression;
+import org.apache.ws.notification.topics.expression.TopicExpressionEvaluator;
+import org.apache.ws.notification.topics.TopicSet;
+import org.apache.ws.notification.topics.TopicSpace;
+import org.apache.ws.notification.topics.TopicSpaceSet;
+import org.apache.ws.notification.topics.expression.InvalidTopicExpressionException;
+import org.apache.ws.notification.topics.expression.TopicExpressionException;
+import org.apache.ws.notification.topics.expression.TopicExpressionException;
+import org.apache.ws.notification.topics.expression.TopicExpressionResolutionException;
+import org.apache.ws.notification.topics.expression.TopicPathDialectUnknownException;
+import org.apache.ws.notification.topics.expression.TopicPathDialectUnknownException;
+import org.apache.ws.notification.topics.expression.impl.AbstractTopicExpressionEvaluator;
+import org.apache.ws.notification.topics.v2004_06.TopicsConstants;
+import org.apache.ws.util.xml.NamespaceContext;
+
+import javax.xml.namespace.QName;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+/**
+ * Topic expression evalutor for the WS-Topics "Full" topic dialect.
+ *
+ * @see TopicExpressionEvaluator
+ *
+ * @author Ian Springer (ian DOT springer AT hp DOT com)
+ */
+public class FullTopicExpressionEvaluator extends AbstractTopicExpressionEvaluator
+{
+
+    //private static final Log LOG = LogFactory.getLog( FullTopicExpressionEvaluator.class.getName() );
+
+    private static final String[] SUPPORTED_DIALECTS = {TopicsConstants.TOPIC_EXPR_DIALECT_FULL};
+
+    public Topic[] evaluate( TopicSpaceSet topicSpaceSet, TopicExpression topicExpr )
+            throws TopicPathDialectUnknownException,
+            TopicExpressionResolutionException,
+            InvalidTopicExpressionException,
+            TopicExpressionException
+    {
+        String expr = getContent( topicExpr );
+        NamespaceContext nsContext = getNamespaceContext( topicExpr );
+        StringTokenizer exprTokenizer = new StringTokenizer( expr, "|" );
+        Set allMatchedTopics = new HashSet();
+        while ( exprTokenizer.hasMoreTokens() )
+        {
+            QName topicPath = toQName( exprTokenizer.nextToken(), nsContext );
+            List matchedTopics = evaluateTopicPath( topicSpaceSet, topicPath );
+            allMatchedTopics.addAll( matchedTopics );
+        }
+        if ( topicSpaceSet.isFixed() && allMatchedTopics.isEmpty() )
+        {
+            throw new InvalidTopicExpressionException( "Full topic expression '" + expr +
+                    "' does not match any topics, and the target topic set is fixed." );
+        }
+        return (Topic[]) allMatchedTopics.toArray( new Topic[0] );
+    }
+
+    public String[] getDialects()
+    {
+        return SUPPORTED_DIALECTS;
+    }
+
+    private List evaluateTopicPath( TopicSpaceSet topicSpaceSet, QName topicPath )
+            throws TopicExpressionResolutionException, InvalidTopicExpressionException
+    {
+        List matchedTopics = new ArrayList();
+        TopicSpace topicSpace = getTopicSpace( topicSpaceSet, topicPath );
+        if ( topicPath.getLocalPart().indexOf( "///" ) != -1 )
+        {
+            throw new InvalidTopicExpressionException( "Topic path '" + topicPath +
+                    "' contains an empty path component." );
+        }
+        PathTokenizer pathTokenizer = new PathTokenizer( topicPath.getLocalPart() );
+        List topicSetsToSearch = new ArrayList();
+        topicSetsToSearch.add( topicSpace );
+        boolean atFirstToken = true;
+        while ( pathTokenizer.hasMoreTokens() )
+        {
+            String pathToken = pathTokenizer.nextToken();
+            matchedTopics.clear();
+            for ( int i = 0; i < topicSetsToSearch.size(); i++ )
+            {
+                TopicSet topicSetToSearch = (TopicSet) topicSetsToSearch.get( i );
+                boolean recurse = pathToken.startsWith( "/" );
+                String name = recurse ? pathToken.substring( 1 ) : pathToken;
+                matchedTopics.addAll( findTopics( topicSetToSearch, name, recurse ) );
+            }
+            if ( atFirstToken && matchedTopics.isEmpty() )
+            {
+                throw new InvalidTopicExpressionException( "Topic path '" + topicPath +
+                        "' refers to a root topic that is not defined in the referenced topic space." );
+            }
+            topicSetsToSearch.clear();
+            topicSetsToSearch.addAll( matchedTopics );
+            atFirstToken = false;
+        }
+        return matchedTopics;
+    }
+
+    private List findTopics( TopicSet topicSet, String name, boolean recurse ) throws InvalidTopicExpressionException
+    {
+        List allMatchedTopics = new ArrayList();
+        if ( name.equals( "." ) )
+        {
+            allMatchedTopics.add( topicSet );
+            name = "*";  // we only want to evaluate "." the first time through during recursion
+        }
+        List matchedTopics = findTopics( topicSet, name );
+        allMatchedTopics.addAll( matchedTopics );
+        if ( recurse )
+        {
+            Iterator topicIter = topicSet.topicIterator();
+            while ( topicIter.hasNext() )
+            {
+                allMatchedTopics.addAll( findTopics( (Topic) topicIter.next(), name, recurse ) );
+            }
+        }
+        return allMatchedTopics;
+    }
+
+    private List findTopics( TopicSet topicSet, String name )
+    {
+        List matchedTopics = new ArrayList();
+        if ( name.equals( "*" ) )
+        {
+            Iterator topicIter = topicSet.topicIterator();
+            while ( topicIter.hasNext() )
+            {
+                matchedTopics.add( (Topic) topicIter.next() );
+            }
+        }
+        else
+        {
+            if ( topicSet.containsTopic( name ) )
+            {
+                matchedTopics.add( topicSet.getTopic( name ) );
+            }
+        }
+        return matchedTopics;
+    }
+
+    protected class PathTokenizer
+    {
+        private String m_path;
+        private int m_currentPos;
+        private int m_maxPos;
+
+        public PathTokenizer( String path )
+        {
+            m_path = path;
+            m_maxPos = m_path.length();
+        }
+
+        public boolean hasMoreTokens()
+        {
+            return m_currentPos < m_maxPos;
+        }
+
+        public String nextToken() throws InvalidTopicExpressionException
+        {
+            if ( m_currentPos >= m_maxPos )
+            {
+                throw new NoSuchElementException();
+            }
+            int startPos = m_currentPos;
+            m_currentPos = scanToken( startPos );
+            String token = m_path.substring( startPos, m_currentPos );
+            if ( token.startsWith( "//" ) )
+            {
+                token = token.substring( 1 );
+            }
+            ++m_currentPos; // skip the slash
+            return token;
+        }
+
+        private int scanToken( int startPos ) throws InvalidTopicExpressionException
+        {
+            int newPos = startPos;
+            if ( newPos == 0 )  // special handling for head of path, as per spec
+            {
+                if ( m_path.startsWith( "//" ) )
+                {
+                    newPos += 2;
+                }
+                if ( m_path.charAt( newPos ) == '.' )
+                {
+                    throw new InvalidTopicExpressionException(
+                            "'.' may not be used as the first component of a topic path." );
+                }
+            }
+            else
+            {
+                if ( m_path.charAt( newPos ) == '/' )
+                {
+                    newPos += 1;  // do not count leading slash as a delim
+                }
+            }
+            while ( newPos < m_maxPos )
+            {
+                if ( m_path.charAt( newPos ) == '/' )
+                {
+                    break;
+                }
+                newPos++;
+            }
+            return newPos;
+        }
+    }
+
+}

Added: incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/impl/SimpleTopicExpressionEvaluator.java
URL: http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/impl/SimpleTopicExpressionEvaluator.java?rev=170431&view=auto
==============================================================================
--- incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/impl/SimpleTopicExpressionEvaluator.java (added)
+++ incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/impl/SimpleTopicExpressionEvaluator.java Mon May 16 12:12:04 2005
@@ -0,0 +1,93 @@
+/*
+ *  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.expression.impl;
+
+import org.apache.ws.notification.topics.Topic;
+import org.apache.ws.notification.topics.expression.TopicExpression;
+import org.apache.ws.notification.topics.expression.TopicExpressionEvaluator;
+import org.apache.ws.notification.topics.TopicSpace;
+import org.apache.ws.notification.topics.TopicSpaceSet;
+import org.apache.ws.notification.topics.expression.InvalidTopicExpressionException;
+import org.apache.ws.notification.topics.expression.TopicExpressionException;
+import org.apache.ws.notification.topics.expression.TopicExpressionResolutionException;
+import org.apache.ws.notification.topics.expression.TopicPathDialectUnknownException;
+import org.apache.ws.notification.topics.expression.InvalidTopicExpressionException;
+import org.apache.ws.notification.topics.expression.TopicExpressionException;
+import org.apache.ws.notification.topics.expression.TopicExpressionResolutionException;
+import org.apache.ws.notification.topics.expression.TopicExpression;
+import org.apache.ws.notification.topics.expression.impl.AbstractTopicExpressionEvaluator;
+import org.apache.ws.notification.topics.v2004_06.TopicsConstants;
+import org.apache.ws.util.xml.NamespaceContext;
+
+import javax.xml.namespace.QName;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Topic expression evalutor for the WS-Topics "Simple" topic dialect.
+ *
+ * @see org.apache.ws.notification.topics.expression.TopicExpressionEvaluator
+ *
+ * @author Ian Springer (ian DOT springer AT hp DOT com)
+ */
+public class SimpleTopicExpressionEvaluator extends AbstractTopicExpressionEvaluator
+{
+
+    //private static final Log LOG = LogFactory.getLog(SimpleTopicExpressionEvaluator.class.getName());
+
+    private static final String[] SUPPORTED_DIALECTS = {TopicsConstants.TOPIC_EXPR_DIALECT_SIMPLE};
+
+    public Topic[] evaluate( TopicSpaceSet topicSpaceSet, TopicExpression topicExpr )
+        throws TopicPathDialectUnknownException,
+            TopicExpressionResolutionException,
+               InvalidTopicExpressionException,
+            TopicExpressionException
+    {
+        String expr = getContent( topicExpr );
+        NamespaceContext nsContext = getNamespaceContext( topicExpr );
+        QName topicPath = toQName( expr, nsContext );
+        List matchedTopics = evaluateTopicPath( topicSpaceSet, topicPath );
+        return (Topic[]) matchedTopics.toArray( new Topic[0] );
+    }
+
+    public String[] getDialects()
+    {
+        return SUPPORTED_DIALECTS;
+    }
+
+    private List evaluateTopicPath( TopicSpaceSet topicSpaceSet, QName topicPath )
+            throws TopicExpressionResolutionException, InvalidTopicExpressionException
+    {
+        List matchedTopics = new ArrayList();
+        TopicSpace topicSpace = getTopicSpace( topicSpaceSet, topicPath );
+        if ( topicPath.getLocalPart().indexOf( "/" ) != -1 ||
+             topicPath.getLocalPart().indexOf( "*" ) != -1 ||
+             topicPath.getLocalPart().indexOf( "|" ) != -1 ||
+             topicPath.getLocalPart().indexOf( "." ) != -1 )
+        {
+            throw new InvalidTopicExpressionException( "Topic path '" + topicPath +
+                    "' contains one or more illegal characters ('/', '*', '|' or '.')." );
+        }
+        String name = topicPath.getLocalPart();
+        Topic topic = topicSpace.getTopic( name );
+        if ( topic != null )
+        {
+            matchedTopics.add( topic );
+        }
+        return matchedTopics;
+    }
+
+}

Added: incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/impl/TopicExpressionEngineImpl.java
URL: http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/impl/TopicExpressionEngineImpl.java?rev=170431&view=auto
==============================================================================
--- incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/impl/TopicExpressionEngineImpl.java (added)
+++ incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/expression/impl/TopicExpressionEngineImpl.java Mon May 16 12:12:04 2005
@@ -0,0 +1,189 @@
+/*
+ *  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.expression.impl;
+
+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.TopicSpaceSet;
+import org.apache.ws.notification.topics.expression.InvalidTopicExpressionException;
+import org.apache.ws.notification.topics.expression.TopicExpression;
+import org.apache.ws.notification.topics.expression.TopicExpressionEngine;
+import org.apache.ws.notification.topics.expression.TopicExpressionEvaluator;
+import org.apache.ws.notification.topics.expression.TopicExpressionException;
+import org.apache.ws.notification.topics.expression.TopicExpressionResolutionException;
+import org.apache.ws.notification.topics.expression.TopicPathDialectUnknownException;
+import org.apache.ws.resource.JndiConstants;
+import org.apache.ws.util.jndi.JNDIUtils;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NameClassPair;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * 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
+ */
+public class TopicExpressionEngineImpl implements TopicExpressionEngine
+{
+
+    private static final Log LOG =
+            LogFactory.getLog( TopicExpressionEngineImpl.class.getName() );
+
+    private Map m_evaluators = new HashMap();
+
+    public TopicExpressionEngineImpl()
+    {
+        this.refresh();
+    }
+
+    /**
+     * Get the default topic expression engine instance (currently used to hide JNDI lookup details, may change in the
+     * future)
+     *
+     * @return The default topic expression engine instance
+     */
+    public static TopicExpressionEngine getInstance()
+    {
+        try
+        {
+            Context context = new InitialContext();
+            return (TopicExpressionEngine) context.lookup( JndiConstants.KEY_NAME_DEFAULT_TOPIC_EXPRESSION_ENGINE );
+        }
+        catch ( NamingException ne )
+        {
+            LOG.warn( "topicEngineConfigError: " + ne );
+            return new TopicExpressionEngineImpl();
+        }
+    }
+
+    /**
+     * Refresh the set of registered topic expression evaluators using information discovered from the JNDI registry.
+     * This method removes any previously registered topic expression evaluators, so handle with care.
+     */
+    public synchronized void refresh()
+    {
+        m_evaluators.clear();
+        NamingEnumeration list = null;
+        try
+        {
+            Context context = new InitialContext();
+            list = context.list( JndiConstants.TOPIC_EXPRESSION_EVALUATOR_CONTEXT );
+            while ( list.hasMore() )
+            {
+                NameClassPair pair = (NameClassPair) list.next();
+                TopicExpressionEvaluator evaluator = (TopicExpressionEvaluator) JNDIUtils.lookup( context,
+                        JndiConstants.TOPIC_EXPRESSION_EVALUATOR_CONTEXT + "/" + pair.getName(),
+                        TopicExpressionEvaluator.class );
+                registerEvaluator( evaluator );
+            }
+        }
+        catch ( NamingException ne )
+        {
+            LOG.warn( "topicEngineInitError: " + ne );
+            registerEvaluator( new FullTopicExpressionEvaluator() );
+        }
+        finally
+        {
+            if ( list != null )
+            {
+                try
+                {
+                    list.close();
+                }
+                catch ( NamingException ne )
+                {
+                }
+            }
+        }
+    }
+
+    public synchronized void registerEvaluator( TopicExpressionEvaluator evaluator )
+    {
+        LOG.debug( "Adding dialects for " + evaluator.getClass().getName() );
+        String[] dialects = evaluator.getDialects();
+        for ( int i = 0; i < dialects.length; i++ )
+        {
+            LOG.debug( "Adding dialect: " + dialects[i] );
+            this.m_evaluators.put( dialects[i], evaluator );
+        }
+    }
+
+    public synchronized TopicExpressionEvaluator getEvaluator( String dialect )
+    {
+        TopicExpressionEvaluator evaluator =
+                (TopicExpressionEvaluator) this.m_evaluators.get( dialect );
+        return evaluator;
+    }
+
+    public synchronized Topic[] evaluateTopicExpression( TopicSpaceSet topicSpaceSet,
+                                                            TopicExpression topicExpression )
+            throws org.apache.ws.notification.topics.expression.TopicPathDialectUnknownException,
+            TopicExpressionResolutionException,
+            InvalidTopicExpressionException,
+            TopicExpressionException
+    {
+        if ( topicExpression == null )
+        {
+            throw new InvalidTopicExpressionException(  "nullArgument"+"topicExpression"  );
+        }
+
+        if ( topicExpression.getDialect() == null )
+        {
+            throw new org.apache.ws.notification.topics.expression.TopicPathDialectUnknownException(
+                     "nullArgument"+"topicExpression.dialect"  );
+        }
+
+        String dialect = topicExpression.getDialect().toString();
+        TopicExpressionEvaluator evaluator = getEvaluator( dialect );
+
+        if ( evaluator == null )
+        {
+            if ( LOG.isDebugEnabled() )
+            {
+                LOG.debug( "Dialect not supported:" + dialect );
+                LOG.debug( "Registered dialects are:" );
+                Iterator keyIterator = m_evaluators.keySet().iterator();
+                Object key = null;
+                while ( keyIterator.hasNext() )
+                {
+                    key = keyIterator.next();
+                    LOG.debug( key );
+                }
+                LOG.debug( "key.equals(dialect): " + ( key.equals( dialect.toString() ) ) );
+                LOG.debug( "this.evaluators.containsKey(dialect): " +
+                        this.m_evaluators.containsKey( dialect.toString() ) );
+                LOG.debug( "HashCode of key: " + String.valueOf( key.hashCode() ) );
+                LOG.debug( "HashCode of dialect: " + String.valueOf( dialect.toString().hashCode() ) );
+                LOG.debug( "Object stored for key: " + this.m_evaluators.get( key ) );
+            }
+            throw new TopicPathDialectUnknownException( "The dialect " + dialect + " was not recognized." );
+        }
+        return evaluator.evaluate( topicSpaceSet, topicExpression );
+    }
+
+    public synchronized String[] getSupportedDialects()
+    {
+        return (String[]) this.m_evaluators.keySet().toArray( new String[this.m_evaluators.size()] );
+    }
+}



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