@Override public void afterStop(ComponentManager mgr, boolean isStandby) { Framework.getRuntime().getComponentManager().removeListener(this); } });
public static Collection<RegistrationInfo> getComponents() { return Framework.getRuntime().getComponentManager().getRegistrations(); }
/** * @deprecated since 9.3, this method is only used in deployBundles and undeployBundles which are deprecated. Keep * it for backward compatibility. */ @Deprecated protected void refreshComponents() { String reloadStrategy = Framework.getProperty(RELOAD_STRATEGY_PARAMETER, RELOAD_STRATEGY_VALUE_DEFAULT); log.info("Refresh components. Strategy={}", reloadStrategy); // reload components / contributions ComponentManager mgr = Framework.getRuntime().getComponentManager(); switch (reloadStrategy) { case RELOAD_STRATEGY_VALUE_UNSTASH: // compat mode mgr.unstash(); break; case RELOAD_STRATEGY_VALUE_STANDBY: // standby / resume mgr.standby(); mgr.unstash(); mgr.resume(); break; case RELOAD_STRATEGY_VALUE_RESTART: default: // restart mode mgr.refresh(false); break; } }
protected void tryDeploy() { // the registry is updated here and not using before or teardown methods. // this approach ensure the components are not stopped between tearDown and the next test // (so that custom feature that relly on the runtime between the two tests are not affected by stopping // components) ComponentManager mgr = harness.getContext().getRuntime().getComponentManager(); // the stash may already contains contribs (from @Setup methods) if (mgr.hasChanged()) { // first reset the registry if it was changed by the last test mgr.reset(); // the registry is now stopped } // deploy current test contributions if any deploy(runner, harness); mgr.refresh(true); // now the stash is empty mgr.start(); // ensure components are started }
log.info("Before stop/standby component manager"); if (RELOAD_STRATEGY_VALUE_RESTART.equals(reloadStrategy)) { componentManager.stop(); } else { componentManager.standby(); componentManager.unstash(); componentManager.unstash(); log.info("Before start/resume component manager"); if (RELOAD_STRATEGY_VALUE_RESTART.equals(reloadStrategy)) { componentManager.start(); } else { componentManager.resume();
@Override public void start(ComponentContext context) { TransactionHelper.runInTransaction(this::doCreateRepositories); Framework.getRuntime().getComponentManager().addListener(new ComponentManager.Listener() { @Override public void afterStart(ComponentManager mgr, boolean isResume) { initRepositories(); // call all RepositoryInitializationHandler } @Override public void afterStop(ComponentManager mgr, boolean isStandby) { Framework.getRuntime().getComponentManager().removeListener(this); } }); }
/** * Should be called by subclasses after one or more inline deployments are made inside a test method. Without * calling this the inline deployment(s) will not have any effects. * <p /> * <b>Be Warned</b> that if you reference runtime services or components you should lookup them again after calling * this method! * <p /> * This method also calls {@link #postSetUp()} for convenience. */ protected void applyInlineDeployments() throws Exception { runtime.getComponentManager().refresh(false); runtime.getComponentManager().start(); // make sure components are started postSetUp(); }
/** * Should be called by subclasses to remove any inline deployments made in the current test method. * <p /> * <b>Be Warned</b> that if you reference runtime services or components you should lookup them again after calling * this method! * <p /> * This method also calls {@link #postSetUp()} for convenience. */ protected void removeInlineDeployments() throws Exception { runtime.getComponentManager().reset(); runtime.getComponentManager().start(); postSetUp(); }
public void undeploy(String... contribs) throws Exception { if (contribs != null && contribs.length > 0) { for (String contrib : contribs) { int i = contrib.indexOf(':'); if (i == -1) { throw new InvalidParameterException("Cannot undeploy bundle " + contrib); } harness.undeployContrib(contrib.substring(0, i), contrib.substring(i + 1)); } } // use false to prevent removing the local test method deployments Framework.getRuntime().getComponentManager().refresh(false); }
@Override public void start(ComponentContext context) { if (config == null || config.getDataFileName() == null) { return; } Framework.getRuntime().getComponentManager().addListener(new ComponentManager.Listener() { @Override public void afterStart(ComponentManager mgr, boolean isResume) { // needs to run after RepositoryInitializationHandlers, run by RepositoryService scheduleImport(); } @Override public void afterStop(ComponentManager mgr, boolean isStandby) { Framework.getRuntime().getComponentManager().removeListener(this); } }); }
public void deploy(String... contribs) throws Exception { if (contribs != null && contribs.length > 0) { for (String contrib : contribs) { int i = contrib.indexOf(':'); if (i > -1) { String bundleId = contrib.substring(0, i); if (bundleId.startsWith("@")) { bundleId = bundleId.substring(1); harness.deployTestContrib(bundleId, contrib.substring(i + 1)); } else { harness.deployContrib(bundleId, contrib.substring(i + 1)); } } else { harness.deployBundle(contrib); } } } // use false to prevent removing the local test method deployments Framework.getRuntime().getComponentManager().refresh(false); }
@Override public void afterStop(ComponentManager mgr, boolean isStandby) { Framework.getRuntime().getComponentManager().removeListener(this); } });
Framework.getRuntime().getComponentManager().addListener(new ComponentManager.Listener() { @Override public void beforeStop(ComponentManager mgr, boolean isStandby) {
public static synchronized SimplifiedServerInfo getInfo() { if (info == null) { RuntimeService runtime = Framework.getRuntime(); Collection<RegistrationInfo> registrations = runtime.getComponentManager().getRegistrations(); bundleIds = new ArrayList<>(); List<SimplifiedBundleInfo> bundles = new ArrayList<>(); for (RegistrationInfo ri : registrations) { Bundle bundle = ri.getContext().getBundle(); if (bundle != null && !bundleIds.contains(bundle.getSymbolicName())) { SimplifiedBundleInfo bi = getBundleSimplifiedInfo(bundle); bundleIds.add(bundle.getSymbolicName()); if (bi != null) { bundles.add(bi); } } } Collections.sort(bundles); info = new SimplifiedServerInfo(); info.setBundleInfos(bundles); info.setRuntimeVersion(runtime.getVersion().toString()); info.setWarnings(runtime.getWarnings()); } return info; }
@Override public void afterStop(ComponentManager mgr, boolean isStandby) { Framework.getRuntime().getComponentManager().removeListener(this); } });
@Override @SuppressWarnings("deprecation") public void start(ComponentContext context) { backend = backendConfig.newInstance(this); backend.onApplicationStarted(); if (Framework.isBooleanPropertyFalse(STREAM_AUDIT_ENABLED_PROP)) { bulker = bulkerConfig.newInstance(backend); bulker.onApplicationStarted(); } // init storages after runtime was started (as we don't have started order for storages which are backends) Framework.getRuntime().getComponentManager().addListener(new Listener() { @Override public void afterStart(ComponentManager mgr, boolean isResume) { for (Entry<String, AuditStorageDescriptor> descriptor : auditStorageDescriptors.entrySet()) { AuditStorage storage = descriptor.getValue().newInstance(); if (storage instanceof AuditBackend) { ((AuditBackend) storage).onApplicationStarted(); } auditStorages.put(descriptor.getKey(), storage); } } @Override public void afterStop(ComponentManager mgr, boolean isStandby) { uninstall(); } }); }
public static synchronized SimplifiedServerInfo getInfo() { if (info == null) { RuntimeService runtime = Framework.getRuntime(); Collection<RegistrationInfo> registrations = runtime.getComponentManager().getRegistrations(); bundleIds = new ArrayList<>(); List<SimplifiedBundleInfo> bundles = new ArrayList<>(); for (RegistrationInfo ri : registrations) { Bundle bundle = ri.getContext().getBundle(); if (bundle != null && !bundleIds.contains(bundle.getSymbolicName())) { SimplifiedBundleInfo bi = getBundleSimplifiedInfo(bundle); bundleIds.add(bundle.getSymbolicName()); if (bi != null) { bundles.add(bi); } } } Collections.sort(bundles); info = new SimplifiedServerInfo(); info.setBundleInfos(bundles); info.setRuntimeVersion(runtime.getVersion().toString()); RuntimeMessageHandler runtimeMessageHandler = runtime.getMessageHandler(); info.setWarnings(runtimeMessageHandler.getWarnings()); info.setErrors(runtimeMessageHandler.getErrors()); } return info; }
@Override public void beforeStop(ComponentManager mgr, boolean isStandby) { // this is called before components are stopped stopComputations(); Framework.getRuntime().getComponentManager().removeListener(this); } }