@Test public void testEquals() throws PicoCompositionException { ComponentAdapter componentAdapter = createComponentFactory().createComponentAdapter(new NullComponentMonitor(), new NullLifecycleStrategy(), new Properties( Characteristics .CDI), Touchable.class, SimpleTouchable.class, null, null, null); assertEquals(componentAdapter, componentAdapter); assertTrue(!componentAdapter.equals("blah")); }
private ComponentAdapter<?> createComponentAdapter(final String className, final ClassLoader classLoader) { Class<?> implementation = loadClass(classLoader, className); ComponentFactory factory = new AdaptingInjection(); return factory.createComponentAdapter(new NullComponentMonitor(), new NullLifecycleStrategy(), new Properties(), className, implementation, //Adapting injection will now support simultanous constructor //and other types of injection (since 3.0) //Must provide empty parameter array to use the default constructor. // new ConstructorParameters(new Parameter[0]), null, null); }
.createComponentAdapter(monitor, lifecycle, componentProps, key, impl, constructorParams, fieldParams, methodParams);
private void addComponentAdapter(final ClassLoadingPicoContainer container, final Element element, final ClassLoadingPicoContainer metaContainer) throws ClassNotFoundException, PicoCompositionException, MalformedURLException { String className = element.getAttribute(CLASS); if (notSet(className)) { throw new ScriptedPicoContainerMarkupException("'" + CLASS + "' attribute not specified for " + element.getNodeName()); } Class<?> implementationClass = getClassLoader().loadClass(className); Object key = element.getAttribute(KEY); String classKey = element.getAttribute(CLASS_NAME_KEY); if (notSet(key)) { if (!notSet(classKey)) { key = getClassLoader().loadClass(classKey); } else { key = implementationClass; } } Parameter[] parameters = createChildParameters(container, element); ComponentFactory componentFactory = createComponentFactory(element.getAttribute(FACTORY), metaContainer); container.as(Characteristics.NONE).addAdapter(componentFactory.createComponentAdapter(new NullComponentMonitor(), new NullLifecycleStrategy(), new Properties(), key, implementationClass, new ConstructorParameters(parameters), null, null)); }
.createComponentAdapter(monitor, lifecycle, componentProps, key, impl, constructorParams, fieldParams, methodParams);
public <T> ComponentAdapter<T> createComponentAdapter(final ComponentMonitor monitor, final LifecycleStrategy lifecycle, final Properties componentProps, final Object key, final Class<T> impl, final ConstructorParameters constructorParams, final FieldParameters[] fieldParams, final MethodParameters[] methodParams) throws PicoCompositionException { if (delegate == null) { delegate = new AdaptingInjection(); } ComponentAdapter<T> compAdapter = delegate.createComponentAdapter(monitor, lifecycle, componentProps, key, impl, constructorParams, fieldParams, methodParams); boolean enableCircular = removePropertiesIfPresent(componentProps, Characteristics.ENABLE_CIRCULAR); if (enableCircular && delegate instanceof InjectionType) { return monitor.changedBehavior(new ImplementationHiding.HiddenImplementation<T>(compAdapter)); } else { return compAdapter; } }
@Test public void testUnregisterComponent() throws PicoCompositionException { ComponentAdapter componentAdapter = createComponentFactory().createComponentAdapter(new NullComponentMonitor(), new NullLifecycleStrategy(), new Properties(Characteristics .CDI), Touchable.class, SimpleTouchable.class, null, null, null); picoContainer.addAdapter(componentAdapter); picoContainer.removeComponent(Touchable.class); assertFalse(picoContainer.getComponentAdapters().contains(componentAdapter)); } }
public <T> ComponentAdapter<T> createComponentAdapter(final ComponentMonitor monitor, final LifecycleStrategy lifecycle, final Properties componentProps, final Object key, final Class<T> impl, final ConstructorParameters constructorParams, final FieldParameters[] fieldParams, final MethodParameters[] methodParams) throws PicoCompositionException { if (delegate == null) { delegate = new AdaptingInjection(); } ComponentAdapter<T> compAdapter = delegate.createComponentAdapter(monitor, lifecycle, componentProps, key, impl, constructorParams, fieldParams, methodParams); boolean enableCircular = removePropertiesIfPresent(componentProps, Characteristics.ENABLE_CIRCULAR); if (enableCircular && delegate instanceof InjectionType) { return monitor.changedBehavior(new ImplementationHiding.HiddenImplementation<T>(compAdapter)); } else { return compAdapter; } }
@Test public void testRegisterComponent() throws PicoCompositionException { ComponentAdapter componentAdapter = createComponentFactory().createComponentAdapter(new NullComponentMonitor(), new NullLifecycleStrategy(), new Properties(Characteristics .CDI), Touchable.class, SimpleTouchable.class, null, null, null); picoContainer.addAdapter(componentAdapter); ComponentAdapter adapter = (ComponentAdapter)picoContainer.getComponentAdapters().toArray()[0]; assertSame(componentAdapter.getComponentKey(), adapter.getComponentKey()); }
return completedFactory.createComponentAdapter(monitor, lifecycle, componentProps,
return completedFactory.createComponentAdapter(monitor, lifecycle, componentProps,
ComponentAdapter<?> adapter = componentFactory.createComponentAdapter(monitor, lifecycle, tmpProperties,
ComponentAdapter<?> adapter = componentFactory.createComponentAdapter(monitor, lifecycle, tmpProperties,