@Override public Object getComponent(final Object componentKeyOrType, final Class<? extends Annotation> annotation) { try { return super.getComponent(componentKeyOrType, annotation); } catch (Throwable t) { throw new IllegalStateException("Unable to load component " + componentKeyOrType, t); } }
/** * Get internal component. * * @param componentType component type class * @param <T> component type * @return component */ public <T> T getComponent(Class<T> componentType) { return m_container.getComponent(componentType); } }
/** * Run agent controller in synchronized way. */ public void run() { if (m_shutdown) { throw processException("The console can not be run because it's already shutdown"); } m_container.start(); m_container.getComponent(AgentProcessControlImplementation.class); ConsoleCommunication communication = m_container.getComponent(ConsoleCommunication.class); synchronized (m_eventSyncCondition) { // Now ready to work m_eventSyncCondition.notifyAll(); } // CHECKSTYLE:OFF while (communication.processOneMessage()) { noOp(); // Fall through // Process until communication is shut down. } }
/** * Shut down the console. * */ public void shutdown() { m_shutdown = true; m_container.getComponent(ConsoleCommunication.class).shutdown(); try { m_timer.cancel(); } catch (Exception e) { // Fall through noOp(); } if (m_container.getLifecycleState().isStarted()) { m_container.stop(); } }
@Override public Object getComponent(final Object componentKeyOrType, final Class<? extends Annotation> annotation) { try { return super.getComponent(componentKeyOrType, annotation); } catch (Throwable t) { throw new IllegalStateException("Unable to load component " + componentKeyOrType, t); } }
/** * Constructor. * * @param resources message resource * @param logger logger * @param properties {@link ConsoleProperties} * @param eventSyncCondition event synchronized condition to synchronize server stop phase. */ public AgentControllerServer(Resources resources, Logger logger, ConsoleProperties properties, Condition eventSyncCondition, ConsoleCommunicationSetting consoleCommunicationSetting) { m_eventSyncCondition = eventSyncCondition; m_container = new DefaultPicoContainer(new Caching()); m_container.addComponent(logger); m_container.addComponent(resources); m_container.addComponent(properties); m_container.addComponent(new StandardTimeAuthority()); m_container.addComponent(consoleCommunicationSetting); m_container.addComponent(ConsoleCommunicationImplementationEx.class); m_container.addComponent(AgentProcessControlImplementation.class); m_timer = new Timer(true); m_container.addComponent(m_timer); // m_container.addComponent(WireEnhancedProcessReportMessage.class); m_container.addComponent(ErrorQueue.class); ErrorQueue errorQueue = m_container.getComponent(ErrorQueue.class); errorQueue.setErrorHandler(new ErrorHandlerImplementation(logger)); }
public TCPProxyFilter resolveFilter() { if (m_filterKeys.size() == 0) { add(EchoFilter.class); } final CompositeFilter result = new CompositeFilter(); for (String key : m_filterKeys) { result.add((TCPProxyFilter) m_filterContainer.getComponent(key)); } return result; } }
/** * process adapter node * * @param container * @param rootElement */ @SuppressWarnings("unchecked") protected void insertAdapter(MutablePicoContainer container, Element rootElement) { String key = rootElement.getAttribute(KEY); String klass = rootElement.getAttribute(CLASS); try { DefaultPicoContainer nested = new DefaultPicoContainer(); populateContainer(nested, rootElement); if (key != null) { container.addAdapter((ComponentAdapter) nested.getComponent(key)); } else if (klass != null) { Class clazz = getClassLoader().loadClass(klass); container.addAdapter((ComponentAdapter) nested.getComponent(clazz)); } else { container.addAdapter(nested.getComponent(ComponentAdapter.class)); } } catch (ClassNotFoundException ex) { throw new ScriptedPicoContainerMarkupException(ex); } }
public ClassLoadingPicoContainer build() { DefaultPicoContainer tpc = new TransientPicoContainer(); tpc.addComponent(ClassLoader.class, classLoader); tpc.addComponent("sc", scriptClass); tpc.addComponent(MutablePicoContainer.class, picoBuilder.build()); ClassLoadingPicoContainer pico = (ClassLoadingPicoContainer) tpc.getComponent("sc"); for (URL url : urls) { pico.addClassLoaderURL(url); } return pico; }