1 // 2 // ======================================================================== 3 // Copyright (c) 1995-2013 Mort Bay Consulting Pty. Ltd. 4 // ------------------------------------------------------------------------ 5 // All rights reserved. This program and the accompanying materials 6 // are made available under the terms of the Eclipse Public License v1.0 7 // and Apache License v2.0 which accompanies this distribution. 8 // 9 // The Eclipse Public License is available at 10 // http://www.eclipse.org/legal/epl-v10.html 11 // 12 // The Apache License v2.0 is available at 13 // http://www.opensource.org/licenses/apache2.0.php 14 // 15 // You may elect to redistribute this code under either of these licenses. 16 // ======================================================================== 17 // 18 19 package org.eclipse.jetty.util.component; 20 21 import java.util.Collection; 22 23 public interface Container 24 { 25 public boolean addBean(Object o); 26 27 /** 28 * @return the list of beans known to this aggregate 29 * @see #getBean(Class) 30 */ 31 public Collection<Object> getBeans(); 32 33 /** 34 * @param clazz the class of the beans 35 * @return the list of beans of the given class (or subclass) 36 * @see #getBeans() 37 */ 38 public <T> Collection<T> getBeans(Class<T> clazz); 39 40 /** 41 * @param clazz the class of the bean 42 * @return the first bean of a specific class (or subclass), or null if no such bean exist 43 */ 44 public <T> T getBean(Class<T> clazz); 45 46 /** 47 * Removes the given bean. 48 * @return whether the bean was removed 49 * @see #removeBeans() 50 */ 51 public boolean removeBean(Object o); 52 53 /** 54 * A listener for Container events. 55 * If an added bean implements this interface it will receive the events 56 * for this container. 57 */ 58 public interface Listener 59 { 60 void beanAdded(Container parent,Object child); 61 void beanRemoved(Container parent,Object child); 62 } 63 64 /** 65 * Inherited Listener. 66 * If an added bean implements this interface, then it will 67 * be added to all contained beans that are themselves Containers 68 */ 69 public interface InheritedListener extends Listener 70 { 71 } 72 }