use of org.osgi.service.component.annotations.Activate in project jackrabbit-oak by apache.
the class ConsolidatedCacheStats method activate.
@Activate
private void activate(BundleContext context) {
Whiteboard wb = new OsgiWhiteboard(context);
cacheStats = wb.track(CacheStatsMBean.class);
persistentCacheStats = wb.track(PersistentCacheStatsMBean.class);
mbeanReg = registerMBean(wb, ConsolidatedCacheStatsMBean.class, this, ConsolidatedCacheStatsMBean.TYPE, "Consolidated Cache statistics");
}
use of org.osgi.service.component.annotations.Activate in project jackrabbit-oak by apache.
the class DocumentNodeStoreService method activate.
@Activate
protected void activate(ComponentContext context, Configuration config) throws Exception {
closer = Closer.create();
this.config = DocumentNodeStoreServiceConfiguration.create(context, configurationAdmin, preset.configuration, config);
this.context = context;
whiteboard = new OsgiWhiteboard(context.getBundleContext());
executor = new WhiteboardExecutor();
executor.start(whiteboard);
customBlobStore = this.config.customBlobStore();
documentStoreType = DocumentStoreType.fromString(this.config.documentStoreType());
registerNodeStoreIfPossible();
}
use of org.osgi.service.component.annotations.Activate in project jackrabbit-oak by apache.
the class DocumentDiscoveryLiteService method activate.
/**
* On activate the DocumentDiscoveryLiteService tries to start the
* background job
*/
@Activate
public void activate(ComponentContext context) {
logger.trace("activate: start");
// set the ClusterStateChangeListener with the DocumentNodeStore
this.documentNodeStore = (DocumentNodeStore) nodeStore;
documentNodeStore.setClusterStateChangeListener(this);
// retrieve the clusterId
clusterNodeId = documentNodeStore.getClusterId();
// start the background worker
backgroundWorker = new BackgroundWorker();
Thread th = new Thread(backgroundWorker, "DocumentDiscoveryLiteService-BackgroundWorker-[" + clusterNodeId + "]");
th.setDaemon(true);
th.start();
// register the Descriptors - for Oak to pass it upwards
if (context != null) {
OsgiWhiteboard whiteboard = new OsgiWhiteboard(context.getBundleContext());
whiteboard.register(Descriptors.class, new DiscoveryLiteDescriptor(), Collections.emptyMap());
}
logger.trace("activate: end");
}
use of org.osgi.service.component.annotations.Activate in project adeptj-modules by AdeptJ.
the class LoggingConfigFactory method start.
@Activate
protected void start(LoggingConfig config) {
String level = config.level();
String logFile = config.logFile();
String[] loggerNames = config.loggerNames();
boolean additivity = config.additivity();
LogbackManager logbackMgr = LogbackManager.INSTANCE;
// If configuration is for error.log, add the configured loggers to both FILE and CONSOLE appender.
if (StringUtils.endsWith(logFile, DEFAULT_LOG_FILE)) {
logbackMgr.addLogger(LogbackConfig.builder().loggers(loggerNames).level(level).additivity(additivity).appenders(logbackMgr.getAppenders()).build());
return;
}
// If no log file provided then add the configured loggers only to CONSOLE appender.
if (StringUtils.endsWith(logFile, SLASH)) {
logbackMgr.addLogger(LogbackConfig.builder().loggers(loggerNames).level(level).additivity(additivity).appender(logbackMgr.getAppender(APPENDER_CONSOLE)).build());
return;
}
String rolloverFile = config.rolloverFile();
String pattern = config.pattern();
int logMaxHistory = config.logMaxHistory();
String logMaxSize = config.logMaxSize();
boolean immediateFlush = config.immediateFlush();
boolean addAsyncAppender = config.addAsyncAppender();
int asyncLogQueueSize = config.asyncLogQueueSize();
int asyncLogDiscardingThreshold = config.asyncLogDiscardingThreshold();
LogbackConfig logbackConfig = LogbackConfig.builder().appenderName(UUID.randomUUID().toString()).asyncAppenderName(UUID.randomUUID().toString()).level(level).logFile(logFile).additivity(additivity).rolloverFile(rolloverFile).pattern(pattern).logMaxHistory(logMaxHistory).logMaxSize(logMaxSize).immediateFlush(immediateFlush).addAsyncAppender(addAsyncAppender).asyncLogQueueSize(asyncLogQueueSize).asyncLogDiscardingThreshold(asyncLogDiscardingThreshold).loggers(loggerNames).build();
RollingFileAppender<ILoggingEvent> fileAppender = logbackMgr.createRollingFileAppender(logbackConfig);
logbackConfig.getAppenders().add(fileAppender);
if (logbackConfig.isAddAsyncAppender()) {
logbackConfig.setAsyncAppender(fileAppender);
logbackMgr.addAppender(fileAppender).createAsyncAppender(logbackConfig);
}
logbackMgr.addLogger(logbackConfig);
}
use of org.osgi.service.component.annotations.Activate in project adeptj-modules by AdeptJ.
the class AwsSnsService method start.
@Activate
protected void start(SmsConfig smsConfig) {
this.smsAttributes = new HashMap<>();
this.smsAttributes.put("AWS.SNS.SMS.SenderID", new MessageAttributeValue().withStringValue(smsConfig.senderId()).withDataType("String"));
this.smsAttributes.put("AWS.SNS.SMS.SMSType", new MessageAttributeValue().withStringValue(smsConfig.smsType()).withDataType("String"));
try {
this.asyncSNS = AmazonSNSAsyncClient.asyncBuilder().withEndpointConfiguration(AwsUtil.getEndpointConfig(smsConfig.serviceEndpoint(), smsConfig.signingRegion())).withCredentials(AwsUtil.getCredentialsProvider(smsConfig.accessKey(), smsConfig.secretKey())).build();
} catch (Exception ex) {
LOGGER.error("Exception while starting SmsService!!", ex);
throw new AwsException(ex.getMessage(), ex);
}
}
Aggregations