blob: e67e7da8f5079616144935874a533603d75a4554 (
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
56
57
58
59
60
|
/*******************************************************************************
* Copyright (c) 2010 Boeing.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
package org.eclipse.osee.ote.ui.message.util;
import java.util.logging.Level;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.ote.client.msg.IOteMessageService;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.util.tracker.ServiceTracker;
/**
* @author Ken J. Aguilar
*
*/
public class ClientMessageServiceTracker extends ServiceTracker {
private final IOteMessageClientView viewer;
/**
* @param context
* @param filter
* @param customizer
*/
public ClientMessageServiceTracker(BundleContext context, IOteMessageClientView viewer) {
super(context, IOteMessageService.class.getName(), null);
this.viewer = viewer;
}
@Override
public synchronized Object addingService(ServiceReference reference) {
IOteMessageService service = (IOteMessageService)super.addingService(reference);
try {
viewer.oteMessageServiceAcquired(service);
} catch (RuntimeException e) {
OseeLog.log(ClientMessageServiceTracker.class, Level.SEVERE, "exception while notifying viewer of service", e);
}
return service;
}
@Override
public synchronized void removedService(ServiceReference reference, Object service) {
try {
viewer.oteMessageServiceReleased();
} catch (RuntimeException e) {
OseeLog.log(ClientMessageServiceTracker.class, Level.SEVERE, "exception while notifying viewer of service stop", e);
} finally {
super.removedService(reference, service);
}
}
}
|