1
2
3
4
5 package gboat2.cxf;
6
7 import gboat2.base.core.ActivatorInnerThread;
8 import gboat2.cxf.business.IWebServiceConfigBusiness;
9
10 import org.apache.commons.lang3.time.DateUtils;
11 import org.osgi.framework.BundleActivator;
12 import org.osgi.framework.BundleContext;
13 import org.osgi.framework.ServiceReference;
14 import org.osgi.util.tracker.ServiceTracker;
15
16
17
18
19
20
21
22 public class Activator implements BundleActivator {
23
24 private ServiceTracker<IWebServiceConfigBusiness, Object> tracker;
25
26 @Override
27 public void start(final BundleContext bundleContext) throws Exception {
28 tracker = new ServiceTracker<IWebServiceConfigBusiness, Object>(bundleContext, IWebServiceConfigBusiness.class.getName(), null) {
29 @Override
30 public Object addingService(final ServiceReference<IWebServiceConfigBusiness> ref) {
31 new ActivatorInnerThread(DateUtils.MILLIS_PER_MINUTE * 2) {
32 @Override
33 public boolean task() {
34 IWebServiceConfigBusiness busi = bundleContext.getService(ref);
35 busi.startPublishAndTrackWebService();
36 tracker.close();
37 tracker = null;
38 return true;
39 }
40 }.start();
41
42
43
44
45
46
47
48 return super.addingService(ref);
49 }
50
51 };
52 tracker.open();
53 }
54
55 @Override
56 public void stop(BundleContext bundleContext) throws Exception {
57
58
59
60
61
62
63
64
65
66
67
68 }
69 }