org.apache.ws.notification.topics.impl
Class TopicImpl

java.lang.Object
  extended byorg.apache.ws.notification.topics.impl.TopicImpl
All Implemented Interfaces:
Topic, TopicListener, TopicListenerList, TopicSet
Direct Known Subclasses:
ResourcePropertyValueChangeTopicImpl, ResourceTerminationTopicImpl

public class TopicImpl
extends java.lang.Object
implements Topic, TopicListener

Simple in-memory implementation of the Topic interface


Field Summary
protected  java.lang.Object m_currentMsg
           
protected  java.util.Collection m_listeners
           
protected  java.lang.String m_name
           
protected  TopicExpression m_reference
           
protected  java.util.Map m_subTopics
           
protected  java.util.List m_topicPath
           
protected  TopicSpace m_topicSpace
           
 
Constructor Summary
TopicImpl(java.util.Map subTopics, TopicExpression reference, java.util.Collection listeners, java.lang.String name, java.lang.Object current, java.util.List topicPath)
          Create a topic with the given parameters
TopicImpl(java.lang.String name)
          Create a topic with the given name
 
Method Summary
 Topic addTopic(java.lang.String name)
          Creates a new Topic object with the specified name and adds it to this set.
 Topic addTopic(Topic topic)
          Adds the specified topic to this set.
 void addTopicListener(TopicListener listener)
          Add a topic listener
 boolean containsTopic(java.lang.String name)
          Returns true if this set contains a topic with the specified name.
 java.lang.Object getCurrentMessage()
          Get the latest notification message published to this topic.
 java.lang.String getName()
          Get the name of this topic.
 Topic getParent()
           
 Topic getTopic(java.lang.String topicName)
          Gets the topic with the specified name.
 java.util.List getTopicPath()
          Get the topic path.
 TopicExpression getTopicReference()
          Get the topic expression for the topic(s) that this topic references.
 TopicSpace getTopicSpace()
          gets the TopicSpace this Topic is part of
 boolean isReference()
          Is this a topic reference?
 void publish(java.lang.Object msg)
          Publish a notification message to this topic.
 void removeTopic(java.lang.String name)
          Removes the topic with the specified name from this set.
 void removeTopic(Topic topic)
           
 void removeTopicListener(TopicListener listener)
          Remove a topic listener
 void setTopicPath(java.util.List topicPath)
          Set the topic path.
 void setTopicReference(TopicExpression topicPath)
          Set the topic expression that resolves to a set of topics that this topic references.
 void setTopicSpace(TopicSpace topicSpace)
          Set the TopicSpace this Topic is part of
 void topicAdded(Topic topic)
          Called when a topic is added
 void topicChanged(Topic topic)
          Called when the value of the topic changes
 java.util.Iterator topicIterator()
          Gets an iterator of the topics in this set.
 java.util.Iterator topicListenerIterator()
          Get a iterator for the list of TopicListeners
 void topicRemoved(Topic topic)
          Called when a topic is removed
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_subTopics

protected java.util.Map m_subTopics

m_reference

protected TopicExpression m_reference

m_listeners

protected java.util.Collection m_listeners

m_name

protected java.lang.String m_name

m_currentMsg

protected java.lang.Object m_currentMsg

m_topicPath

protected java.util.List m_topicPath

m_topicSpace

protected TopicSpace m_topicSpace
Constructor Detail

TopicImpl

public TopicImpl(java.lang.String name)
Create a topic with the given name

Parameters:
name - The name of the created topic

TopicImpl

public TopicImpl(java.util.Map subTopics,
                 TopicExpression reference,
                 java.util.Collection listeners,
                 java.lang.String name,
                 java.lang.Object current,
                 java.util.List topicPath)
Create a topic with the given parameters

Parameters:
subTopics - A map of child topics
reference - A topic expression (only used if this is a topic alias)
listeners - A collection of topic listeners
name - The name of this topic
current - The current value of this topic
topicPath - The concrete topic path of this topic
Method Detail

addTopic

public Topic addTopic(Topic topic)
               throws java.lang.Exception
Description copied from interface: TopicSet
Adds the specified topic to this set.

Specified by:
addTopic in interface TopicSet
Parameters:
topic - the topic to add
Throws:
java.lang.Exception - if topic is null or has the same name as a topic already in this set

addTopic

public Topic addTopic(java.lang.String name)
               throws java.lang.Exception
Description copied from interface: TopicSet
Creates a new Topic object with the specified name and adds it to this set.

Specified by:
addTopic in interface TopicSet
Parameters:
name - the name of the topic to add
Throws:
java.lang.Exception - if name is null, invalid (contains '/', '*', or '.'), or is the same as the name of a topic already in this set

removeTopic

public void removeTopic(java.lang.String name)
Description copied from interface: TopicSet
Removes the topic with the specified name from this set.

Specified by:
removeTopic in interface TopicSet
Parameters:
name - the name of the topic to remove

addTopicListener

public void addTopicListener(TopicListener listener)
Description copied from interface: TopicListenerList
Add a topic listener

Specified by:
addTopicListener in interface TopicListenerList
Parameters:
listener - The topic listener to add
See Also:
TopicListener

getName

public java.lang.String getName()
Description copied from interface: Topic
Get the name of this topic.

Specified by:
getName in interface Topic
Returns:
the name of this topic

getTopic

public Topic getTopic(java.lang.String topicName)
Description copied from interface: TopicSet
Gets the topic with the specified name.

Specified by:
getTopic in interface TopicSet
Parameters:
topicName - the name of the topic to get
Returns:
the topic, or null if no topic with the given name exists in this set

containsTopic

public boolean containsTopic(java.lang.String name)
Description copied from interface: TopicSet
Returns true if this set contains a topic with the specified name.

Specified by:
containsTopic in interface TopicSet
Parameters:
name - the name
Returns:
true if this set contains a topic with the specified name

getTopicReference

public TopicExpression getTopicReference()
Get the topic expression for the topic(s) that this topic references.

Specified by:
getTopicReference in interface Topic
Returns:
The topic expression that this topic reference or null if this topic is not a reference.

isReference

public boolean isReference()
Description copied from interface: Topic
Is this a topic reference?

Specified by:
isReference in interface Topic
Returns:
true if this topic is a reference to another topic, false if not

topicIterator

public java.util.Iterator topicIterator()
Description copied from interface: TopicSet
Gets an iterator of the topics in this set.

Specified by:
topicIterator in interface TopicSet
Returns:
the iterator

publish

public void publish(java.lang.Object msg)
             throws java.lang.Exception
Description copied from interface: Topic
Publish a notification message to this topic.

Specified by:
publish in interface Topic
Parameters:
msg - the notification message to be published
Throws:
java.lang.Exception - on error

getCurrentMessage

public java.lang.Object getCurrentMessage()
Description copied from interface: Topic
Get the latest notification message published to this topic.

Specified by:
getCurrentMessage in interface Topic
Returns:
an Object representing the latest notification message published to this topic, or null if no messages have yet been published

removeTopic

public void removeTopic(Topic topic)

removeTopicListener

public void removeTopicListener(TopicListener listener)
Description copied from interface: TopicListenerList
Remove a topic listener

Specified by:
removeTopicListener in interface TopicListenerList
Parameters:
listener - The topic listener to remove.
See Also:
TopicListener

topicListenerIterator

public java.util.Iterator topicListenerIterator()
Description copied from interface: TopicListenerList
Get a iterator for the list of TopicListeners

Specified by:
topicListenerIterator in interface TopicListenerList
Returns:
The iterator
See Also:
TopicListener

setTopicReference

public void setTopicReference(TopicExpression topicPath)
Description copied from interface: Topic
Set the topic expression that resolves to a set of topics that this topic references. Only used for reference topics.

Specified by:
setTopicReference in interface Topic
Parameters:
topicPath - The topic expression to set.

setTopicPath

public void setTopicPath(java.util.List topicPath)
Description copied from interface: Topic
Set the topic path. The topic path is represented as a ordered list of topic names

Specified by:
setTopicPath in interface Topic
Parameters:
topicPath - The topic path to associate with this topic

getTopicPath

public java.util.List getTopicPath()
Description copied from interface: Topic
Get the topic path. The topic path is represented as a ordered list of topic names

Specified by:
getTopicPath in interface Topic
Returns:
The topic path of this topic

topicAdded

public void topicAdded(Topic topic)
Description copied from interface: TopicListener
Called when a topic is added

Specified by:
topicAdded in interface TopicListener
Parameters:
topic - The topic being added

topicChanged

public void topicChanged(Topic topic)
Description copied from interface: TopicListener
Called when the value of the topic changes

Specified by:
topicChanged in interface TopicListener
Parameters:
topic - The topic that changed

topicRemoved

public void topicRemoved(Topic topic)
Description copied from interface: TopicListener
Called when a topic is removed

Specified by:
topicRemoved in interface TopicListener
Parameters:
topic - The topic being removed

getParent

public Topic getParent()

toString

public java.lang.String toString()

setTopicSpace

public void setTopicSpace(TopicSpace topicSpace)
Description copied from interface: Topic
Set the TopicSpace this Topic is part of

Specified by:
setTopicSpace in interface Topic
Parameters:
topicSpace - The TopicSpace this Topic is part of

getTopicSpace

public TopicSpace getTopicSpace()
Description copied from interface: Topic
gets the TopicSpace this Topic is part of

Specified by:
getTopicSpace in interface Topic
Returns:
The TopicSpace this Topic is part of


Copyright © 2004-2005 Apache Software Foundation. All Rights Reserved.