Search in sources :

Example 71 with Activate

use of org.osgi.service.component.annotations.Activate in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class CoreFormHandlingServlet method activate.

@Activate
protected void activate(Configuration configuration) {
    String[] dataNameWhitelist = PropertiesUtil.toStringArray(configuration.name_whitelist());
    boolean allowExpressions = PropertiesUtil.toBoolean(configuration.allow_expressions(), PROP_ALLOW_EXPRESSION_DEFAULT);
    formsHandlingServletHelper = new FormsHandlingServletHelper(dataNameWhitelist, validator, FormConstants.RT_ALL_CORE_FORM_CONTAINER, allowExpressions, formStructureHelperFactory);
}
Also used : FormsHandlingServletHelper(com.day.cq.wcm.foundation.forms.FormsHandlingServletHelper) Activate(org.osgi.service.component.annotations.Activate)

Example 72 with Activate

use of org.osgi.service.component.annotations.Activate in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class AdaptiveImageServletMappingConfigurationConsumer method activate.

/**
 * Activation method
 *
 * @param componentContext - Component context
 * @param bundleContext - Bundle context
 * @param config - Config properties
 */
@Activate
public void activate(ComponentContext componentContext, BundleContext bundleContext, Map<String, Object> config) {
    try {
        Configuration[] configurations = configurationAdmin.listConfigurations("(" + Constants.SERVICE_PID + "=" + AdaptiveImageServlet.class.getName() + ")");
        if (ArrayUtils.isNotEmpty(configurations)) {
            Configuration oldConfig = configurations[0];
            oldAISDefaultResizeWidth = PropertiesUtil.toInteger(oldConfig.getProperties().get("defaultResizeWidth"), Integer.MIN_VALUE);
            if (oldAISDefaultResizeWidth > 0) {
                LOG.warn("Found previous custom configuration for the {}. The configuration will be reused to control the {} " + "registrations managed by this component. Please migrate the previous configuration to the {} factory" + " configurations.", AdaptiveImageServlet.class.getName(), AdaptiveImageServlet.class.getName(), AdaptiveImageServletMappingConfigurationFactory.class.getName());
            }
        }
    } catch (IOException | InvalidSyntaxException | RuntimeException e) {
        LOG.error("Unable to retrieve previous configuration for the " + AdaptiveImageServlet.class.getName() + " component. " + "The configuration, if it still exists, will not be reused to configure the defaultResizeWidth property of the " + "servlet's registrations managed by this component.", e);
    }
    this.bundleContext = bundleContext;
    updateServletRegistrations();
}
Also used : Configuration(org.osgi.service.cm.Configuration) InvalidSyntaxException(org.osgi.framework.InvalidSyntaxException) IOException(java.io.IOException) Activate(org.osgi.service.component.annotations.Activate)

Example 73 with Activate

use of org.osgi.service.component.annotations.Activate in project carbon-apimgt by wso2.

the class APITokenMgtServiceComponent method activate.

@Activate
protected void activate(ComponentContext ctxt) {
    try {
        TokenMgtDataHolder.initData();
        listener = new KeyManagerUserOperationListener();
        serviceRegistration = ctxt.getBundleContext().registerService(UserOperationEventListener.class.getName(), listener, null);
        log.debug("Key Manager User Operation Listener is enabled.");
        APIManagerConfigurationService configurationService = ServiceReferenceHolder.getInstance().getAPIManagerConfigurationService();
        boolean accessTokenBindingEnable;
        String firstProperty = configurationService.getAPIManagerConfiguration().getFirstProperty(APIConstants.AccessTokenBinding.ACCESS_TOKEN_BINDING_ENABLED);
        if (firstProperty != null) {
            accessTokenBindingEnable = Boolean.parseBoolean(firstProperty);
        } else {
            accessTokenBindingEnable = false;
        }
        if (!accessTokenBindingEnable) {
            // registering logout token revoke listener
            try {
                SessionDataPublisherImpl dataPublisher = new SessionDataPublisherImpl();
                ctxt.getBundleContext().registerService(AuthenticationDataPublisher.class.getName(), dataPublisher, null);
                log.debug("SessionDataPublisherImpl bundle is activated");
            } catch (Throwable e) {
                log.error("SessionDataPublisherImpl bundle activation Failed", e);
            }
        }
    } catch (Exception e) {
        log.error("Failed to initialize key management service.", e);
    }
}
Also used : APIManagerConfigurationService(org.wso2.carbon.apimgt.impl.APIManagerConfigurationService) SessionDataPublisherImpl(org.wso2.carbon.apimgt.tokenmgt.handlers.SessionDataPublisherImpl) KeyManagerUserOperationListener(org.wso2.carbon.apimgt.tokenmgt.listeners.KeyManagerUserOperationListener) AuthenticationDataPublisher(org.wso2.carbon.identity.application.authentication.framework.AuthenticationDataPublisher) Activate(org.osgi.service.component.annotations.Activate)

Example 74 with Activate

use of org.osgi.service.component.annotations.Activate in project carbon-apimgt by wso2.

the class StartupServiceComponent method activate.

@Activate
protected void activate(ComponentContext componentContext) {
    try {
        log.debug("Startup Service Component activated");
        BundleContext bundleContext = componentContext.getBundleContext();
        registration = bundleContext.registerService(ServerStartupObserver.class.getName(), new ServerStartupListener(), null);
    } catch (Exception e) {
        log.error("Error occurred in startup service component activation", e);
    }
}
Also used : ServerStartupListener(org.wso2.carbon.apimgt.impl.listeners.ServerStartupListener) BundleContext(org.osgi.framework.BundleContext) Activate(org.osgi.service.component.annotations.Activate)

Example 75 with Activate

use of org.osgi.service.component.annotations.Activate in project carbon-apimgt by wso2.

the class SolaceManagerComponent method activate.

@Activate
protected void activate(ComponentContext componentContext) throws Exception {
    if (log.isDebugEnabled()) {
        log.debug("Activating SolaceManager component");
    }
    BundleContext bundleContext = componentContext.getBundleContext();
    // Registering Notifiers
    bundleContext.registerService(Notifier.class.getName(), new SolaceSubscriptionsNotifier(), null);
    bundleContext.registerService(Notifier.class.getName(), new SolaceApplicationNotifier(), null);
    bundleContext.registerService(Notifier.class.getName(), new SolaceKeyGenNotifier(), null);
    if (log.isDebugEnabled()) {
        log.debug("SolaceManager component activated");
    }
}
Also used : SolaceSubscriptionsNotifier(org.wso2.carbon.apimgt.solace.notifiers.SolaceSubscriptionsNotifier) SolaceApplicationNotifier(org.wso2.carbon.apimgt.solace.notifiers.SolaceApplicationNotifier) BundleContext(org.osgi.framework.BundleContext) Notifier(org.wso2.carbon.apimgt.impl.notifier.Notifier) SolaceSubscriptionsNotifier(org.wso2.carbon.apimgt.solace.notifiers.SolaceSubscriptionsNotifier) SolaceApplicationNotifier(org.wso2.carbon.apimgt.solace.notifiers.SolaceApplicationNotifier) SolaceKeyGenNotifier(org.wso2.carbon.apimgt.solace.notifiers.SolaceKeyGenNotifier) SolaceKeyGenNotifier(org.wso2.carbon.apimgt.solace.notifiers.SolaceKeyGenNotifier) 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