@Test public void module_includes_ProjectAnalysisDataChange_classes() { ComponentContainer container = new ComponentContainer(); underTest.configure(container); assertThat(ProjectAnalysisDataChangesImpl.getDataChangeClasses() .stream() .map(t -> container.getPicoContainer().getComponentAdapter(t)) .filter(Objects::nonNull)).hasSize(ProjectAnalysisDataChangesImpl.getDataChangeClasses().size()); } }
@Test public void defines_CeTaskInterrupterProvider_object() { ComponentContainer container = new ComponentContainer(); underTest.configure(container); assertThat(container.getPicoContainer().getComponentAdapter(CeTaskInterrupter.class)) .isInstanceOf(CeTaskInterrupterProvider.class); } }
/** * 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) { return container.getComponentAdapter(type); }
@Override public <T> ComponentAdapter<T> getComponentAdapter(final Class<T> componentType, final NameBinding componentNameBinding) { return delegatePicoContainer.getComponentAdapter(componentType, componentNameBinding); }
@Override public <T> ComponentAdapter<T> getComponentAdapter(final Class<T> componentType, final Class<? extends Annotation> binding) { return delegatePicoContainer.getComponentAdapter(componentType, binding); }
@Override public ComponentAdapter<?> getComponentAdapter(final Object componentKey) { return delegatePicoContainer.getComponentAdapter(componentKey); }
ComponentAdapter getComponentAdapter(final Class<?> key) { return container.getComponentAdapter(key); }
public ComponentAdapter getComponentAdapter(Object componentKey) { return delegate.getComponentAdapter(componentKey); }
public <T> ComponentAdapter<T> getComponentAdapter(final Class<T> componentType, final Class<? extends Annotation> binding) { if (logger.isDebugEnabled()) { logger.debug("Grabbing component adapter for container: " + delegate + " of type: " + componentType.getName() + ", binding:" + binding.getName()); } return delegate.getComponentAdapter(componentType, binding); }
public <T> ComponentAdapter<T> getComponentAdapter(final Class<T> componentType, final Class<? extends Annotation> binding) { if (log.isDebugEnabled()) { log.debug("Grabbing component adapter for container: " + delegate + " of type: " + componentType.getName() + ", binding:" + binding.getName()); } return delegate.getComponentAdapter(componentType, binding); }
@SuppressWarnings("unchecked") public Class getClassInstance(String name) throws ClassNotFoundException { Class clazz = super.getClassInstance(name); synchronized (this) { MutablePicoContainer reqContainer = currentRequestContainer.get(); if (reqContainer != null) { // forces a registration via noComponentFound() reqContainer.getComponentAdapter(clazz); } } return clazz; }
/** * Returns the class of the binding used to parse the type with the * specified qualified name. * * @param type The qualified name of the type of the binding. * * @return The binding class, or null if no such class exists. */ public Class getBinding(QName type) { ComponentAdapter adapter = container.getComponentAdapter(type); if (adapter == null) { return null; } return adapter.getComponentImplementation(); }
/** * {@inheritDoc} * * @param componentType * @return ComponentAdapter or null. * @see org.picocontainer.PicoContainer#getComponentAdapter(java.lang.Class, NameBinding) */ public <T> ComponentAdapter<T> getComponentAdapter(final Class<T> componentType, final NameBinding componentNameBinding) { if (log.isDebugEnabled()) { log.debug("Locating component adapter with type " + componentType); } ComponentAdapter<T> ca = delegate.getComponentAdapter(componentType, componentNameBinding); if (ca == null) { onKeyOrTypeDoesNotExistInContainer(ca, log); } return ca; }
/** * Loads a binding with a specifc QName into a context. * * @param qName The qualified name of the type of the binding object. * @param context The context which is to contain the binding. * * @return The binding object of the associated type, otherwise null if * no such binding could be created. * */ public Binding loadBinding(QName qName, MutablePicoContainer context) { ComponentAdapter adapter = container.getComponentAdapter(qName); if ( adapter == null ) { return null; } return (Binding) adapter.getComponentInstance( context ); }
/** * {@inheritDoc} * * @param componentKey * * @return * * @see org.picocontainer.PicoContainer#getComponentAdapter(java.lang.Object) */ public ComponentAdapter<?> getComponentAdapter(final Object componentKey) { if (log.isDebugEnabled()) { log.debug("Locating component adapter with key " + componentKey); } ComponentAdapter adapter = delegate.getComponentAdapter(componentKey); if (adapter == null) { onKeyOrTypeDoesNotExistInContainer(componentKey, log); } return adapter; }
/** * {@inheritDoc} * * @param componentKey * * @return * * @see org.picocontainer.PicoContainer#getComponentAdapter(java.lang.Object) */ public ComponentAdapter<?> getComponentAdapter(final Object componentKey) { if (logger.isDebugEnabled()) { logger.debug("Locating component adapter with key " + componentKey); } ComponentAdapter adapter = delegate.getComponentAdapter(componentKey); if (adapter == null) { onKeyOrTypeDoesNotExistInContainer(componentKey, logger); } return adapter; }
/** * {@inheritDoc} * * @param componentType * * @return ComponentAdapter or null. * * @see org.picocontainer.PicoContainer#getComponentAdapter(java.lang.Class) */ public <T> ComponentAdapter<T> getComponentAdapter(final Class<T> componentType, final NameBinding componentNameBinding) { if (logger.isDebugEnabled()) { logger.debug("Locating component adapter with type " + componentType); } ComponentAdapter<T> ca = delegate.getComponentAdapter(componentType, componentNameBinding); if (ca == null) { onKeyOrTypeDoesNotExistInContainer(ca, logger); } return ca; }
MutablePicoContainer context = new PicoBuilder().withBehaviors(new Intercepting()).build(); context.addComponent(MapInfoRoutingManagement.class, MapInfoRoutingManagementBean.class); Intercepted intercepted = context.getComponentAdapter(MapInfoRoutingManagement.class).findAdapterOfType(Intercepted.class); intercepted.addPostInvocation(MapInfoRoutingManagement.class, new ChangeMapInfoEndpointInterceptor());
public void unregisterComponents(final MutablePicoContainer container) { // Check that we have classloaded the interface if required. if (interfaceClazzName != null && interfaceClazz == null) { throw new PluginException("Cannot unregister component '" + interfaceClazzName + "' in plugin '" + getKey() + "' because we haven't loaded the class. This means that this plugin has not been successfully enabled."); } if (container.getComponentAdapter(interfaceClazz) != null) { container.removeComponent(interfaceClazz); } // TODO: Should this be in an else clause? It is probably harmless, but also pointless. container.removeComponent(getModuleClass()); } }
private ComponentAdapter registerComponent(Class<?> toRegister, Binding binding) { if (binding.hasConstructorSpecified()) { picoContainer.registerComponentImplementation(toRegister, binding.getInstanceClass(), getPicoParameters(binding.getConstructorParameters())); } else { picoContainer.registerComponentImplementation(toRegister, binding.getInstanceClass()); } return picoContainer.getComponentAdapter(toRegister); // have to do this as apparently the register* methods sometimes return null! }