diff options
author | slewis | 2013-10-25 20:16:50 +0000 |
---|---|---|
committer | slewis | 2013-10-25 20:16:50 +0000 |
commit | b2bd8a99cccb6173feb7c1ef734a573854196aea (patch) | |
tree | 698ae90a42cfc12da2b4cf0a90d67c5cdb5cad9e /osgi | |
parent | 70aa545dc4edc139f6fc87d0fe142b9cbb71a7a0 (diff) | |
download | org.eclipse.ecf-b2bd8a99cccb6173feb7c1ef734a573854196aea.tar.gz org.eclipse.ecf-b2bd8a99cccb6173feb7c1ef734a573854196aea.tar.xz org.eclipse.ecf-b2bd8a99cccb6173feb7c1ef734a573854196aea.zip |
Fix for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=420419
Diffstat (limited to 'osgi')
-rw-r--r-- | osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteServiceAdmin.java | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteServiceAdmin.java b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteServiceAdmin.java index 0ea0f49a3..b0b870d1e 100644 --- a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteServiceAdmin.java +++ b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteServiceAdmin.java @@ -1506,15 +1506,15 @@ public class RemoteServiceAdmin implements private ImportEndpoint createAndRegisterProxy( final EndpointDescription endpointDescription, - IRemoteServiceContainer rsContainer, - IRemoteServiceReference selectedRsReference) throws Exception { + final IRemoteServiceContainer rsContainer, + final IRemoteServiceReference selectedRsReference) throws Exception { final BundleContext proxyServiceFactoryContext = getProxyServiceFactoryContext(endpointDescription); if (proxyServiceFactoryContext == null) throw new NullPointerException( "getProxyServiceFactoryContext returned null. Cannot register proxy service factory"); //$NON-NLS-1$ - IRemoteServiceContainerAdapter containerAdapter = rsContainer + final IRemoteServiceContainerAdapter containerAdapter = rsContainer .getContainerAdapter(); ID rsContainerID = rsContainer.getContainer().getID(); // First get IRemoteService for selectedRsReference @@ -1540,7 +1540,7 @@ public class RemoteServiceAdmin implements return proxyServiceFactoryContext.registerService( (String[]) serviceTypes .toArray(new String[serviceTypes.size()]), - createProxyServiceFactory(endpointDescription, + createProxyServiceFactory(endpointDescription,containerAdapter,selectedRsReference, rs), (Dictionary) PropertiesUtil .createDictionaryFromMap(proxyProperties)); @@ -1593,9 +1593,9 @@ public class RemoteServiceAdmin implements private ServiceFactory createProxyServiceFactory( EndpointDescription endpointDescription, - IRemoteService remoteService) { + IRemoteServiceContainerAdapter containerAdapter, IRemoteServiceReference selectedRsReference, IRemoteService remoteService) { return new ProxyServiceFactory( - endpointDescription.getInterfaceVersions(), remoteService); + endpointDescription.getInterfaceVersions(), containerAdapter, selectedRsReference, remoteService); } private Collection<Class> loadServiceInterfacesViaBundle(Bundle bundle, @@ -1623,22 +1623,32 @@ public class RemoteServiceAdmin implements } class ProxyServiceFactory implements ServiceFactory { + private final IRemoteServiceContainerAdapter containerAdapter; + private final IRemoteServiceReference rsReference; private IRemoteService remoteService; private Map<String, Version> interfaceVersions; - + private long remoteProxyCount = 0L; + public ProxyServiceFactory(Map<String, Version> interfaceVersions, - IRemoteService remoteService) { + IRemoteServiceContainerAdapter containerAdapter, IRemoteServiceReference rsReference, IRemoteService remoteService) { + this.containerAdapter = containerAdapter; + this.rsReference = rsReference; this.interfaceVersions = interfaceVersions; this.remoteService = remoteService; } public Object getService(Bundle bundle, ServiceRegistration registration) { - return createProxy(bundle, registration.getReference(), + Object proxy = createProxy(bundle, registration.getReference(), remoteService, interfaceVersions); + remoteProxyCount++; + return proxy; } public void ungetService(Bundle bundle, ServiceRegistration registration, Object service) { + if (remoteProxyCount == 1L) + containerAdapter.ungetRemoteService(rsReference); + remoteProxyCount--; ungetProxyClassLoader(bundle); } } |