Search in sources :

Example 51 with Activate

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

the class LuceneIndexProviderService method activate.

@Activate
private void activate(BundleContext bundleContext, Map<String, ?> config) throws NotCompliantMBeanException, IOException {
    boolean disabled = PropertiesUtil.toBoolean(config.get(PROP_DISABLED), PROP_DISABLED_DEFAULT);
    hybridIndex = PropertiesUtil.toBoolean(config.get(PROP_HYBRID_INDEXING), PROP_DISABLED_DEFAULT);
    if (disabled) {
        log.info("Component disabled by configuration");
        return;
    }
    configureIndexDefinitionStorage(config);
    configureBooleanClauseLimit(config);
    initializeFactoryClassLoaders(getClass().getClassLoader());
    if (System.getProperty(BufferedOakDirectory.ENABLE_WRITING_SINGLE_BLOB_INDEX_FILE_PARAM) == null) {
        BufferedOakDirectory.setEnableWritingSingleBlobIndexFile(PropertiesUtil.toBoolean(config.get(PROP_NAME_ENABLE_SINGLE_BLOB_PER_INDEX_FILE), PROP_ENABLE_SINGLE_BLOB_PER_INDEX_FILE_DEFAULT));
    } else {
        log.info("Not setting config for single blob for an index file as it's set by command line!");
    }
    whiteboard = new OsgiWhiteboard(bundleContext);
    threadPoolSize = PropertiesUtil.toInteger(config.get(PROP_THREAD_POOL_SIZE), PROP_THREAD_POOL_SIZE_DEFAULT);
    initializeIndexDir(bundleContext, config);
    initializeExtractedTextCache(bundleContext, config);
    tracker = createTracker(bundleContext, config);
    indexProvider = new LuceneIndexProvider(tracker, scorerFactory, augmentorFactory);
    initializeActiveBlobCollector(whiteboard, config);
    initializeLogging(config);
    initialize();
    regs.add(bundleContext.registerService(QueryIndexProvider.class.getName(), indexProvider, null));
    registerObserver(bundleContext, config);
    registerLocalIndexObserver(bundleContext, tracker, config);
    registerIndexEditor(bundleContext, tracker, config);
    registerIndexInfoProvider(bundleContext);
    registerIndexImporterProvider(bundleContext);
    registerPropertyIndexCleaner(config, bundleContext);
    oakRegs.add(registerMBean(whiteboard, LuceneIndexMBean.class, new LuceneIndexMBeanImpl(indexProvider.getTracker(), nodeStore, indexPathService, getIndexCheckDir(), cleaner), LuceneIndexMBean.TYPE, "Lucene Index statistics"));
    registerGCMonitor(whiteboard, indexProvider.getTracker());
}
Also used : OsgiWhiteboard(org.apache.jackrabbit.oak.osgi.OsgiWhiteboard) Activate(org.apache.felix.scr.annotations.Activate)

Example 52 with Activate

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

the class SegmentNodeStoreFactory method activate.

@Activate
public void activate(ComponentContext context) throws IOException {
    String role = property(ROLE, context);
    // In secondaryNodeStore mode customBlobStore is always enabled
    boolean isSecondaryStoreMode = "secondary".equals(role);
    boolean customBlobStore = Boolean.parseBoolean(property(CUSTOM_BLOB_STORE, context)) || isSecondaryStoreMode;
    boolean customSegmentStore = Boolean.parseBoolean(property(CUSTOM_SEGMENT_STORE, context));
    boolean registerRepositoryDescriptors = Boolean.parseBoolean(property(REGISTER_DESCRIPTORS, context));
    log.info("activate: SegmentNodeStore '" + role + "' starting.");
    if (blobStore == null && customBlobStore) {
        log.info("BlobStore use enabled. SegmentNodeStore would be initialized when BlobStore would be available");
        return;
    }
    if (segmentStore == null && customSegmentStore) {
        log.info("customSegmentStore enabled. SegmentNodeStore will be initialized once the custom segment store becomes available");
        return;
    }
    if (role != null) {
        registrations = Closer.create();
        OsgiWhiteboard whiteboard = new OsgiWhiteboard(context.getBundleContext());
        final SegmentNodeStore store = SegmentNodeStoreService.registerSegmentStore(context, blobStore, segmentStore, statisticsProvider, registrations, whiteboard, role, registerRepositoryDescriptors);
        if (store != null) {
            Map<String, Object> props = new HashMap<String, Object>();
            props.put(NodeStoreProvider.ROLE, role);
            registrations.register(asCloseable(whiteboard.register(NodeStoreProvider.class, new NodeStoreProvider() {

                @Override
                public NodeStore getNodeStore() {
                    return store;
                }
            }, props)));
            log.info("Registered NodeStoreProvider backed by SegmentNodeStore of type '{}'", role);
        }
    }
}
Also used : NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) OsgiWhiteboard(org.apache.jackrabbit.oak.osgi.OsgiWhiteboard) HashMap(java.util.HashMap) NodeStoreProvider(org.apache.jackrabbit.oak.spi.state.NodeStoreProvider) Activate(org.apache.felix.scr.annotations.Activate)

Example 53 with Activate

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

the class Registrations method activate.

@Activate
public void activate(ComponentContext context) throws IOException {
    Configuration configuration = new Configuration(context);
    if (blobStore == null && configuration.hasCustomBlobStore()) {
        log.info("BlobStore enabled. SegmentNodeStore will be initialized once the blob " + "store becomes available");
        return;
    }
    if (segmentStore == null && configuration.hasCustomSegmentStore()) {
        log.info("customSegmentStore enabled. SegmentNodeStore will be initialized once the custom segment " + "store becomes available");
        return;
    }
    closer = Closer.create();
    OsgiWhiteboard whiteboard = new OsgiWhiteboard(context.getBundleContext());
    registerSegmentStore(context, blobStore, segmentStore, statisticsProvider, closer, whiteboard, null, true);
}
Also used : OsgiWhiteboard(org.apache.jackrabbit.oak.osgi.OsgiWhiteboard) Activate(org.apache.felix.scr.annotations.Activate)

Example 54 with Activate

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

the class ConsolidatedListenerMBeanImpl method activate.

// ~---------------------------------------< OSGi >
@Activate
private void activate(BundleContext context) {
    Whiteboard wb = new OsgiWhiteboard(context);
    mbeanReg = registerMBean(wb, ConsolidatedListenerMBean.class, this, ConsolidatedListenerMBean.TYPE, "Consolidated Event Listener statistics");
}
Also used : OsgiWhiteboard(org.apache.jackrabbit.oak.osgi.OsgiWhiteboard) ConsolidatedListenerMBean(org.apache.jackrabbit.oak.jcr.observation.jmx.ConsolidatedListenerMBean) Whiteboard(org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard) OsgiWhiteboard(org.apache.jackrabbit.oak.osgi.OsgiWhiteboard) Activate(org.apache.felix.scr.annotations.Activate)

Example 55 with Activate

use of org.apache.felix.scr.annotations.Activate in project CQ-Actions by Cognifide.

the class MessageWebsocketServlet method activate.

@Activate
public void activate() throws Exception {
    WebSocketBehavior behavior = WebSocketBehavior.SERVER;
    WebSocketPolicy policy = new WebSocketPolicy(behavior);
    webSocketFactory = new WebSocketServerFactory(policy);
    webSocketFactory.register(MessageSocket.class);
    webSocketFactory.setCreator(this);
    webSocketFactory.start();
}
Also used : WebSocketPolicy(org.eclipse.jetty.websocket.api.WebSocketPolicy) WebSocketServerFactory(org.eclipse.jetty.websocket.server.WebSocketServerFactory) WebSocketBehavior(org.eclipse.jetty.websocket.api.WebSocketBehavior) 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