Search in sources :

Example 56 with Activate

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

the class WiserSmtpService method activate.

@Activate
public void activate(final WiserSmtpServiceConfiguration configuration) throws Exception {
    wiser = new Wiser(configuration.smtpPort());
    wiser.start();
}
Also used : Wiser(org.subethamail.wiser.Wiser) Activate(org.osgi.service.component.annotations.Activate)

Example 57 with Activate

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

the class SetupService method activate.

@Activate
protected void activate(final BundleContext bc) throws IOException, LoginException, PersistenceException, RepositoryException {
    logger.info("Setting up SlingShot...");
    ResourceResolver resolver = null;
    try {
        resolver = this.factory.getServiceResourceResolver(null);
        setupContent(resolver);
    } finally {
        if (resolver != null) {
            resolver.close();
        }
    }
    logger.info("Finished setting up SlingShot");
}
Also used : ResourceResolver(org.apache.sling.api.resource.ResourceResolver) Activate(org.osgi.service.component.annotations.Activate)

Example 58 with Activate

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

the class SystemPropertyConfigurationOverrideProvider method activate.

@Activate
void activate(Config config) {
    List<String> overrides = new ArrayList<>();
    if (config.enabled()) {
        Properties properties = System.getProperties();
        Enumeration<Object> keys = properties.keys();
        while (keys.hasMoreElements()) {
            Object keyObject = keys.nextElement();
            if (keyObject instanceof String) {
                String key = (String) keyObject;
                if (StringUtils.startsWith(key, SYSTEM_PROPERTY_PREFIX)) {
                    overrides.add(StringUtils.substringAfter(key, SYSTEM_PROPERTY_PREFIX) + "=" + System.getProperty(key));
                }
            }
        }
    }
    this.overrideStrings = overrides;
}
Also used : ArrayList(java.util.ArrayList) Properties(java.util.Properties) Activate(org.osgi.service.component.annotations.Activate)

Example 59 with Activate

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

the class JobManagerConfiguration method activate.

/**
     * Activate this component.
     * @param props Configuration properties
     * @param config Configuration properties
     * @throws RuntimeException If the default paths can't be created
     */
@Activate
protected void activate(final Map<String, Object> props, final Config config) {
    this.update(props, config);
    this.jobsBasePathWithSlash = PropertiesUtil.toString(props.get(PROPERTY_REPOSITORY_PATH), DEFAULT_REPOSITORY_PATH) + '/';
    // create initial resources
    this.assignedJobsPath = this.jobsBasePathWithSlash + "assigned";
    this.unassignedJobsPath = this.jobsBasePathWithSlash + "unassigned";
    this.localJobsPath = this.assignedJobsPath.concat("/").concat(Environment.APPLICATION_ID);
    this.localJobsPathWithSlash = this.localJobsPath.concat("/");
    this.previousVersionAnonPath = this.jobsBasePathWithSlash + "anon";
    this.previousVersionIdentifiedPath = this.jobsBasePathWithSlash + "identified";
    this.storedCancelledJobsPath = this.jobsBasePathWithSlash + "cancelled";
    this.storedSuccessfulJobsPath = this.jobsBasePathWithSlash + "finished";
    this.scheduledJobsPath = PropertiesUtil.toString(props.get(PROPERTY_SCHEDULED_JOBS_PATH), DEFAULT_SCHEDULED_JOBS_PATH);
    this.scheduledJobsPathWithSlash = this.scheduledJobsPath + "/";
    // create initial resources
    final ResourceResolver resolver = this.createResourceResolver();
    try {
        ResourceHelper.getOrCreateBasePath(resolver, this.getLocalJobsPath());
        ResourceHelper.getOrCreateBasePath(resolver, this.getUnassignedJobsPath());
    } catch (final PersistenceException pe) {
        logger.error("Unable to create default paths: " + pe.getMessage(), pe);
        throw new RuntimeException(pe);
    } finally {
        resolver.close();
    }
    this.active.set(true);
    // SLING-5560 : use an InitDelayingTopologyEventListener
    if (this.startupDelay > 0) {
        logger.debug("activate: job manager will start in {} sec. ({})", this.startupDelay, config.startup_delay());
        this.startupDelayListener = new InitDelayingTopologyEventListener(startupDelay, new TopologyEventListener() {

            @Override
            public void handleTopologyEvent(TopologyEvent event) {
                doHandleTopologyEvent(event);
            }
        }, logger);
    } else {
        logger.debug("activate: job manager will start without delay. ({}:{})", config.startup_delay(), this.startupDelay);
    }
}
Also used : TopologyEvent(org.apache.sling.discovery.TopologyEvent) ResourceResolver(org.apache.sling.api.resource.ResourceResolver) PersistenceException(org.apache.sling.api.resource.PersistenceException) InitDelayingTopologyEventListener(org.apache.sling.discovery.commons.InitDelayingTopologyEventListener) InitDelayingTopologyEventListener(org.apache.sling.discovery.commons.InitDelayingTopologyEventListener) TopologyEventListener(org.apache.sling.discovery.TopologyEventListener) Activate(org.osgi.service.component.annotations.Activate)

Example 60 with Activate

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

the class ActiveMQConnectionFactoryService method activate.

@Activate
public void activate(Config config) {
    pooledConnectionFactory = new PooledConnectionFactory(config.jms_brokerUri());
    pooledConnectionFactory.start();
}
Also used : PooledConnectionFactory(org.apache.activemq.pool.PooledConnectionFactory) Activate(org.osgi.service.component.annotations.Activate)

Aggregations

Activate (org.osgi.service.component.annotations.Activate)100 BundleContext (org.osgi.framework.BundleContext)13 File (java.io.File)8 OsgiWhiteboard (org.apache.jackrabbit.oak.osgi.OsgiWhiteboard)7 IOException (java.io.IOException)6 Hashtable (java.util.Hashtable)6 ResourceResolver (org.apache.sling.api.resource.ResourceResolver)5 FinderPath (com.liferay.portal.kernel.dao.orm.FinderPath)4 ArrayList (java.util.ArrayList)4 Properties (java.util.Properties)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 Date (java.util.Date)2 Dictionary (java.util.Dictionary)2 ObjectName (javax.management.ObjectName)2 Whiteboard (org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard)2 WhiteboardExecutor (org.apache.jackrabbit.oak.spi.whiteboard.WhiteboardExecutor)2 LoginException (org.apache.sling.api.resource.LoginException)2