public ComponentAdapter createComponentAdapter(Object componentKey, Class componentImplementation, Parameter[] parameters) throws PicoIntrospectionException, AssignabilityRegistrationException, NotConcreteRegistrationException { return new CachingComponentAdapter(super.createComponentAdapter(componentKey, componentImplementation, parameters)); } }
/** * Disposes the cached component instance * {@inheritDoc} */ public void dispose(PicoContainer container) { if ( delegateHasLifecylce ){ if (disposed) throw new IllegalStateException("Already disposed"); dispose(getComponentInstance(container)); disposed = true; } }
/** * Starts the cached component instance * {@inheritDoc} */ public void start(PicoContainer container) { if ( delegateHasLifecylce ){ if (disposed) throw new IllegalStateException("Already disposed"); if (started) throw new IllegalStateException("Already started"); start(getComponentInstance(container)); started = true; } }
/** * Stops the cached component instance * {@inheritDoc} */ public void stop(PicoContainer container) { if ( delegateHasLifecylce ){ if (disposed) throw new IllegalStateException("Already disposed"); if (!started) throw new IllegalStateException("Not started"); stop(getComponentInstance(container)); started = false; } }
/** * Flushes the cache. * If the component instance is started is will stop and dispose it before * flushing the cache. */ public void flush() { Object instance = instanceReference.get(); if ( instance != null && delegateHasLifecylce && started ) { stop(instance); dispose(instance); } instanceReference.set(null); }
/** * Construct a ThreadLocalComponentAdapter using {@link Proxy} instances. * * @param delegate The {@link ComponentAdapter} to delegate. * @throws PicoIntrospectionException Thrown if the component does not implement any interface. */ public ThreadLocalComponentAdapter(final ComponentAdapter delegate) throws PicoIntrospectionException { this(new CachingComponentAdapter(delegate, new ThreadLocalReference()), new StandardProxyFactory()); }
/** * Construct a ThreadLocalComponentAdapter. * * @param delegate The {@link ComponentAdapter} to delegate. * @param proxyFactory The {@link ProxyFactory} to use. * @throws PicoIntrospectionException Thrown if the component does not implement any interface. */ public ThreadLocalComponentAdapter(final ComponentAdapter delegate, final ProxyFactory proxyFactory) throws PicoIntrospectionException { super(new CachingComponentAdapter(delegate, new ThreadLocalReference())); this.proxyFactory = proxyFactory; interfaces = getInterfaces(); }
public ComponentAdapter createComponentAdapter(Object componentKey, Class componentImplementation, Parameter[] parameters) throws PicoIntrospectionException, AssignabilityRegistrationException, NotConcreteRegistrationException { return new CachingComponentAdapter(new ConstructorInjectionComponentAdapter(componentKey, componentImplementation, parameters, false, currentMonitor(), lifecycleStrategy)); }
private static void registerORBServices(final MutablePicoContainer container) { // register services that need to be looked up via orb using custom componentadapter // POA container.registerComponent(new CachingComponentAdapter(new BiDirGiopPOAComponentAdapter(new POAComponentAdapter()))); // DynAnyFactory container.registerComponent(new CachingComponentAdapter(new DynAnyFactoryComponentAdapter())); // Configuration container.registerComponent(new CachingComponentAdapter(new ConfigurationComponentAdapter())); // FilterFactory container.registerComponent(new CachingComponentAdapter(new FilterFactoryComponentAdapter())); // IFR container.registerComponent(new CachingComponentAdapter(new RepositoryComponentAdapter())); // CurrentTimeUtil container.registerComponent(new CurrentTimeUtilComponentAdapter()); }
public ComponentAdapter createComponentAdapter( Object componentKey, Class componentImplementation, Parameter[] parameters) throws PicoIntrospectionException, AssignabilityRegistrationException, NotConcreteRegistrationException { final ComponentAdapter componentAdapter; if (ensureThreadLocal) { componentAdapter = new ThreadLocalComponentAdapter(super.createComponentAdapter( componentKey, componentImplementation, parameters), proxyFactory); } else { componentAdapter = new CachingComponentAdapter(super.createComponentAdapter( componentKey, componentImplementation, parameters), new ThreadLocalReference()); } return componentAdapter; }
private static void registerEvaluationContextFactory(final MutablePicoContainer container) { // PoolingEvaluationContextFactory depends on DefaultEvaluationContextFactory. // however both implement the same interface users depend on which causes an ambiguity. // therefore DefaultEvaluationContextFactory should be only visible to PoolingEvaluationContextFactory. final ConstructorInjectionComponentAdapter _serviceCA = new ConstructorInjectionComponentAdapter(DefaultEvaluationContextFactory.class, DefaultEvaluationContextFactory.class); final ConstructorInjectionComponentAdapter _poolingServiceCA = new ConstructorInjectionComponentAdapter(EvaluationContextFactory.class, PoolingEvaluationContextFactory.class, new Parameter[] {BasicComponentParameter.BASIC_DEFAULT, new BasicComponentParameter(DefaultEvaluationContextFactory.class)}); final LocalParameterComponentAdapter _localParamCA = new LocalParameterComponentAdapter(_poolingServiceCA, new ComponentAdapter[] {_serviceCA}); final ComponentAdapter _cachingCA = new CachingComponentAdapter(_localParamCA); container.registerComponent(_cachingCA); }
public SupplierAdminImpl(IEventChannel channelServant, ORB orb, POA poa, Configuration config, MessageFactory messageFactory, OfferManager offerManager, SubscriptionManager subscriptionManager) { super(channelServant, orb, poa, config, messageFactory, offerManager, subscriptionManager); thisCorbaRef_ = SupplierAdminHelper.narrow(activate()); container_.registerComponent(new CachingComponentAdapter(new CORBAObjectComponentAdapter( SupplierAdmin.class, thisCorbaRef_))); registerDisposable(new Disposable() { public void dispose() { container_.unregisterComponent(SupplierAdmin.class); } }); }
private static void registerCoreServices(final MutablePicoContainer container) { container.registerComponent(new CachingComponentAdapter( new PushTaskExecutorFactoryComponentAdapter( new ConstructorInjectionComponentAdapter(PushTaskExecutorFactory.class, ConfigurablePushTaskExecutorFactory.class)))); // etcl evaluator container.registerComponentImplementation(DefaultETCLEvaluator.class); // message factory container.registerComponentImplementation(DefaultMessageFactory.class); // taskprocessor container.registerComponentImplementation(DefaultTaskFactory.class); container.registerComponentImplementation(DefaultTaskProcessor.class); registerEvaluationContextFactory(container); }
container_.registerComponent(new CachingComponentAdapter(new CORBAObjectComponentAdapter( ConsumerAdmin.class, _thisRef)));