Project: cometd
Revision: 512
Author: gregw
Date: 10 Aug 2008 23:45:04
Changes:JETTY-682
Files:added: /trunk/cometd-java/api/src/main/java/org/cometd/ChannelBayeuxListener.java (
try)
modified: /trunk/cometd-java/api/src/main/java/org/cometd/Bayeux.java (
try)
added: /trunk/cometd-java/api/src/main/java/org/cometd/ChannelListener.java (
try)
modified: /trunk/cometd-java/api/src/main/java/org/cometd/Client.java (
try)
added: /trunk/cometd-java/api/src/main/java/org/cometd/ClientBayeuxListener.java (
try)
added: /trunk/cometd-java/api/src/main/java/org/cometd/BayeuxListener.java (
try)
modified: /trunk/cometd-java/api/src/main/java/org/cometd/RemoveListener.java (
try)
modified: /trunk/cometd-java/api/src/main/java/org/cometd/ClientListener.java (
try)
modified: /trunk/cometd-java/api/src/main/java/org/cometd/Channel.java (
try)
added: /trunk/cometd-java/api/src/main/java/org/cometd/QueueListener.java (
try)
added: /trunk/cometd-java/api/src/main/java/org/cometd/SubscriptionListener.java (
try)
Diff:
| ... | ...@@ -0,0 +1,27 @@ |
| 1 | // ======================================================================== |
| 2 | // Copyright 2008 Dojo Foundation |
| 3 | // ------------------------------------------------------------------------ |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // Unless required by applicable law or agreed to in writing, software |
| 9 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 | // See the License for the specific language governing permissions and |
| 12 | // limitations under the License. |
| 13 | //======================================================================== |
| 14 | package org.cometd; |
| 15 | |
| 16 | /** |
| 17 | * A {@link BayeuxListener} with call backs for channel life cycle events |
| 18 | * |
| 19 | */ |
| 20 | public interface ChannelBayeuxListener extends BayeuxListener |
| 21 | { |
| 22 | /* ------------------------------------------------------------ */ |
| 23 | public void channelAdded(Channel channel); |
| 24 | |
| 25 | /* ------------------------------------------------------------ */ |
| 26 | public void channelRemoved(Channel channel); |
| 27 | } |
| ... | ...@@ -1,5 +1,5 @@ |
| 1 | 1 | // ======================================================================== |
| 2 | | // Copyright 2007 Dojo Foundation |
| 2 | // Copyright 2007-2008 Dojo Foundation |
| 3 | 3 | // ------------------------------------------------------------------------ |
| 4 | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | // you may not use this file except in compliance with the License. |
| ... | ...@@ -172,4 +172,21 @@ |
| 172 | 172 | * @param ext |
| 173 | 173 | */ |
| 174 | 174 | public void addExtension(Extension ext); |
| 175 | |
| 176 | /* ------------------------------------------------------------ */ |
| 177 | public void addListener(BayeuxListener listener); |
| 178 | |
| 179 | /* ------------------------------------------------------------ */ |
| 180 | /** |
| 181 | * @param size The size which if a client queue exceeds, forces a call to |
| 182 | * {@link QueueListener#queueMaxed(Client, Message)} to check if the message should be |
| 183 | * added. If set to -1, there is no queue limit. If set to zero, messages are |
| 184 | * not queued. |
| 185 | */ |
| 186 | public void setMaxClientQueue(int size); |
| 187 | |
| 188 | /* ------------------------------------------------------------ */ |
| 189 | public int getMaxClientQueue(); |
| 190 | |
| 191 | |
| 175 | 192 | } |
| ... | ...@@ -0,0 +1,25 @@ |
| 1 | // ======================================================================== |
| 2 | // Copyright 2008 Dojo Foundation |
| 3 | // ------------------------------------------------------------------------ |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // Unless required by applicable law or agreed to in writing, software |
| 9 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 | // See the License for the specific language governing permissions and |
| 12 | // limitations under the License. |
| 13 | //======================================================================== |
| 14 | package org.cometd; |
| 15 | |
| 16 | import java.util.EventListener; |
| 17 | |
| 18 | /** |
| 19 | * A marker interface for all interfaces that listen for Channel events |
| 20 | * |
| 21 | */ |
| 22 | public interface ChannelListener extends EventListener |
| 23 | { |
| 24 | |
| 25 | } |
| ... | ...@@ -16,6 +16,7 @@ |
| 16 | 16 | |
| 17 | 17 | import java.util.EventListener; |
| 18 | 18 | import java.util.List; |
| 19 | import java.util.Queue; |
| 19 | 20 | |
| 20 | 21 | /* ------------------------------------------------------------ */ |
| 21 | 22 | /** A Bayeux Client. |
| ... | ...@@ -80,5 +81,24 @@ |
| 80 | 81 | */ |
| 81 | 82 | public void endBatch(); |
| 82 | 83 | |
| 83 | | |
| 84 | |
| 85 | /* ------------------------------------------------------------ */ |
| 86 | /** |
| 87 | * Access the message queue. |
| 88 | * |
| 89 | * @return A queue that is synchronized on the Client instance. |
| 90 | */ |
| 91 | public Queue<Message> getQueue(); |
| 92 | |
| 93 | /* ------------------------------------------------------------ */ |
| 94 | /** |
| 95 | * @param max The size which if a client queue exceeds, forces a call to |
| 96 | * {@link QueueListener#queueMaxed(Client, Message)} to check if the message should be |
| 97 | * added. If set to -1, there is no queue limit. If set to zero, messages are |
| 98 | * not queued. |
| 99 | */ |
| 100 | public void setMaxQueue(int max); |
| 101 | |
| 102 | /* ------------------------------------------------------------ */ |
| 103 | public int getMaxQueue(); |
| 84 | 104 | } |
| 85 | 105 | \ No newline at end of file |
| ... | ...@@ -0,0 +1,27 @@ |
| 1 | // ======================================================================== |
| 2 | // Copyright 2008 Dojo Foundation |
| 3 | // ------------------------------------------------------------------------ |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // Unless required by applicable law or agreed to in writing, software |
| 9 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 | // See the License for the specific language governing permissions and |
| 12 | // limitations under the License. |
| 13 | //======================================================================== |
| 14 | package org.cometd; |
| 15 | |
| 16 | /** |
| 17 | * A {@link BayeuxListener} with call backs for client life cycle events |
| 18 | * |
| 19 | */ |
| 20 | public interface ClientBayeuxListener extends BayeuxListener |
| 21 | { |
| 22 | /* ------------------------------------------------------------ */ |
| 23 | public void clientAdded(Client client); |
| 24 | |
| 25 | /* ------------------------------------------------------------ */ |
| 26 | public void clientRemoved(Client client); |
| 27 | } |
| ... | ...@@ -0,0 +1,26 @@ |
| 1 | // ======================================================================== |
| 2 | // Copyright 2008 Dojo Foundation |
| 3 | // ------------------------------------------------------------------------ |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // Unless required by applicable law or agreed to in writing, software |
| 9 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 | // See the License for the specific language governing permissions and |
| 12 | // limitations under the License. |
| 13 | //======================================================================== |
| 14 | package org.cometd; |
| 15 | |
| 16 | import java.util.EventListener; |
| 17 | |
| 18 | |
| 19 | /** |
| 20 | * A marker interface for all interfaces that listen for Bayeux events |
| 21 | * |
| 22 | */ |
| 23 | public interface BayeuxListener extends EventListener |
| 24 | { |
| 25 | |
| 26 | } |
| ... | ...@@ -26,7 +26,7 @@ |
| 26 | 26 | public interface RemoveListener extends ClientListener |
| 27 | 27 | { |
| 28 | 28 | /** |
| 29 | | * This method is called when the client is removed (explicitly or from a timeout) |
| 29 | * This method is called after the client is removed (explicitly or from a timeout) |
| 30 | 30 | */ |
| 31 | 31 | public void removed(String clientId, boolean timeout); |
| 32 | 32 | |
| ... | ...@@ -1,7 +1,25 @@ |
| 1 | // ======================================================================== |
| 2 | // Copyright 2007-2008 Dojo Foundation |
| 3 | // ------------------------------------------------------------------------ |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // Unless required by applicable law or agreed to in writing, software |
| 9 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 | // See the License for the specific language governing permissions and |
| 12 | // limitations under the License. |
| 13 | //======================================================================== |
| 14 | |
| 1 | 15 | package org.cometd; |
| 2 | 16 | |
| 3 | 17 | import java.util.EventListener; |
| 4 | 18 | |
| 19 | /** |
| 20 | * A marker interface for all interfaces that listen for Client events |
| 21 | * |
| 22 | */ |
| 5 | 23 | public interface ClientListener extends EventListener { |
| 6 | 24 | |
| 7 | 25 | } |
| ... | ...@@ -1,5 +1,5 @@ |
| 1 | 1 | // ======================================================================== |
| 2 | | // Copyright 2007 Dojo Foundation |
| 2 | // Copyright 2007-2008 Dojo Foundation |
| 3 | 3 | // ------------------------------------------------------------------------ |
| 4 | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | // you may not use this file except in compliance with the License. |
| ... | ...@@ -87,4 +87,6 @@ |
| 87 | 87 | /* ------------------------------------------------------------ */ |
| 88 | 88 | public Collection<DataFilter> getDataFilters(); |
| 89 | 89 | |
| 90 | /* ------------------------------------------------------------ */ |
| 91 | public void addListener(ChannelListener listener); |
| 90 | 92 | } |
| ... | ...@@ -0,0 +1,40 @@ |
| 1 | // ======================================================================== |
| 2 | // Copyright 2008 Dojo Foundation |
| 3 | // ------------------------------------------------------------------------ |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // Unless required by applicable law or agreed to in writing, software |
| 9 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 | // See the License for the specific language governing permissions and |
| 12 | // limitations under the License. |
| 13 | //======================================================================== |
| 14 | |
| 15 | package org.cometd; |
| 16 | |
| 17 | import org.cometd.Client; |
| 18 | import org.cometd.ClientListener; |
| 19 | import org.cometd.Message; |
| 20 | |
| 21 | /** |
| 22 | * @author athena |
| 23 | * |
| 24 | */ |
| 25 | public interface QueueListener extends ClientListener |
| 26 | { |
| 27 | /* ------------------------------------------------------------ */ |
| 28 | /** |
| 29 | * Call back to notify if a message for a client will result in the |
| 30 | * message queue exceeding {@link Client#getMaxQueue()}. |
| 31 | * This is called with the client instance locked, so it is safe for the |
| 32 | * handler to manipulate the queue returned by {@link Client#getQueue()}, but |
| 33 | * action in the callback that may result in another Client instance should be |
| 34 | * avoided as that would risk deadlock. |
| 35 | * @param client |
| 36 | * @param message |
| 37 | * @return true if the message should be added to the client queue |
| 38 | */ |
| 39 | public boolean queueMaxed(Client client, Message message); |
| 40 | } |
| ... | ...@@ -0,0 +1,28 @@ |
| 1 | // ======================================================================== |
| 2 | // Copyright 2008 Dojo Foundation |
| 3 | // ------------------------------------------------------------------------ |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // Unless required by applicable law or agreed to in writing, software |
| 9 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 | // See the License for the specific language governing permissions and |
| 12 | // limitations under the License. |
| 13 | //======================================================================== |
| 14 | package org.cometd; |
| 15 | |
| 16 | |
| 17 | /** |
| 18 | * A {@link BayeuxListener} with call backs for subscription life cycle events |
| 19 | * |
| 20 | */ |
| 21 | public interface SubscriptionListener extends ChannelListener |
| 22 | { |
| 23 | /* ------------------------------------------------------------ */ |
| 24 | public void subscribed(Client client); |
| 25 | |
| 26 | /* ------------------------------------------------------------ */ |
| 27 | public void unsubscribed(Client client); |
| 28 | } |
To list