@Override protected void onStop() throws Exception { getEventsHandler().removeListener(this); for (String channelName : getChannelNames()) { try { unregisterFeedbackChannel(channelName); } catch (IOException exception) { logWarning("Failed to close feedback channel '%s'", exception, channelName); } } }
@Override protected void onStart() throws Exception { // Make sure the default audit log is present... registerFeedbackChannel(AUDITLOG_FEEDBACK_CHANNEL); }
Set<String> seen = new HashSet<>(m_channels.keySet()); Set<String> channelNames = split(value); if (channelNames.containsAll(seen) && seen.containsAll(channelNames)) { registerFeedbackChannel(channelName); seen.remove(channelName); logError("Failed to created feedback channel for '%s'", exception, channelName); unregisterFeedbackChannel(oldChannelName); logError("Failed to close feedback channel for '%s'", exception, oldChannelName);
@BeforeClass public void setUpAgain() throws Exception { m_agentContextImpl = mockAgentContext(); replayTestMocks(); BundleContext bc = mockBundleContext(); m_agentContextImpl.setHandler(FeedbackHandler.class, new FeedbackHandlerImpl()); m_agentContextImpl.setHandler(EventsHandler.class, new EventsHandlerImpl(bc)); m_agentContextImpl.setHandler(ConfigurationHandler.class, new ConfigurationHandlerImpl(bc)); m_agentContextImpl.start(); }
private void registerFeedbackChannel(String channelName) throws IOException { FeedbackChannelImpl channel = new FeedbackChannelImpl(getAgentContext(), channelName); m_channels.putIfAbsent(channelName, channel); }
@Override protected void onInit() throws Exception { getEventsHandler().addListener(this); }
/** * Called by our {@link DependencyTrackerImpl} when all dependencies are satisfied. */ public void componentStarted(BundleContext context) throws Exception { final File bundleDataArea = context.getDataFile(""); m_agentContext = new AgentContextImpl(bundleDataArea); m_agentContext.setHandler(LoggingHandler.class, new LoggingHandlerImpl(context)); m_agentContext.setHandler(ConfigurationHandler.class, new ConfigurationHandlerImpl(context)); m_agentContext.setHandler(EventsHandler.class, new EventsHandlerImpl(context)); m_agentContext.setHandler(ScheduledExecutorService.class, m_executorService); m_agentContext.setHandler(DownloadHandler.class, new DownloadHandlerImpl(bundleDataArea)); m_agentContext.setHandler(DeploymentHandler.class, new DeploymentHandlerImpl(context, m_packageAdmin)); m_agentContext.setHandler(AgentUpdateHandler.class, new AgentUpdateHandlerImpl(context)); m_agentContext.setHandler(FeedbackHandler.class, new FeedbackHandlerImpl()); IdentificationHandler identificationHandler = (m_identificationHandler != null) ? m_identificationHandler : new IdentificationHandlerImpl(); m_agentContext.setHandler(IdentificationHandler.class, identificationHandler); DiscoveryHandler discoveryHandler = (m_discoveryHandler != null) ? m_discoveryHandler : new DiscoveryHandlerImpl(); m_agentContext.setHandler(DiscoveryHandler.class, discoveryHandler); ConnectionHandler connectionHandler = (m_connectionHandler != null) ? m_connectionHandler : new ConnectionHandlerImpl(); m_agentContext.setHandler(ConnectionHandler.class, connectionHandler); m_agentContext.addComponent(new EventLoggerImpl(context)); // Lastly, inject the (custom) controller for this agent... m_agentContext.setController(m_controller); m_agentContext.start(); m_agentControlRegistration = context.registerService(AgentControl.class.getName(), new AgentControlImpl(m_agentContext), null); }