Search in sources :

Example 26 with Activate

use of org.osgi.service.component.annotations.Activate in project adeptj-modules by AdeptJ.

the class HibernateValidatorService method start.

// --------------------------- INTERNAL ---------------------------
// ---------------- Component lifecycle methods -------------------
@Activate
protected void start() {
    try {
        final long startTime = System.nanoTime();
        this.validatorFactory = Validation.byProvider(HibernateValidator.class).configure().parameterNameProvider(new ParanamerParameterNameProvider()).buildValidatorFactory();
        LOGGER.info("HibernateValidator initialized in [{}] ms!!", NANOSECONDS.toMillis(System.nanoTime() - startTime));
    } catch (NoProviderFoundException ex) {
        LOGGER.error("Could not create ValidatorFactory!!", ex);
        throw ex;
    }
}
Also used : NoProviderFoundException(javax.validation.NoProviderFoundException) ParanamerParameterNameProvider(org.hibernate.validator.parameternameprovider.ParanamerParameterNameProvider) Activate(org.osgi.service.component.annotations.Activate)

Example 27 with Activate

use of org.osgi.service.component.annotations.Activate in project adeptj-modules by AdeptJ.

the class ThymeleafViewEngine method activate.

@Activate
protected void activate(ViewEngineConfig config, BundleContext bundleContext) {
    TemplateEngine engine = new TemplateEngine();
    BundleTemplateResolver templateResolver = new BundleTemplateResolver(bundleContext.getBundle());
    templateResolver.setPrefix("views/");
    templateResolver.setSuffix(".html");
    templateResolver.setCharacterEncoding("UTF-8");
    templateResolver.setTemplateMode(TemplateMode.HTML);
    // default is cacheable
    templateResolver.setCacheable(false);
    templateResolver.setOrder(1);
    // RK: This is performance intensive OP, need to look into code for a
    // better alternative
    templateResolver.setCheckExistence(true);
    engine.addTemplateResolver(templateResolver);
}
Also used : TemplateEngine(org.thymeleaf.TemplateEngine) Activate(org.osgi.service.component.annotations.Activate)

Example 28 with Activate

use of org.osgi.service.component.annotations.Activate in project feature-flags-for-osgi by amitjoy.

the class FeatureManagerProvider method activate.

@Activate
protected void activate(final BundleContext bundleContext) throws Exception {
    logger = new Logger(bundleContext);
    extender = new MetaTypeExtender(metaTypeService, logger, bundlePids, allFeatures);
    extender.start(bundleContext);
}
Also used : Logger(org.apache.felix.utils.log.Logger) Activate(org.osgi.service.component.annotations.Activate)

Example 29 with Activate

use of org.osgi.service.component.annotations.Activate in project com-liferay-apio-architect by liferay.

the class RootEndpointImpl method activate.

@Activate
public void activate() {
    RequestFunction<Optional<APITitle>> apiTitleRequestFunction = httpServletRequest -> _providerManager.provideOptional(httpServletRequest, APITitle.class);
    RequestFunction<Optional<APIDescription>> apiDescriptionRequestFunction = httpServletRequest -> _providerManager.provideOptional(httpServletRequest, APIDescription.class);
    _documentation = new Documentation(apiTitleRequestFunction, apiDescriptionRequestFunction);
}
Also used : JsonObject(com.google.gson.JsonObject) CollectionRouterManager(com.liferay.apio.architect.wiring.osgi.manager.router.CollectionRouterManager) ItemRoutes(com.liferay.apio.architect.routes.ItemRoutes) ExceptionSupplierUtil.notFound(com.liferay.apio.architect.endpoint.ExceptionSupplierUtil.notFound) NestedCollectionRoutes(com.liferay.apio.architect.routes.NestedCollectionRoutes) RequestFunction(com.liferay.apio.architect.alias.RequestFunction) BinaryEndpoint(com.liferay.apio.architect.endpoint.BinaryEndpoint) HttpServletRequest(javax.servlet.http.HttpServletRequest) MediaType(javax.ws.rs.core.MediaType) Component(org.osgi.service.component.annotations.Component) NestedCollectionRouterManager(com.liferay.apio.architect.wiring.osgi.manager.router.NestedCollectionRouterManager) Documentation(com.liferay.apio.architect.documentation.Documentation) Activate(org.osgi.service.component.annotations.Activate) ProviderManager(com.liferay.apio.architect.wiring.osgi.manager.ProviderManager) SingleModel(com.liferay.apio.architect.single.model.SingleModel) ReusableNestedCollectionRouterManager(com.liferay.apio.architect.wiring.osgi.manager.router.ReusableNestedCollectionRouterManager) RootEndpoint(com.liferay.apio.architect.endpoint.RootEndpoint) Try(com.liferay.apio.architect.functional.Try) PathIdentifierMapperManager(com.liferay.apio.architect.wiring.osgi.manager.PathIdentifierMapperManager) Context(javax.ws.rs.core.Context) APIDescription(com.liferay.apio.architect.documentation.APIDescription) RepresentableManager(com.liferay.apio.architect.wiring.osgi.manager.representable.RepresentableManager) ServerURL(com.liferay.apio.architect.url.ServerURL) Path(com.liferay.apio.architect.uri.Path) APITitle(com.liferay.apio.architect.documentation.APITitle) IdentifierClassManager(com.liferay.apio.architect.wiring.osgi.manager.representable.IdentifierClassManager) List(java.util.List) Response(javax.ws.rs.core.Response) FormEndpoint(com.liferay.apio.architect.endpoint.FormEndpoint) Optional(java.util.Optional) Reference(org.osgi.service.component.annotations.Reference) ItemRouterManager(com.liferay.apio.architect.wiring.osgi.manager.router.ItemRouterManager) Optional(java.util.Optional) Documentation(com.liferay.apio.architect.documentation.Documentation) Activate(org.osgi.service.component.annotations.Activate)

Example 30 with Activate

use of org.osgi.service.component.annotations.Activate in project activemq-artemis by apache.

the class OsgiBroker method activate.

@Activate
public void activate(ComponentContext cctx) throws Exception {
    final BundleContext context = cctx.getBundleContext();
    final Dictionary<String, Object> properties = cctx.getProperties();
    configurationUrl = getMandatory(properties, "config");
    name = getMandatory(properties, "name");
    rolePrincipalClass = (String) properties.get("rolePrincipalClass");
    String domain = getMandatory(properties, "domain");
    ActiveMQJAASSecurityManager security = new ActiveMQJAASSecurityManager(domain);
    if (rolePrincipalClass != null) {
        security.setRolePrincipalClass(rolePrincipalClass);
    }
    String brokerInstance = null;
    String karafDataDir = System.getProperty("karaf.data");
    if (karafDataDir != null) {
        brokerInstance = karafDataDir + "/artemis/" + name;
    }
    // todo if we start to pullout more configs from the main config then we
    // should pull out the configuration objects from factories if available
    FileConfiguration configuration = new FileConfiguration();
    if (brokerInstance != null) {
        configuration.setBrokerInstance(new File(brokerInstance));
    }
    FileJMSConfiguration jmsConfiguration = new FileJMSConfiguration();
    FileDeploymentManager fileDeploymentManager = new FileDeploymentManager(configurationUrl);
    fileDeploymentManager.addDeployable(configuration).addDeployable(jmsConfiguration).readConfiguration();
    components = fileDeploymentManager.buildService(security, ManagementFactory.getPlatformMBeanServer());
    final ActiveMQServer server = (ActiveMQServer) components.get("core");
    String[] requiredProtocols = getRequiredProtocols(server.getConfiguration().getAcceptorConfigurations());
    ServerTrackerCallBack callback = new ServerTrackerCallBackImpl(server, context, properties);
    StoreConfiguration storeConfiguration = server.getConfiguration().getStoreConfiguration();
    String dataSourceName = String.class.cast(properties.get("dataSourceName"));
    if (storeConfiguration != null && storeConfiguration.getStoreType() == StoreType.DATABASE && dataSourceName != null && !dataSourceName.isEmpty()) {
        callback.setDataSourceDependency(true);
        String filter = "(&(objectClass=javax.sql.DataSource)(osgi.jndi.service.name=" + dataSourceName + "))";
        DataSourceTracker trackerCust = new DataSourceTracker(name, context, DatabaseStorageConfiguration.class.cast(storeConfiguration), (ServerTrackerCallBack) callback);
        dataSourceTracker = new ServiceTracker(context, context.createFilter(filter), trackerCust);
        dataSourceTracker.open();
    }
    ProtocolTracker trackerCust = new ProtocolTracker(name, context, requiredProtocols, callback);
    tracker = new ServiceTracker(context, ProtocolManagerFactory.class, trackerCust);
    tracker.open();
}
Also used : ProtocolManagerFactory(org.apache.activemq.artemis.spi.core.protocol.ProtocolManagerFactory) ServiceTracker(org.osgi.util.tracker.ServiceTracker) ActiveMQJAASSecurityManager(org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager) FileConfiguration(org.apache.activemq.artemis.core.config.impl.FileConfiguration) DatabaseStorageConfiguration(org.apache.activemq.artemis.core.config.storage.DatabaseStorageConfiguration) ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) FileJMSConfiguration(org.apache.activemq.artemis.jms.server.config.impl.FileJMSConfiguration) StoreConfiguration(org.apache.activemq.artemis.core.config.StoreConfiguration) FileDeploymentManager(org.apache.activemq.artemis.core.config.FileDeploymentManager) File(java.io.File) BundleContext(org.osgi.framework.BundleContext) 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