+ 8 // level 3 ); assertThat(picoContainer.getParent().getParent().getComponentAdapters()).hasSize( CONTAINER_ITSELF + 20 // MigrationConfigurationModule + 17 // level 2 ); assertThat(picoContainer.getParent().getParent().getParent().getComponentAdapters()).hasSize( COMPONENTS_IN_LEVEL_1_AT_CONSTRUCTION + 26 // level 1 (Class) CeDistributedInformationImpl.class).contains( (Class) StandaloneCeDistributedInformation.class); assertThat(picoContainer.getParent().getParent().getParent().getParent()).isNull(); } finally { underTest.stop();
/** * Unregisters a component in the container and all parent containers. * * @param container The container. * @param key The key of the component. */ public static void unregisterComponent(PicoContainer container, final Object key) { // go to the top of the hierachy while (container.getParent() != null) { container = container.getParent(); } container.accept( new PicoVisitor() { public Object traverse(Object node) { return null; } public void visitContainer(PicoContainer container) { if (container instanceof MutablePicoContainer) { ((MutablePicoContainer) container).unregisterComponent(key); } } public void visitComponentAdapter(ComponentAdapter adapter) {} public void visitParameter(Parameter parameter) {} }); }
/** * Obtains all instances of a particular class from a container by navigating up the container * hierachy. * * @param container The container. * @param clazz The class. * @return A list of all instances of <code>clazz</code>, or the empty list if none found. */ public static List getComponentInstancesOfType(PicoContainer container, Class clazz) { List instances = new ArrayList(); while (container != null) { List l = container.getComponentInstancesOfType(clazz); instances.addAll(l); container = container.getParent(); } return instances; }
/** * Obtains all component adapters of a particular class from a container by navigating up the * container hierarchy. * * @param container The container. * @param clazz The class. * @return A list of all adapters for components of class <code>clazz</code>, or the empty list * if none found. */ public static List<ComponentAdapter> getComponentAdaptersOfType( PicoContainer container, Class clazz) { List instances = new ArrayList(); while (container != null) { List l = container.getComponentAdaptersOfType(clazz); instances.addAll(l); container = container.getParent(); } return instances; }
public synchronized PicoContainer getParent() { return delegate.getParent(); }
/** * Unregisters a component in the container and all parent containers. * * @param container The container. * @param key The key of the component. * */ public static void unregisterComponent(PicoContainer container, final Object key) { //go to the top of the hierachy while (container.getParent() != null) { container = container.getParent(); } container.accept(new PicoVisitor() { public Object traverse(Object node) { return null; } public void visitContainer(PicoContainer container) { if (container instanceof MutablePicoContainer) { ((MutablePicoContainer) container).unregisterComponent(key); } } public void visitComponentAdapter(ComponentAdapter adapter) { } public void visitParameter(Parameter parameter) { } }); }
/** * Unregisters a component in the container and all parent containers. * * @param container The container. * @param key The key of the component. * */ public static void unregisterComponent(PicoContainer container, final Object key) { //go to the top of the hierachy while (container.getParent() != null) { container = container.getParent(); } container.accept(new PicoVisitor() { public Object traverse(Object node) { return null; } public void visitContainer(PicoContainer container) { if (container instanceof MutablePicoContainer) { ((MutablePicoContainer) container).unregisterComponent(key); } } public void visitComponentAdapter(ComponentAdapter adapter) { } public void visitParameter(Parameter parameter) { } }); }
/** * Obtains all instances of a particular class from a container by navigating * up the container hierachy. * * @param container The container. * @param clazz The class. * * @return A list of all instances of <code>clazz</code>, or the empty list if none found. */ public static List getComponentInstancesOfType(PicoContainer container, Class clazz) { List instances = new ArrayList(); while (container != null) { List l = container.getComponentInstancesOfType(clazz); instances.addAll(l); container = container.getParent(); } return instances; }
/** * Obtains all instances of a particular class from a container by navigating * up the container hierachy. * * @param container The container. * @param clazz The class. * * @return A list of all instances of <code>clazz</code>, or the empty list if none found. */ public static List getComponentInstancesOfType( PicoContainer container, Class clazz ) { List instances = new ArrayList(); while( container != null ) { List l = container.getComponentInstancesOfType( clazz ); instances.addAll( l ); container = container.getParent(); } return instances; }
/** * Obtains all instances of a particular class from a container by navigating * up the container hierachy. * * @param container The container. * @param clazz The class. * * @return A list of all instances of <code>clazz</code>, or the empty list if none found. */ public static List getComponentInstancesOfType(PicoContainer container, Class clazz) { List instances = new ArrayList(); while (container != null) { List l = container.getComponentInstancesOfType(clazz); instances.addAll(l); container = container.getParent(); } return instances; }
final PicoContainer parent = container.getParent(); if (parent != null) { adapterMap.putAll(getMatchingComponentAdapters(parent, adapter, keyType, valueType));
public void killContainer(PicoContainer container) { if (startMode.isInvokeLifecycle()) { if (container instanceof Startable) { ((Startable) container).stop(); } } if (container instanceof Disposable) { ((Disposable) container).dispose(); } PicoContainer parent = container.getParent(); if (parent != null && parent instanceof MutablePicoContainer) { // see comment in buildContainer synchronized (parent) { ((MutablePicoContainer) parent).removeChildContainer(container); } } }