public ComponentContainer addPicoAdapter(ComponentAdapter<?> adapter) { pico.addAdapter(adapter); return this; }
/** * @param singleton return always the same instance if true, else a new instance * is returned each time the component is requested */ public ComponentContainer addComponent(Object component, boolean singleton) { Object key = componentKeys.of(component); if (component instanceof ComponentAdapter) { pico.addAdapter((ComponentAdapter) component); } else { try { pico.as(singleton ? Characteristics.CACHE : Characteristics.NO_CACHE).addComponent(key, component); } catch (Throwable t) { throw new IllegalStateException("Unable to register component " + getName(component), t); } declareExtension("", component); } return this; }
@Override public MutablePicoContainer addAdapter(final ComponentAdapter<?> componentAdapter) { delegatePicoContainer.addAdapter(componentAdapter); return this; }
public ComponentContainer addPicoAdapter(ComponentAdapter adapter) { pico.addAdapter(adapter); return this; }
public ComponentContainer addPicoAdapter(ComponentAdapter<?> adapter) { pico.addAdapter(adapter); return this; }
/** * {@inheritDoc} * * @param componentAdapter * * @return * * @see org.picocontainer.MutablePicoContainer#addAdapter(org.picocontainer.ComponentAdapter) */ public MutablePicoContainer addAdapter(final ComponentAdapter componentAdapter) { if (logger.isDebugEnabled()) { logger.debug("Registering component adapter " + componentAdapter); } return delegate.addAdapter(componentAdapter); }
/** * {@inheritDoc} * * @param componentAdapter * * @return * * @see org.picocontainer.MutablePicoContainer#addAdapter(org.picocontainer.ComponentAdapter) */ public MutablePicoContainer addAdapter(final ComponentAdapter componentAdapter) { if (log.isDebugEnabled()) { log.debug("Registering component adapter " + componentAdapter); } return delegate.addAdapter(componentAdapter); }
/** * Register all component factories found in classpath scanning * * @param container * @param componentFactoryMap */ private void registerComponentFactories(MutablePicoContainer container, Map<Class<?>, Class<? extends ComponentFactory>> componentFactoryMap) { for (Map.Entry<Class<?>, Class<? extends ComponentFactory>> targetTypeEntry : componentFactoryMap.entrySet()) { container.addAdapter(new PicoComponentAdapter(targetTypeEntry.getKey(), targetTypeEntry.getValue())); } }
/** * Add a number of IntFromRequest adapters to a container. * @param toContainer the container to add to * @param names the list of names to make adapters from */ public static void addIntegerRequestParameters(MutablePicoContainer toContainer, String... names) { for (String name : names) { toContainer.addAdapter(new IntFromRequest(name)); } }
/** * Add a number of StringFromRequest adapters to a container. * @param toContainer the container to add to * @param names the list of names to make adapters from */ public static void addStringRequestParameters(MutablePicoContainer toContainer, String... names) { for (String name : names) { toContainer.addAdapter(new StringFromRequest(name)); } }
void component(final Scope scope, final ComponentAdapter componentAdapter) { // needs to do some smarts to work out if available scope.get(registry).register(componentAdapter); container.addAdapter(componentAdapter); }
public final void instantiateAndBindComponents(){ for (Class<?> implementation : getImplementations()){ ConstructorInjector constructorInjector = new ConstructorInjector(implementation); container.addAdapter(constructorInjector); } }
private void checkInitialization(Class<?> requiredType, Class<?> type) { if (type.isAnnotationPresent(ApplicationScoped.class) && initialized) { logger.warn("VRaptor was already initialized, the contexts were created but you are registering a component." + "This is nasty. The original component might already be in use." + "Avoid doing it: " + requiredType.getName()); this.appContainer.addComponent(requiredType, type); if (isComponentFactory(requiredType, type)) { Class<?> targetType = new ComponentFactoryIntrospector().targetTypeForComponentFactory(type); this.appContainer.addAdapter(new PicoComponentAdapter(targetType, (Class<? extends ComponentFactory<?>>) type)); } } }
private void populateContainer(String resourcePath, MutablePicoContainer container) { PicoContainer buildContainer = buildContainer(resourcePath, container.getParent()); for (ComponentAdapter<?> adapter : buildContainer.getComponentAdapters()) { container.addAdapter(adapter); } }
/** * populate container for given path. cache result in container recorders * * @param container the MutablePicoContainer used by the recorder * @param path the String representing the servlet path used as key for the * recorder cache */ private void populateContainer(String resourcePath, MutablePicoContainer container) { PicoContainer buildContainer = buildContainer(resourcePath, container.getParent()); for (ComponentAdapter<?> adapter : buildContainer.getComponentAdapters()) { container.addAdapter(adapter); } }
public void init(FilterConfig filterConfig) throws ServletException { ServletContext context = filterConfig.getServletContext(); ScopedContainers scopedContainers = getScopedContainers(context); setAppContainer(scopedContainers.getApplicationContainer()); isStateless = Boolean.parseBoolean(context.getInitParameter(PicoServletContainerListener.STATELESS_WEBAPP)); printSessionSize = Boolean.parseBoolean(context.getInitParameter(PicoServletContainerListener.PRINT_SESSION_SIZE)); String exposeServletInfrastructureString = filterConfig.getInitParameter("exposeServletInfrastructure"); if (exposeServletInfrastructureString == null || Boolean.parseBoolean(exposeServletInfrastructureString)) { exposeServletInfrastructure = true; } scopedContainers.getRequestContainer().as(Characteristics.NO_CACHE).addAdapter(new HttpSessionInjector()); scopedContainers.getRequestContainer().as(Characteristics.NO_CACHE).addAdapter(new HttpServletRequestInjector()); scopedContainers.getRequestContainer().as(Characteristics.NO_CACHE).addAdapter(new HttpServletResponseInjector()); initAdditionalScopedComponents(scopedContainers.getSessionContainer(), scopedContainers.getRequestContainer()); }
/** * Add CompilerDataComponent by processing command line args * * @param args command line args passed to the main */ public void processCompileDataFromArgs(String[] args) { getContainer().addAdapter(new ProviderAdapter(new CompilerDataProvider(args))); }
/** * @param singleton return always the same instance if true, else a new instance * is returned each time the component is requested */ public ComponentContainer addComponent(Object component, boolean singleton) { Object key = componentKeys.of(component); if (component instanceof ComponentAdapter) { pico.addAdapter((ComponentAdapter) component); } else { pico.as(singleton ? Characteristics.CACHE : Characteristics.NO_CACHE).addComponent(key, component); declareExtension(null, component); } return this; }
/** * @param singleton return always the same instance if true, else a new instance * is returned each time the component is requested */ public ComponentContainer addComponent(Object component, boolean singleton) { Object key = componentKeys.of(component); if (component instanceof ComponentAdapter) { pico.addAdapter((ComponentAdapter) component); } else { try { pico.as(singleton ? Characteristics.CACHE : Characteristics.NO_CACHE).addComponent(key, component); } catch (Throwable t) { throw new IllegalStateException("Unable to register component " + getName(component), t); } declareExtension("", component); } return this; }
/** * Registers components with the container. * * @param container the container */ @Override protected void registerComponents(MutablePicoContainer container) { super.registerComponents(container); container .addAdapter(new ProviderAdapter(new AutomatedInstallDataProvider())) .addAdapter(new ProviderAdapter(new AutomatedPanelsProvider())); container .addComponent(AutomatedPrompt.class) .addComponent(AutomatedInstaller.class) .addComponent(ConsolePanelAutomationHelper.class) .addComponent(ConsolePackResources.class) .addComponent(MultiVolumeUnpackerAutomationHelper.class); } }