Search in sources :

Example 11 with Activate

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

the class HealthCheckExecutorImpl method activate.

@Activate
protected final void activate(final Map<String, Object> properties, final BundleContext bundleContext) {
    this.bundleContext = bundleContext;
    final ModifiableThreadPoolConfig hcThreadPoolConfig = new ModifiableThreadPoolConfig();
    hcThreadPoolConfig.setMaxPoolSize(25);
    hcThreadPool = threadPoolManager.create(hcThreadPoolConfig, "Health Check Thread Pool");
    this.modified(properties);
    try {
        this.bundleContext.addServiceListener(this, "(" + Constants.OBJECTCLASS + "=" + HealthCheck.class.getName() + ")");
    } catch (final InvalidSyntaxException ise) {
        // this should really never happen as the expression above is constant
        throw new RuntimeException("Unexpected exception occured.", ise);
    }
}
Also used : HealthCheck(org.apache.sling.hc.api.HealthCheck) ModifiableThreadPoolConfig(org.apache.sling.commons.threads.ModifiableThreadPoolConfig) InvalidSyntaxException(org.osgi.framework.InvalidSyntaxException) Activate(org.apache.felix.scr.annotations.Activate)

Example 12 with Activate

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

the class CompositeHealthCheck method activate.

@Activate
protected void activate(final ComponentContext ctx) {
    bundleContext = ctx.getBundleContext();
    componentContext = ctx;
    healthCheckFilter = new HealthCheckFilter(bundleContext);
    filterTags = PropertiesUtil.toStringArray(ctx.getProperties().get(PROP_FILTER_TAGS), new String[] {});
    log.debug("Activated, will select HealthCheck having tags {}", Arrays.asList(filterTags));
}
Also used : HealthCheckFilter(org.apache.sling.hc.util.HealthCheckFilter) Activate(org.apache.felix.scr.annotations.Activate)

Example 13 with Activate

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

the class ResourceModuleProvider method activate.

@Activate
private void activate(Map<String, Object> props) {
    final int maxRecursionLevels = PropertiesUtil.toInteger(props.get(PROP_MAX_RECURSION_LEVELS), DEFAULT_MAX_RECURSION_LEVELS);
    this.moduleInstance = new SimpleModule();
    SimpleSerializers serializers = new SimpleSerializers();
    serializers.addSerializer(Resource.class, new ResourceSerializer(maxRecursionLevels));
    moduleInstance.setSerializers(serializers);
}
Also used : SimpleSerializers(com.fasterxml.jackson.databind.module.SimpleSerializers) SimpleModule(com.fasterxml.jackson.databind.module.SimpleModule) Activate(org.apache.felix.scr.annotations.Activate)

Example 14 with Activate

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

the class REPLJavaSourceCodeServlet method activate.

@Activate
@SuppressWarnings("unused")
protected void activate(ComponentContext componentContext) {
    for (Bundle bundle : componentContext.getBundleContext().getBundles()) {
        if (FS_CLASSLOADER_SN.equals(bundle.getSymbolicName())) {
            BundleContext context = bundle.getBundleContext();
            classesFolder = new File(context.getDataFile(""), "classes");
        }
    }
}
Also used : Bundle(org.osgi.framework.Bundle) File(java.io.File) BundleContext(org.osgi.framework.BundleContext) Activate(org.apache.felix.scr.annotations.Activate)

Example 15 with Activate

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

the class AsyncJobConsumer method activate.

@Activate
public void activate(Map<String, Object> properites) {
    int corePoolSize = (int) properites.get(CORE_THREAD_POOL_SIZE);
    int maxPoolSize = (int) properites.get(MAC_THREAD_POOL_SIZE);
    int maxBacklog = (int) properites.get(MAX_QUEUED_BACKLOG);
    shutdownWaitSeconds = (long) properites.get(SHUTDOWN_WAIT_SECONDS);
    workQueue = new LinkedBlockingQueue<Runnable>(maxBacklog);
    executor = new ThreadPoolExecutor(corePoolSize, maxPoolSize, 60, TimeUnit.SECONDS, workQueue);
}
Also used : ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) Activate(org.apache.felix.scr.annotations.Activate)

Aggregations

Activate (org.apache.felix.scr.annotations.Activate)153 ConfigurationException (org.osgi.service.cm.ConfigurationException)31 ServiceTracker (org.osgi.util.tracker.ServiceTracker)20 BundleContext (org.osgi.framework.BundleContext)19 File (java.io.File)15 OsgiWhiteboard (org.apache.jackrabbit.oak.osgi.OsgiWhiteboard)12 URL (java.net.URL)11 Hashtable (java.util.Hashtable)11 ServiceReference (org.osgi.framework.ServiceReference)11 ServiceTrackerCustomizer (org.osgi.util.tracker.ServiceTrackerCustomizer)9 HashSet (java.util.HashSet)8 IOException (java.io.IOException)7 HashMap (java.util.HashMap)7 Map (java.util.Map)6 Session (javax.jcr.Session)5 StandardMBean (javax.management.StandardMBean)5 Whiteboard (org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard)5 Filter (org.osgi.framework.Filter)5 InputStream (java.io.InputStream)4 ArrayList (java.util.ArrayList)4