01: /*
02: * Copyright 2005 Joe Walker
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.directwebremoting;
17:
18: import org.directwebremoting.event.MessageListener;
19:
20: /**
21: * A server-side hub that can publish data across reverse ajax and sync with
22: * a number of other hubs, including: JMS, the OpenAjax Alliance hub, and
23: * potentially others.
24: * @author Joe Walker [joe at getahead dot ltd dot uk]
25: */
26: public interface Hub {
27: /**
28: * Called to create a subscription so that future publishes to a similarly
29: * named topic alert the MessageListener that a publish has happened.
30: * <p><b>Warning</b>
31: * Currently the topic is a simple string pattern match. This more closely
32: * resembles JMS rather than the OpenAjax hub because we're taking the
33: * simplistic approach for now. I'm sure there will be some nasty problems
34: * that fall out of this.
35: * <p>The OpenAjax hub allows subscriber data that is passed back to the
36: * subscriber when the event happens. Since listeners are an ideal place for
37: * this data it isn't supported here. The OAA hub also allows for filters,
38: * but I'm thinking that this can be easily supported by the listener. What
39: * am I missing?
40: * @param topicName The topic to subscribe to.
41: * @param listener The object to notify of matching calls to publish()
42: */
43: void subscribe(String topicName, MessageListener listener);
44:
45: /**
46: * Reverse the action of {@link #subscribe(String, MessageListener)}
47: * @param topicName The topic to subscribe to.
48: * @param listener The object to notify of matching calls to publish()
49: */
50: boolean unsubscribe(String topicName, MessageListener listener);
51:
52: /**
53: * Publish some data to a certain topic.
54: * @param topicName The topic to subscribe to.
55: * @param message The data to publish
56: */
57: void publish(String topicName, Object message);
58: }
|