1 /* 2 Copyright 2008 Ramon Servadei 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 8 http://www.apache.org/licenses/LICENSE-2.0 9 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 fulmine.event.subscription; 17 18 import fulmine.IDomain; 19 import fulmine.IType; 20 import fulmine.distribution.IDistributionManager; 21 import fulmine.event.IEventSource; 22 import fulmine.event.listener.IEventListener; 23 import fulmine.event.system.EventSourceNotObservedEvent; 24 import fulmine.event.system.EventSourceObservedEvent; 25 import fulmine.event.system.ISystemEventListener; 26 import fulmine.event.system.SubscribeEvent; 27 import fulmine.event.system.UnsubscribeEvent; 28 import fulmine.model.container.IContainer; 29 30 /** 31 * Receives notifications when a local {@link IContainer} is subscribed or 32 * unsubscribed for, when the first {@link IEventListener} is added and when 33 * there are no more listeners. This occurs either locally via 34 * {@link IDistributionManager#subscribe(String, String, IType, IDomain, fulmine.event.listener.IEventListener)} 35 * or when a remote context subscribes for the event source. The events received 36 * are one of: 37 * <ul> 38 * <li>{@link SubscribeEvent} 39 * <li>{@link UnsubscribeEvent} 40 * <li>{@link EventSourceObservedEvent} 41 * <li>{@link EventSourceNotObservedEvent} 42 * </ul> 43 * <p> 44 * The {@link UnsubscribeEvent} informs the listener that a subscription has 45 * terminated, however there maybe other subscriptions that intersect with the 46 * {@link IEventSource} instances covered by the terminated subscription. 47 * Because of this, removing all resources servicing all matching 48 * {@link IEventSource} for an {@link UnsubscribeEvent} should not be done. The 49 * {@link EventSourceNotObservedEvent} should be used to clean up any resources 50 * that are servicing the identified {@link IEventSource}. 51 * 52 * @see IDistributionManager#addSubscriptionListener(ISubscriptionListener) 53 * @see IDistributionManager#removeSubscriptionListener(ISubscriptionListener) 54 * @see IDistributionManager#subscribe(String, String, IType, IDomain, 55 * fulmine.event.listener.IEventListener) 56 * @see IDistributionManager#unsubscribe(String, String, IType, IDomain, 57 * fulmine.event.listener.IEventListener) 58 * @author Ramon Servadei 59 */ 60 public interface ISubscriptionListener extends ISystemEventListener 61 { 62 }