@Deactivate void deactivate(ComponentContext compContext) { logger.debug("Deactivating Service {}", compContext); cleanup(); if (embeddedServer != null) { embeddedServer.deactivate(); } logger.info("Repository stopped."); }
@Activate void activate(ComponentContext compContext) throws Exception { logger.debug("Activating Service with configuration {}", compContext.getProperties()); try { existingConfig = enhancedConfig.getConfigurationAsJson(compContext); } catch (RuntimeException ex) { logger.warn( "Configuration invalid and could not be parsed, can not start OrientDB repository: " + ex.getMessage(), ex); throw ex; } embeddedServer = new EmbeddedOServerService(); embeddedServer.activate(existingConfig); init(existingConfig); logger.info("Repository started."); }
/** * Handle an existing activated service getting changed; e.g. configuration changes or dependency * changes * * @param compContext THe OSGI component context * @throws Exception if handling the modified event failed */ @Modified void modified(ComponentContext compContext) throws Exception { logger.debug("Handle repository service modified notification"); JsonValue newConfig = null; try { newConfig = enhancedConfig.getConfigurationAsJson(compContext); } catch (RuntimeException ex) { logger.warn( "Configuration invalid and could not be parsed, can not start OrientDB repository", ex); throw ex; } if (existingConfig != null && !existingConfig.get("embeddedServer").equals(newConfig.get("embeddedServer"))) { // The embedded server configuration has changed so re-initialize it. embeddedServer.modified(newConfig); } if (existingConfig != null && user.equals(getUser(newConfig)) && password.equals(getPassword(newConfig)) && dbURL.equals(getDBUrl(newConfig)) && poolMinSize == getPoolMinSize(newConfig) && poolMaxSize == getPoolMaxSize(newConfig)) { // If the DB pool settings don't change keep the existing pool logger.info("(Re-)initialize repository with latest configuration."); } else { // If the DB pool settings changed do a more complete re-initialization logger.info( "Re-initialize repository with latest configuration - including DB pool setting changes."); DBHelper.closePool(dbURL, pool); } init(newConfig); if (bootRepo != null) { bootRepo.init(newConfig); } existingConfig = newConfig; logger.debug("Repository service modified"); }