You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cl...@apache.org on 2013/06/05 18:41:52 UTC
svn commit: r1489948 -
/felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/extender/internal/linker/ManagedType.java
Author: clement
Date: Wed Jun 5 16:41:52 2013
New Revision: 1489948
URL: http://svn.apache.org/r1489948
Log:
Fix FELIX-4105
Factories not disposed when their bundle is leaving
Modified:
felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/extender/internal/linker/ManagedType.java
Modified: felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/extender/internal/linker/ManagedType.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/extender/internal/linker/ManagedType.java?rev=1489948&r1=1489947&r2=1489948&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/extender/internal/linker/ManagedType.java (original)
+++ felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/extender/internal/linker/ManagedType.java Wed Jun 5 16:41:52 2013
@@ -161,6 +161,15 @@ public class ManagedType implements Fact
* Stopping the management.
*/
public void stop() {
+ try {
+ IPojoFactory factory = m_future.get();
+ if (factory != null) {
+ factory.dispose();
+ }
+ } catch (Exception e) {
+ // Ignored.
+ }
+
m_instanceTracker.close();
m_extensionTracker.close();
}
@@ -187,7 +196,6 @@ public class ManagedType implements Fact
*/
private class ExtensionSupport implements ServiceTrackerCustomizer {
public Object addingService(ServiceReference reference) {
- // TODO Check if we can cast the instance
final Object service = m_bundleContext.getService(reference);
if (service instanceof ExtensionDeclaration) {
m_future = m_queueService.submit(new ReferenceableCallable<IPojoFactory>(reference.getBundle()) {
@@ -233,8 +241,8 @@ public class ManagedType implements Fact
IPojoFactory factory = m_future.get();
// It is possible that the factory couldn't be created
if (factory != null) {
- factory.stop();
factory.removeFactoryStateListener(ManagedType.this);
+ factory.dispose();
m_declaration.unbind("Extension '%s' is missing");
}
} catch (InterruptedException e) {
@@ -248,7 +256,6 @@ public class ManagedType implements Fact
private class InstanceSupport implements ServiceTrackerCustomizer {
public Object addingService(final ServiceReference reference) {
- // TODO Check if we can cast the instance
Object service = m_bundleContext.getService(reference);
if (service instanceof InstanceDeclaration) {
final InstanceDeclaration instanceDeclaration = (InstanceDeclaration) service;
@@ -325,7 +332,7 @@ public class ManagedType implements Fact
public void removedService(ServiceReference reference, Object o) {
InstanceDeclaration instanceDeclaration = (InstanceDeclaration) m_bundleContext.getService(reference);
Future<ComponentInstance> future = (Future<ComponentInstance>) o;
- ComponentInstance instance = null;
+ ComponentInstance instance;
try {
instance = future.get();
// It is possible that the instance couldn't be created