Search in sources :

Example 91 with Activate

use of org.apache.felix.scr.annotations.Activate in project jackrabbit-oak by apache.

the class SecondaryStoreCacheService method activate.

@Activate
private void activate(BundleContext context, Map<String, Object> config) {
    bundleContext = context;
    whiteboard = new OsgiWhiteboard(context);
    String[] includedPaths = toStringArray(config.get(PROP_INCLUDES), new String[] { "/" });
    //TODO Support for exclude is not possible as once a NodeState is loaded from secondary
    //store it assumes that complete subtree is in same store. With exclude it would need to
    //check for each child access and route to primary
    pathFilter = new PathFilter(asList(includedPaths), Collections.<String>emptyList());
    SecondaryStoreBuilder builder = new SecondaryStoreBuilder(secondaryStoreProvider.getNodeStore()).differ(differ).metaPropNames(DocumentNodeStore.META_PROP_NAMES).statisticsProvider(statisticsProvider).pathFilter(pathFilter);
    SecondaryStoreCache cache = builder.buildCache();
    SecondaryStoreObserver observer = builder.buildObserver(cache);
    registerObserver(observer, config);
    regs.add(bundleContext.registerService(DocumentNodeStateCache.class.getName(), cache, null));
//TODO Need to see OSGi dynamics. Its possible that DocumentNodeStore works after the cache
//gets deregistered but the SegmentNodeState instances might still be in use and that would cause
//failure
}
Also used : PathFilter(org.apache.jackrabbit.oak.plugins.index.PathFilter) OsgiWhiteboard(org.apache.jackrabbit.oak.osgi.OsgiWhiteboard) Activate(org.apache.felix.scr.annotations.Activate)

Example 92 with Activate

use of org.apache.felix.scr.annotations.Activate in project jackrabbit-oak by apache.

the class FileBlobStoreService method activate.

@Activate
protected void activate(ComponentContext context, Map<String, Object> config) {
    String homeDir = lookup(context, PROP_HOME);
    if (homeDir != null) {
        log.info("Initializing the FileBlobStore with homeDir [{}]", homeDir);
    }
    BlobStore blobStore = new FileBlobStore(FilenameUtils.concat(homeDir, "datastore"));
    PropertiesUtil.populate(blobStore, config, false);
    Dictionary<String, Object> props = new Hashtable<String, Object>();
    if (context.getProperties().get(PROP_SPLIT_BLOBSTORE) != null) {
        props.put(PROP_SPLIT_BLOBSTORE, context.getProperties().get(PROP_SPLIT_BLOBSTORE));
    }
    reg = context.getBundleContext().registerService(new String[] { BlobStore.class.getName(), GarbageCollectableBlobStore.class.getName() }, blobStore, props);
}
Also used : Hashtable(java.util.Hashtable) FileBlobStore(org.apache.jackrabbit.oak.spi.blob.FileBlobStore) GarbageCollectableBlobStore(org.apache.jackrabbit.oak.spi.blob.GarbageCollectableBlobStore) BlobStore(org.apache.jackrabbit.oak.spi.blob.BlobStore) FileBlobStore(org.apache.jackrabbit.oak.spi.blob.FileBlobStore) Activate(org.apache.felix.scr.annotations.Activate)

Example 93 with Activate

use of org.apache.felix.scr.annotations.Activate in project jackrabbit-oak by apache.

the class AsyncIndexerService method activate.

@Activate
public void activate(BundleContext bundleContext, Map<String, Object> config) {
    List<AsyncConfig> asyncIndexerConfig = getAsyncConfig(PropertiesUtil.toStringArray(config.get(PROP_ASYNC_CONFIG), new String[0]));
    Whiteboard whiteboard = new OsgiWhiteboard(bundleContext);
    indexRegistration = new IndexMBeanRegistration(whiteboard);
    indexEditorProvider.start(whiteboard);
    executor = new WhiteboardExecutor();
    executor.start(whiteboard);
    long leaseTimeOutMin = PropertiesUtil.toInteger(config.get(PROP_LEASE_TIME_OUT), PROP_LEASE_TIMEOUT_DEFAULT);
    if (!(nodeStore instanceof Clusterable)) {
        leaseTimeOutMin = 0;
        log.info("Detected non clusterable setup. Lease checking would be disabled for async indexing");
    }
    TrackingCorruptIndexHandler corruptIndexHandler = createCorruptIndexHandler(config);
    for (AsyncConfig c : asyncIndexerConfig) {
        AsyncIndexUpdate task = new AsyncIndexUpdate(c.name, nodeStore, indexEditorProvider, statisticsProvider, false);
        task.setCorruptIndexHandler(corruptIndexHandler);
        task.setValidatorProviders(Collections.singletonList(validatorProvider));
        task.setLeaseTimeOut(TimeUnit.MINUTES.toMillis(leaseTimeOutMin));
        indexRegistration.registerAsyncIndexer(task, c.timeIntervalInSecs);
        closer.register(task);
    }
    registerAsyncReindexSupport(whiteboard);
    log.info("Configured async indexers {} ", asyncIndexerConfig);
    log.info("Lease time: {} mins and AsyncIndexUpdate configured with {}", leaseTimeOutMin, validatorProvider.getClass().getName());
}
Also used : Clusterable(org.apache.jackrabbit.oak.spi.state.Clusterable) OsgiWhiteboard(org.apache.jackrabbit.oak.osgi.OsgiWhiteboard) WhiteboardExecutor(org.apache.jackrabbit.oak.spi.whiteboard.WhiteboardExecutor) Whiteboard(org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard) OsgiWhiteboard(org.apache.jackrabbit.oak.osgi.OsgiWhiteboard) Activate(org.apache.felix.scr.annotations.Activate)

Example 94 with Activate

use of org.apache.felix.scr.annotations.Activate in project jackrabbit-oak by apache.

the class RepositoryManager method activate.

@Activate
public void activate(BundleContext bundleContext, Map<String, ?> config) throws Exception {
    observationQueueLength = PropertiesUtil.toInteger(prop(config, bundleContext, OBSERVATION_QUEUE_LENGTH), DEFAULT_OBSERVATION_QUEUE_LENGTH);
    if (PropertiesUtil.toBoolean(prop(config, bundleContext, COMMIT_RATE_LIMIT), DEFAULT_COMMIT_RATE_LIMIT)) {
        commitRateLimiter = new CommitRateLimiter();
    } else {
        commitRateLimiter = null;
    }
    fastQueryResultSize = PropertiesUtil.toBoolean(prop(config, bundleContext, FAST_QUERY_RESULT_SIZE), DEFAULT_FAST_QUERY_RESULT_SIZE);
    whiteboard = new OsgiWhiteboard(bundleContext);
    initializers = whiteboard.track(RepositoryInitializer.class);
    editorProvider.start(whiteboard);
    indexEditorProvider.start(whiteboard);
    indexProvider.start(whiteboard);
    registration = registerRepository(bundleContext);
}
Also used : CommitRateLimiter(org.apache.jackrabbit.oak.plugins.observation.CommitRateLimiter) OsgiWhiteboard(org.apache.jackrabbit.oak.osgi.OsgiWhiteboard) RepositoryInitializer(org.apache.jackrabbit.oak.spi.lifecycle.RepositoryInitializer) Activate(org.apache.felix.scr.annotations.Activate)

Example 95 with Activate

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

the class SlingAuthenticator method activate.

// ---------- SCR integration
@SuppressWarnings("unused")
@Activate
private void activate(final BundleContext bundleContext, final Map<String, Object> properties) {
    modified(properties);
    AuthenticatorWebConsolePlugin plugin = new AuthenticatorWebConsolePlugin(this);
    Hashtable<String, Object> props = new Hashtable<String, Object>();
    props.put("felix.webconsole.label", plugin.getLabel());
    props.put("felix.webconsole.title", plugin.getTitle());
    props.put("felix.webconsole.category", "Sling");
    props.put(Constants.SERVICE_DESCRIPTION, "Sling Request Authenticator WebConsole Plugin");
    props.put(Constants.SERVICE_VENDOR, properties.get(Constants.SERVICE_VENDOR));
    webConsolePlugin = bundleContext.registerService("javax.servlet.Servlet", plugin, props);
    serviceListener = SlingAuthenticatorServiceListener.createListener(bundleContext, this.authRequiredCache);
    authHandlerTracker = new AuthenticationHandlerTracker(bundleContext, authHandlerCache);
    engineAuthHandlerTracker = new EngineAuthenticationHandlerTracker(bundleContext, authHandlerCache);
    authInfoPostProcessorTracker = new ServiceTracker(bundleContext, AuthenticationInfoPostProcessor.SERVICE_NAME, null);
    authInfoPostProcessorTracker.open();
}
Also used : ServiceTracker(org.osgi.util.tracker.ServiceTracker) Hashtable(java.util.Hashtable) 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