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();
}
}
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());
}
}
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();
}
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);
}
}
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());
}
Aggregations