public MutablePicoContainer makeChildContainer() { DefaultPicoContainer pc = new DefaultPicoContainer(componentAdapterFactory, this); addChildContainer(pc); return pc; }
DefaultPicoContainer pico = new DefaultPicoContainer(); pico.addComponent(ThreadPool.class, DefaultThreadPool.class); pico.addComponent(MyComp.class, MyComp.class); MyComp myComp = (MyComp)pico.getInstance(MyComp.class);
public MutablePicoContainer makeChildContainer() { DefaultPicoContainer pc = new DefaultPicoContainer(componentAdapterFactory, lifecycleStrategyForInstanceRegistrations, this); addChildContainer(pc); return pc; }
public Object getComponentInstance(Object componentKey) { ComponentAdapter componentAdapter = getComponentAdapter(componentKey); if (componentAdapter != null) { return getInstance(componentAdapter); } else { return null; } }
public ComponentAdapter unregisterComponentByInstance(Object componentInstance) { Collection componentAdapters = getComponentAdapters(); for (Iterator iterator = componentAdapters.iterator(); iterator.hasNext();) { ComponentAdapter componentAdapter = (ComponentAdapter) iterator.next(); if (getInstance(componentAdapter).equals(componentInstance)) { return unregisterComponent(componentAdapter.getComponentKey()); } } return null; }
public Object getComponentInstanceOfType(Class componentType) { final ComponentAdapter componentAdapter = getComponentAdapterOfType(componentType); return componentAdapter == null ? null : getInstance(componentAdapter); }
public List getComponentInstancesOfType(Class componentType) { if (componentType == null) { return Collections.EMPTY_LIST; } Map adapterToInstanceMap = new HashMap(); for (Iterator iterator = componentAdapters.iterator(); iterator.hasNext();) { ComponentAdapter componentAdapter = (ComponentAdapter) iterator.next(); if (componentType.isAssignableFrom(componentAdapter.getComponentImplementation())) { Object componentInstance = getInstance(componentAdapter); adapterToInstanceMap.put(componentAdapter, componentInstance); // This is to ensure all are added. (Indirect dependencies will be added // from InstantiatingComponentAdapter). addOrderedComponentAdapter(componentAdapter); } } List result = new ArrayList(); for (Iterator iterator = orderedComponentAdapters.iterator(); iterator.hasNext();) { Object componentAdapter = iterator.next(); final Object componentInstance = adapterToInstanceMap.get(componentAdapter); if (componentInstance != null) { // may be null in the case of the "implicit" adapter // representing "this". result.add(componentInstance); } } return result; }
/** * Creates a new configuration. * * <p>Any dependent schemas should be added in subclass constructor. The xml schema dependency * does not have to be added. */ public Configuration(XSD xsd) { this.xsd = xsd; dependencies = Collections.synchronizedList(new ArrayList()); // bootstrap check if (!(this instanceof XSConfiguration)) { dependencies.add(new XSConfiguration()); } properties = Collections.synchronizedSet(new HashSet()); context = new DefaultPicoContainer(); }
public Binding stratagy(QName qname) throws Exception { return factory.loadBinding(qname, new DefaultPicoContainer()); }
public Binding stratagy(String name) throws Exception { return factory.loadBinding(xs(name), new DefaultPicoContainer()); }
pico = new DefaultPicoContainer(); pico.addComponent(A.class); pico.addComponent(B.class); IA a = pico.getComponent(IA.class); // a is an instance of A with an instance of B passed to the constructor
/** Construct a new EmptyComponentManager * */ public EmptyComponentManager() { pico = new DefaultPicoContainer(); } /** the picocontainer that manages the components */
public BindingLoader() { container = new DefaultPicoContainer(); }
public BindingLoader() { container = new DefaultPicoContainer(); }
public PicoMap() { mutablePicoContainer = new DefaultPicoContainer(); }
setContext(new DefaultPicoContainer(parent.getContext()));
context = new DefaultPicoContainer(); context = config.setupContext(context); if (contextCustomizer != null) {
MutablePicoContainer context = new DefaultPicoContainer(); context = configuration.setupContext(context);
context = new DefaultPicoContainer(); context.registerComponentInstance(this);
/** * Creates a new container with a parent container. */ public CachingPicoContainer(ComponentAdapterFactory caf, PicoContainer parent) { super(new DefaultPicoContainer(makeComponentAdapterFactory(caf), parent)); this.caf = caf; }