1 // ======================================================================== 2 // Copyright 2007 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 dojox.cometd; 16 17 import java.util.Collection; 18 19 /* ------------------------------------------------------------ */ 20 /** A Bayeux Channel. 21 * 22 */ 23 public interface Channel 24 { 25 /* ------------------------------------------------------------ */ 26 /** 27 * @return true if the Channel has been removed, false if it was not possible to remove the channel 28 */ 29 public abstract boolean remove(); 30 31 /* ------------------------------------------------------------ */ 32 public abstract String getId(); 33 34 /* ------------------------------------------------------------ */ 35 /** Publish a message 36 * This is equivalent to Bayeux.publish(fromClient,channel.getId(),data,msgId). 37 */ 38 public void publish(Client fromClient, Object data, String msgId); 39 40 /* ------------------------------------------------------------ */ 41 /** Is the channel persistent. 42 * Non persistent channels are removed when the last subscription is 43 * removed 44 * @return true if the Channel will persist without any subscription. 45 */ 46 public boolean isPersistent(); 47 48 /* ------------------------------------------------------------ */ 49 /** 50 * @param persistent true if the Channel will persist without any subscription. 51 */ 52 public void setPersistent(boolean persistent); 53 54 /* ------------------------------------------------------------ */ 55 /** Subscribe to a channel. 56 * Equivalent to bayeux.subscribe(channel.getId(),subscriber,false); 57 * @param toChannel 58 * @param subscriber 59 */ 60 public void subscribe(Client subscriber); 61 62 /* ------------------------------------------------------------ */ 63 /** Unsubscribe to a channel 64 * @param toChannel 65 * @param subscriber 66 */ 67 public void unsubscribe(Client subscriber); 68 69 /* ------------------------------------------------------------ */ 70 public Collection<Client> getSubscribers(); 71 72 /* ------------------------------------------------------------ */ 73 public int getSubscriberCount(); 74 75 /* ------------------------------------------------------------ */ 76 public void addDataFilter(DataFilter filter); 77 78 /* ------------------------------------------------------------ */ 79 public DataFilter removeDataFilter(DataFilter filter); 80 81 /* ------------------------------------------------------------ */ 82 public Collection<DataFilter> getDataFilters(); 83 84 }