/** * Starts the plugin deployer which will effectively ask the plugin deployer to persist * information about all detected agent and server plugins. * * <p>Because this will scan and register the initial plugins right now, make sure this is called * prior to starting the master plugin container; otherwise, the master PC will not have any * plugins to start. * * @throws RuntimeException */ private void startPluginDeployer() throws RuntimeException { log.info("Starting the agent/server plugin deployer..."); try { PluginDeploymentScannerMBean deployer = getPluginDeploymentScanner(); deployer.startDeployment(); } catch (Exception e) { throw new RuntimeException("Cannot start the agent/server plugin deployer!", e); } }
@Timeout // does AS7 EJB3 container allow this? We do not want a tx here! @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public void scanForPlugins(final Timer timer) { try { PluginDeploymentScannerMBean deployer = getPluginDeploymentScanner(); deployer.scanAndRegister(); } catch (Throwable t) { log.error("Plugin scan failed. Cause: " + ThrowableUtil.getAllMessages(t)); if (log.isDebugEnabled()) { log.debug("Plugin scan failure stack trace follows:", t); } } }
public void unpreparePluginScannerService() throws Exception { if (pluginScannerService != null) { pluginScannerService.stop(); pluginScannerService = null; } MBeanServer mbs = getPlatformMBeanServer(); if (mbs.isRegistered(PluginDeploymentScannerMBean.OBJECT_NAME)) { mbs.unregisterMBean(PluginDeploymentScannerMBean.OBJECT_NAME); } }
/** * Creates the timer that will trigger periodic scans for new plugins. * * @throws RuntimeException */ private void registerPluginDeploymentScannerJob() throws RuntimeException { log.info("Creating timer to begin scanning for plugins..."); try { PluginDeploymentScannerMBean deployer = getPluginDeploymentScanner(); long scanPeriod = 5 * 60000L; try { String scanPeriodString = deployer.getScanPeriod(); scanPeriod = Long.parseLong(scanPeriodString); } catch (Exception e) { log.warn("could not determine plugin scanner scan period - using: " + scanPeriod, e); } // create a non-persistent periodic timer (we'll reset it ever startup) with the scan period // as configured in our scanner object timerService.createIntervalTimer(scanPeriod, scanPeriod, new TimerConfig(null, false)); } catch (Exception e) { throw new RuntimeException( "Cannot schedule plugin scanning timer - new plugins will not be detected!", e); } }
/** * Note that the standard plugin scanner service is deployed automatically with the test rhq ear, * this is only necessary if you want a custom service. * * @param scannerService */ public PluginDeploymentScannerMBean preparePluginScannerService( PluginDeploymentScannerMBean scannerService) { try { MBeanServer mbs = getPlatformMBeanServer(); if (mbs.isRegistered(PluginDeploymentScannerMBean.OBJECT_NAME)) { mbs.unregisterMBean(PluginDeploymentScannerMBean.OBJECT_NAME); } // Now replace with the test service... mbs.registerMBean(scannerService, PluginDeploymentScannerMBean.OBJECT_NAME); pluginScannerService = scannerService; pluginScannerService.start(); return pluginScannerService; } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(e); } }