@Deactivate void deactivate() throws Exception { if (registeredListener && mBeanServer != null) { mBeanServer.removeNotificationListener(MBeanServerDelegate.DELEGATE_NAME, listener); } // lets remove all the previously generated paths List<String> paths = new ArrayList<String>(registeredZkPaths); for (String path : paths) { removeZkPath(path); } deactivateComponent(); versionNodeMonitor.getListenable().removeListener(this); Closeables.closeQuietly(versionNodeMonitor); versionNodeMonitor = null; }
/** * When {@link FabricService} becomes available, we can initialize this {@link PlaceholderResolver} * @param fabricService */ public void initialize(FabricService fabricService) { this.fabricService = fabricService; encryptor = getEncryptor(fabricService); if (bundleContext != null) { seRegistration = bundleContext.registerService(PBEStringEncryptor.class, encryptor, null); BundleContext context = FrameworkUtil.getBundle(PersistenceManager.class).getBundleContext(); encryptingPersistenceManager = new EncryptingPersistenceManager( context, context.getProperty(ConfigurationManager.CM_CONFIG_DIR), encryptor); originalPersistenceManager = inject(configAdmin, encryptingPersistenceManager); passwordNodeCache = new NodeCacheExtended(fabricService.adapt(CuratorFramework.class), AUTHENTICATION_CRYPT_PASSWORD.getPath()); passwordNodeCache.getListenable().addListener(this); alogrithmNodeCache = new NodeCacheExtended(fabricService.adapt(CuratorFramework.class), AUTHENTICATION_CRYPT_ALGORITHM.getPath()); alogrithmNodeCache.getListenable().addListener(this); try { passwordNodeCache.start(); alogrithmNodeCache.start(); } catch (Exception e) { throw new FabricException(e); } } }
@Activate void activate() throws Exception { activateComponent(); if (mBeanServer == null) { mBeanServer = ManagementFactory.getPlatformMBeanServer(); } if (mBeanServer != null) { Object handback = null; mBeanServer.addNotificationListener(MBeanServerDelegate.DELEGATE_NAME, listener, filter, handback); this.registeredListener = true; } String id = getCurrentContainer().getId(); String zkPath = ZkPath.CONFIG_CONTAINER.getPath(id); versionNodeMonitor = new NodeCacheExtended(curator.get(), zkPath); versionNodeMonitor.getListenable().addListener(this); versionNodeMonitor.start(); replay(); }