Lines 59-82
Link Here
|
59 |
} |
59 |
} |
60 |
eventBus.addListener(busListener = new SynchronousProvisioningListener() { |
60 |
eventBus.addListener(busListener = new SynchronousProvisioningListener() { |
61 |
//The GC is triggered when an uninstall event occurred during a "transaction" and the transaction is committed. |
61 |
//The GC is triggered when an uninstall event occurred during a "transaction" and the transaction is committed. |
62 |
private boolean uninstallEventOccurred = false; |
62 |
private String uninstallEventProfileId = null; |
63 |
|
63 |
|
64 |
public void notify(EventObject o) { |
64 |
public void notify(EventObject o) { |
65 |
if (o instanceof InstallableUnitEvent) { |
65 |
if (o instanceof TransactionEvent && uninstallEventProfileId != null) { |
66 |
InstallableUnitEvent event = (InstallableUnitEvent) o; |
66 |
TransactionEvent event = (TransactionEvent) o; |
67 |
if (event.isUninstall() && event.isPost()) { |
67 |
// GC should only be run when a commit occurs with the same profile as the Uninstall event |
68 |
uninstallEventOccurred = true; |
68 |
if (o instanceof CommitOperationEvent && uninstallEventProfileId.equals(event.getProfile().getProfileId())) { |
69 |
} |
69 |
if (getBooleanPreference(GC_ENABLED, true)) |
70 |
} else if (o instanceof CommitOperationEvent) { |
|
|
71 |
if (uninstallEventOccurred == true) { |
72 |
CommitOperationEvent event = (CommitOperationEvent) o; |
73 |
if (getBooleanPreference(GC_ENABLED, true)) { |
74 |
new GarbageCollector().runGC(event.getProfile()); |
70 |
new GarbageCollector().runGC(event.getProfile()); |
75 |
} |
71 |
uninstallEventProfileId = null; |
76 |
uninstallEventOccurred = false; |
72 |
} else if (o instanceof RollbackOperationEvent && uninstallEventProfileId.equals(event.getProfile().getProfileId())) { |
|
|
73 |
// ProfileId is only unset when a rollback occurs with the same profile as the Uninstall event |
74 |
uninstallEventProfileId = null; |
77 |
} |
75 |
} |
78 |
} else if (o instanceof RollbackOperationEvent) { |
76 |
} else if (o instanceof InstallableUnitEvent) { |
79 |
uninstallEventOccurred = false; |
77 |
InstallableUnitEvent event = (InstallableUnitEvent) o; |
|
|
78 |
// If an Uninstall event is occurring, store the profileId for later comparison |
79 |
if (event.isUninstall() && event.isPost()) |
80 |
uninstallEventProfileId = event.getProfile().getProfileId(); |
80 |
} |
81 |
} |
81 |
} |
82 |
} |
82 |
}); |
83 |
}); |