modules/core/domain/src/main/java/org/rhq/core/domain/cloud/FailoverListDetails.java | 2
modules/core/domain/src/main/java/org/rhq/core/domain/cloud/Server.java | 2
modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSource.java | 6
modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSourceType.java | 5
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceTypeCriteria.java | 2
modules/core/domain/src/main/java/org/rhq/core/domain/operation/OperationHistory.java | 8
modules/core/domain/src/main/java/org/rhq/core/domain/operation/OperationScheduleEntity.java | 6
modules/core/domain/src/main/java/org/rhq/core/domain/plugin/ServerPlugin.java | 52 +--
modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java | 56 +--
modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceType.java | 4
modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/service/ManagementService.java | 5
modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/InstallerGWTServiceImpl.java | 156 +++++++---
modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/ServerInstallUtil.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/CustomJaasDeploymentService.java | 16 -
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/service/ManagementService.java | 5
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/ServerPluginsBeanTest.java | 2
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/ContentMetadataManagerBeanTest.java | 4
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/OperationMetadataManagerBeanTest.java | 10
18 files changed, 216 insertions(+), 127 deletions(-)
New commits:
commit fe14d79a25f594d41feaa1b6320012a3dd1e5ce6
Author: Jay Shaughnessy <jshaughn(a)jshaughn.csb>
Date: Thu Sep 20 14:37:34 2012 -0400
H4 is more strict about the use of identification variables (aka alias)
in queries. Make sure we define them and use them if necesssary. This was
a particular problem in ServerPlugin queries.
FYI: H4 may throw a NoResultException when this issue occurs.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/cloud/FailoverListDetails.java b/modules/core/domain/src/main/java/org/rhq/core/domain/cloud/FailoverListDetails.java
index 9682e35..790ba9a 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/cloud/FailoverListDetails.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/cloud/FailoverListDetails.java
@@ -50,7 +50,7 @@ import javax.persistence.Table;
@NamedQueries( //
{
@NamedQuery(name = FailoverListDetails.QUERY_GET_VIA_AGENT_ID, query = "SELECT fld FROM FailoverListDetails fld WHERE fld.failoverList IN ( SELECT fl FROM FailoverList fl WHERE fl.agent.id = :agentId )"),
- @NamedQuery(name = FailoverListDetails.QUERY_GET_VIA_AGENT_ID_WITH_SERVERS, query = "SELECT fld FROM FailoverListDetails fld JOIN FETCH fld.server WHERE fld.failoverList IN ( SELECT fl FROM FailoverList fl WHERE fl.agent.id = :agentId )"),
+ @NamedQuery(name = FailoverListDetails.QUERY_GET_VIA_AGENT_ID_WITH_SERVERS, query = "SELECT fld FROM FailoverListDetails fld JOIN FETCH fld.server server WHERE fld.failoverList IN ( SELECT fl FROM FailoverList fl WHERE fl.agent.id = :agentId )"),
@NamedQuery(name = FailoverListDetails.QUERY_DELETE_VIA_AGENT, query = "DELETE FROM FailoverListDetails fld WHERE fld.failoverList IN ( SELECT fl FROM FailoverList fl WHERE fl.agent = :agent )"),
@NamedQuery(name = FailoverListDetails.QUERY_DELETE_VIA_SERVER, query = "DELETE FROM FailoverListDetails fld WHERE fld.server.id = :serverId"),
@NamedQuery(name = FailoverListDetails.QUERY_GET_ASSIGNED_LOADS, query = "SELECT new org.rhq.core.domain.cloud.composite.FailoverListDetailsComposite(fld.ordinal, fld.serverId, COUNT(fld.serverId)) FROM FailoverListDetails fld GROUP BY fld.ordinal, fld.serverId ORDER BY fld.ordinal ASC"),
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/cloud/Server.java b/modules/core/domain/src/main/java/org/rhq/core/domain/cloud/Server.java
index 520ab14..64b7224 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/cloud/Server.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/cloud/Server.java
@@ -66,7 +66,7 @@ import org.rhq.core.domain.resource.Agent;
@NamedQuery(name = Server.QUERY_FIND_BY_NAME, query = "" //
+ " SELECT s " //
+ " FROM Server s " //
- + "LEFT JOIN FETCH s.affinityGroup " //
+ + "LEFT JOIN FETCH s.affinityGroup ag " //
+ " WHERE s.name = :name"),
@NamedQuery(name = Server.QUERY_FIND_ALL_CLOUD_MEMBERS, query = "SELECT s FROM Server s WHERE NOT s.operationMode = 'INSTALLED'"),
@NamedQuery(name = Server.QUERY_FIND_ALL_NORMAL_CLOUD_MEMBERS, query = "SELECT s FROM Server s WHERE s.operationMode = 'NORMAL'"),
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSource.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSource.java
index 0ac09c0..ed03b52 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSource.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSource.java
@@ -61,12 +61,12 @@ import org.rhq.core.domain.configuration.Configuration;
@Entity
@NamedQueries( {
@NamedQuery(name = ContentSource.QUERY_FIND_ALL, query = "SELECT cs FROM ContentSource cs "),
- @NamedQuery(name = ContentSource.QUERY_FIND_ALL_WITH_CONFIG, query = "SELECT cs FROM ContentSource cs LEFT JOIN FETCH cs.configuration"),
+ @NamedQuery(name = ContentSource.QUERY_FIND_ALL_WITH_CONFIG, query = "SELECT cs FROM ContentSource cs LEFT JOIN FETCH cs.configuration config"),
@NamedQuery(name = ContentSource.QUERY_FIND_BY_NAME_AND_TYPENAME, query = "SELECT cs " + " FROM ContentSource cs "
- + " LEFT JOIN FETCH cs.configuration" + " WHERE cs.name = :name "
+ + " LEFT JOIN FETCH cs.configuration config" + " WHERE cs.name = :name "
+ " AND cs.contentSourceType.name = :typeName "),
@NamedQuery(name = ContentSource.QUERY_FIND_BY_ID_WITH_CONFIG, query = "SELECT cs " + " FROM ContentSource cs "
- + " LEFT JOIN FETCH cs.configuration" + " WHERE cs.id = :id "),
+ + " LEFT JOIN FETCH cs.configuration config" + " WHERE cs.id = :id "),
@NamedQuery(name = ContentSource.QUERY_FIND_BY_REPO_ID, // do not do a fetch join here
query = "SELECT cs FROM ContentSource cs LEFT JOIN cs.repoContentSources ccs WHERE ccs.repo.id = :id"),
@NamedQuery(name = ContentSource.QUERY_FIND_AVAILABLE_BY_REPO_ID, //
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSourceType.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSourceType.java
index 84f40ae..7802ea1 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSourceType.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSourceType.java
@@ -56,10 +56,11 @@ import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
@Entity
@NamedQueries( {
@NamedQuery(name = ContentSourceType.QUERY_FIND_ALL, query = "SELECT cst " + " FROM ContentSourceType cst "
- + " LEFT JOIN FETCH cst.contentSourceConfigurationDefinition d " + " LEFT JOIN FETCH d.templates "),
+ + " LEFT JOIN FETCH cst.contentSourceConfigurationDefinition d "
+ + " LEFT JOIN FETCH d.templates t "),
@NamedQuery(name = ContentSourceType.QUERY_FIND_BY_NAME_WITH_CONFIG_DEF, query = "SELECT cst "
+ " FROM ContentSourceType cst " + " LEFT JOIN FETCH cst.contentSourceConfigurationDefinition d "
- + " LEFT JOIN FETCH d.templates " + " WHERE cst.name = :name"),
+ + " LEFT JOIN FETCH d.templates t " + " WHERE cst.name = :name"),
@NamedQuery(name = ContentSourceType.QUERY_FIND_BY_NAME, query = "SELECT cst " + " FROM ContentSourceType cst "
+ " WHERE cst.name = :name") })
@SequenceGenerator(allocationSize = org.rhq.core.domain.util.Constants.ALLOCATION_SIZE, name = "SEQ", sequenceName = "RHQ_CONTENT_SOURCE_TYPE_ID_SEQ")
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceTypeCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceTypeCriteria.java
index de69bae..15e07c5 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceTypeCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceTypeCriteria.java
@@ -97,7 +97,7 @@ public class ResourceTypeCriteria extends Criteria {
filterOverrides.put("categories", "category in ( ? )");
filterOverrides.put("parentResourceTypesEmpty", "" //
+ "id IN ( SELECT innerRt.id FROM ResourceType innerRt " //
- + " LEFT JOIN innerRt.parentResourceTypes " //
+ + " LEFT JOIN innerRt.parentResourceTypes innerParentRt" //
+ " WHERE ( ? = true AND innerRt.parentResourceTypes IS EMPTY ) " //
+ " OR ( ? = false AND innerRt.parentResourceTypes IS NOT EMPTY ) )");
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/OperationHistory.java b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/OperationHistory.java
index d5bc23e..ff4d4c6 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/OperationHistory.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/OperationHistory.java
@@ -60,7 +60,7 @@ import org.rhq.core.domain.configuration.Configuration;
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@NamedQueries( {
- @NamedQuery(name = OperationHistory.QUERY_FIND_BY_JOB_ID, query = "SELECT h FROM OperationHistory h LEFT JOIN FETCH h.parameters "
+ @NamedQuery(name = OperationHistory.QUERY_FIND_BY_JOB_ID, query = "SELECT h FROM OperationHistory h LEFT JOIN FETCH h.parameters hp "
+ " WHERE h.jobName = :jobName " + " AND h.jobGroup = :jobGroup " + " AND h.createdTime = :createdTime"),
@NamedQuery(name = OperationHistory.QUERY_GET_RECENTLY_COMPLETED_RESOURCE_ADMIN, query = "SELECT DISTINCT new org.rhq.core.domain.operation.composite.ResourceOperationLastCompletedComposite( "
+ " ro.id, "
@@ -100,9 +100,9 @@ import org.rhq.core.domain.configuration.Configuration;
+ " go.operationDefinition.displayName, "
+ " go.createdTime, "
+ " go.status, "
- + " go.group.id, "
- + " go.group.name, "
- + " go.group.resourceType.name) "
+ + " g.id, "
+ + " g.name, "
+ + " g.resourceType.name) "
+ " FROM GroupOperationHistory go JOIN go.group g JOIN g.roles r JOIN r.subjects s "
+ " WHERE go.status != 'INPROGRESS' AND s = :subject "),
@NamedQuery(name = OperationHistory.QUERY_GET_PARAMETER_CONFIGURATION_IDS, query = "" //
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/OperationScheduleEntity.java b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/OperationScheduleEntity.java
index dc68031..eab6e43 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/operation/OperationScheduleEntity.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/operation/OperationScheduleEntity.java
@@ -105,9 +105,9 @@ import javax.persistence.Table;
+ " go.jobGroup, " //
+ " '', " //
+ " go.nextFireTime, " //
- + " go.group.id, " //
- + " go.group.name, " //
- + " go.group.resourceType.name) " //
+ + " g.id, " //
+ + " g.name, " //
+ + " g.resourceType.name) " //
+ " FROM GroupOperationScheduleEntity go " //
+ " JOIN go.group g " //
+ " JOIN g.roles r " //
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/plugin/ServerPlugin.java b/modules/core/domain/src/main/java/org/rhq/core/domain/plugin/ServerPlugin.java
index 34d2f17..d351ea1 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/plugin/ServerPlugin.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/plugin/ServerPlugin.java
@@ -73,14 +73,14 @@ import org.rhq.core.domain.configuration.Configuration;
+ " p.md5, " //
+ " p.version, " //
+ " p.ampsVersion, " //
- + " p.pluginConfiguration, " //
- + " p.scheduledJobsConfiguration, " //
+ + " pluginConfig, " //
+ + " jobsConfig, " //
+ " p.type, " //
+ " p.ctime, " //
+ " p.mtime) " //
+ " FROM ServerPlugin AS p " //
- + " LEFT JOIN p.pluginConfiguration " //
- + " LEFT JOIN p.scheduledJobsConfiguration " //
+ + " LEFT JOIN p.pluginConfiguration AS pluginConfig " //
+ + " LEFT JOIN p.scheduledJobsConfiguration AS jobsConfig " //
+ " WHERE p.id IN (:ids) " //
+ " AND p.status = 'INSTALLED' "), //
@@ -99,14 +99,14 @@ import org.rhq.core.domain.configuration.Configuration;
+ " p.md5, " //
+ " p.version, " //
+ " p.ampsVersion, " //
- + " p.pluginConfiguration, " //
- + " p.scheduledJobsConfiguration, " //
+ + " pluginConfig, " //
+ + " jobsConfig, " //
+ " p.type, " //
+ " p.ctime, " //
+ " p.mtime) " //
+ " FROM ServerPlugin AS p " //
- + " LEFT JOIN p.pluginConfiguration " //
- + " LEFT JOIN p.scheduledJobsConfiguration " //
+ + " LEFT JOIN p.pluginConfiguration AS pluginConfig " //
+ + " LEFT JOIN p.scheduledJobsConfiguration AS jobsConfig " //
+ " WHERE p.id IN (:ids) "), //
// this query does not load the content blob, but loads everything else
@@ -123,15 +123,15 @@ import org.rhq.core.domain.configuration.Configuration;
+ " p.md5, " //
+ " p.version, " //
+ " p.ampsVersion, " //
- + " p.pluginConfiguration, " //
- + " p.scheduledJobsConfiguration, " //
+ + " pluginConfig, " //
+ + " jobsConfig, " //
+ " p.type, " //
+ " p.ctime, " //
+ " p.mtime) " //
- + " FROM ServerPlugin AS p " //
- + " LEFT JOIN p.pluginConfiguration " //
- + " LEFT JOIN p.scheduledJobsConfiguration " //
- + " WHERE p.name=:name " //
+ + " FROM ServerPlugin AS p" //
+ + " LEFT JOIN p.pluginConfiguration AS pluginConfig " //
+ + " LEFT JOIN p.scheduledJobsConfiguration AS jobsConfig " //
+ + " WHERE p.name = :name " //
+ " AND p.status = 'INSTALLED' "), //
// gets the plugin, even if it is deleted
@@ -149,14 +149,14 @@ import org.rhq.core.domain.configuration.Configuration;
+ " p.md5, " //
+ " p.version, " //
+ " p.ampsVersion, " //
- + " p.pluginConfiguration, " //
- + " p.scheduledJobsConfiguration, " //
+ + " pluginConfig, " //
+ + " jobsConfig, " //
+ " p.type, " //
+ " p.ctime, " //
+ " p.mtime) " //
+ " FROM ServerPlugin AS p " //
- + " LEFT JOIN p.pluginConfiguration " //
- + " LEFT JOIN p.scheduledJobsConfiguration " //
+ + " LEFT JOIN p.pluginConfiguration AS pluginConfig " //
+ + " LEFT JOIN p.scheduledJobsConfiguration AS jobsConfig " //
+ " WHERE p.name=:name "), //
// finds all installed AND deleted
@@ -174,14 +174,14 @@ import org.rhq.core.domain.configuration.Configuration;
+ " p.md5, " //
+ " p.version, " //
+ " p.ampsVersion, " //
- + " p.pluginConfiguration, " //
- + " p.scheduledJobsConfiguration, " //
+ + " pluginConfig, " //
+ + " jobsConfig, " //
+ " p.type, " //
+ " p.ctime, " //
+ " p.mtime) " //
+ " FROM ServerPlugin AS p " //
- + " LEFT JOIN p.pluginConfiguration " //
- + " LEFT JOIN p.scheduledJobsConfiguration "),
+ + " LEFT JOIN p.pluginConfiguration AS pluginConfig " //
+ + " LEFT JOIN p.scheduledJobsConfiguration AS jobsConfig "),
// finds all installed - ignores those plugins marked as deleted
// this query does not load the content blob, but loads everything else
@@ -198,14 +198,14 @@ import org.rhq.core.domain.configuration.Configuration;
+ " p.md5, " //
+ " p.version, " //
+ " p.ampsVersion, " //
- + " p.pluginConfiguration, " //
- + " p.scheduledJobsConfiguration, " //
+ + " pluginConfig, " //
+ + " jobsConfig, " //
+ " p.type, " //
+ " p.ctime, " //
+ " p.mtime) " //
+ " FROM ServerPlugin AS p " //
- + " LEFT JOIN p.pluginConfiguration " //
- + " LEFT JOIN p.scheduledJobsConfiguration " //
+ + " LEFT JOIN p.pluginConfiguration AS pluginConfig " //
+ + " LEFT JOIN p.scheduledJobsConfiguration AS jobsConfig " //
+ " WHERE p.status = 'INSTALLED' "), //
// returns all installed plugins, both enabled and disabled
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java
index 424cab2..846d910 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java
@@ -235,7 +235,7 @@ import org.rhq.core.domain.util.Summary;
@NamedQuery(name = Resource.QUERY_FIND_RESOURCE_AUTOGROUP_COMPOSITE, query = ""
+ " SELECT new org.rhq.core.domain.resource.group.composite.AutoGroupComposite(avg(a.availabilityType), res.parentResource, rt, count(res)) "
+ " FROM Resource res "
- + " JOIN res.resourceType rt LEFT JOIN rt.subCategory JOIN res.currentAvailability a "
+ + " JOIN res.resourceType rt LEFT JOIN rt.subCategory sc JOIN res.currentAvailability a "
+ " WHERE res.id = :id "
+ " AND res.id IN (SELECT rr.id FROM Resource rr JOIN rr.implicitGroups g JOIN g.roles r JOIN r.subjects s WHERE s = :subject)"
+ "GROUP BY res.parentResource, rt "),
@@ -248,16 +248,16 @@ import org.rhq.core.domain.util.Summary;
+ "GROUP BY res.parentResource, rt "),
@NamedQuery(name = Resource.QUERY_FIND_RESOURCE_AUTOGROUP_COMPOSITE_ADMIN, query = "" //
+ " SELECT new org.rhq.core.domain.resource.group.composite.AutoGroupComposite(avg(a.availabilityType), res.parentResource, rt, count(res)) "
- + " FROM Resource res JOIN res.currentAvailability a JOIN res.resourceType rt LEFT JOIN rt.subCategory "
+ + " FROM Resource res JOIN res.currentAvailability a JOIN res.resourceType rt LEFT JOIN rt.subCategory sc "
+ " WHERE res.id = :id " + "GROUP BY res.parentResource, rt"),
@NamedQuery(name = Resource.QUERY_FIND_RESOURCE_AUTOGROUPS_COMPOSITE_ADMIN, query = "" //
+ " SELECT new org.rhq.core.domain.resource.group.composite.AutoGroupComposite(avg(a.availabilityType), res.parentResource, rt, count(res)) "
- + " FROM Resource res JOIN res.currentAvailability a JOIN res.resourceType rt LEFT JOIN rt.subCategory "
+ + " FROM Resource res JOIN res.currentAvailability a JOIN res.resourceType rt LEFT JOIN rt.subCategory sc "
+ " WHERE res.id IN ( :ids ) " + "GROUP BY res.parentResource, rt"),
@NamedQuery(name = Resource.QUERY_FIND_CHILDREN_AUTOGROUP_COMPOSITES, query = ""
+ " SELECT new org.rhq.core.domain.resource.group.composite.AutoGroupComposite(avg(a.availabilityType), res.parentResource, rt, count(res)) "
+ " FROM Resource res "
- + " JOIN res.resourceType rt LEFT JOIN rt.subCategory JOIN res.currentAvailability a "
+ + " JOIN res.resourceType rt LEFT JOIN rt.subCategory sc JOIN res.currentAvailability a "
+ " WHERE res.parentResource = :parent " //
+ " AND res.id IN (SELECT rr.id FROM Resource rr JOIN rr.implicitGroups g JOIN g.roles r JOIN r.subjects s WHERE s = :subject)"
+ " AND res.inventoryStatus = :inventoryStatus " //
@@ -272,7 +272,7 @@ import org.rhq.core.domain.util.Summary;
@NamedQuery(name = Resource.QUERY_FIND_CHILDREN_AUTOGROUP_COMPOSITES_BY_TYPE, query = ""
+ " SELECT new org.rhq.core.domain.resource.group.composite.AutoGroupComposite(avg(a.availabilityType), res.parentResource, rt, count(res)) "
+ " FROM Resource res "
- + " JOIN res.resourceType rt LEFT JOIN rt.subCategory JOIN res.currentAvailability a "
+ + " JOIN res.resourceType rt LEFT JOIN rt.subCategory sc JOIN res.currentAvailability a "
+ " WHERE res.parentResource = :parent " //
+ " AND rt.id IN ( :resourceTypeIds ) " //
+ " AND res.id IN (SELECT rr.id FROM Resource rr JOIN rr.implicitGroups g JOIN g.roles r JOIN r.subjects s WHERE s = :subject)"
@@ -282,7 +282,7 @@ import org.rhq.core.domain.util.Summary;
+ " SELECT new org.rhq.core.domain.resource.group.composite.AutoGroupComposite(avg(a.availabilityType), res.parentResource, rt, count(res)) "
+ " FROM Resource res " //
+ " JOIN res.currentAvailability a " //
- + " JOIN res.resourceType rt LEFT JOIN rt.subCategory " //
+ + " JOIN res.resourceType rt LEFT JOIN rt.subCategory sc " //
+ " WHERE res.parentResource = :parent " //
+ " AND rt.id IN ( :resourceTypeIds ) " //
+ " AND res.inventoryStatus = :inventoryStatus GROUP BY res.parentResource, rt"),
@@ -541,14 +541,14 @@ import org.rhq.core.domain.util.Summary;
@NamedQuery(name = Resource.QUERY_FIND_BY_ID, query = "" //
+ " SELECT res " //
+ " FROM Resource res " //
- + "LEFT JOIN FETCH res.currentAvailability " // fetch to remove extra query, LEFT so unit tests needn't set it
- + " JOIN FETCH res.resourceType " // fetch to remove extra query
+ + "LEFT JOIN FETCH res.currentAvailability ca " // fetch to remove extra query, LEFT so unit tests needn't set it
+ + " JOIN FETCH res.resourceType rt " // fetch to remove extra query
+ " WHERE res.id = :resourceId "),
@NamedQuery(name = Resource.QUERY_FIND_BY_IDS, query = "" //
+ " SELECT res " //
+ " FROM Resource res " //
- + "LEFT JOIN FETCH res.currentAvailability " // fetch to remove extra query, LEFT so unit tests needn't set it
- + " JOIN FETCH res.resourceType " // fetch to remove extra query
+ + "LEFT JOIN FETCH res.currentAvailability ca " // fetch to remove extra query, LEFT so unit tests needn't set it
+ + " JOIN FETCH res.resourceType rt " // fetch to remove extra query
+ " WHERE res.id IN ( :ids ) " //
+ " AND res.id IN ( SELECT rr.id FROM Resource rr " //
+ " JOIN rr.implicitGroups g JOIN g.roles r JOIN r.subjects s " //
@@ -556,17 +556,17 @@ import org.rhq.core.domain.util.Summary;
@NamedQuery(name = Resource.QUERY_FIND_BY_IDS_ADMIN, query = "" //
+ " SELECT res " //
+ " FROM Resource res " //
- + "LEFT JOIN FETCH res.currentAvailability " // fetch to remove extra query, LEFT so unit tests needn't set it
- + " JOIN FETCH res.resourceType " // fetch to remove extra query
+ + "LEFT JOIN FETCH res.currentAvailability ca " // fetch to remove extra query, LEFT so unit tests needn't set it
+ + " JOIN FETCH res.resourceType rt " // fetch to remove extra query
+ " WHERE res.id IN ( :ids )"),
@NamedQuery(name = Resource.QUERY_FIND_WITH_PARENT_BY_IDS, query = "" //
+ " SELECT res " //
+ " FROM Resource res " //
- + "LEFT JOIN FETCH res.currentAvailability " // fetch to remove extra query, LEFT so unit tests needn't set it
- + " JOIN FETCH res.resourceType " // fetch to remove extra query
+ + "LEFT JOIN FETCH res.currentAvailability ca " // fetch to remove extra query, LEFT so unit tests needn't set it
+ + " JOIN FETCH res.resourceType rt " // fetch to remove extra query
+ "LEFT JOIN FETCH res.parentResource parent " //
- + "LEFT JOIN FETCH parent.currentAvailability " // left fetch to remove extra query for parent
- + "LEFT JOIN FETCH parent.resourceType " // left fetch to remove extra query for parent
+ + "LEFT JOIN FETCH parent.currentAvailability pca " // left fetch to remove extra query for parent
+ + "LEFT JOIN FETCH parent.resourceType prt " // left fetch to remove extra query for parent
+ " WHERE res.id IN ( :ids ) " //
+ " AND res.id IN ( SELECT rr.id FROM Resource rr " //
+ " JOIN rr.implicitGroups g JOIN g.roles r JOIN r.subjects s " //
@@ -574,11 +574,11 @@ import org.rhq.core.domain.util.Summary;
@NamedQuery(name = Resource.QUERY_FIND_WITH_PARENT_BY_IDS_ADMIN, query = "" //
+ " SELECT res " //
+ " FROM Resource res " //
- + "LEFT JOIN FETCH res.currentAvailability " // fetch to remove extra query, LEFT so unit tests needn't set it
- + " JOIN FETCH res.resourceType " // fetch to remove extra query
+ + "LEFT JOIN FETCH res.currentAvailability ca " // fetch to remove extra query, LEFT so unit tests needn't set it
+ + " JOIN FETCH res.resourceType rt " // fetch to remove extra query
+ "LEFT JOIN FETCH res.parentResource parent " //
- + "LEFT JOIN FETCH parent.currentAvailability " // left fetch to remove extra query for parent
- + "LEFT JOIN FETCH parent.resourceType " // left fetch to remove extra query for parent
+ + "LEFT JOIN FETCH parent.currentAvailability pca " // left fetch to remove extra query for parent
+ + "LEFT JOIN FETCH parent.resourceType prt " // left fetch to remove extra query for parent
+ " WHERE res.id IN ( :ids )"),
@NamedQuery(name = Resource.QUERY_FIND_COMPOSITE, query = "" //
+ "SELECT new org.rhq.core.domain.resource.composite.ResourceComposite(res, a.availabilityType, " //
@@ -751,23 +751,23 @@ import org.rhq.core.domain.util.Summary;
@NamedQuery(name = Resource.QUERY_RESOURCE_VERSION_AND_DRIFT_IN_COMPLIANCE, query = ""
+ "SELECT new org.rhq.core.domain.resource.composite.ResourceInstallCount("
- + "r.resourceType.name, r.resourceType.plugin, r.resourceType.category, r.resourceType.id, count(distinct r), "
+ + "rt.name, rt.plugin, rt.category, rt.id, count(distinct r), "
+ "r.version, size(templates), 0) "
- + "FROM Resource r JOIN r.resourceType type JOIN type.driftDefinitionTemplates templates "
+ + "FROM Resource r JOIN r.resourceType rt JOIN rt.driftDefinitionTemplates templates "
+ "WHERE r.inventoryStatus = 'COMMITTED' AND " //
+ " 0 = ( SELECT COUNT(defs) FROM r.driftDefinitions defs WHERE NOT defs.complianceStatus = 0) "
- + "GROUP BY r.resourceType.name, r.resourceType.plugin, r.resourceType.category, r.resourceType.id, r.version "
- + "ORDER BY r.resourceType.category, r.resourceType.plugin, r.resourceType.name, r.version "),
+ + "GROUP BY rt.name, rt.plugin, rt.category, rt.id, r.version "
+ + "ORDER BY rt.category, rt.plugin, rt.name, r.version "),
@NamedQuery(name = Resource.QUERY_RESOURCE_VERSION_AND_DRIFT_OUT_OF_COMPLIANCE, query = ""
+ "SELECT new org.rhq.core.domain.resource.composite.ResourceInstallCount("
- + "r.resourceType.name, r.resourceType.plugin, r.resourceType.category, r.resourceType.id, count(distinct r), "
+ + "rt.name, rt.plugin, rt.category, rt.id, count(distinct r), "
+ "r.version, size(templates), 1) "
- + "FROM Resource r JOIN r.resourceType type JOIN type.driftDefinitionTemplates templates "
+ + "FROM Resource r JOIN r.resourceType rt JOIN rt.driftDefinitionTemplates templates "
+ "WHERE r.inventoryStatus = 'COMMITTED' AND " //
+ " 0 < ( SELECT COUNT(defs) FROM r.driftDefinitions defs WHERE defs.complianceStatus <> 0) "
- + "GROUP BY r.resourceType.name, r.resourceType.plugin, r.resourceType.category, r.resourceType.id, r.version "
- + "ORDER BY r.resourceType.category, r.resourceType.plugin, r.resourceType.name, r.version ") })
+ + "GROUP BY rt.name, rt.plugin, rt.category, rt.id, r.version "
+ + "ORDER BY rt.category, rt.plugin, rt.name, r.version ") })
@SequenceGenerator(allocationSize = org.rhq.core.domain.util.Constants.ALLOCATION_SIZE, name = "RHQ_RESOURCE_SEQ", sequenceName = "RHQ_RESOURCE_ID_SEQ")
@Table(name = Resource.TABLE_NAME)
@XmlAccessorType(XmlAccessType.FIELD)
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceType.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceType.java
index 64d6079..1efaf2d 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceType.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/ResourceType.java
@@ -169,8 +169,8 @@ import org.rhq.core.domain.util.Summary;
+ "WHERE rt.subCategory = :subCategory AND rt.deleted = false"),
@NamedQuery(name = ResourceType.QUERY_FIND_BY_ID_WITH_ALL_OPERATIONS, query = "SELECT DISTINCT rt "
+ "FROM ResourceType rt " + "LEFT JOIN FETCH rt.operationDefinitions def "
- + "LEFT JOIN FETCH def.parametersConfigurationDefinition "
- + "LEFT JOIN FETCH def.resultsConfigurationDefinition " + "WHERE rt.id = :id AND rt.deleted = false"),
+ + "LEFT JOIN FETCH def.parametersConfigurationDefinition psDef "
+ + "LEFT JOIN FETCH def.resultsConfigurationDefinition rcDef " + "WHERE rt.id = :id AND rt.deleted = false"),
@NamedQuery(name = ResourceType.QUERY_FIND_RESOURCE_FACETS, query = "" //
+ "SELECT new org.rhq.core.domain.resource.composite.ResourceFacets " //
+ " ( " //
diff --git a/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/ServerInstallUtil.java b/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/ServerInstallUtil.java
index e80ad53..855091c 100644
--- a/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/ServerInstallUtil.java
+++ b/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/ServerInstallUtil.java
@@ -117,7 +117,7 @@ public class ServerInstallUtil {
CoreJBossASClient client = new CoreJBossASClient(mcc);
// the EAR could take a long time to deploy, increase the deployment timeout
- client.setAppServerDefaultDeploymentTimeout(1800); // 30 minutes should be plenty of time
+ client.setAppServerDefaultDeploymentTimeout(240); // 30 minutes should be plenty of time
// We don't need to scan the deployment directory after everything is installed.
// TODO: We would like this to be 0, so it only scans at startup, but the installer
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/ServerPluginsBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/ServerPluginsBeanTest.java
index 935721c..9ce4829 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/ServerPluginsBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/ServerPluginsBeanTest.java
@@ -78,7 +78,7 @@ public class ServerPluginsBeanTest extends AbstractEJB3Test {
em = getEntityManager();
Query q = em
- .createQuery("SELECT p FROM ServerPlugin p LEFT JOIN FETCH p.pluginConfiguration LEFT JOIN FETCH p.scheduledJobsConfiguration WHERE p.name LIKE 'serverplugintest%'");
+ .createQuery("SELECT p FROM ServerPlugin p LEFT JOIN FETCH p.pluginConfiguration ppc LEFT JOIN FETCH p.scheduledJobsConfiguration psjc WHERE p.name LIKE 'serverplugintest%'");
List<ServerPlugin> doomed = q.getResultList();
for (ServerPlugin plugin : doomed) {
em.remove(em.getReference(ServerPlugin.class, plugin.getId()));
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/ContentMetadataManagerBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/ContentMetadataManagerBeanTest.java
index 712606d..6f5582a 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/ContentMetadataManagerBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/ContentMetadataManagerBeanTest.java
@@ -111,7 +111,7 @@ public class ContentMetadataManagerBeanTest extends MetadataBeanTest {
PackageType loadPackageType(String resourceType, String plugin, String packageType) {
return (PackageType) getEntityManager()
.createQuery(
- "from PackageType p left join fetch p.deploymentConfigurationDefinition "
+ "from PackageType p left join fetch p.deploymentConfigurationDefinition pdcd "
+ "where p.name = :packageType and " + "p.resourceType.name = :resourceType and "
+ "p.resourceType.plugin = :plugin").setParameter("packageType", packageType)
.setParameter("plugin", plugin).setParameter("resourceType", resourceType).getSingleResult();
@@ -120,7 +120,7 @@ public class ContentMetadataManagerBeanTest extends MetadataBeanTest {
ResourceType loadResourceTypeWithBundleType(String resourceType, String plugin) {
return (ResourceType) getEntityManager()
.createQuery(
- "from ResourceType t left join fetch t.bundleType where t.name = :resourceType and t.plugin = :plugin")
+ "from ResourceType t left join fetch t.bundleType tbt where t.name = :resourceType and t.plugin = :plugin")
.setParameter("resourceType", resourceType).setParameter("plugin", plugin).getSingleResult();
}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/OperationMetadataManagerBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/OperationMetadataManagerBeanTest.java
index b2b02d9..59f5d44 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/OperationMetadataManagerBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/OperationMetadataManagerBeanTest.java
@@ -1,7 +1,9 @@
package org.rhq.enterprise.server.resource.metadata;
+import static java.util.Arrays.asList;
+import static java.util.Collections.EMPTY_LIST;
+
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import org.testng.annotations.Test;
@@ -10,9 +12,6 @@ import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.operation.OperationDefinition;
import org.rhq.core.domain.resource.ResourceType;
-import static java.util.Arrays.asList;
-import static java.util.Collections.EMPTY_LIST;
-
public class OperationMetadataManagerBeanTest extends MetadataBeanTest {
@Test(groups = {"plugin.metadata", "Operations.NewPlugin"})
@@ -114,7 +113,8 @@ public class OperationMetadataManagerBeanTest extends MetadataBeanTest {
ResourceType loadResourceTypeWithOperationDefs(String resourceType, String plugin) {
return (ResourceType) getEntityManager().createQuery(
- "from ResourceType t left join fetch t.operationDefinitions " +
+ "from ResourceType t left join fetch t.operationDefinitions tod "
+ +
"where t.name = :resourceType and t.plugin = :plugin")
.setParameter("resourceType", resourceType)
.setParameter("plugin", plugin)
commit 2a6ad04a961939d27bac537a31f74eb773487ee0
Author: Jay Shaughnessy <jshaughn(a)jshaughn.csb>
Date: Wed Sep 19 16:10:00 2012 -0400
Call ModelControllerClient.close() when done with it.
diff --git a/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/service/ManagementService.java b/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/service/ManagementService.java
index add78a6..f7d0c38 100644
--- a/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/service/ManagementService.java
+++ b/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/service/ManagementService.java
@@ -50,6 +50,11 @@ public class ManagementService implements ServiceActivator {
private static volatile ModelController controller;
private static volatile ExecutorService executor;
+ /**
+ * The caller should call ModelControllerClient.close() when finished with the client.
+ *
+ * @return the ModelControllerClient
+ */
public static ModelControllerClient getClient() {
return controller.createClient(executor);
}
diff --git a/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/InstallerGWTServiceImpl.java b/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/InstallerGWTServiceImpl.java
index 830b76b..ba636a2 100644
--- a/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/InstallerGWTServiceImpl.java
+++ b/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/server/servlet/InstallerGWTServiceImpl.java
@@ -111,23 +111,30 @@ public class InstallerGWTServiceImpl extends RemoteServiceServlet implements Ins
@Override
public String getInstallationResults() throws Exception {
- // use JBossAS's marker files to determine the status of the application EAR
- CoreJBossASClient client = new CoreJBossASClient(getClient());
- String deployDir = client.getAppServerDefaultDeploymentDir();
- boolean deployedExists = ServerInstallUtil.markerFileExists(deployDir, EAR_NAME, Marker.DEPLOYED);
- boolean failedExists = ServerInstallUtil.markerFileExists(deployDir, EAR_NAME, Marker.FAILED);
- if (!failedExists) {
- if (deployedExists) {
- return ""; // everything looks OK and the ear has been successfully deployed
+ ModelControllerClient mcc = null;
+ try {
+ mcc = getModelControllerClient();
+
+ // use JBossAS's marker files to determine the status of the application EAR
+ CoreJBossASClient client = new CoreJBossASClient(mcc);
+ String deployDir = client.getAppServerDefaultDeploymentDir();
+ boolean deployedExists = ServerInstallUtil.markerFileExists(deployDir, EAR_NAME, Marker.DEPLOYED);
+ boolean failedExists = ServerInstallUtil.markerFileExists(deployDir, EAR_NAME, Marker.FAILED);
+ if (!failedExists) {
+ if (deployedExists) {
+ return ""; // everything looks OK and the ear has been successfully deployed
+ } else {
+ return null; // installer hasn't done anything yet
+ }
} else {
- return null; // installer hasn't done anything yet
- }
- } else {
- String error = slurpFile(ServerInstallUtil.getMarkerFile(deployDir, EAR_NAME, Marker.FAILED));
- if (error.length() == 0) {
- error = "Unknown installation error";
+ String error = slurpFile(ServerInstallUtil.getMarkerFile(deployDir, EAR_NAME, Marker.FAILED));
+ if (error.length() == 0) {
+ error = "Unknown installation error";
+ }
+ return error;
}
- return error;
+ } finally {
+ safeClose(mcc);
}
}
@@ -317,7 +324,13 @@ public class InstallerGWTServiceImpl extends RemoteServiceServlet implements Ins
ServerInstallUtil.createKeystore(serverDetails, getAppServerConfigDir());
// Make sure our deployment scanner is configured to be ready for deploy our services and application
- ServerInstallUtil.configureDeploymentScanner(getClient());
+ ModelControllerClient mcc = null;
+ try {
+ mcc = getModelControllerClient();
+ ServerInstallUtil.configureDeploymentScanner(mcc);
+ } finally {
+ safeClose(mcc);
+ }
// now create our deployment services and our main EAR
deployServices(serverProperties);
@@ -438,34 +451,64 @@ public class InstallerGWTServiceImpl extends RemoteServiceServlet implements Ins
@Override
public String getAppServerVersion() throws Exception {
- final CoreJBossASClient client = new CoreJBossASClient(getClient());
- final String version = client.getAppServerVersion();
- return version;
+ ModelControllerClient mcc = null;
+ try {
+ mcc = getModelControllerClient();
+ final CoreJBossASClient client = new CoreJBossASClient(mcc);
+ final String version = client.getAppServerVersion();
+ return version;
+ } finally {
+ safeClose(mcc);
+ }
}
@Override
public String getOperatingSystem() throws Exception {
- final CoreJBossASClient client = new CoreJBossASClient(getClient());
- final String osName = client.getOperatingSystem();
- return osName;
+ ModelControllerClient mcc = null;
+ try {
+ mcc = getModelControllerClient();
+ final CoreJBossASClient client = new CoreJBossASClient(mcc);
+ final String osName = client.getOperatingSystem();
+ return osName;
+ } finally {
+ safeClose(mcc);
+ }
}
private String getAppServerHomeDir() throws Exception {
- final CoreJBossASClient client = new CoreJBossASClient(getClient());
- final String dir = client.getAppServerHomeDir();
- return dir;
+ ModelControllerClient mcc = null;
+ try {
+ mcc = getModelControllerClient();
+ final CoreJBossASClient client = new CoreJBossASClient(mcc);
+ final String dir = client.getAppServerHomeDir();
+ return dir;
+ } finally {
+ safeClose(mcc);
+ }
}
private String getAppServerConfigDir() throws Exception {
- final CoreJBossASClient client = new CoreJBossASClient(getClient());
- final String dir = client.getAppServerConfigDir();
- return dir;
+ ModelControllerClient mcc = null;
+ try {
+ mcc = getModelControllerClient();
+ final CoreJBossASClient client = new CoreJBossASClient(mcc);
+ final String dir = client.getAppServerConfigDir();
+ return dir;
+ } finally {
+ safeClose(mcc);
+ }
}
private String getLogDir() throws Exception {
- final CoreJBossASClient client = new CoreJBossASClient(getClient());
- final String dir = client.getAppServerLogDir();
- return dir;
+ ModelControllerClient mcc = null;
+ try {
+ mcc = getModelControllerClient();
+ final CoreJBossASClient client = new CoreJBossASClient(mcc);
+ final String dir = client.getAppServerLogDir();
+ return dir;
+ } finally {
+ safeClose(mcc);
+ }
}
private File getServerPropertiesFile() throws Exception {
@@ -559,48 +602,63 @@ public class InstallerGWTServiceImpl extends RemoteServiceServlet implements Ins
return serverDetails;
}
- private ModelControllerClient getClient() {
+ private ModelControllerClient getModelControllerClient() {
final ModelControllerClient client = ManagementService.getClient();
return client;
}
private void deployServices(HashMap<String, String> serverProperties) throws Exception {
+
+ ModelControllerClient mcc = null;
try {
- ModelControllerClient client = getClient();
+ mcc = getModelControllerClient();
// create the security domain needed by the datasources
- ServerInstallUtil.createDatasourceSecurityDomain(client, serverProperties);
+ ServerInstallUtil.createDatasourceSecurityDomain(mcc, serverProperties);
// create the security domain needed by REST
- ServerInstallUtil.createRESTSecurityDomain(client, serverProperties);
+ ServerInstallUtil.createRESTSecurityDomain(mcc, serverProperties);
// set up REST cache
- ServerInstallUtil.createNewCaches(client, serverProperties);
+ ServerInstallUtil.createNewCaches(mcc, serverProperties);
// create the JDBC driver configurations for use by datasources
- ServerInstallUtil.createNewJdbcDrivers(client, serverProperties);
+ ServerInstallUtil.createNewJdbcDrivers(mcc, serverProperties);
// create the datasources
- ServerInstallUtil.createNewDatasources(client, serverProperties);
+ ServerInstallUtil.createNewDatasources(mcc, serverProperties);
// create the JMS queues
- ServerInstallUtil.createNewJMSQueues(client, serverProperties);
+ ServerInstallUtil.createNewJMSQueues(mcc, serverProperties);
// setup the email service
- ServerInstallUtil.setupMailService(client, serverProperties);
+ ServerInstallUtil.setupMailService(mcc, serverProperties);
// we don't want to the JBossAS welcome screen; turn it off
- new WebJBossASClient(client).setEnableWelcomeRoot(false);
+ new WebJBossASClient(mcc).setEnableWelcomeRoot(false);
} catch (Exception e) {
log("deployServices failed", e);
throw new Exception("Failed to deploy services: " + ThrowableUtil.getAllMessages(e));
+ } finally {
+ safeClose(mcc);
+ }
+ }
+
+ private static void safeClose(final ModelControllerClient mcc) {
+ if (null != mcc) {
+ try {
+ mcc.close();
+ } catch (Exception e) {
+ }
}
}
private void deployApp() throws Exception {
+ ModelControllerClient mcc = null;
try {
- final CoreJBossASClient client = new CoreJBossASClient(getClient());
+ mcc = getModelControllerClient();
+ final CoreJBossASClient client = new CoreJBossASClient(mcc);
final String deployDir = client.getAppServerDefaultDeploymentDir();
if (deployDir == null) {
throw new IllegalStateException("Missing the deployment scanner - cannot finish install");
@@ -620,22 +678,30 @@ public class InstallerGWTServiceImpl extends RemoteServiceServlet implements Ins
} catch (Exception e) {
log("deployApp failed", e);
throw new Exception("Failed to deploy the app: " + ThrowableUtil.getAllMessages(e));
+ } finally {
+ safeClose(mcc);
}
}
private void reloadConfiguration() throws Exception {
+ ModelControllerClient mcc = null;
try {
- final CoreJBossASClient client = new CoreJBossASClient(getClient());
+ mcc = getModelControllerClient();
+ final CoreJBossASClient client = new CoreJBossASClient(mcc);
client.reload();
} catch (Exception e) {
log("reloadConfiguration failed - restart the server to complete the installation", e);
+ } finally {
+ safeClose(mcc);
}
}
// left this here in case we want to undeploy the installer in the future; for now, we don't use this
private void undeployInstaller() throws Exception {
+ ModelControllerClient mcc = null;
try {
- final CoreJBossASClient client = new CoreJBossASClient(getClient());
+ mcc = getModelControllerClient();
+ final CoreJBossASClient client = new CoreJBossASClient(mcc);
final String deployDir = client.getAppServerDefaultDeploymentDir();
if (deployDir == null) {
throw new IllegalStateException("Missing the deployment scanner - cannot undeploy installer");
@@ -663,6 +729,8 @@ public class InstallerGWTServiceImpl extends RemoteServiceServlet implements Ins
} catch (Exception e) {
log("undeployInstaller failed", e);
throw new Exception("Failed to undeploy the installer: " + ThrowableUtil.getAllMessages(e));
+ } finally {
+ safeClose(mcc);
}
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/CustomJaasDeploymentService.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/CustomJaasDeploymentService.java
index 339a73b..ddd0815 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/CustomJaasDeploymentService.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/CustomJaasDeploymentService.java
@@ -50,8 +50,6 @@ import org.rhq.enterprise.server.util.security.UntrustedSSLSocketFactory;
* module is only deployed if LDAP is enabled in the RHQ configuration.
*/
public class CustomJaasDeploymentService implements CustomJaasDeploymentServiceMBean, MBeanRegistration {
- private static final String AUTH_METHOD = "addAppConfig";
- private static final String AUTH_OBJECTNAME = "jboss.security:service=XMLLoginConfig";
private Log log = LogFactory.getLog(CustomJaasDeploymentService.class.getName());
private MBeanServer mbeanServer = null;
@@ -105,8 +103,9 @@ public class CustomJaasDeploymentService implements CustomJaasDeploymentServiceM
private void registerJaasModules(Properties systemConfig) throws Exception {
+ ModelControllerClient mcc = null;
try {
- final ModelControllerClient mcc = ManagementService.getClient();
+ mcc = ManagementService.getClient();
final SecurityDomainJBossASClient client = new SecurityDomainJBossASClient(mcc);
final String securityDomain = RHQ_USER_SECURITY_DOMAIN;
@@ -163,6 +162,17 @@ public class CustomJaasDeploymentService implements CustomJaasDeploymentServiceM
}
} catch (Exception e) {
throw new Exception("Error registering RHQ JAAS modules", e);
+ } finally {
+ safeClose(mcc);
+ }
+ }
+
+ private static void safeClose(final ModelControllerClient mcc) {
+ if (null != mcc) {
+ try {
+ mcc.close();
+ } catch (Exception e) {
+ }
}
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/service/ManagementService.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/service/ManagementService.java
index fd6f052..f22cff0 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/service/ManagementService.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/service/ManagementService.java
@@ -50,6 +50,11 @@ public class ManagementService implements ServiceActivator {
private static volatile ModelController controller;
private static volatile ExecutorService executor;
+ /**
+ * The caller should call ModelControllerClient.close() when finished with the client.
+ *
+ * @return the ModelControllerClient
+ */
public static ModelControllerClient getClient() {
return controller.createClient(executor);
}