Search in sources :

Example 6 with Deactivate

use of org.apache.felix.scr.annotations.Deactivate in project sling by apache.

the class LogTracer method deactivate.

@Deactivate
private void deactivate() {
    if (logServlet != null) {
        logServlet.unregister();
    }
    if (slingFilterRegistration != null) {
        slingFilterRegistration.unregister();
        slingFilterRegistration = null;
    }
    if (filterRegistration != null) {
        filterRegistration.unregister();
        filterRegistration = null;
    }
    ServiceRegistration reg = logCollectorReg.getAndSet(null);
    if (reg != null) {
        reg.unregister();
    }
    requestContextHolder.remove();
}
Also used : ServiceRegistration(org.osgi.framework.ServiceRegistration) Deactivate(org.apache.felix.scr.annotations.Deactivate)

Example 7 with Deactivate

use of org.apache.felix.scr.annotations.Deactivate in project stanbol by apache.

the class RefactorEnhancementEngine method deactivate.

@Deactivate
protected void deactivate(ComponentContext context) {
    // Deactivation clears all the rules and releases OntoNet resources.
    IRI recipeId = new IRI(engineConfiguration.getRecipeId());
    try {
        // step 1: get all the rules
        log.debug("Recipe {} and its associated rules will be removed from the rule store.", recipeId);
        Recipe recipe = null;
        try {
            recipe = ruleStore.getRecipe(recipeId);
        } catch (RecipeConstructionException e) {
            log.error(e.getMessage());
        }
        if (recipe != null) {
            // step 2: remove the recipe
            try {
                if (ruleStore.removeRecipe(recipeId)) {
                    log.debug("Recipe {} has been removed correctly. Note that its rules will be removed separately.", recipeId);
                } else
                    log.error("Recipe {} cannot be removed.", recipeId);
            } catch (RecipeEliminationException e) {
                log.error(e.getMessage());
            }
        }
    } catch (NoSuchRecipeException ex) {
        log.error("The recipe " + engineConfiguration.getRecipeId() + " doesn't exist", ex);
    }
    // step 3: clear OntoNet resources
    scope.getCoreSpace().tearDown();
    scope.tearDown();
    onManager.deregisterScope(scope);
    log.debug("OntoNet resources released : scope {}", scope);
    log.info("in " + RefactorEnhancementEngine.class + " deactivate with context " + context);
}
Also used : IRI(org.apache.clerezza.commons.rdf.IRI) RecipeEliminationException(org.apache.stanbol.rules.base.api.RecipeEliminationException) Recipe(org.apache.stanbol.rules.base.api.Recipe) NoSuchRecipeException(org.apache.stanbol.rules.base.api.NoSuchRecipeException) RecipeConstructionException(org.apache.stanbol.rules.base.api.RecipeConstructionException) Deactivate(org.apache.felix.scr.annotations.Deactivate)

Example 8 with Deactivate

use of org.apache.felix.scr.annotations.Deactivate in project stanbol by apache.

the class EntityhubDereferenceEngine method deactivate.

/**
     * Deactivates this components. 
     */
@Deactivate
protected void deactivate(ComponentContext context) {
    //* unregister service
    ServiceRegistration reg = engineRegistration;
    if (reg != null) {
        reg.unregister();
        engineRegistration = null;
    }
    if (executorService != null) {
        executorService.shutdown();
        executorService = null;
    }
    //* reset engine
    entityDereferenceEngine = null;
    engineMetadata = null;
    //close the tracking EntitySearcher
    entityDereferencer.close();
    entityDereferencer = null;
}
Also used : ServiceRegistration(org.osgi.framework.ServiceRegistration) Deactivate(org.apache.felix.scr.annotations.Deactivate)

Example 9 with Deactivate

use of org.apache.felix.scr.annotations.Deactivate in project sling by apache.

the class WorkspaceCreator method deactivate.

@SuppressWarnings("unused")
@Deactivate
private void deactivate() {
    Session s = null;
    try {
        s = repo.loginAdministrative(null);
        Workspace w = s.getWorkspace();
        deleteWorkspace(w, "ws3");
        deleteWorkspace(w, "ws2");
        deleteWorkspace(w, "ws1");
    } catch (Exception e) {
    // ignore
    } finally {
        if (s != null) {
            s.logout();
        }
    }
}
Also used : Session(javax.jcr.Session) Workspace(javax.jcr.Workspace) Deactivate(org.apache.felix.scr.annotations.Deactivate)

Example 10 with Deactivate

use of org.apache.felix.scr.annotations.Deactivate in project sling by apache.

the class SuperimposingManagerImpl method deactivate.

@Deactivate
protected synchronized void deactivate(final ComponentContext ctx) throws RepositoryException {
    try {
        // make sure initialization has finished
        if (null != initialization && !initialization.isDone()) {
            initialization.cancel(/* myInterruptIfRunning */
            true);
        }
        // de-register JCR observation
        if (resolver != null) {
            final Session session = resolver.adaptTo(Session.class);
            if (session != null && this.observationEventListeners != null) {
                for (EventListener eventListener : this.observationEventListeners) {
                    session.getWorkspace().getObservationManager().removeEventListener(eventListener);
                }
            }
        }
        // de-register all superimpsing resource providers
        for (final SuperimposingResourceProviderImpl srp : superimposingProviders.values()) {
            srp.unregisterService();
        }
    } finally {
        if (null != resolver) {
            resolver.close();
            resolver = null;
        }
        initialization = null;
        superimposingProviders.clear();
    }
}
Also used : EventListener(javax.jcr.observation.EventListener) Session(javax.jcr.Session) Deactivate(org.apache.felix.scr.annotations.Deactivate)

Aggregations

Deactivate (org.apache.felix.scr.annotations.Deactivate)11 ServiceRegistration (org.osgi.framework.ServiceRegistration)6 Session (javax.jcr.Session)2 ExecutorCloser (org.apache.jackrabbit.oak.commons.concurrent.ExecutorCloser)2 Closeable (java.io.Closeable)1 LinkedList (java.util.LinkedList)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 Workspace (javax.jcr.Workspace)1 EventListener (javax.jcr.observation.EventListener)1 IRI (org.apache.clerezza.commons.rdf.IRI)1 Registration (org.apache.jackrabbit.oak.spi.whiteboard.Registration)1 HealthCheckMetadata (org.apache.sling.hc.util.HealthCheckMetadata)1 NoSuchRecipeException (org.apache.stanbol.rules.base.api.NoSuchRecipeException)1 Recipe (org.apache.stanbol.rules.base.api.Recipe)1 RecipeConstructionException (org.apache.stanbol.rules.base.api.RecipeConstructionException)1 RecipeEliminationException (org.apache.stanbol.rules.base.api.RecipeEliminationException)1