modules/core/dbutils/pom.xml | 2
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml | 11 -
modules/enterprise/binding/src/main/java/org/rhq/bindings/client/RhqManager.java | 25 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java | 24 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/DurationItem.java | 102 +++++++++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/trigger/JobTriggerEditor.java | 4
modules/enterprise/remoting/cli/src/test/java/org/rhq/enterprise/client/commands/ScriptCommandTest.java | 4
modules/enterprise/server/client-api/src/main/java/org/rhq/enterprise/client/LocalClient.java | 66 ------
modules/enterprise/server/client-api/src/test/java/org/rhq/enterprise/client/test/LocalClientTest.java | 26 ++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java | 33 ++-
10 files changed, 205 insertions(+), 92 deletions(-)
New commits:
commit 9dc4def9a1ba181c507f58209b8fa750a17d6a91
Merge: 9555368 f4e6014
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Oct 8 11:07:54 2012 -0400
Merge remote-tracking branch 'origin/master' into as7-master-merge
Conflicts:
modules/core/dbutils/pom.xml
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
diff --cc modules/core/dbutils/pom.xml
index 33c0072,e0ceba4..6825b8f
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@@ -17,7 -17,7 +17,7 @@@
<description>Database schema setup, upgrade and other utilities</description>
<properties>
- <db.schema.version>2.126</db.schema.version>
- <db.schema.version>2.124</db.schema.version>
++ <db.schema.version>2.125</db.schema.version>
<rhq.ds.type-mapping>${rhq.test.ds.type-mapping}</rhq.ds.type-mapping>
<rhq.ds.server-name>${rhq.test.ds.server-name}</rhq.ds.server-name>
<rhq.ds.db-name>${rhq.test.ds.db-name}</rhq.ds.db-name>
diff --cc modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index 6ef82c8,84fbf5e..40bfecd
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@@ -4049,18 -4052,12 +4052,20 @@@
UPDATE RHQ_CONFIG_PROP_DEF
SET MAX_ENTRIES = 32767
WHERE MAX_ENTRIES IS NULL
+ AND DTYPE = 'list'
</statement>
</schema-directSQL>
+
</schemaSpec>
- <schemaSpec version="2.126">
++ <schemaSpec version="2.125">
+ <schema-dropTable table="JMS_MESSAGES" ignoreError="true" />
+ <schema-dropTable table="JMS_TRANSACTIONS" ignoreError="true" />
+ <schema-dropTable table="JMS_USERS" ignoreError="true" />
+ <schema-dropTable table="JMS_ROLES" ignoreError="true" />
+ <schema-dropTable table="JMS_SUBSCRIPTIONS" ignoreError="true" />
+ </schemaSpec>
+
</dbupgrade>
</target>
</project>
diff --cc modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
index c3a4945,8ef6a9f..b090c99
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
@@@ -616,25 -632,53 +616,39 @@@ public final class LookupUtil
return service;
}
+ private static MBeanServer getJBossMBeanServer() {
+ // The default MBean server for AS7 is the platform MBeanServer
+ MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
+ return mbs;
+ }
+
/**
+ * Generic method to lookup an Ejb bean by name and the interface name
+ *
+ * @param beanName the name of the EJB bean
+ * @param interfaceName the full class name of either the remote or local interface
+ *
+ * @return the bean accessed through specified inerface
+ */
+ public static Object getEjb(String beanName, String interfaceName) {
+ return lookupByName(beanName, interfaceName);
+ }
+
- //--------------------------------------------
- // The TEST services
- //--------------------------------------------
-
- public static AccessLocal getAccessLocal() {
- return lookupLocal(AccessBean.class);
- }
-
- public static CoreTestLocal getCoreTest() {
- return lookupLocal(CoreTestBean.class);
- }
-
- public static DiscoveryTestLocal getDiscoveryTest() {
- return lookupLocal(DiscoveryTestBean.class);
- }
-
- public static MeasurementTestLocal getMeasurementTest() {
- return lookupLocal(MeasurementTestBean.class);
- }
-
- public static ResourceGroupTestBeanLocal getResourceGroupTestBean() {
- return lookupLocal(ResourceGroupTestBean.class);
++ /**
+ * This is a test bean used only by test code or by things like control.jsp.
+ */
+ public static TestLocal getTest() {
+ return lookupLocal(TestBean.class);
}
// Private Methods
- private static <T> String getLocalJNDIName(@NotNull
- Class<? super T> beanClass) {
- return (embeddedDeployment ? "" : ("java:global/rhq/rhq-enterprise-server-ejb3/")) + beanClass.getSimpleName()
- + "!" + beanClass.getName().replace("Bean", "Local");
- //in this method, we don't actually need the interfaceName yet, but
- //this will become necessary as soon as we start using AS7 as our container.
- //So let's be proactive here ;)
+ private static String getLocalJNDIName(String beanName, String interfaceName) {
- return (embeddedDeployment ? "" : (RHQConstants.EAR_NAME + "/")) + beanName + "/local";
++ return (embeddedDeployment ? "" : ("java:global/rhq/rhq-enterprise-server-ejb3/")) + beanName + "!" + interfaceName;
+ }
+
+ private static <T> String getLocalJNDIName(@NotNull Class<? super T> beanClass) {
+ return getLocalJNDIName(beanClass.getSimpleName(), beanClass.getName().replace("Bean", "Local"));
}
/**
commit f4e6014c04a1b6d7bb81c1392f49a372d4477f93
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Mon Oct 8 14:52:02 2012 +0200
[BZ 857462 - RFE: Disable 'Purge' button on destination level when no deployment is LIVE] If at least one deployment is LIVE the button is enabled, otherwise it is disabled. The call is made, when constructing the UI components.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java
index 5ac720f..ed1cf7b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationView.java
@@ -37,7 +37,9 @@ import com.smartgwt.client.widgets.form.fields.CanvasItem;
import com.smartgwt.client.widgets.form.fields.StaticTextItem;
import org.rhq.core.domain.bundle.Bundle;
+import org.rhq.core.domain.bundle.BundleDeployment;
import org.rhq.core.domain.bundle.BundleDestination;
+import org.rhq.core.domain.criteria.BundleDeploymentCriteria;
import org.rhq.core.domain.criteria.BundleDestinationCriteria;
import org.rhq.core.domain.tagging.Tag;
import org.rhq.core.domain.util.PageList;
@@ -235,6 +237,7 @@ public class BundleDestinationView extends LocatableVLayout implements Bookmarka
});
}
});
+ checkIfDisabled(purgeButton);
actionLayout.addMember(purgeButton);
IButton deleteButton = new LocatableIButton(actionLayout.extendLocatorId("Delete"), MSG.common_button_delete());
@@ -277,6 +280,27 @@ public class BundleDestinationView extends LocatableVLayout implements Bookmarka
return actionLayout;
}
+ private void checkIfDisabled(final IButton purgeButton) {
+ BundleGWTServiceAsync bundleService = GWTServiceLookup.getBundleService();
+ BundleDeploymentCriteria criteria = new BundleDeploymentCriteria();
+ criteria.addFilterDestinationId(destination.getId());
+ bundleService.findBundleDeploymentsByCriteria(criteria, new AsyncCallback<PageList<BundleDeployment>>() {
+ public void onFailure(Throwable caught) {
+ purgeButton.setDisabled(false);
+ }
+
+ public void onSuccess(PageList<BundleDeployment> result) {
+ for (BundleDeployment deployment : result) {
+ if (deployment.isLive()) {
+ purgeButton.setDisabled(false);
+ return;
+ }
+ }
+ purgeButton.setDisabled(true);
+ }
+ });
+ }
+
private Table createDeploymentsTable() {
Criteria criteria = new Criteria();
criteria.addCriteria("bundleDestinationId", destination.getId());
commit 84017565d54238af8d59fa832bb809d5d8005bc1
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Wed Oct 3 09:50:04 2012 -0500
[BZ 861127] Revert back to sequential db upgrade ids.
(cherry picked from commit 84e7e552a2ee7d05aff8eb489c66cdfe6adf2bd0)
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index 700e079..e0ceba4 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -17,7 +17,7 @@
<description>Database schema setup, upgrade and other utilities</description>
<properties>
- <db.schema.version>2.125</db.schema.version>
+ <db.schema.version>2.124</db.schema.version>
<rhq.ds.type-mapping>${rhq.test.ds.type-mapping}</rhq.ds.type-mapping>
<rhq.ds.server-name>${rhq.test.ds.server-name}</rhq.ds.server-name>
<rhq.ds.db-name>${rhq.test.ds.db-name}</rhq.ds.db-name>
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index 00722db..84fbf5e 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -4037,20 +4037,25 @@
</schemaSpec>
-<!-- RHQ 4.5.0 uses DB Schema 2.125 -->
- <schemaSpec version="2.125">
+<!-- RHQ 4.5.0 uses DB Schema 2.123 -->
+
+ <schemaSpec version="2.124">
+
<schema-directSQL>
<statement desc="Update the NULL to 0 for MIN_ENTRIES">
UPDATE RHQ_CONFIG_PROP_DEF
SET MIN_ENTRIES = 0
WHERE MIN_ENTRIES IS NULL
+ AND DTYPE = 'list'
</statement>
<statement desc="Update the NULL to 32767 for MAX_ENTRIES">
UPDATE RHQ_CONFIG_PROP_DEF
SET MAX_ENTRIES = 32767
WHERE MAX_ENTRIES IS NULL
+ AND DTYPE = 'list'
</statement>
</schema-directSQL>
+
</schemaSpec>
</dbupgrade>
commit 47a3f040c5019f794bd7eb198a662dd2ac5ad0ea
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Wed Oct 3 09:49:02 2012 -0500
Revert "Trivial: Comment on skipped db-upgrade version 2.124"
This reverts commit 783da488b14c341d9dabd2f678f0cbd6150db2a1.
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index 52b359c..00722db 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -4037,8 +4037,6 @@
</schemaSpec>
-<!-- DB Schema 2.124 was bad so skipping intentionally -->
-
<!-- RHQ 4.5.0 uses DB Schema 2.125 -->
<schemaSpec version="2.125">
<schema-directSQL>
commit 88e982cc45e152fc2025bd73f7e8f7a6ed9d52bb
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Tue Oct 2 22:18:32 2012 +0200
[Bug 860818 - operation schedule doesn't show proper "repeat every" value] The "seconds" unit type was used no matter what actual units were selected. Now when the operation is scheduled, the "repeat every" value is persisted to DB in millis and when displaying the details about the op., the millis are converted to human readable form.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/DurationItem.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/DurationItem.java
index 486b20b..acd80bf 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/DurationItem.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/DurationItem.java
@@ -55,6 +55,14 @@ public class DurationItem extends CanvasItem {
private static final String FIELD_VALUE = "value";
private static final String FIELD_UNITS = "units";
+
+ private static final long SECOND_IN_MILLIS = 1000L;
+ private static final long MINUTE_IN_MILLIS = 60 * SECOND_IN_MILLIS;
+ private static final long HOUR_IN_MILLIS = 60 * MINUTE_IN_MILLIS;
+ private static final long DAY_IN_MILLIS = 24 * HOUR_IN_MILLIS;
+ private static final long WEEK_IN_MILLIS = 7 * DAY_IN_MILLIS;
+ private static final long MONTH_IN_MILLIS = 30 * DAY_IN_MILLIS;
+ private static final long YEAR_IN_MILLIS = 365 * DAY_IN_MILLIS;
private final DynamicForm form;
private TimeUnit defaultTimeUnit;
@@ -214,6 +222,86 @@ public class DurationItem extends CanvasItem {
setValue(value);
}
+ /**
+ * Sets human readable time representation to the form's field "value"
+ *
+ * @param longValue the time period representation in milliseconds
+ */
+ public void setAndFormatValue(long longValue) {
+ if (longValue < 0) {
+ throw new IllegalArgumentException("negative time period " + longValue);
+ }
+ String formattedOutput = formatMilliseconds(longValue);
+ this.unitType = UnitType.TIME;
+ this.form.setValue(FIELD_VALUE, formattedOutput);
+ setValue(formattedOutput);
+ }
+
+ /**
+ * formatMilliseconds(10 * WEEK_IN_MILLIS + 2 * SECOND_IN_MILLIS) = 2 months 2 weeks 2 seconds
+ *
+ * @param longValue
+ * @return formatted string with time period representation
+ */
+ private String formatMilliseconds(long longValue) {
+ if (longValue < 0) {
+ throw new IllegalArgumentException("negative time period " + longValue);
+ }
+ String formattedOutput = null;
+ long wholeUnits = 0;
+ if (longValue < SECOND_IN_MILLIS) { //ms
+ return getTimeValue(longValue, TimeUnit.MILLISECONDS);
+ } else if (longValue < MINUTE_IN_MILLIS) { //s
+ wholeUnits = longValue / SECOND_IN_MILLIS;
+ formattedOutput = getTimeValue(wholeUnits, TimeUnit.SECONDS);
+ return formattedOutput
+ + ((wholeUnits * SECOND_IN_MILLIS < longValue) ? " "
+ + formatMilliseconds(longValue - wholeUnits * SECOND_IN_MILLIS) : "");
+ } else if (longValue < HOUR_IN_MILLIS) { //m
+ wholeUnits = longValue / MINUTE_IN_MILLIS;
+ formattedOutput = getTimeValue(wholeUnits, TimeUnit.MINUTES);
+ return formattedOutput
+ + ((wholeUnits * MINUTE_IN_MILLIS < longValue) ? " "
+ + formatMilliseconds(longValue - wholeUnits * MINUTE_IN_MILLIS) : "");
+ } else if (longValue < DAY_IN_MILLIS) { //h
+ wholeUnits = longValue / HOUR_IN_MILLIS;
+ formattedOutput = getTimeValue(wholeUnits, TimeUnit.HOURS);
+ return formattedOutput
+ + ((wholeUnits * HOUR_IN_MILLIS < longValue) ? " "
+ + formatMilliseconds(longValue - wholeUnits * HOUR_IN_MILLIS) : "");
+ } else if (longValue < WEEK_IN_MILLIS) { //d
+ wholeUnits = longValue / DAY_IN_MILLIS;
+ formattedOutput = getTimeValue(wholeUnits, TimeUnit.DAYS);
+ return formattedOutput
+ + ((wholeUnits * DAY_IN_MILLIS < longValue) ? " "
+ + formatMilliseconds(longValue - wholeUnits * DAY_IN_MILLIS) : "");
+ } else if (longValue < MONTH_IN_MILLIS) { //w
+ wholeUnits = longValue / WEEK_IN_MILLIS;
+ formattedOutput = getTimeValue(wholeUnits, TimeUnit.WEEKS);
+ return formattedOutput
+ + ((wholeUnits * WEEK_IN_MILLIS < longValue) ? " "
+ + formatMilliseconds(longValue - wholeUnits * WEEK_IN_MILLIS) : "");
+ } else if (longValue < YEAR_IN_MILLIS) { //M
+ wholeUnits = longValue / MONTH_IN_MILLIS;
+ formattedOutput = getTimeValue(wholeUnits, TimeUnit.MONTHS);
+ return formattedOutput
+ + ((wholeUnits * MONTH_IN_MILLIS < longValue) ? " "
+ + formatMilliseconds(longValue - wholeUnits * MONTH_IN_MILLIS) : "");
+ } else if (longValue >= YEAR_IN_MILLIS) { //y
+ wholeUnits = longValue / YEAR_IN_MILLIS;
+ formattedOutput = getTimeValue(wholeUnits, TimeUnit.YEARS);
+ return formattedOutput
+ + ((wholeUnits * YEAR_IN_MILLIS < longValue) ? " "
+ + formatMilliseconds(longValue - wholeUnits * YEAR_IN_MILLIS) : "");
+ } else {
+ return "";
+ }
+ }
+
+ private String getTimeValue(long value, TimeUnit valueUnit) {
+ return value + " " + valueUnit.getDisplayName();
+ }
+
private void updateValue() {
Long value = calculateValue();
setValue(value);
@@ -253,7 +341,7 @@ public class DurationItem extends CanvasItem {
convertedValue = integerValue;
break;
case MILLISECONDS:
- convertedValue = integerValue * 1000;
+ convertedValue = integerValue * SECOND_IN_MILLIS;
break;
}
break;
@@ -266,7 +354,7 @@ public class DurationItem extends CanvasItem {
convertedValue = integerValue * 60;
break;
case MILLISECONDS:
- convertedValue = integerValue * 60 * 1000;
+ convertedValue = integerValue * MINUTE_IN_MILLIS;
break;
}
break;
@@ -282,7 +370,7 @@ public class DurationItem extends CanvasItem {
convertedValue = integerValue * 60 * 60;
break;
case MILLISECONDS:
- convertedValue = integerValue * 60 * 60 * 1000;
+ convertedValue = integerValue * HOUR_IN_MILLIS;
break;
}
break;
@@ -301,7 +389,7 @@ public class DurationItem extends CanvasItem {
convertedValue = integerValue * 24 * 60 * 60;
break;
case MILLISECONDS:
- convertedValue = integerValue * 24 * 60 * 60 * 1000;
+ convertedValue = integerValue * DAY_IN_MILLIS;
break;
}
break;
@@ -323,7 +411,7 @@ public class DurationItem extends CanvasItem {
convertedValue = integerValue * 7 * 24 * 60 * 60;
break;
case MILLISECONDS:
- convertedValue = integerValue * 7 * 24 * 60 * 60 * 1000;
+ convertedValue = integerValue * WEEK_IN_MILLIS;
break;
}
break;
@@ -348,7 +436,7 @@ public class DurationItem extends CanvasItem {
convertedValue = integerValue * 30 * 24 * 60 * 60;
break;
case MILLISECONDS:
- convertedValue = integerValue * 30 * 24 * 60 * 60 * 1000;
+ convertedValue = integerValue * MONTH_IN_MILLIS;
break;
}
break;
@@ -376,7 +464,7 @@ public class DurationItem extends CanvasItem {
convertedValue = integerValue * 365 * 24 * 60 * 60;
break;
case MILLISECONDS:
- convertedValue = integerValue * 365 * 24 * 60 * 60 * 1000;
+ convertedValue = integerValue * YEAR_IN_MILLIS;
break;
}
break;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/trigger/JobTriggerEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/trigger/JobTriggerEditor.java
index 3cde889..c9c1c35 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/trigger/JobTriggerEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/trigger/JobTriggerEditor.java
@@ -149,8 +149,8 @@ public class JobTriggerEditor extends LocatableVLayout {
changeCalendarType("laterAndRepeat");
DurationItem repeatIntervalItem = (DurationItem) this.repeatForm.getItem(FIELD_REPEAT_INTERVAL);
- repeatIntervalItem.setValue(this.jobTrigger.getRepeatInterval().intValue(), UnitType.TIME);
-
+ repeatIntervalItem.setAndFormatValue(this.jobTrigger.getRepeatInterval());
+
FormItem endTimeItem = this.repeatForm.getField(FIELD_END_TIME);
DurationItem repeatDurationItem = (DurationItem) this.repeatForm.getItem(FIELD_REPEAT_DURATION);
FormItem recurrenceTypeItem = this.repeatForm.getField(FIELD_RECURRENCE_TYPE);
commit 76a91bd24c1acb40e190c66271964ecea3bfe881
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Oct 2 16:45:55 2012 +0200
Make the RhqManager class the sole place to define everything is necessary
for defining and making available a new *Manager to the scripting clients.
Also removed a property on RhqManager that was only used in a single test
method and replaced its usage.
diff --git a/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/RhqManager.java b/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/RhqManager.java
index cfa52e2..1dd79f1 100644
--- a/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/RhqManager.java
+++ b/modules/enterprise/binding/src/main/java/org/rhq/bindings/client/RhqManager.java
@@ -89,14 +89,17 @@ public enum RhqManager {
SynchronizationManager(SynchronizationManagerRemote.class, "${SynchronizationManager}");
private Class<?> remote;
- private String remoteName;
+ private String localInterfaceClassName;
private String beanName;
private boolean enabled;
+ private static final int REMOTE_IFACE_SUFFIX_LENGTH = "Remote".length();
+
private RhqManager(Class<?> remote, String enable) {
this.remote = remote;
this.beanName = this.name() + "Bean";
- this.remoteName = this.name() + "Remote";
+ localInterfaceClassName = getLocalInterfaceClassName(remote);
+
//defaults and evaluates to TRUE unless the string contains "false". Done to defend against
//possible errors in string replacement during rhq build.
this.enabled = true;
@@ -119,15 +122,25 @@ public enum RhqManager {
return this.remote;
}
- public String beanName() {
- return this.beanName;
+ public String localInterfaceClassName() {
+ return localInterfaceClassName;
}
- public String remoteName() {
- return this.remoteName;
+ public String beanName() {
+ return this.beanName;
}
public boolean enabled() {
return this.enabled;
}
+
+ private static String getLocalInterfaceClassName(Class<?> remoteIface) {
+ String ifaceName = remoteIface.getName();
+ if (!ifaceName.endsWith("Remote")) {
+ throw new AssertionError("Inconsistent SLSB naming in RHQ! Remote interface '" + remoteIface.getName()
+ + "' does not follow the established naming convention. This is a bug, please report it.");
+ }
+
+ return ifaceName.substring(0, ifaceName.length() - REMOTE_IFACE_SUFFIX_LENGTH) + "Local";
+ }
}
\ No newline at end of file
diff --git a/modules/enterprise/remoting/cli/src/test/java/org/rhq/enterprise/client/commands/ScriptCommandTest.java b/modules/enterprise/remoting/cli/src/test/java/org/rhq/enterprise/client/commands/ScriptCommandTest.java
index 8cf3ceb..d5f1c00 100644
--- a/modules/enterprise/remoting/cli/src/test/java/org/rhq/enterprise/client/commands/ScriptCommandTest.java
+++ b/modules/enterprise/remoting/cli/src/test/java/org/rhq/enterprise/client/commands/ScriptCommandTest.java
@@ -61,11 +61,11 @@ public class ScriptCommandTest {
void assertManagersBoundToScript() {
ScriptEngine scriptEngine = client.getScriptEngine();
- List<String> mgrsNotBound = new ArrayList<String>();
+ List<Class<?>> mgrsNotBound = new ArrayList<Class<?>>();
for (RhqManager mgr : RhqManager.values()) {
if (!scriptEngine.getBindings(ScriptContext.ENGINE_SCOPE).containsKey(mgr.name())) {
- mgrsNotBound.add(mgr.remoteName());
+ mgrsNotBound.add(mgr.remote());
}
}
diff --git a/modules/enterprise/server/client-api/src/main/java/org/rhq/enterprise/client/LocalClient.java b/modules/enterprise/server/client-api/src/main/java/org/rhq/enterprise/client/LocalClient.java
index 5cbed7e..a918389 100644
--- a/modules/enterprise/server/client-api/src/main/java/org/rhq/enterprise/client/LocalClient.java
+++ b/modules/enterprise/server/client-api/src/main/java/org/rhq/enterprise/client/LocalClient.java
@@ -137,70 +137,6 @@ public class LocalClient implements RhqFacade {
}
private Object getLocalSLSB(RhqManager manager) {
- switch (manager) {
- case AlertDefinitionManager:
- return LookupUtil.getAlertDefinitionManager();
- case AlertManager:
- return LookupUtil.getAlertManager();
- case AvailabilityManager:
- return LookupUtil.getAvailabilityManager();
- case BundleManager:
- return LookupUtil.getBundleManager();
- case CallTimeDataManager:
- return LookupUtil.getCallTimeDataManager();
- case ConfigurationManager:
- return LookupUtil.getConfigurationManager();
- case ContentManager:
- return LookupUtil.getContentManager();
- case DataAccessManager:
- return LookupUtil.getDataAccessManager();
- case DiscoveryBoss:
- return LookupUtil.getDiscoveryBoss();
- case DriftManager:
- return LookupUtil.getDriftManager();
- case DriftTemplateManager:
- return LookupUtil.getDriftTemplateManager();
- case EventManager:
- return LookupUtil.getEventManager();
- case MeasurementBaselineManager:
- return LookupUtil.getMeasurementBaselineManager();
- case MeasurementDataManager:
- return LookupUtil.getMeasurementDataManager();
- case MeasurementDefinitionManager:
- return LookupUtil.getMeasurementDefinitionManager();
- case MeasurementScheduleManager:
- return LookupUtil.getMeasurementScheduleManager();
- case OperationManager:
- return LookupUtil.getOperationManager();
- case RemoteInstallManager:
- return LookupUtil.getRemoteInstallManager();
- case RepoManager:
- return LookupUtil.getRepoManagerLocal();
- case ResourceFactoryManager:
- return LookupUtil.getResourceFactoryManager();
- case ResourceGroupManager:
- return LookupUtil.getResourceGroupManager();
- case ResourceManager:
- return LookupUtil.getResourceManager();
- case ResourceTypeManager:
- return LookupUtil.getResourceTypeManager();
- case RoleManager:
- return LookupUtil.getRoleManager();
- case SavedSearchManager:
- return LookupUtil.getSavedSearchManager();
- case SubjectManager:
- return LookupUtil.getSubjectManager();
- case SupportManager:
- return LookupUtil.getSupportManager();
- case SynchronizationManager:
- return LookupUtil.getSynchronizationManager();
- case SystemManager:
- return LookupUtil.getSystemManager();
- case TagManager:
- return LookupUtil.getTagManager();
- }
-
- throw new IllegalStateException("LocalClient does not handle the manager: " + manager
- + ". This is a bug, please report it.");
+ return LookupUtil.getEjb(manager.beanName(), manager.localInterfaceClassName());
}
}
diff --git a/modules/enterprise/server/client-api/src/test/java/org/rhq/enterprise/client/test/LocalClientTest.java b/modules/enterprise/server/client-api/src/test/java/org/rhq/enterprise/client/test/LocalClientTest.java
index 61f9ea0..c7165cc 100644
--- a/modules/enterprise/server/client-api/src/test/java/org/rhq/enterprise/client/test/LocalClientTest.java
+++ b/modules/enterprise/server/client-api/src/test/java/org/rhq/enterprise/client/test/LocalClientTest.java
@@ -19,11 +19,15 @@
package org.rhq.enterprise.client.test;
+import static org.testng.Assert.assertEquals;
+
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.net.URL;
import java.net.URLClassLoader;
+import java.util.Arrays;
+import java.util.HashSet;
import java.util.Hashtable;
import javax.naming.Context;
@@ -63,8 +67,12 @@ public class LocalClientTest extends JMockTest {
System.setProperty(Context.INITIAL_CONTEXT_FACTORY, FakeContextFactory.class.getName());
}
- @Test
- public void testResilienceAgainstContextClassloaders() throws Exception {
+ /**
+ * Needs to be called from within a test method so that the "context" variable is available.
+ *
+ * @throws NamingException
+ */
+ private void setupFakeJndiLookup() throws NamingException {
CONTEXT_MOCK_FOR_TEST = context.mock(Context.class);
context.checking(new Expectations() {{
@@ -102,6 +110,20 @@ public class LocalClientTest extends JMockTest {
allowing(CONTEXT_MOCK_FOR_TEST).close();
}});
+ }
+
+ @Test
+ public void testAllManagersInstantiable() throws Exception {
+ setupFakeJndiLookup();
+
+ LocalClient lc = new LocalClient(null);
+ assertEquals(lc.getScriptingAPI().keySet(), new HashSet<RhqManager>(Arrays.asList(RhqManager.values())),
+ "Scripting API contains different managers than expected.");
+ }
+
+ @Test
+ public void testResilienceAgainstContextClassloaders() throws Exception {
+ setupFakeJndiLookup();
ClassLoader origCl = Thread.currentThread().getContextClassLoader();
try {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
index e49498c..8ef6a9f 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
@@ -632,6 +632,18 @@ public final class LookupUtil {
return service;
}
+ /**
+ * Generic method to lookup an Ejb bean by name and the interface name
+ *
+ * @param beanName the name of the EJB bean
+ * @param interfaceName the full class name of either the remote or local interface
+ *
+ * @return the bean accessed through specified inerface
+ */
+ public static Object getEjb(String beanName, String interfaceName) {
+ return lookupByName(beanName, interfaceName);
+ }
+
//--------------------------------------------
// The TEST services
//--------------------------------------------
@@ -658,8 +670,15 @@ public final class LookupUtil {
// Private Methods
+ //in this method, we don't actually need the interfaceName yet, but
+ //this will become necessary as soon as we start using AS7 as our container.
+ //So let's be proactive here ;)
+ private static String getLocalJNDIName(String beanName, String interfaceName) {
+ return (embeddedDeployment ? "" : (RHQConstants.EAR_NAME + "/")) + beanName + "/local";
+ }
+
private static <T> String getLocalJNDIName(@NotNull Class<? super T> beanClass) {
- return (embeddedDeployment ? "" : (RHQConstants.EAR_NAME + "/")) + beanClass.getSimpleName() + "/local";
+ return getLocalJNDIName(beanClass.getSimpleName(), beanClass.getName().replace("Bean", "Local"));
}
/**
@@ -685,6 +704,17 @@ public final class LookupUtil {
}
}
+ private static Object lookupByName(String beanName, String localInterfaceName) {
+ String localJNDIName = "-not initialized-";
+ try {
+ localJNDIName = getLocalJNDIName(beanName, localInterfaceName);
+ return lookup(localJNDIName);
+ } catch (NamingException e) {
+ throw new RuntimeException("Failed to lookup local interface to EJB " + beanName + ", localJNDI=["
+ + localJNDIName + "]", e);
+ }
+ }
+
@SuppressWarnings("unchecked")
private static <T> T lookupRemote(Class<? super T> type) {
try {
commit 783da488b14c341d9dabd2f678f0cbd6150db2a1
Author: mtho11 <mikecthompson(a)gmail.com>
Date: Mon Oct 1 08:31:19 2012 -0700
Trivial: Comment on skipped db-upgrade version 2.124
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index 00722db..52b359c 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -4037,6 +4037,8 @@
</schemaSpec>
+<!-- DB Schema 2.124 was bad so skipping intentionally -->
+
<!-- RHQ 4.5.0 uses DB Schema 2.125 -->
<schemaSpec version="2.125">
<schema-directSQL>