Search in sources :

Example 16 with Activate

use of org.osgi.service.component.annotations.Activate in project karaf by apache.

the class GreeterServiceFactoryManager method activate.

/**
 * Called when all of the SCR Components required dependencies have been satisfied.
 */
@Activate
public void activate() {
    LOG.info("Activating the {}", COMPONENT_LABEL);
    try {
        lock.readLock().lock();
        if (factory != null) {
            final Properties props = new Properties();
            props.setProperty("salutation", "Hello");
            props.setProperty("name", "User");
            instance = factory.newInstance((Dictionary) props);
            greeterService = (GreeterServiceComponentFactory) instance.getInstance();
            greeterService.startGreeter();
        }
    } finally {
        lock.readLock().unlock();
    }
}
Also used : Dictionary(java.util.Dictionary) Properties(java.util.Properties) Activate(org.osgi.service.component.annotations.Activate)

Example 17 with Activate

use of org.osgi.service.component.annotations.Activate in project smarthome by eclipse.

the class ProxyServletService method activate.

@Activate
protected void activate(Map<String, Object> config) {
    try {
        Servlet servlet = getImpl();
        logger.debug("Starting up '{}' servlet  at /{}", servlet.getServletInfo(), PROXY_ALIAS);
        Hashtable<String, String> props = propsFromConfig(config);
        httpService.registerServlet("/" + PROXY_ALIAS, servlet, props, createHttpContext());
    } catch (NamespaceException | ServletException e) {
        logger.error("Error during servlet startup: {}", e.getMessage());
    }
}
Also used : ServletException(javax.servlet.ServletException) HttpServlet(javax.servlet.http.HttpServlet) Servlet(javax.servlet.Servlet) NamespaceException(org.osgi.service.http.NamespaceException) Activate(org.osgi.service.component.annotations.Activate)

Example 18 with Activate

use of org.osgi.service.component.annotations.Activate in project smarthome by eclipse.

the class RuleEngineImpl method activate.

@Activate
public void activate() {
    injector = RulesStandaloneSetup.getInjector();
    triggerManager = injector.getInstance(RuleTriggerManager.class);
    if (!isEnabled()) {
        logger.info("Rule engine is disabled.");
        return;
    }
    logger.debug("Started rule engine");
    // read all rule files
    for (String ruleModelName : modelRepository.getAllModelNamesOfType("rules")) {
        EObject model = modelRepository.getModel(ruleModelName);
        if (model instanceof RuleModel) {
            RuleModel ruleModel = (RuleModel) model;
            triggerManager.addRuleModel(ruleModel);
        }
    }
    // register us as listeners
    itemRegistry.addRegistryChangeListener(this);
    modelRepository.addModelRepositoryChangeListener(this);
    // register us on all items which are already available in the registry
    for (Item item : itemRegistry.getItems()) {
        internalItemAdded(item);
    }
    scheduleStartupRules();
}
Also used : GenericItem(org.eclipse.smarthome.core.items.GenericItem) Item(org.eclipse.smarthome.core.items.Item) EObject(org.eclipse.emf.ecore.EObject) RuleModel(org.eclipse.smarthome.model.rule.rules.RuleModel) Activate(org.osgi.service.component.annotations.Activate)

Example 19 with Activate

use of org.osgi.service.component.annotations.Activate in project smarthome by eclipse.

the class RootResource method activate.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Activate
public void activate() {
    Configuration configuration;
    try {
        configuration = configurationAdmin.getConfiguration(Constants.JAXRS_CONNECTOR_CONFIG, null);
        if (configuration != null) {
            Dictionary properties = configuration.getProperties();
            if (properties == null) {
                properties = new Properties();
            }
            String rootAlias = (String) properties.get(Constants.JAXRS_CONNECTOR_ROOT_PROPERTY);
            if (!RESTConstants.REST_URI.equals(rootAlias)) {
                properties.put(Constants.JAXRS_CONNECTOR_ROOT_PROPERTY, RESTConstants.REST_URI);
                configuration.update(properties);
            }
        }
    } catch (IOException e) {
        logger.error("Could not set REST configuration properties!", e);
    }
}
Also used : Dictionary(java.util.Dictionary) Configuration(org.osgi.service.cm.Configuration) IOException(java.io.IOException) Properties(java.util.Properties) Activate(org.osgi.service.component.annotations.Activate)

Example 20 with Activate

use of org.osgi.service.component.annotations.Activate in project jackrabbit-oak by apache.

the class AsyncIndexerService method activate.

@Activate
public void activate(BundleContext bundleContext, Configuration config) {
    List<AsyncConfig> asyncIndexerConfig = getAsyncConfig(config.asyncConfigs());
    Whiteboard whiteboard = new OsgiWhiteboard(bundleContext);
    indexRegistration = new IndexMBeanRegistration(whiteboard);
    indexEditorProvider.start(whiteboard);
    executor = new WhiteboardExecutor();
    executor.start(whiteboard);
    long leaseTimeOutMin = config.leaseTimeOutMinutes();
    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.osgi.service.component.annotations.Activate)

Aggregations

Activate (org.osgi.service.component.annotations.Activate)78 BundleContext (org.osgi.framework.BundleContext)12 OsgiWhiteboard (org.apache.jackrabbit.oak.osgi.OsgiWhiteboard)7 IOException (java.io.IOException)6 Hashtable (java.util.Hashtable)6 File (java.io.File)5 ResourceResolver (org.apache.sling.api.resource.ResourceResolver)5 ArrayList (java.util.ArrayList)4 Properties (java.util.Properties)3 Whiteboard (org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard)3 ServiceReference (org.osgi.framework.ServiceReference)3 PromiseFactory (org.osgi.util.promise.PromiseFactory)3 ServerStartupObserver (org.wso2.carbon.core.ServerStartupObserver)3 JsonObject (com.google.gson.JsonObject)2 Dictionary (java.util.Dictionary)2 ObjectName (javax.management.ObjectName)2 WhiteboardExecutor (org.apache.jackrabbit.oak.spi.whiteboard.WhiteboardExecutor)2 LoginException (org.apache.sling.api.resource.LoginException)2 ServiceListener (org.osgi.framework.ServiceListener)2 ServiceTracker (org.osgi.util.tracker.ServiceTracker)2