Skip to main content
summaryrefslogtreecommitdiffstats
blob: 85ecfe2cb2bac43c5c48a2028efa03b09ebc3374 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
 * Created on Mar 11, 2010
 *
 * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
 */
package org.eclipse.osee.framework.messaging.event.res;

import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.messaging.ConnectionNode;
import org.eclipse.osee.framework.messaging.MessageService;
import org.osgi.framework.ServiceReference;
import org.osgi.util.tracker.ServiceTracker;

/**
 * @author Donald G. Dunne
 */
public class ResMessagingTracker extends ServiceTracker {

   private ConnectionNode connectionNode;

   public ResMessagingTracker() {
      super(Activator.getInstance().getBundle().getBundleContext(), MessageService.class.getName(), null);
   }

   @Override
   public Object addingService(ServiceReference reference) {
      MessageService service = (MessageService) super.addingService(reference);
      try {
         connectionNode = service.getDefault();
      } catch (OseeCoreException ex) {
         System.err.println("Can't add RES messaging service " + ex.getLocalizedMessage());
         ex.printStackTrace();
      }
      return service;
   }

   @Override
   public void removedService(ServiceReference reference, Object service) {
      super.removedService(reference, service);
   }

   @Override
   public MessageService getService() {
      return (MessageService) super.getService();
   }

   public ConnectionNode getConnectionNode() {
      return connectionNode;
   }

   public void setConnectionNode(ConnectionNode connectionNode) {
      this.connectionNode = connectionNode;
   }

}

Back to the top