modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java | 5 ++--- modules/core/plugin-container/src/main/java/org/rhq/core/pc/content/ContentContextImpl.java | 7 +++---- modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java | 8 ++------ modules/core/plugin-container/src/main/java/org/rhq/core/pc/operation/OperationContextImpl.java | 8 ++++---- 4 files changed, 11 insertions(+), 17 deletions(-)
New commits: commit 00e0ed6c0abd80754d34d2ac8425f05cecbcb007 Author: John Sanda jsanda@redhat.com Date: Mon Feb 14 10:30:04 2011 -0500
[BZ 677349] Fixing more places that prematurely obtained PC read locks
ContentContextImpl and OperationContextImpl suffered from the same problems as EventContextImpl in that the PluginContainer locks are obtained prematurely. I have refactored these classes so that they do not obtain the lock (which occurs when calling the various PluginContainer.getXXXManager methods) until it is requested.
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java index 42600be..cbf6dde 100644 --- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java +++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java @@ -396,9 +396,8 @@ public class StandaloneContainer { }
- OperationManager opMan = pc.getOperationManager(); - OperationServices operationServices = new OperationServicesAdapter(opMan); - OperationContext operationContext = new OperationContextImpl(resourceId, operationServices); + OperationContext operationContext = new OperationContextImpl(resourceId); + OperationServices operationServices = operationContext.getOperationServices(); opId++;
Configuration config = null; diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/content/ContentContextImpl.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/content/ContentContextImpl.java index babf51e..7590231 100644 --- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/content/ContentContextImpl.java +++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/content/ContentContextImpl.java @@ -22,6 +22,7 @@ */ package org.rhq.core.pc.content;
+import org.rhq.core.pc.PluginContainer; import org.rhq.core.pluginapi.content.ContentContext; import org.rhq.core.pluginapi.content.ContentServices;
@@ -34,11 +35,9 @@ import org.rhq.core.pluginapi.content.ContentServices; */ public class ContentContextImpl implements ContentContext { private int resourceId; - private ContentServices contentServices;
- public ContentContextImpl(int resourceId, ContentServices contentServices) { + public ContentContextImpl(int resourceId) { this.resourceId = resourceId; - this.contentServices = contentServices; }
public int getResourceId() { @@ -46,6 +45,6 @@ public class ContentContextImpl implements ContentContext { }
public ContentServices getContentServices() { - return contentServices; + return PluginContainer.getInstance().getContentManager(); } } \ No newline at end of file diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java index 496b1f5..6afb021 100644 --- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java +++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java @@ -2284,9 +2284,7 @@ public class InventoryManager extends AgentService implements ContainerService, log.warn("RESOURCE ID IS 0! Operation features may not work - resource needs to be synced with server"); }
- OperationManager operationManager = PluginContainer.getInstance().getOperationManager(); - OperationServices operationServices = new OperationServicesAdapter(operationManager); - OperationContext operationContext = new OperationContextImpl(resource.getId(), operationServices); + OperationContext operationContext = new OperationContextImpl(resource.getId()); return operationContext; }
@@ -2310,9 +2308,7 @@ public class InventoryManager extends AgentService implements ContainerService, if (resource.getId() == 0) { log.warn("RESOURCE ID IS 0! Content features may not work - Resource needs to be synced with server"); } - ContentServices contentManager = PluginContainer.getInstance().getContentManager(); - //noinspection UnnecessaryLocalVariable - ContentContext contentContext = new ContentContextImpl(resource.getId(), contentManager); + ContentContext contentContext = new ContentContextImpl(resource.getId()); return contentContext; }
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/operation/OperationContextImpl.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/operation/OperationContextImpl.java index 6ed9605..32b0ca9 100644 --- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/operation/OperationContextImpl.java +++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/operation/OperationContextImpl.java @@ -22,6 +22,7 @@ */ package org.rhq.core.pc.operation;
+import org.rhq.core.pc.PluginContainer; import org.rhq.core.pluginapi.operation.OperationContext; import org.rhq.core.pluginapi.operation.OperationServices;
@@ -33,15 +34,14 @@ import org.rhq.core.pluginapi.operation.OperationServices; */ public class OperationContextImpl implements OperationContext { private int resourceId; - private OperationServices operationServices;
- public OperationContextImpl(int resourceId, OperationServices operationServices) { + public OperationContextImpl(int resourceId) { this.resourceId = resourceId; - this.operationServices = operationServices; }
public OperationServices getOperationServices() { - return operationServices; + OperationManager operationManager = PluginContainer.getInstance().getOperationManager(); + return new OperationServicesAdapter(operationManager); }
public int getResourceId() {
rhq-commits@lists.fedorahosted.org