1
2
3
4
5 package gboat2.approveflow.service;
6
7
8 import java.util.LinkedList;
9 import java.util.List;
10
11 import org.osgi.framework.BundleContext;
12 import org.osgi.framework.ServiceReference;
13 import org.osgi.util.tracker.ServiceTracker;
14 import org.osgi.util.tracker.ServiceTrackerCustomizer;
15
16
17
18
19
20
21
22
23
24
25 public class ApproveFlowServiceFactory extends ServiceTracker {
26
27 private static List<IApproveFlowService> services = new LinkedList<IApproveFlowService>();
28
29 public ApproveFlowServiceFactory(BundleContext context, String filterName, ServiceTrackerCustomizer customizer) {
30 super(context, filterName, customizer);
31 }
32
33 @Override
34 public Object addingService(ServiceReference reference){
35 IApproveFlowService approveFlowService = (IApproveFlowService)context.getService(reference);
36 services.add(approveFlowService);
37 return super.addingService(reference);
38 }
39
40 @Override
41 public void remove(ServiceReference reference){
42 IApproveFlowService approveFlowService = (IApproveFlowService)context.getService(reference);
43 services.remove(approveFlowService);
44 }
45
46
47
48
49
50
51 public static List<IApproveFlowService> getApproveFlowServices() {
52 return services;
53 }
54
55 }