PicoBasedContainer provideRequestContainer(RequestInfo request) { HttpSession session = request.getRequest().getSession(); MutablePicoContainer sessionScope = (MutablePicoContainer) session.getAttribute(CONTAINER_SESSION_KEY); if (sessionScope == null) { sessionScope = createSessionContainer(session); } if (logger.isDebugEnabled()) { logger.debug("Request components are " + requestScoped); } MutablePicoContainer requestContainer = new DefaultPicoContainer( new Caching(), new JavaEE5LifecycleStrategy(new NullComponentMonitor()), sessionScope); for (Map.Entry<Class<?>, Class<?>> entry : requestScoped.entrySet()) { requestContainer.addComponent(entry.getKey(), entry.getValue()); } for (Map.Entry<Class<?>, Class<?>> entry : prototypeScoped.entrySet()) { requestContainer.as(Characteristics.NO_CACHE).addComponent(entry.getKey(), entry.getValue()); } requestContainer .addComponent(request) .addComponent(request.getRequest()) .addComponent(request.getResponse()); registerComponentFactories(requestContainer, componentFactoryRegistry.getRequestMap()); return new PicoBasedContainer(requestContainer, this.appContainer.getComponent(Router.class)); }
private void init() { log.info("creating Saros runtime context..."); /* * All singletons which exist for the whole plug-in life-cycle are * managed by PicoContainer for us. */ PicoBuilder picoBuilder = new PicoBuilder( new CompositeInjection(new ConstructorInjection(), new AnnotatedFieldInjection())) .withCaching() .withLifecycle(); /* * If given, the dotMonitor is used to capture an architecture diagram * of the application */ if (dotMonitor != null) picoBuilder = picoBuilder.withMonitor(dotMonitor); // Initialize our dependency injection container container = picoBuilder.build(); // Add Adapter which creates ChildContainers container .as(Characteristics.NO_CACHE) .addAdapter(new ProviderAdapter(new ChildContainerProvider(this.container))); for (ISarosContextFactory factory : factories) { factory.createComponents(container); } container.addComponent(ISarosContext.class, this); /* * Create a reinjector to allow platform specific stuff to reinject * itself into the context. */ reinjector = new Reinjector(container); initAccountStore(container.getComponent(XMPPAccountStore.class)); installPacketExtensionProviders(); XMPPUtils.setDefaultConnectionService(container.getComponent(XMPPConnectionService.class)); log.info("successfully created Saros runtime context"); }
public MutablePicoContainer as(final Properties... properties) { return delegate.as(properties); }