/** * Returns the component adapter for a binding with the specified name. * * @param type The qualified name of the type of the binding. * @return The binding class, or null if no such class exists. */ protected ComponentAdapter getBinding(QName type) { Object o = bindings.get(type); if (o == null) { return null; } if (o instanceof ComponentAdapter) { return (ComponentAdapter) o; } if (o instanceof Class) { return new ConstructorInjectionComponentAdapter(null, (Class) o); } return new InstanceComponentAdapter(null, o); } }
public ComponentAdapter getComponentAdapter(Object componentKey) { if (componentKey == null) { return null; } Object o = get(componentKey); if (o == null) { return null; } if (o instanceof Class) { // TODO: determine which form of injection to use return new ConstructorInjectionComponentAdapter(componentKey, (Class) o); } return new InstanceComponentAdapter(componentKey, o); }
/** * {@inheritDoc} The returned ComponentAdapter will be an * {@link InstanceComponentAdapter}. */ public ComponentAdapter registerComponentInstance(Object componentKey, Object componentInstance) throws PicoRegistrationException { if (componentInstance instanceof MutablePicoContainer) { MutablePicoContainer pc = (MutablePicoContainer) componentInstance; Object contrivedKey = new Object(); String contrivedComp = ""; pc.registerComponentInstance(contrivedKey, contrivedComp); try { if (this.getComponentInstance(contrivedKey) != null) { throw new PicoRegistrationException("Cannot register a container to itself. The container is already implicitly registered."); } } finally { pc.unregisterComponent(contrivedKey); } } ComponentAdapter componentAdapter = new InstanceComponentAdapter(componentKey, componentInstance); registerComponent(componentAdapter); return componentAdapter; }
/** * {@inheritDoc} * The returned ComponentAdapter will be an {@link InstanceComponentAdapter}. */ public ComponentAdapter registerComponentInstance(Object componentKey, Object componentInstance) { ComponentAdapter componentAdapter = new InstanceComponentAdapter(componentKey, componentInstance, lifecycleStrategyForInstanceRegistrations); return registerComponent(componentAdapter); }
/** * Returns the component adapter for a binding with the specified name. * * @param type The qualified name of the type of the binding. * * @return The binding class, or null if no such class exists. */ protected ComponentAdapter getBinding(QName type) { Object o = bindings.get( type ); if ( o == null ) { return null; } if ( o instanceof Class ) { return new ConstructorInjectionComponentAdapter( null, (Class) o ); } return new InstanceComponentAdapter( null, o ); } }
public ComponentAdapter getComponentAdapter(Object componentKey) { if ( componentKey == null ) { return null; } Object o = get( componentKey ); if ( o == null ) { return null; } if ( o instanceof Class ) { //TODO: determine which form of injection to use return new ConstructorInjectionComponentAdapter( componentKey, (Class) o ); } return new InstanceComponentAdapter( componentKey, o ); }