[KARAF-4344] Migrating SLA components to DS
Project: http://git-wip-us.apache.org/repos/asf/karaf-decanter/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf-decanter/commit/e5992a37 Tree: http://git-wip-us.apache.org/repos/asf/karaf-decanter/tree/e5992a37 Diff: http://git-wip-us.apache.org/repos/asf/karaf-decanter/diff/e5992a37 Branch: refs/heads/DS-target Commit: e5992a37fa38aefee19f26a8c573a1f222b2bf2c Parents: fc488f2 Author: Christian Schneider <[email protected]> Authored: Thu Feb 18 17:05:51 2016 +0100 Committer: Christian Schneider <[email protected]> Committed: Thu Feb 18 17:06:18 2016 +0100 ---------------------------------------------------------------------- sla/camel/pom.xml | 1 - .../karaf/decanter/sla/camel/Activator.java | 76 ---------------- .../karaf/decanter/sla/camel/CamelAlerter.java | 25 +++++- sla/checker/pom.xml | 1 - .../karaf/decanter/sla/checker/Activator.java | 85 ------------------ .../karaf/decanter/sla/checker/Checker.java | 24 ++++- sla/email/pom.xml | 1 - .../karaf/decanter/sla/email/Activator.java | 94 -------------------- .../karaf/decanter/sla/email/EmailAlerter.java | 69 ++++++++------ sla/log/pom.xml | 1 - .../karaf/decanter/sla/log/Activator.java | 45 ---------- .../apache/karaf/decanter/sla/log/Logger.java | 7 ++ 12 files changed, 92 insertions(+), 337 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/karaf-decanter/blob/e5992a37/sla/camel/pom.xml ---------------------------------------------------------------------- diff --git a/sla/camel/pom.xml b/sla/camel/pom.xml index 03a20cb..9651107 100644 --- a/sla/camel/pom.xml +++ b/sla/camel/pom.xml @@ -48,7 +48,6 @@ <artifactId>maven-bundle-plugin</artifactId> <configuration> <instructions> - <Bundle-Activator>org.apache.karaf.decanter.sla.camel.Activator</Bundle-Activator> </instructions> </configuration> </plugin> http://git-wip-us.apache.org/repos/asf/karaf-decanter/blob/e5992a37/sla/camel/src/main/java/org/apache/karaf/decanter/sla/camel/Activator.java ---------------------------------------------------------------------- diff --git a/sla/camel/src/main/java/org/apache/karaf/decanter/sla/camel/Activator.java b/sla/camel/src/main/java/org/apache/karaf/decanter/sla/camel/Activator.java deleted file mode 100644 index 307ce3b..0000000 --- a/sla/camel/src/main/java/org/apache/karaf/decanter/sla/camel/Activator.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.karaf.decanter.sla.camel; - -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; -import org.osgi.framework.Constants; -import org.osgi.framework.ServiceRegistration; -import org.osgi.service.cm.ConfigurationException; -import org.osgi.service.cm.ManagedService; -import org.osgi.service.event.EventConstants; -import org.osgi.service.event.EventHandler; - -import java.util.Dictionary; -import java.util.Hashtable; - -public class Activator implements BundleActivator { - - private ServiceRegistration serviceRegistration; - - private final static String CONFIG_PID = "org.apache.karaf.decanter.sla.camel"; - - public void start(BundleContext bundleContext) { - Dictionary<String, String> properties = new Hashtable<>(); - properties.put(Constants.SERVICE_PID, CONFIG_PID); - serviceRegistration = bundleContext.registerService(ManagedService.class.getName(), new ConfigUpdater(bundleContext), - properties); - } - - public void stop(BundleContext bundleContext) { - if (serviceRegistration != null) { - serviceRegistration.unregister(); - } - } - - private final class ConfigUpdater implements ManagedService { - - private BundleContext bundleContext; - private ServiceRegistration serviceReg; - - public ConfigUpdater(BundleContext bundleContext) { - this.bundleContext = bundleContext; - } - - @Override - public void updated(Dictionary config) throws ConfigurationException { - if (serviceReg != null) { - serviceReg.unregister(); - } - if (config == null || config.get("alert.destination.uri") == null) { - throw new ConfigurationException("alert.destination.uri", "alert.destination.uri property is not defined"); - } - String alertDestinationUri = (String) config.get("alert.destination.uri"); - CamelAlerter alerter = new CamelAlerter(alertDestinationUri); - Dictionary<String, String> properties = new Hashtable<>(); - properties.put(EventConstants.EVENT_TOPIC, "decanter/alert/*"); - serviceReg = bundleContext.registerService(EventHandler.class, alerter, properties); - } - - } - -} http://git-wip-us.apache.org/repos/asf/karaf-decanter/blob/e5992a37/sla/camel/src/main/java/org/apache/karaf/decanter/sla/camel/CamelAlerter.java ---------------------------------------------------------------------- diff --git a/sla/camel/src/main/java/org/apache/karaf/decanter/sla/camel/CamelAlerter.java b/sla/camel/src/main/java/org/apache/karaf/decanter/sla/camel/CamelAlerter.java index 52357b2..16e4dad 100644 --- a/sla/camel/src/main/java/org/apache/karaf/decanter/sla/camel/CamelAlerter.java +++ b/sla/camel/src/main/java/org/apache/karaf/decanter/sla/camel/CamelAlerter.java @@ -19,19 +19,36 @@ package org.apache.karaf.decanter.sla.camel; import org.apache.camel.CamelContext; import org.apache.camel.ProducerTemplate; import org.apache.camel.impl.DefaultCamelContext; +import org.osgi.service.cm.ConfigurationException; +import org.osgi.service.component.ComponentContext; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Deactivate; import org.osgi.service.event.Event; +import org.osgi.service.event.EventConstants; import org.osgi.service.event.EventHandler; +import java.util.Dictionary; import java.util.HashMap; import java.util.Map; +@Component( + configurationPid="org.apache.karaf.decanter.sla.camel", + property=EventConstants.EVENT_TOPIC + "=decanter/alert/*" +) public class CamelAlerter implements EventHandler { private CamelContext camelContext; private String alertDestinationUri; - public CamelAlerter(String alertDestinationUri) { - this.alertDestinationUri = alertDestinationUri; + @SuppressWarnings("unchecked") + @Activate + public void activate(ComponentContext context) throws ConfigurationException { + Dictionary<String, String> config = context.getProperties(); + this.alertDestinationUri = (String) config.get("alert.destination.uri"); + if (alertDestinationUri == null) { + throw new ConfigurationException("alert.destination.uri", "alert.destination.uri property is not defined"); + } this.camelContext = new DefaultCamelContext(); } @@ -49,4 +66,8 @@ public class CamelAlerter implements EventHandler { producerTemplate.sendBodyAndHeaders(alertDestinationUri, data, headers); } + @Deactivate + public void deactivate() throws Exception { + this.camelContext.stop(); + } } http://git-wip-us.apache.org/repos/asf/karaf-decanter/blob/e5992a37/sla/checker/pom.xml ---------------------------------------------------------------------- diff --git a/sla/checker/pom.xml b/sla/checker/pom.xml index 6113ae0..867d7b5 100644 --- a/sla/checker/pom.xml +++ b/sla/checker/pom.xml @@ -40,7 +40,6 @@ <artifactId>maven-bundle-plugin</artifactId> <configuration> <instructions> - <Bundle-Activator>org.apache.karaf.decanter.sla.checker.Activator</Bundle-Activator> </instructions> </configuration> </plugin> http://git-wip-us.apache.org/repos/asf/karaf-decanter/blob/e5992a37/sla/checker/src/main/java/org/apache/karaf/decanter/sla/checker/Activator.java ---------------------------------------------------------------------- diff --git a/sla/checker/src/main/java/org/apache/karaf/decanter/sla/checker/Activator.java b/sla/checker/src/main/java/org/apache/karaf/decanter/sla/checker/Activator.java deleted file mode 100644 index f199ffe..0000000 --- a/sla/checker/src/main/java/org/apache/karaf/decanter/sla/checker/Activator.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.karaf.decanter.sla.checker; - -import org.osgi.framework.*; -import org.osgi.service.cm.ConfigurationException; -import org.osgi.service.cm.ManagedService; -import org.osgi.service.event.EventAdmin; -import org.osgi.service.event.EventConstants; -import org.osgi.service.event.EventHandler; -import org.osgi.util.tracker.ServiceTracker; - -import java.util.Dictionary; -import java.util.Hashtable; - -public class Activator implements BundleActivator { - - private ServiceTracker<EventAdmin, ServiceRegistration> tracker; - - public void start(final BundleContext bundleContext) throws Exception { - tracker = new ServiceTracker<EventAdmin, ServiceRegistration>(bundleContext, EventAdmin.class, null) { - - @Override - public ServiceRegistration<?> addingService(ServiceReference<EventAdmin> reference) { - EventAdmin eventAdmin = bundleContext.getService(reference); - ConfigUpdater configManager = new ConfigUpdater(bundleContext, eventAdmin); - Hashtable<String, Object> properties = new Hashtable<String, Object>(); - properties.put(Constants.SERVICE_PID, "org.apache.karaf.decanter.sla.checker"); - return bundleContext.registerService(ManagedService.class, configManager, properties); - } - - @Override - public void removedService(ServiceReference<EventAdmin> reference, ServiceRegistration reg) { - reg.unregister(); - super.removedService(reference, reg); - } - - }; - tracker.open(); - } - - public void stop(BundleContext bundleContext) throws Exception { - tracker.close(); - } - - private final class ConfigUpdater implements ManagedService { - - private BundleContext bundleContext; - private EventAdmin eventAdmin; - private ServiceRegistration<?> serviceReg; - private Checker checker; - - public ConfigUpdater(BundleContext bundleContext, EventAdmin eventAdmin) { - this.bundleContext = bundleContext; - this.eventAdmin = eventAdmin; - } - - @Override - public void updated(Dictionary config) throws ConfigurationException { - if (checker != null) { - serviceReg.unregister(); - } - checker = new Checker(config, eventAdmin); - Dictionary<String, String> properties = new Hashtable<>(); - properties.put(EventConstants.EVENT_TOPIC, "decanter/collect/*"); - serviceReg = bundleContext.registerService(EventHandler.class, checker, properties); - } - - } - -} http://git-wip-us.apache.org/repos/asf/karaf-decanter/blob/e5992a37/sla/checker/src/main/java/org/apache/karaf/decanter/sla/checker/Checker.java ---------------------------------------------------------------------- diff --git a/sla/checker/src/main/java/org/apache/karaf/decanter/sla/checker/Checker.java b/sla/checker/src/main/java/org/apache/karaf/decanter/sla/checker/Checker.java index f32c07e..085a8d0 100644 --- a/sla/checker/src/main/java/org/apache/karaf/decanter/sla/checker/Checker.java +++ b/sla/checker/src/main/java/org/apache/karaf/decanter/sla/checker/Checker.java @@ -16,8 +16,13 @@ */ package org.apache.karaf.decanter.sla.checker; +import org.osgi.service.component.ComponentContext; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Reference; import org.osgi.service.event.Event; import org.osgi.service.event.EventAdmin; +import org.osgi.service.event.EventConstants; import org.osgi.service.event.EventHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -31,16 +36,22 @@ import java.util.regex.Pattern; /** * Receive all collect events to validate SLA and eventually throw alert events */ +@Component( + name="org.apache.karaf.decanter.sla.checker", + immediate=true, + property=EventConstants.EVENT_TOPIC + "=decanter/collect/*" +) public class Checker implements EventHandler { private final static Logger LOGGER = LoggerFactory.getLogger(Checker.class); - private Dictionary config; + private Dictionary<String, Object> config; private EventAdmin eventAdmin; - public Checker(Dictionary config, EventAdmin eventAdmin) { - this.config = config; - this.eventAdmin = eventAdmin; + @SuppressWarnings("unchecked") + @Activate + public void activate(ComponentContext context) { + this.config = context.getProperties(); } @Override @@ -381,4 +392,9 @@ public class Checker implements EventHandler { } } + @Reference + public void setEventAdmin(EventAdmin eventAdmin) { + this.eventAdmin = eventAdmin; + } + } http://git-wip-us.apache.org/repos/asf/karaf-decanter/blob/e5992a37/sla/email/pom.xml ---------------------------------------------------------------------- diff --git a/sla/email/pom.xml b/sla/email/pom.xml index c33d5a3..5bf3aa7 100644 --- a/sla/email/pom.xml +++ b/sla/email/pom.xml @@ -48,7 +48,6 @@ <artifactId>maven-bundle-plugin</artifactId> <configuration> <instructions> - <Bundle-Activator>org.apache.karaf.decanter.sla.email.Activator</Bundle-Activator> </instructions> </configuration> </plugin> http://git-wip-us.apache.org/repos/asf/karaf-decanter/blob/e5992a37/sla/email/src/main/java/org/apache/karaf/decanter/sla/email/Activator.java ---------------------------------------------------------------------- diff --git a/sla/email/src/main/java/org/apache/karaf/decanter/sla/email/Activator.java b/sla/email/src/main/java/org/apache/karaf/decanter/sla/email/Activator.java deleted file mode 100644 index 91fd45b..0000000 --- a/sla/email/src/main/java/org/apache/karaf/decanter/sla/email/Activator.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.karaf.decanter.sla.email; - -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; -import org.osgi.framework.Constants; -import org.osgi.framework.ServiceRegistration; -import org.osgi.service.cm.ConfigurationException; -import org.osgi.service.cm.ManagedService; -import org.osgi.service.event.EventConstants; -import org.osgi.service.event.EventHandler; - -import java.util.Dictionary; -import java.util.Hashtable; - -public class Activator implements BundleActivator { - - private ServiceRegistration serviceRegistration; - - private final static String CONFIG_PID = "org.apache.karaf.decanter.sla.email"; - - @Override - public void start(BundleContext bundleContext) { - Dictionary<String, String> properties = new Hashtable<>(); - properties.put(Constants.SERVICE_PID, CONFIG_PID); - serviceRegistration = bundleContext.registerService(ManagedService.class.getName(), new ConfigUpdater(bundleContext), - properties); - } - - @Override - public void stop(BundleContext bundleContext) { - if (serviceRegistration != null) { - serviceRegistration.unregister(); - } - } - - private class ConfigUpdater implements ManagedService { - - private BundleContext bundleContext; - private ServiceRegistration registration; - - public ConfigUpdater(BundleContext bundleContext) { - this.bundleContext = bundleContext; - } - - public void updated(Dictionary config) throws ConfigurationException { - if (registration != null) { - registration.unregister(); - } - if (config == null || config.get("from") == null) { - throw new ConfigurationException("from", "from property is not defined"); - } - String from = (String) config.get("from"); - if (config == null || config.get("to") == null) { - throw new ConfigurationException("to", "to property is not defined"); - } - String to = (String) config.get("to"); - if (config == null || config.get("host") == null) { - throw new ConfigurationException("host", "host property is not defined"); - } - String host = (String) config.get("host"); - String port = (String) config.get("port"); - String auth = (String) config.get("auth"); - String starttls = (String) config.get("starttls"); - String ssl = (String) config.get("ssl"); - String username = null; - String password = null; - if (config != null) { - username = (String) config.get("username"); - password = (String) config.get("password"); - } - EmailAlerter alerter = new EmailAlerter(from, to, host, port, auth, starttls, ssl, username, password); - Dictionary<String, String> properties = new Hashtable<>(); - properties.put(EventConstants.EVENT_TOPIC, "decanter/alert/*"); - registration = bundleContext.registerService(EventHandler.class, alerter, properties); - } - - } -} http://git-wip-us.apache.org/repos/asf/karaf-decanter/blob/e5992a37/sla/email/src/main/java/org/apache/karaf/decanter/sla/email/EmailAlerter.java ---------------------------------------------------------------------- diff --git a/sla/email/src/main/java/org/apache/karaf/decanter/sla/email/EmailAlerter.java b/sla/email/src/main/java/org/apache/karaf/decanter/sla/email/EmailAlerter.java index ec24b17..41f67fe 100644 --- a/sla/email/src/main/java/org/apache/karaf/decanter/sla/email/EmailAlerter.java +++ b/sla/email/src/main/java/org/apache/karaf/decanter/sla/email/EmailAlerter.java @@ -16,7 +16,11 @@ */ package org.apache.karaf.decanter.sla.email; +import org.osgi.service.cm.ConfigurationException; +import org.osgi.service.component.ComponentContext; +import org.osgi.service.component.annotations.Component; import org.osgi.service.event.Event; +import org.osgi.service.event.EventConstants; import org.osgi.service.event.EventHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -26,46 +30,57 @@ import javax.mail.Session; import javax.mail.Transport; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; + +import java.util.Dictionary; import java.util.Properties; +@Component( + name = "org.apache.karaf.decanter.sla.email", + property = EventConstants.EVENT_TOPIC + "=decanter/alert/*" +) public class EmailAlerter implements EventHandler { private final static Logger LOGGER = LoggerFactory.getLogger(EmailAlerter.class); private String from; private String to; - private String host; - private String port; - private String auth; - private String starttls; - private String ssl; - private String username; - private String password; - public EmailAlerter(String from, String to, String host, String port, String auth, String starttls, String ssl, String username, String password) { - this.from = from; - this.to = to; - this.host = host; - this.port = port; - this.auth = auth; - this.starttls = starttls; - this.ssl = ssl; - this.username = username; - this.password = password; + private Properties properties; + + @SuppressWarnings("unchecked") + public void activate(ComponentContext context) throws ConfigurationException { + Dictionary<String, String> config = context.getProperties(); + requireProperty(config, "from"); + requireProperty(config, "to"); + requireProperty(config, "host"); + + this.from = config.get("from"); + this.to = config.get("to"); + + properties = new Properties(); + properties.put("mail.smtp.host", config.get("host")); + properties.put("mail.smtp.port", config.get("port")); + properties.put("mail.smtp.auth", config.get("auth")); + properties.put("mail.smtp.starttls.enable", config.get("starttls")); + properties.put("mail.smtp.ssl.enable", config.get("ssl")); + String username = (String) config.get("username"); + String password = (String) config.get("password"); + if (username != null) { + properties.put("mail.user", username); + } + if (password != null) { + properties.put("mail.password", password); + } + } + + private void requireProperty(Dictionary<String, ?> config, String key) throws ConfigurationException { + if (config.get(key) == null) { + throw new ConfigurationException(key, key + " property is not defined"); + } } @Override public void handleEvent(Event event) { - Properties properties = new Properties(); - properties.put("mail.smtp.host", host); - properties.put("mail.smtp.port", port); - properties.put("mail.smtp.auth", auth); - properties.put("mail.smtp.starttls.enable", starttls); - properties.put("mail.smtp.ssl.enable", ssl); - if (username != null) - properties.put("mail.user", username); - if (password != null) - properties.put("mail.password", password); Session session = Session.getDefaultInstance(properties); MimeMessage message = new MimeMessage(session); try { http://git-wip-us.apache.org/repos/asf/karaf-decanter/blob/e5992a37/sla/log/pom.xml ---------------------------------------------------------------------- diff --git a/sla/log/pom.xml b/sla/log/pom.xml index 8011b39..b4da436 100644 --- a/sla/log/pom.xml +++ b/sla/log/pom.xml @@ -40,7 +40,6 @@ <artifactId>maven-bundle-plugin</artifactId> <configuration> <instructions> - <Bundle-Activator>org.apache.karaf.decanter.sla.log.Activator</Bundle-Activator> </instructions> </configuration> </plugin> http://git-wip-us.apache.org/repos/asf/karaf-decanter/blob/e5992a37/sla/log/src/main/java/org/apache/karaf/decanter/sla/log/Activator.java ---------------------------------------------------------------------- diff --git a/sla/log/src/main/java/org/apache/karaf/decanter/sla/log/Activator.java b/sla/log/src/main/java/org/apache/karaf/decanter/sla/log/Activator.java deleted file mode 100644 index adc020c..0000000 --- a/sla/log/src/main/java/org/apache/karaf/decanter/sla/log/Activator.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.karaf.decanter.sla.log; - -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceRegistration; -import org.osgi.service.event.EventConstants; -import org.osgi.service.event.EventHandler; - -import java.util.Dictionary; -import java.util.Hashtable; - -public class Activator implements BundleActivator { - - private ServiceRegistration registration; - - public void start(BundleContext bundleContext) { - Logger logger = new Logger(); - Dictionary<String, String> properties = new Hashtable<>(); - properties.put(EventConstants.EVENT_TOPIC, "decanter/alert/*"); - registration = bundleContext.registerService(EventHandler.class, logger, properties); - } - - public void stop(BundleContext bundleContext) { - if (registration != null) { - registration.unregister(); - } - } - -} http://git-wip-us.apache.org/repos/asf/karaf-decanter/blob/e5992a37/sla/log/src/main/java/org/apache/karaf/decanter/sla/log/Logger.java ---------------------------------------------------------------------- diff --git a/sla/log/src/main/java/org/apache/karaf/decanter/sla/log/Logger.java b/sla/log/src/main/java/org/apache/karaf/decanter/sla/log/Logger.java index 12d57e6..cf54fb9 100644 --- a/sla/log/src/main/java/org/apache/karaf/decanter/sla/log/Logger.java +++ b/sla/log/src/main/java/org/apache/karaf/decanter/sla/log/Logger.java @@ -16,10 +16,17 @@ */ package org.apache.karaf.decanter.sla.log; +import org.osgi.service.component.annotations.Component; import org.osgi.service.event.Event; +import org.osgi.service.event.EventConstants; import org.osgi.service.event.EventHandler; import org.slf4j.LoggerFactory; +@Component( + name="org.apache.karaf.decanter.sla.log", + immediate=true, + property=EventConstants.EVENT_TOPIC + "=decanter/alert/*" +) public class Logger implements EventHandler { private final static org.slf4j.Logger LOGGER = LoggerFactory.getLogger(Logger.class);
