1
2
3
4
5
6
7
8
9
10
11
12
13
14 package integrator;
15
16 import org.osgi.framework.Bundle;
17 import org.osgi.framework.BundleActivator;
18 import org.osgi.framework.BundleContext;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
21
22 import ch.qos.logback.classic.LoggerContext;
23 import ch.qos.logback.classic.joran.JoranConfigurator;
24 import ch.qos.logback.core.joran.spi.JoranException;
25 import ch.qos.logback.core.util.StatusPrinter;
26
27
28
29
30
31
32
33 public class Activator implements BundleActivator {
34
35 private BundleContext m_context = null;
36
37 public void start(BundleContext context) {
38 LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
39
40 try {
41 JoranConfigurator configurator = new JoranConfigurator();
42 configurator.setContext(lc);
43
44
45 lc.reset();
46 configurator.doConfigure("src/test/input/osgi/simple.xml");
47 } catch (JoranException je) {
48 je.printStackTrace();
49 }
50 StatusPrinter.printInCaseOfErrorsOrWarnings(lc);
51
52 Logger logger = LoggerFactory.getLogger(this.getClass());
53 logger.info("Activator.start()");
54 m_context = context;
55 }
56
57 public void stop(BundleContext context) {
58 m_context = null;
59 Logger logger = LoggerFactory.getLogger(this.getClass());
60 logger.info("Activator.stop");
61 }
62
63 public Bundle[] getBundles() {
64 if (m_context != null) {
65 return m_context.getBundles();
66 }
67 return null;
68 }
69 }