/** * This method must be called if overwritten by implementations !! * * @param componentContext */ @Deactivate private void deactivate(final ComponentContext componentContext) { super.stop(); this.adminUserName = null; this.componentContext = null; this.namespaceMapperRefs.clear(); this.namespaceMappers = null; }
@Override public Object getService(Bundle bundle, ServiceRegistration registration) { return AbstractSlingRepositoryManager.this.create(bundle); }
@Override public void ungetService(Bundle bundle, ServiceRegistration registration, Object service) { AbstractSlingRepositoryManager.this.destroy((AbstractSlingRepository2) service); } }, props);
try { log.debug("start: calling acquireRepository()"); Repository newRepo = this.acquireRepository(); if (newRepo != null) { if ( stopRequested ) { log.debug("Stop requested, cancelling initialisation and stopping repository"); stop(); return; this.masterSlingRepository = this.create(this.bundleContext.getBundle()); executeRepositoryInitializers(this.masterSlingRepository); } catch(Throwable e) { t = e; this.repositoryService = registerService(); if (t != null) { stop();
if (repository != null || isRepositoryServiceRegistered()) { log.info("stop: Repository still running, forcing shutdown"); if (isRepositoryServiceRegistered()) { try { log.debug("stop: Unregistering SlingRepository service, registration=" + repositoryService); unregisterService(repositoryService); } catch (Throwable t) { log.info("stop: Uncaught problem unregistering the repository service", t); this.destroy(this.masterSlingRepository); disposeRepository(oldRepo); } catch (Throwable t) { log.info("stop: Uncaught problem disposing the repository", t);
protected final boolean start(final BundleContext bundleContext, final String defaultWorkspace, final boolean disableLoginAdministrative) { start(bundleContext, new Config(defaultWorkspace, disableLoginAdministrative)); long end = System.currentTimeMillis() + 5000; // wait up to 5 seconds for repository registration while (!isRepositoryServiceRegistered() && end > System.currentTimeMillis()) { try { TimeUnit.MILLISECONDS.sleep(100); return isRepositoryServiceRegistered();
/** * This method must be called if overwritten by implementations !! */ @Activate private void activate(final ComponentContext componentContext) throws Exception { this.componentContext = componentContext; @SuppressWarnings("unchecked") Dictionary<String, Object> properties = componentContext.getProperties(); final String defaultWorkspace = PropertiesUtil.toString(properties.get(PROPERTY_DEFAULT_WORKSPACE), null); final boolean disableLoginAdministrative = !PropertiesUtil.toBoolean( properties.get(PROPERTY_LOGIN_ADMIN_ENABLED), DEFAULT_LOGIN_ADMIN_ENABLED); this.adminUserName = PropertiesUtil.toString(properties.get(PROPERTY_ADMIN_USER), DEFAULT_ADMIN_USER); super.start(componentContext.getBundleContext(), defaultWorkspace, disableLoginAdministrative); }
/** * Login as an administrative user. This method is deprecated and its use * can be completely disabled by setting {@code disableLoginAdministrative} * to {@code true}. * <p> * This implementation cannot be overwritten but, unless disabled, forwards * to the {@link #createAdministrativeSession(String)} method. * * @param workspace The workspace to access or {@code null} to access the * {@link #getDefaultWorkspace() default workspace} * @return An administrative session * @throws RepositoryException If the login fails or has been disabled */ @Override public final Session loginAdministrative(final String workspace) throws RepositoryException { final boolean whitelisted = getSlingRepositoryManager().allowLoginAdministrativeForBundle(usingBundle); if(!whitelisted) { final String symbolicName = usingBundle.getSymbolicName(); logger.error("Bundle {} is NOT whitelisted to use SlingRepository.loginAdministrative", symbolicName); throw new LoginException("Bundle " + symbolicName +" is NOT whitelisted"); } else if (this.getSlingRepositoryManager().isDisableLoginAdministrative()) { logger.error("SlingRepository.loginAdministrative is disabled. Please use SlingRepository.loginService."); throw new LoginException("SlingRepository.loginAdministrative is disabled."); } logger.debug("SlingRepository.loginAdministrative is deprecated. Please use SlingRepository.loginService."); return createAdministrativeSession(workspace); }
/** * Returns the actual repository to which all JCR Repository interface * methods implemented by this class are delegated. * * @return The delegated repository. */ protected final Repository getRepository() { return this.getSlingRepositoryManager().getRepository(); }
/** * Returns the default workspace to login to if any of the {@code login} and * {@code createSession} methods is called without an explicit workspace * name. * <p> * This method may return {@code null} in which case the actual default * workspace used depends on the underlying JCR Repository implementation. */ @Override public final String getDefaultWorkspace() { return this.getSlingRepositoryManager().getDefaultWorkspace(); }