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);
}
}
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);
}
}
}
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}\" }"));
}
});
}
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);
}
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();
}
Aggregations