blob: e6fb5cbe3fbc6cb108bc668a3e3f755cce8dae79 (
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
61
62
63
|
/*******************************************************************************
* 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.service;
import org.eclipse.osee.connection.service.IConnectionService;
import org.eclipse.osee.framework.messaging.MessageService;
import org.eclipse.osee.framework.messaging.services.RemoteServiceLookup;
import org.eclipse.osee.framework.plugin.core.util.ExportClassLoader;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.util.tracker.ServiceTracker;
/**
* @author Andrew M. Finkbeiner
*/
class RemoteLookupServiceTracker extends ServiceTracker {
private final MessageService messageService;
private final IConnectionService connectionService;
private final ExportClassLoader exportClassLoader;
private OteJmsServiceConnector oteJmsServiceConnector;
RemoteLookupServiceTracker(BundleContext context, MessageService messageService, IConnectionService connectionService, ExportClassLoader exportClassLoader) {
super(context, RemoteServiceLookup.class.getName(), null);
this.messageService = messageService;
this.connectionService = connectionService;
this.exportClassLoader = exportClassLoader;
}
@Override
public Object addingService(ServiceReference reference) {
RemoteServiceLookup remoteServiceLookup = (RemoteServiceLookup) context.getService(reference);
oteJmsServiceConnector =
new OteJmsServiceConnector(remoteServiceLookup, messageService, connectionService);
oteJmsServiceConnector.start();
return super.addingService(reference);
}
@Override
public void close() {
if (oteJmsServiceConnector != null) {
oteJmsServiceConnector.stop();
oteJmsServiceConnector = null;
}
super.close();
}
@Override
public void removedService(ServiceReference reference, Object service) {
if (oteJmsServiceConnector != null) {
oteJmsServiceConnector.stop();
}
super.removedService(reference, service);
}
}
|