Search in sources :

Example 21 with Activate

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");
}
Also used : OsgiWhiteboard(org.apache.jackrabbit.oak.osgi.OsgiWhiteboard) PersistentCacheStatsMBean(org.apache.jackrabbit.oak.api.jmx.PersistentCacheStatsMBean) ConsolidatedCacheStatsMBean(org.apache.jackrabbit.oak.api.jmx.ConsolidatedCacheStatsMBean) CacheStatsMBean(org.apache.jackrabbit.oak.api.jmx.CacheStatsMBean) PersistentCacheStatsMBean(org.apache.jackrabbit.oak.api.jmx.PersistentCacheStatsMBean) ConsolidatedCacheStatsMBean(org.apache.jackrabbit.oak.api.jmx.ConsolidatedCacheStatsMBean) Whiteboard(org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard) OsgiWhiteboard(org.apache.jackrabbit.oak.osgi.OsgiWhiteboard) Activate(org.osgi.service.component.annotations.Activate)

Example 22 with Activate

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();
}
Also used : OsgiWhiteboard(org.apache.jackrabbit.oak.osgi.OsgiWhiteboard) WhiteboardExecutor(org.apache.jackrabbit.oak.spi.whiteboard.WhiteboardExecutor) Activate(org.osgi.service.component.annotations.Activate)

Example 23 with Activate

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");
}
Also used : OsgiWhiteboard(org.apache.jackrabbit.oak.osgi.OsgiWhiteboard) Activate(org.osgi.service.component.annotations.Activate)

Example 24 with Activate

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);
}
Also used : LogbackConfig(com.adeptj.runtime.tools.logging.LogbackConfig) LogbackManager(com.adeptj.runtime.tools.logging.LogbackManager) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent) Activate(org.osgi.service.component.annotations.Activate)

Example 25 with Activate

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);
    }
}
Also used : AwsException(com.adeptj.modules.aws.core.AwsException) AwsException(com.adeptj.modules.aws.core.AwsException) MessageAttributeValue(com.amazonaws.services.sns.model.MessageAttributeValue) 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