/** * Creates a new container with a custom ComponentAdapterFactory and a * parent container. * <p/> * <em> * Important note about caching: If you intend the components to be cached, you should pass * in a factory that creates {@link CachingComponentAdapter} instances, such as for example * {@link CachingComponentAdapterFactory}. CachingComponentAdapterFactory can delegate to * other ComponentAdapterFactories. * </em> * * @param componentAdapterFactory * the factory to use for creation of ComponentAdapters. * @param parent * the parent container (used for component dependency lookups). */ public JdonPicoContainer(ComponentAdapterFactory componentAdapterFactory, PicoContainer parent) { if (componentAdapterFactory == null) throw new NullPointerException("componentAdapterFactory"); this.componentAdapterFactory = componentAdapterFactory; this.parent = parent == null ? null : ImmutablePicoContainerProxyFactory.newProxyInstance(parent); }
/** * Create a new immutable PicoContainer proxy. The proxy will completly hide the implementation of the given * {@link PicoContainer} and will also prevent the invocation of any methods of the lifecycle methods from * {@link Startable} or {@link Disposable}. * * @param pico * @return the new proxy * @throws NullPointerException if <tt>pico</tt> is <code>null</code> * @since 1.2 */ public static PicoContainer newProxyInstance(final PicoContainer pico) { return (PicoContainer)Proxy.newProxyInstance( PicoContainer.class.getClassLoader(), interfaces, new ImmutablePicoContainerProxyFactory(pico)); } }
/** * Creates a new container with a custom ComponentAdapterFactory, LifecycleStrategy for instance registration, * and a parent container. * <p/> * <em> * Important note about caching: If you intend the components to be cached, you should pass * in a factory that creates {@link CachingComponentAdapter} instances, such as for example * {@link CachingComponentAdapterFactory}. CachingComponentAdapterFactory can delegate to * other ComponentAdapterFactories. * </em> * * @param componentAdapterFactory the factory to use for creation of ComponentAdapters. * @param lifecycleStrategyForInstanceRegistrations the lifecylce strategy chosen for regiered * instance (not implementations!) * @param parent the parent container (used for component dependency lookups). */ public DefaultPicoContainer(ComponentAdapterFactory componentAdapterFactory, LifecycleStrategy lifecycleStrategyForInstanceRegistrations, PicoContainer parent) { if (componentAdapterFactory == null) throw new NullPointerException("componentAdapterFactory"); if (lifecycleStrategyForInstanceRegistrations == null) throw new NullPointerException("lifecycleStrategyForInstanceRegistrations"); this.componentAdapterFactory = componentAdapterFactory; this.lifecycleStrategyForInstanceRegistrations = lifecycleStrategyForInstanceRegistrations; this.parent = parent == null ? null : ImmutablePicoContainerProxyFactory.newProxyInstance(parent); }