Search in sources :

Example 91 with Activate

use of org.osgi.service.component.annotations.Activate in project smarthome by eclipse.

the class WebAppServlet method activate.

@Activate
protected void activate(Map<String, Object> configProps, BundleContext bundleContext) {
    config.applyConfig(configProps);
    HttpContext httpContext = createHttpContext(bundleContext.getBundle());
    super.activate(WEBAPP_ALIAS + "/" + SERVLET_NAME, httpContext);
    try {
        httpService.registerResources(WEBAPP_ALIAS, "web", httpContext);
    } catch (NamespaceException e) {
        logger.error("Could not register static resources under {}", WEBAPP_ALIAS, e);
    }
}
Also used : HttpContext(org.osgi.service.http.HttpContext) NamespaceException(org.osgi.service.http.NamespaceException) Activate(org.osgi.service.component.annotations.Activate)

Example 92 with Activate

use of org.osgi.service.component.annotations.Activate in project smarthome by eclipse.

the class RuleEngineImpl method activate.

/**
 * This method is used to create a {@link CompositeModuleHandlerFactory} that handles all composite
 * {@link ModuleType}s. Called from DS to activate the rule engine component.
 */
@Activate
protected void activate() {
    compositeFactory = new CompositeModuleHandlerFactory(mtRegistry, this);
    // enable the rules that are not persisted as Disabled;
    for (Rule rule : ruleRegistry.getAll()) {
        String uid = rule.getUID();
        final Storage<Boolean> disabledRulesStorage = this.disabledRulesStorage;
        if (disabledRulesStorage == null || disabledRulesStorage.get(uid) == null) {
            setEnabled(uid, true);
        }
    }
}
Also used : WrappedRule(org.eclipse.smarthome.automation.core.internal.ruleengine.WrappedRule) Rule(org.eclipse.smarthome.automation.Rule) CompositeModuleHandlerFactory(org.eclipse.smarthome.automation.core.internal.composite.CompositeModuleHandlerFactory) Activate(org.osgi.service.component.annotations.Activate)

Example 93 with Activate

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

the class CamelComponent method activate.

@Activate
public void activate(ComponentContext componentContext) throws Exception {
    BundleContext bundleContext = componentContext.getBundleContext();
    OsgiDefaultCamelContext osgiDefaultCamelContext = new OsgiDefaultCamelContext(bundleContext);
    osgiDefaultCamelContext.setClassResolver(new OsgiClassResolver(camelContext, bundleContext));
    osgiDefaultCamelContext.setDataFormatResolver(new OsgiDataFormatResolver(bundleContext));
    osgiDefaultCamelContext.setLanguageResolver(new OsgiLanguageResolver(bundleContext));
    osgiDefaultCamelContext.setName("context-example");
    camelContext = osgiDefaultCamelContext;
    serviceRegistration = bundleContext.registerService(CamelContext.class, camelContext, null);
    camelContext.start();
    camelContext.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("jetty:http://0.0.0.0:9090/example").id("example-http-inbound").convertBodyTo(String.class).log("[EXAMPLE INBOUND] Received: ${body}").choice().when().simple("${headers.CamelHttpMethod} == 'POST'").setHeader("type").jsonpath("$.notification.type").choice().when().simple("${header.type} == 'email'").log("[EXAMPLE INBOUND] Received email notification").to("direct:email").setHeader("Exchange.HTTP_RESPONSE_CODE", constant(200)).when().simple("${header.type} == 'http'").log("[EXAMPLE INBOUND] Received http notification").to("direct:http").setHeader("Exchange.HTTP_RESPONSE_CODE", constant(200)).otherwise().log("[EXAMPLE INBOUND] Unknown notification").setBody(constant("{ \"status\": \"reject\", \"type\": \"unknown\" }")).setHeader("Exchange.HTTP_RESPONSE_CODE", constant(400)).otherwise().log("[EXAMPLE INBOUND] only POST is accepted (${headers.CamelHttpMethod})").setBody(constant("{ \"error\": \"only POST is accepted\" }")).setHeader("Exchange.HTTP_RESPONSE_CODE", constant(500));
            from("direct:email").id("example-email").log("[EXAMPLE EMAIL] Sending notification email").setHeader("to").jsonpath("$.notification.to").setHeader("subject", constant("Notification")).setHeader("payload").jsonpath("$.notification.message").setBody(simple("{ \"status\": \"email sent\", \"to\": \"${header.to}\", \"subject\": \"${header.subject}\" }"));
            from("direct:http").id("example-http").log("[EXAMPLE HTTP] Sending http notification").setHeader("service").jsonpath("$.notification.service").setBody(simple("{ \"status\": \"http requested\", \"service\": \"${header.service}\" }"));
        }
    });
}
Also used : CamelContext(org.apache.camel.CamelContext) OsgiDefaultCamelContext(org.apache.camel.core.osgi.OsgiDefaultCamelContext) ModelCamelContext(org.apache.camel.model.ModelCamelContext) OsgiDataFormatResolver(org.apache.camel.core.osgi.OsgiDataFormatResolver) OsgiLanguageResolver(org.apache.camel.core.osgi.OsgiLanguageResolver) RouteBuilder(org.apache.camel.builder.RouteBuilder) OsgiDefaultCamelContext(org.apache.camel.core.osgi.OsgiDefaultCamelContext) OsgiClassResolver(org.apache.camel.core.osgi.OsgiClassResolver) BundleContext(org.osgi.framework.BundleContext) Activate(org.osgi.service.component.annotations.Activate)

Example 94 with Activate

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

the class Component method activate.

@Activate
public void activate() throws Exception {
    final String tmpDir = System.getProperty("java.io.tmpdir");
    final Path uploadPath = Paths.get(tmpDir, "karaf", "upload");
    uploadPath.toFile().mkdirs();
    httpService.registerServlet("/upload-example", new UploadServlet(uploadPath), null, null);
}
Also used : Path(java.nio.file.Path) Activate(org.osgi.service.component.annotations.Activate)

Example 95 with Activate

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

the class SoapService method activate.

@Activate
public void activate() throws Exception {
    JaxWsServerFactoryBean bean = new JaxWsServerFactoryBean();
    bean.setAddress("/example");
    bean.setServiceClass(BookingServiceSoap.class);
    bean.setServiceBean(new BookingServiceSoapImpl());
    bean.setBus(BusFactory.getDefaultBus());
    server = bean.create();
}
Also used : JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean) 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