|
(省略)
public class UIActivator implements BundleActivator {
(省略)
@Override
public void start(BundleContext context) throws Exception {
bundle = context.getBundle();
if(tracker == null){
tracker = new ServiceTracker(context, INotificationService.class.getName(),null);
}
tracker.open(true);
createOpenTimer();
}
(省略)
private void createOpenTimer() {
openTimer = new Timer();
openTimer.scheduleAtFixedRate(new TimerTask(){
@Override
public void run() {
final List<INotificationMessage> contents = new ArrayList<INotificationMessage>();
Object[] services = tracker.getServices();
if(services == null) return;
for(Object obj : services){
INotificationService service = (INotificationService) obj;
contents.addAll(service.getContents());
}
(省略)
public void stop(BundleContext context) throws Exception {
openTimer.cancel();
openTimer.purge();
openTimer = null;
tracker.close();
tracker = null;
(省略)
}
|
|