modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDetailsView.java | 2 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertFormatUtility.java | 141 --- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java | 311 ++++--- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/NumberWithUnitsValidator.java | 112 ++ modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestNumberFormatView.java | 78 + modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestTopView.java | 9 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/MeasurementConverterClient.java | 1 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/measurement/GwtMeasurementConverter.java | 4 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/measurement/MeasurementParser.java | 121 +++ modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java | 24 modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationDiscoveryComponent.java | 10 modules/plugins/database/src/main/java/org/rhq/plugins/database/AbstractDatabaseComponent.java | 3 modules/plugins/database/src/main/java/org/rhq/plugins/database/CustomTableComponent.java | 25 modules/plugins/database/src/main/java/org/rhq/plugins/database/CustomTableDiscoveryComponent.java | 6 modules/plugins/database/src/main/java/org/rhq/plugins/database/CustomTableRowDiscoveryComponent.java | 4 modules/plugins/database/src/main/java/org/rhq/plugins/database/DatabaseComponent.java | 3 modules/plugins/hibernate/src/main/java/org/rhq/plugins/hibernate/EntityComponent.java | 48 - modules/plugins/hibernate/src/main/java/org/rhq/plugins/hibernate/EntityDiscoveryComponent.java | 50 - modules/plugins/hibernate/src/main/java/org/rhq/plugins/hibernate/StatisticsComponent.java | 60 - modules/plugins/hudson/src/main/java/org/rhq/plugins/hudson/HudsonServerComponent.java | 14 modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISServerComponent.java | 3 modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISVHostComponent.java | 10 modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISVHostDiscoveryComponent.java | 4 modules/plugins/irc/src/main/java/org/rhq/plugins/irc/IRCServerComponent.java | 2 modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/AbstractManagedComponent.java | 26 modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/AbstractManagedDeploymentComponent.java | 17 modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/AbstractManagedDeploymentDiscoveryComponent.java | 75 - modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerComponent.java | 17 modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JBossMessagingComponent.java | 10 modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JBossMessagingDiscoveryComponent.java | 4 modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JBossWebComponent.java | 22 modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JBossWebDiscoveryComponent.java | 4 modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JmsDestinationDiscoveryComponent.java | 2 modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedComponentComponent.java | 12 modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedComponentDiscoveryComponent.java | 13 modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedDeploymentDiscoveryComponent.java | 4 modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/PlatformComponent.java | 397 ++++------ modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/PlatformDiscoveryComponent.java | 128 +-- modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ProfileServiceComponent.java | 2 modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/WebApplicationContextComponent.java | 192 +--- modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/script/ScriptComponent.java | 64 - modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/script/ScriptDiscoveryComponent.java | 23 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java | 2 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java | 2 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java | 82 -- modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/AbstractMessagingComponent.java | 58 - modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/AbstractMessagingDiscoveryComponent.java | 4 modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/ApplicationComponent.java | 2 modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/ApplicationDiscoveryComponent.java | 16 modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/ConnectionFactoryComponent.java | 4 modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/DatasourceComponent.java | 4 modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/EJB2BeanComponent.java | 2 modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/EJB3BeanComponent.java | 2 modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/EmbeddedWarDiscoveryComponent.java | 19 modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBMDestinationDiscoveryComponent.java | 4 modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASServerComponent.java | 20 modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatConnectorDiscoveryComponent.java | 24 modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatDiscoveryComponent.java | 54 - modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatServerComponent.java | 8 modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatVHostDiscoveryService.java | 4 modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatVHostService.java | 46 - modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossMQDiscoveryComponent.java | 2 modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossMessagingComponent.java | 49 - modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossMessagingDiscoveryComponent.java | 2 modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JMSComponent.java | 53 - modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/WarDiscoveryComponent.java | 2 modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/script/ScriptComponent.java | 7 modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/script/ScriptDiscoveryComponent.java | 75 - modules/plugins/jboss-cache-v3/src/main/java/org/rhq/plugins/jbosscache3/JBossCacheComponent.java | 60 - modules/plugins/jboss-cache-v3/src/main/java/org/rhq/plugins/jbosscache3/JBossCacheDetailComponent.java | 8 modules/plugins/jboss-cache-v3/src/main/java/org/rhq/plugins/jbosscache3/JBossCacheDetailDiscoveryComponent.java | 4 modules/plugins/jboss-cache-v3/src/main/java/org/rhq/plugins/jbosscache3/JBossCacheDiscoveryComponent.java | 4 modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheComponent.java | 8 modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheDiscoveryComponent.java | 6 modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheSubsystemComponent.java | 2 modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheSubsystemDiscovery.java | 4 modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/EmbeddedJMXServerDiscoveryComponent.java | 16 modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/InternalJMXServerDiscoveryComponent.java | 4 modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/JMXServerComponent.java | 3 modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/MBeanResourceComponent.java | 2 modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/MBeanResourceDiscoveryComponent.java | 12 modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ClassNameMBeanComponent.java | 4 modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ClassNameMBeanDiscoveryComponent.java | 3 modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/LoadMetricDiscoveryComponent.java | 7 modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/WebappContextComponent.java | 4 modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/WebappContextDiscoveryComponent.java | 7 modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlComponent.java | 3 modules/plugins/platform/src/main/java/org/rhq/plugins/platform/FileSystemDiscoveryComponent.java | 64 - modules/plugins/platform/src/main/java/org/rhq/plugins/platform/PlatformComponent.java | 7 modules/plugins/postfix/src/main/java/org/rhq/plugins/postfix/PostfixAccessDiscoveryComponent.java | 5 modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresDatabaseComponent.java | 6 modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresDatabaseDiscoveryComponent.java | 8 modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresServerComponent.java | 3 modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresUserComponent.java | 6 modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresUserDiscoveryComponent.java | 6 modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentEnvironmentScriptComponent.java | 4 modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentEnvironmentScriptDiscoveryComponent.java | 8 modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentJavaServiceWrapperComponent.java | 8 modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentJavaServiceWrapperDiscoveryComponent.java | 8 modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentLauncherScriptComponent.java | 6 modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentLauncherScriptDiscoveryComponent.java | 8 modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentServerComponent.java | 5 modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaServerComponent.java | 39 modules/plugins/snmptrapd/src/main/java/org/rhq/plugins/snmptrapd/SnmpTrapdComponent.java | 2 modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatConnectorComponent.java | 6 modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatConnectorDiscoveryComponent.java | 5 modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatServerComponent.java | 16 modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatUserDatabaseComponent.java | 4 modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostComponent.java | 7 modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostDiscoveryComponent.java | 11 modules/plugins/twitter/src/main/java/org/rhq/plugins/twitter/TwitterComponent.java | 2 modules/plugins/virt/src/main/java/org/rhq/plugins/virt/VirtualizationHostComponent.java | 2 112 files changed, 1580 insertions(+), 1431 deletions(-)
New commits: commit 038df495706986f3d0ba03a0eaaf97ddbb2c885d Merge: 3793ec4 457e6d1 Author: Robert Buck rbuck@redhat.com Date: Thu Sep 15 10:11:31 2011 -0400
Merge branch 'master' into feature/performance
* master: don't show the refresh button in the alert details view - they don't do anything and when you click it, they get disabled and never enabled again. [BZ 698600] do some null checks, because i am paranoid [BZ 698600] fix UI so users can enter units and see units in alert condition UI trivial - clean up imports, add TODO to mark a possible duplicate class More wildcard updates propagated upwards from the agent api.
commit 457e6d126578c74a7cf16a4d4f84123d6dcf5d2e Author: John Mazzitelli mazz@redhat.com Date: Thu Sep 15 10:01:49 2011 -0400
don't show the refresh button in the alert details view - they don't do anything and when you click it, they get disabled and never enabled again.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDetailsView.java index c206db6..1ee0b09 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDetailsView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDetailsView.java @@ -197,6 +197,7 @@ public class AlertDetailsView extends LocatableVLayout implements BookmarkableVi this.record = record; setHeight("35%"); setWidth100(); + setShowFooterRefresh(false); }
@Override @@ -263,6 +264,7 @@ public class AlertDetailsView extends LocatableVLayout implements BookmarkableVi this.record = record; setHeight("35%"); setWidth100(); + setShowFooterRefresh(false); }
@Override
commit 1a667256e025ccfc134528613dae82625d0cc1a9 Author: John Mazzitelli mazz@redhat.com Date: Thu Sep 15 01:19:51 2011 -0400
[BZ 698600] do some null checks, because i am paranoid
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertFormatUtility.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertFormatUtility.java index 154336b..4e15bd9 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertFormatUtility.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertFormatUtility.java @@ -78,8 +78,10 @@ public class AlertFormatUtility { // this is a calltime threshold condition str.append(MSG.view_alert_common_tab_conditions_type_metric_calltime_threshold()); str.append(" ["); - str.append(condition.getMeasurementDefinition().getDisplayName()); - str.append(" "); + if (condition.getMeasurementDefinition() != null) { + str.append(condition.getMeasurementDefinition().getDisplayName()); + str.append(" "); + } str.append(condition.getOption()); // MIN, MAX, AVG (never null) str.append(" "); str.append(condition.getComparator()); // <, >, = @@ -124,8 +126,10 @@ public class AlertFormatUtility { // this is a calltime change condition str.append(MSG.view_alert_common_tab_conditions_type_metric_calltime_change()); str.append(" ["); - str.append(condition.getMeasurementDefinition().getDisplayName()); - str.append(" "); + if (condition.getMeasurementDefinition() != null) { + str.append(condition.getMeasurementDefinition().getDisplayName()); + str.append(" "); + } str.append(condition.getOption()); // MIN, MAX, AVG (never null) str.append(" "); str.append(getCalltimeChangeComparator(condition.getComparator())); // LO, HI, CH
commit a4122c29a8788b93f85f5a97e8f3895bb89aa028 Author: John Mazzitelli mazz@redhat.com Date: Thu Sep 15 01:19:05 2011 -0400
[BZ 698600] fix UI so users can enter units and see units in alert condition UI
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertFormatUtility.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertFormatUtility.java index 6c41e21..154336b 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertFormatUtility.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertFormatUtility.java @@ -76,16 +76,15 @@ public class AlertFormatUtility { str.append("]"); } else { // this is a calltime threshold condition - // the name of the metric is only obtainable by querying for the name from the meas def ID - // but since most times (all the time?) there is only one calltime metric per resource, - // not showing the metric name probably isn't detrimental str.append(MSG.view_alert_common_tab_conditions_type_metric_calltime_threshold()); str.append(" ["); + str.append(condition.getMeasurementDefinition().getDisplayName()); + str.append(" "); str.append(condition.getOption()); // MIN, MAX, AVG (never null) str.append(" "); str.append(condition.getComparator()); // <, >, = str.append(" "); - str.append(condition.getThreshold()); + str.append(formatted); str.append("]"); if (condition.getName() != null && condition.getName().length() > 0) { str.append(" "); @@ -123,11 +122,10 @@ public class AlertFormatUtility { str.append("]"); } else { // this is a calltime change condition - // the name of the metric is only obtainable by querying for the name from the meas def ID - // but since most times (all the time?) there is only one calltime metric per resource, - // not showing the metric name probably isn't detrimental str.append(MSG.view_alert_common_tab_conditions_type_metric_calltime_change()); str.append(" ["); + str.append(condition.getMeasurementDefinition().getDisplayName()); + str.append(" "); str.append(condition.getOption()); // MIN, MAX, AVG (never null) str.append(" "); str.append(getCalltimeChangeComparator(condition.getComparator())); // LO, HI, CH @@ -276,129 +274,4 @@ public class AlertFormatUtility { } return recoveryInfo; } - /* THIS IS THE OLD CODE - IT HAS LOTS OF TODOs AND DIDN'T FULLY WORK - - public static String formatAlertConditionForDisplay(AlertCondition condition) { - AlertConditionCategory category = condition.getCategory(); - - StringBuilder textValue = new StringBuilder(); - - // first format the LHS of the operator - if (category == AlertConditionCategory.CONTROL) { - try { - String operationName = condition.getName(); - //Integer resourceTypeId = condition.getAlertDefinition().getResource().getResourceType().getId(); - //OperationManagerLocal operationManager = LookupUtil.getOperationManager(); - //OperationDefinition definition = operationManager.getOperationDefinitionByResourceTypeAndName( - // resourceTypeId, operationName, false); - //String operationDisplayName = definition.getDisplayName(); - textValue.append(operationName).append(' '); - } catch (Exception e) { - textValue.append(condition.getName()).append(' '); - } - } else if (category == AlertConditionCategory.RESOURCE_CONFIG) { - textValue.append("Resource Configuration").append(' '); - } else { - textValue.append(condition.getName()).append(' '); - } - - // next format the RHS - if (category == AlertConditionCategory.CONTROL) { - textValue.append(condition.getOption()); - } else if ((category == AlertConditionCategory.THRESHOLD) || (category == AlertConditionCategory.BASELINE)) { - textValue.append(condition.getComparator()); - textValue.append(' '); - - MeasurementSchedule schedule = null; - - MeasurementUnits units; - double value = condition.getThreshold(); - if (category == AlertConditionCategory.THRESHOLD) { - units = condition.getMeasurementDefinition().getUnits(); - } else // ( category == AlertConditionCategory.BASELINE ) - { - units = MeasurementUnits.PERCENTAGE; - } - - String formatted = MeasurementConverterClient.format(value, units, true); - textValue.append(formatted); - - if (category == AlertConditionCategory.BASELINE) { - textValue.append(" of "); - textValue.append(getBaselineText(condition.getOption(), schedule)); - } - } else if (category == AlertConditionCategory.RESOURCE_CONFIG || category == AlertConditionCategory.CHANGE - || category == AlertConditionCategory.TRAIT) { - textValue.append("Value Changed"); - } else if (category == AlertConditionCategory.EVENT) { - String msgKey = "alert.config.props.CB.EventSeverity"; - List<String> args = new ArrayList<String>(2); - - args.add(condition.getName()); - if ((condition.getOption() != null) && (condition.getOption().length() > 0)) { - msgKey += ".RegexMatch"; - args.add(condition.getOption()); - } - // TODO - textValue.append("TODO ").append(args); - } else if (category == AlertConditionCategory.AVAILABILITY) { - // TODO - textValue.append("Availability ").append(condition.getOption()); - } else { - // do nothing - } - - return textValue.toString(); - } - - private static String getBaselineText(String baselineOption, MeasurementSchedule schedule) { - final String BASELINE_OPT_MEAN = "mean"; - final String BASELINE_OPT_MIN = "min"; - final String BASELINE_OPT_MAX = "max"; - - final String MEASUREMENT_BASELINE_MIN_TEXT = "Min Value"; - final String MEASUREMENT_BASELINE_MEAN_TEXT = "Baseline Value"; - final String MEASUREMENT_BASELINE_MAX_TEXT = "Max Value"; - - if ((null != schedule) && (null != schedule.getBaseline())) { - MeasurementBaseline baseline = schedule.getBaseline(); - - String lookupText = null; - Double value = null; - - if (baselineOption.equals(BASELINE_OPT_MIN)) { - lookupText = MEASUREMENT_BASELINE_MIN_TEXT; - value = baseline.getMin(); - } else if (baselineOption.equals(BASELINE_OPT_MEAN)) { - lookupText = MEASUREMENT_BASELINE_MEAN_TEXT; - value = baseline.getMean(); - } else if (baselineOption.equals(BASELINE_OPT_MAX)) { - lookupText = MEASUREMENT_BASELINE_MAX_TEXT; - value = baseline.getMax(); - } - - if (value != null) { - try { - String formatted = MeasurementConverterClient.scaleAndFormat(value, schedule, true); - return formatted + " (" + lookupText + ")"; - } catch (MeasurementConversionException mce) { - return lookupText; - } - } - - // will need a fall-through here because the value was null; this can happen when the user requests to view - // the formatted baseline before the first time it has been calculated - } - - // here is the fall-through - if (BASELINE_OPT_MIN.equals(baselineOption)) { - return MEASUREMENT_BASELINE_MIN_TEXT; - } else if (BASELINE_OPT_MAX.equals(baselineOption)) { - return MEASUREMENT_BASELINE_MAX_TEXT; - } else { - return MEASUREMENT_BASELINE_MEAN_TEXT; - } - } - - */ } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java index 2ee65a3..81ba472 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java @@ -44,7 +44,6 @@ import com.smartgwt.client.widgets.form.fields.StaticTextItem; import com.smartgwt.client.widgets.form.fields.TextItem; import com.smartgwt.client.widgets.form.fields.events.ClickEvent; import com.smartgwt.client.widgets.form.fields.events.ClickHandler; -import com.smartgwt.client.widgets.form.validator.IsFloatValidator;
import org.rhq.core.domain.alert.AlertCondition; import org.rhq.core.domain.alert.AlertConditionCategory; @@ -53,11 +52,14 @@ import org.rhq.core.domain.event.EventSeverity; import org.rhq.core.domain.measurement.AvailabilityType; import org.rhq.core.domain.measurement.DataType; import org.rhq.core.domain.measurement.MeasurementDefinition; +import org.rhq.core.domain.measurement.MeasurementUnits; import org.rhq.core.domain.measurement.NumericType; import org.rhq.core.domain.operation.OperationDefinition; import org.rhq.core.domain.operation.OperationRequestStatus; import org.rhq.core.domain.resource.ResourceType; import org.rhq.enterprise.gui.coregui.client.CoreGUI; +import org.rhq.enterprise.gui.coregui.client.components.form.NumberWithUnitsValidator; +import org.rhq.enterprise.gui.coregui.client.util.measurement.MeasurementParser; import org.rhq.enterprise.gui.coregui.client.util.message.Message; import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm; @@ -286,169 +288,187 @@ public class NewConditionEditor extends LocatableDynamicForm {
private boolean saveNewCondition() {
- // Find out if this is using the ALL conjunction - if it is, we can't have more than one conditional use the same metric. - // If we do, immediately abort and warn the user. See BZ 737565 - if ((BooleanExpression.ALL.name().equals(this.conditionExpression.getValue().toString())) - && (supportsMetrics && this.resourceType.getMetricDefinitions() != null)) { - - Map<Integer, String> metricIdsUsed = new HashMap<Integer, String>(); - for (AlertCondition condition : this.conditions) { - if (condition.getMeasurementDefinition() != null) { - Integer id = Integer.valueOf(condition.getMeasurementDefinition().getId()); - if (metricIdsUsed.containsKey(id)) { - String msg = MSG.view_alert_definition_condition_editor_metricswarning(metricIdsUsed.get(id)); - Message warning = new Message(msg, Severity.Warning, EnumSet.of(Message.Option.Transient)); - CoreGUI.getMessageCenter().notify(warning); - return false; // multiple conditions used the same metric with ALL conjunction, this doesn't work - abort (BZ 737565) + try { + // Find out if this is using the ALL conjunction - if it is, we can't have more than one conditional use the same metric. + // If we do, immediately abort and warn the user. See BZ 737565 + if ((BooleanExpression.ALL.name().equals(this.conditionExpression.getValue().toString())) + && (supportsMetrics && this.resourceType.getMetricDefinitions() != null)) { + + Map<Integer, String> metricIdsUsed = new HashMap<Integer, String>(); + for (AlertCondition condition : this.conditions) { + if (condition.getMeasurementDefinition() != null) { + Integer id = Integer.valueOf(condition.getMeasurementDefinition().getId()); + if (metricIdsUsed.containsKey(id)) { + String msg = MSG.view_alert_definition_condition_editor_metricswarning(metricIdsUsed + .get(id)); + Message warning = new Message(msg, Severity.Warning, EnumSet.of(Message.Option.Transient)); + CoreGUI.getMessageCenter().notify(warning); + return false; // multiple conditions used the same metric with ALL conjunction, this doesn't work - abort (BZ 737565) + } + metricIdsUsed.put(id, condition.getMeasurementDefinition().getDisplayName()); } - metricIdsUsed.put(id, condition.getMeasurementDefinition().getDisplayName()); } } - }
- final boolean calltimeCategory; - final AlertConditionCategory category; + final boolean calltimeCategory; + final AlertConditionCategory category;
- String selectedCategory = conditionTypeSelectItem.getValue().toString(); - if (selectedCategory.equals(ALERT_CONDITION_CATEGORY_CALLTIME_THRESHOLD)) { - calltimeCategory = true; - category = AlertConditionCategory.THRESHOLD; - } else if (selectedCategory.equals(ALERT_CONDITION_CATEGORY_CALLTIME_CHANGE)) { - calltimeCategory = true; - category = AlertConditionCategory.CHANGE; - } else { - calltimeCategory = false; - category = AlertConditionCategory.valueOf(selectedCategory); - } + String selectedCategory = conditionTypeSelectItem.getValue().toString(); + if (selectedCategory.equals(ALERT_CONDITION_CATEGORY_CALLTIME_THRESHOLD)) { + calltimeCategory = true; + category = AlertConditionCategory.THRESHOLD; + } else if (selectedCategory.equals(ALERT_CONDITION_CATEGORY_CALLTIME_CHANGE)) { + calltimeCategory = true; + category = AlertConditionCategory.CHANGE; + } else { + calltimeCategory = false; + category = AlertConditionCategory.valueOf(selectedCategory); + }
- AlertCondition newCondition = new AlertCondition(); - newCondition.setCategory(category); - - switch (category) { - case AVAILABILITY: { - newCondition.setName(null); - newCondition.setComparator(null); - newCondition.setThreshold(null); - newCondition.setOption(getValueAsString(AVAILABILITY_ITEMNAME)); - newCondition.setMeasurementDefinition(null); - break; - } + AlertCondition newCondition = new AlertCondition(); + newCondition.setCategory(category);
- case THRESHOLD: { - if (!calltimeCategory) { - MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(THRESHOLD_METRIC_ITEMNAME)); + switch (category) { + case AVAILABILITY: { + newCondition.setName(null); + newCondition.setComparator(null); + newCondition.setThreshold(null); + newCondition.setOption(getValueAsString(AVAILABILITY_ITEMNAME)); + newCondition.setMeasurementDefinition(null); + break; + } + + case THRESHOLD: { + if (!calltimeCategory) { + MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(THRESHOLD_METRIC_ITEMNAME)); + newCondition.setName(measDef.getDisplayName()); + newCondition.setThreshold(getMeasurementValue(measDef, + getValueAsString(THRESHOLD_ABSVALUE_ITEMNAME))); + newCondition.setComparator(getValueAsString(THRESHOLD_COMPARATOR_ITEMNAME)); + newCondition.setOption(null); + newCondition.setMeasurementDefinition(measDef); + } else { + MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(CALLTIME_THRESHOLD_METRIC_ITEMNAME)); + newCondition.setName(getValueAsString(CALLTIME_THRESHOLD_REGEX_ITEMNAME)); + newCondition.setThreshold(getMeasurementValue(measDef, + getValueAsString(CALLTIME_THRESHOLD_ABSVALUE_ITEMNAME))); + newCondition.setComparator(getValueAsString(CALLTIME_THRESHOLD_COMPARATOR_ITEMNAME)); + newCondition.setOption(getValueAsString(CALLTIME_THRESHOLD_MINMAXAVG_ITEMNAME)); + newCondition.setMeasurementDefinition(measDef); + } + break; + } + + case BASELINE: { + MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(BASELINE_METRIC_ITEMNAME)); newCondition.setName(measDef.getDisplayName()); - newCondition.setThreshold(Double.valueOf(getValueAsString(THRESHOLD_ABSVALUE_ITEMNAME))); - newCondition.setComparator(getValueAsString(THRESHOLD_COMPARATOR_ITEMNAME)); - newCondition.setOption(null); - newCondition.setMeasurementDefinition(measDef); - } else { - MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(CALLTIME_THRESHOLD_METRIC_ITEMNAME)); - newCondition.setName(getValueAsString(CALLTIME_THRESHOLD_REGEX_ITEMNAME)); - newCondition.setThreshold(Double.valueOf(getValueAsString(CALLTIME_THRESHOLD_ABSVALUE_ITEMNAME))); - newCondition.setComparator(getValueAsString(CALLTIME_THRESHOLD_COMPARATOR_ITEMNAME)); - newCondition.setOption(getValueAsString(CALLTIME_THRESHOLD_MINMAXAVG_ITEMNAME)); + newCondition.setThreshold(getMeasurementValueByUnits(MeasurementUnits.PERCENTAGE, + getValueAsString(BASELINE_PERCENTAGE_ITEMNAME))); + newCondition.setComparator(getValueAsString(BASELINE_COMPARATOR_ITEMNAME)); + newCondition.setOption(getValueAsString(BASELINE_SELECTION_ITEMNAME)); newCondition.setMeasurementDefinition(measDef); + break; } - break; - }
- case BASELINE: { - MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(BASELINE_METRIC_ITEMNAME)); - newCondition.setName(measDef.getDisplayName()); - newCondition.setThreshold(Double.valueOf(getValueAsString(BASELINE_PERCENTAGE_ITEMNAME)) / 100.0); - newCondition.setComparator(getValueAsString(BASELINE_COMPARATOR_ITEMNAME)); - newCondition.setOption(getValueAsString(BASELINE_SELECTION_ITEMNAME)); - newCondition.setMeasurementDefinition(measDef); - break; - } + case CHANGE: { + if (!calltimeCategory) { + MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(CHANGE_METRIC_ITEMNAME)); + newCondition.setName(measDef.getDisplayName()); + newCondition.setComparator(null); + newCondition.setThreshold(null); + newCondition.setOption(null); + newCondition.setMeasurementDefinition(measDef); + } else { + MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(CALLTIME_CHANGE_METRIC_ITEMNAME)); + newCondition.setName(getValueAsString(CALLTIME_CHANGE_REGEX_ITEMNAME)); + newCondition.setThreshold(getMeasurementValueByUnits(MeasurementUnits.PERCENTAGE, + getValueAsString(CALLTIME_CHANGE_PERCENTAGE_ITEMNAME))); + newCondition.setComparator(getValueAsString(CALLTIME_CHANGE_COMPARATOR_ITEMNAME)); + newCondition.setOption(getValueAsString(CALLTIME_CHANGE_MINMAXAVG_ITEMNAME)); + newCondition.setMeasurementDefinition(measDef); + } + break; + }
- case CHANGE: { - if (!calltimeCategory) { - MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(CHANGE_METRIC_ITEMNAME)); + case TRAIT: { + MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(TRAIT_METRIC_ITEMNAME)); newCondition.setName(measDef.getDisplayName()); newCondition.setComparator(null); newCondition.setThreshold(null); newCondition.setOption(null); newCondition.setMeasurementDefinition(measDef); - } else { - MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(CALLTIME_CHANGE_METRIC_ITEMNAME)); - newCondition.setName(getValueAsString(CALLTIME_CHANGE_REGEX_ITEMNAME)); - newCondition - .setThreshold(Double.valueOf(getValueAsString(CALLTIME_CHANGE_PERCENTAGE_ITEMNAME)) / 100.0); - newCondition.setComparator(getValueAsString(CALLTIME_CHANGE_COMPARATOR_ITEMNAME)); - newCondition.setOption(getValueAsString(CALLTIME_CHANGE_MINMAXAVG_ITEMNAME)); - newCondition.setMeasurementDefinition(measDef); + break; } - break; - }
- case TRAIT: { - MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(TRAIT_METRIC_ITEMNAME)); - newCondition.setName(measDef.getDisplayName()); - newCondition.setComparator(null); - newCondition.setThreshold(null); - newCondition.setOption(null); - newCondition.setMeasurementDefinition(measDef); - break; - } + case CONTROL: { + newCondition.setName(getValueAsString(OPERATION_NAME_ITEMNAME)); + newCondition.setComparator(null); + newCondition.setThreshold(null); + newCondition.setOption(getValueAsString(OPERATION_RESULTS_ITEMNAME)); + newCondition.setMeasurementDefinition(null); + break; + }
- case CONTROL: { - newCondition.setName(getValueAsString(OPERATION_NAME_ITEMNAME)); - newCondition.setComparator(null); - newCondition.setThreshold(null); - newCondition.setOption(getValueAsString(OPERATION_RESULTS_ITEMNAME)); - newCondition.setMeasurementDefinition(null); - break; - } + case EVENT: { + newCondition.setName(getValueAsString(EVENT_SEVERITY_ITEMNAME)); + newCondition.setComparator(null); + newCondition.setThreshold(null); + newCondition.setOption(getValueAsString(EVENT_REGEX_ITEMNAME)); + newCondition.setMeasurementDefinition(null); + break; + }
- case EVENT: { - newCondition.setName(getValueAsString(EVENT_SEVERITY_ITEMNAME)); - newCondition.setComparator(null); - newCondition.setThreshold(null); - newCondition.setOption(getValueAsString(EVENT_REGEX_ITEMNAME)); - newCondition.setMeasurementDefinition(null); - break; - } + case RESOURCE_CONFIG: { + newCondition.setName(null); + newCondition.setComparator(null); + newCondition.setThreshold(null); + newCondition.setOption(null); + newCondition.setMeasurementDefinition(null); + break; + }
- case RESOURCE_CONFIG: { - newCondition.setName(null); - newCondition.setComparator(null); - newCondition.setThreshold(null); - newCondition.setOption(null); - newCondition.setMeasurementDefinition(null); - break; - } + case DRIFT: { + newCondition.setName(getValueAsString(DRIFT_CONFIGNAME_REGEX_ITEMNAME)); + newCondition.setComparator(null); + newCondition.setThreshold(null); + newCondition.setOption(getValueAsString(DRIFT_PATHNAME_REGEX_ITEMNAME)); + newCondition.setMeasurementDefinition(null); + break; + }
- case DRIFT: { - newCondition.setName(getValueAsString(DRIFT_CONFIGNAME_REGEX_ITEMNAME)); - newCondition.setComparator(null); - newCondition.setThreshold(null); - newCondition.setOption(getValueAsString(DRIFT_PATHNAME_REGEX_ITEMNAME)); - newCondition.setMeasurementDefinition(null); - break; - } + case RANGE: { + MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(RANGE_METRIC_ITEMNAME)); + newCondition.setName(measDef.getDisplayName()); + newCondition.setThreshold(getMeasurementValue(measDef, getValueAsString(RANGE_LO_ABSVALUE_ITEMNAME))); + newCondition.setComparator(getValueAsString(RANGE_COMPARATOR_ITEMNAME)); + newCondition.setOption(getMeasurementValue(measDef, getValueAsString(RANGE_HI_ABSVALUE_ITEMNAME)) + .toString()); + newCondition.setMeasurementDefinition(measDef); + break; + }
- case RANGE: { - MeasurementDefinition measDef = getMeasurementDefinition(getValueAsString(RANGE_METRIC_ITEMNAME)); - newCondition.setName(measDef.getDisplayName()); - newCondition.setThreshold(Double.valueOf(getValueAsString(RANGE_LO_ABSVALUE_ITEMNAME))); - newCondition.setComparator(getValueAsString(RANGE_COMPARATOR_ITEMNAME)); - newCondition.setOption(Double.valueOf(getValueAsString(RANGE_HI_ABSVALUE_ITEMNAME)).toString()); - newCondition.setMeasurementDefinition(measDef); - break; - } + default: { + CoreGUI.getErrorHandler().handleError( + MSG.view_alert_common_tab_invalid_condition_category(category.name())); // should never happen + break; + } + }
- default: { - CoreGUI.getErrorHandler() - .handleError(MSG.view_alert_common_tab_invalid_condition_category(category.name())); // should never happen - break; - } + this.conditions.add(newCondition); + + return true; + } catch (Exception e) { + CoreGUI.getErrorHandler().handleError("Problem creating condition", e); + return false; } + }
- this.conditions.add(newCondition); + private Double getMeasurementValue(MeasurementDefinition measDef, String userEnteredValue) { + return getMeasurementValueByUnits(measDef.getUnits(), userEnteredValue); + }
- return true; + private Double getMeasurementValueByUnits(MeasurementUnits units, String userEnteredValue) { + return MeasurementParser.parse(userEnteredValue, units).getValue(); }
private ArrayList<FormItem> buildMetricThresholdFormItems() { @@ -471,7 +491,8 @@ public class NewConditionEditor extends LocatableDynamicForm { absoluteValue.setTooltip(MSG.view_alert_definition_condition_editor_metric_threshold_value_tooltip()); absoluteValue.setHoverWidth(200); absoluteValue.setValidateOnChange(true); - absoluteValue.setValidators(new IsFloatValidator()); + absoluteValue.setValidators(new NumberWithUnitsValidator(this.resourceType.getMetricDefinitions(), + metricDropDownMenu)); absoluteValue.setShowIfCondition(ifFunc); formItems.add(absoluteValue); } else { @@ -503,7 +524,8 @@ public class NewConditionEditor extends LocatableDynamicForm { absoluteLowValue.setTooltip(MSG.view_alert_definition_condition_editor_metric_range_lovalue_tooltip()); absoluteLowValue.setHoverWidth(200); absoluteLowValue.setValidateOnChange(true); - absoluteLowValue.setValidators(new IsFloatValidator()); + absoluteLowValue.setValidators(new NumberWithUnitsValidator(this.resourceType.getMetricDefinitions(), + metricDropDownMenu)); absoluteLowValue.setShowIfCondition(ifFunc); formItems.add(absoluteLowValue);
@@ -514,7 +536,8 @@ public class NewConditionEditor extends LocatableDynamicForm { absoluteHighValue.setTooltip(MSG.view_alert_definition_condition_editor_metric_range_hivalue_tooltip()); absoluteHighValue.setHoverWidth(200); absoluteHighValue.setValidateOnChange(true); - absoluteHighValue.setValidators(new IsFloatValidator()); + absoluteHighValue.setValidators(new NumberWithUnitsValidator(this.resourceType.getMetricDefinitions(), + metricDropDownMenu)); absoluteHighValue.setShowIfCondition(ifFunc); formItems.add(absoluteHighValue); } else { @@ -550,7 +573,7 @@ public class NewConditionEditor extends LocatableDynamicForm { baselinePercentage.setHoverWidth(200); baselinePercentage.setShowIfCondition(ifFunc); baselinePercentage.setValidateOnChange(true); - baselinePercentage.setValidators(new IsFloatValidator()); + baselinePercentage.setValidators(new NumberWithUnitsValidator(MeasurementUnits.PERCENTAGE)); formItems.add(baselinePercentage);
SelectItem baselineSelection = new SelectItem(BASELINE_SELECTION_ITEMNAME, MSG @@ -605,7 +628,8 @@ public class NewConditionEditor extends LocatableDynamicForm { StaticTextItem helpItem = buildHelpTextItem("calltimeThresholdHelp", helpStr, ifFunc); formItems.add(helpItem);
- formItems.add(buildCalltimeMetricDropDownMenu(CALLTIME_THRESHOLD_METRIC_ITEMNAME, ifFunc)); + SelectItem metricDropDownMenu = buildCalltimeMetricDropDownMenu(CALLTIME_THRESHOLD_METRIC_ITEMNAME, ifFunc); + formItems.add(metricDropDownMenu);
SelectItem minMaxAvgSelection = new SelectItem(CALLTIME_THRESHOLD_MINMAXAVG_ITEMNAME, MSG .view_alert_definition_condition_editor_metric_calltime_common_limit()); @@ -633,7 +657,8 @@ public class NewConditionEditor extends LocatableDynamicForm { absoluteValue.setHoverWidth(200); absoluteValue.setShowIfCondition(ifFunc); absoluteValue.setValidateOnChange(true); - absoluteValue.setValidators(new IsFloatValidator()); + absoluteValue.setValidators(new NumberWithUnitsValidator(this.resourceType.getMetricDefinitions(), + metricDropDownMenu)); formItems.add(absoluteValue);
TextItem regex = new TextItem(CALLTIME_THRESHOLD_REGEX_ITEMNAME, MSG @@ -686,7 +711,7 @@ public class NewConditionEditor extends LocatableDynamicForm { percentage.setHoverWidth(200); percentage.setShowIfCondition(ifFunc); percentage.setValidateOnChange(true); - percentage.setValidators(new IsFloatValidator()); + percentage.setValidators(new NumberWithUnitsValidator(MeasurementUnits.PERCENTAGE)); formItems.add(percentage);
TextItem regex = new TextItem(CALLTIME_CHANGE_REGEX_ITEMNAME, MSG diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/NumberWithUnitsValidator.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/NumberWithUnitsValidator.java new file mode 100644 index 0000000..37e5589 --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/NumberWithUnitsValidator.java @@ -0,0 +1,112 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2009 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +package org.rhq.enterprise.gui.coregui.client.components.form; + +import java.util.Set; + +import com.smartgwt.client.widgets.form.fields.SelectItem; +import com.smartgwt.client.widgets.form.validator.CustomValidator; + +import org.rhq.core.domain.measurement.MeasurementDefinition; +import org.rhq.core.domain.measurement.MeasurementUnits; +import org.rhq.enterprise.gui.coregui.client.util.measurement.MeasurementParser; + +/** + * Validates user entered numbers with units. This validator can be given + * the units directly or it can derive the units based on a selection component + * whose keys are measurement definition IDs - the measurement definitions must be + * given so the ID can be looked up. + * + * @author John Mazzitelli + */ +public class NumberWithUnitsValidator extends CustomValidator { + + private final MeasurementUnits units; + private final Set<MeasurementDefinition> metricDefs; + private final SelectItem metricDropDownMenu; + + public NumberWithUnitsValidator(Set<MeasurementDefinition> metricDefs, SelectItem metricDropDownMenu) { + if (metricDefs == null) { + throw new NullPointerException("metricDefs == null"); + } + if (metricDropDownMenu == null) { + throw new NullPointerException("metricDropDownMenu == null"); + } + this.metricDefs = metricDefs; + this.metricDropDownMenu = metricDropDownMenu; + this.units = null; + } + + public NumberWithUnitsValidator(MeasurementUnits units) { + if (units == null) { + throw new NullPointerException("units == null"); + } + this.metricDefs = null; + this.metricDropDownMenu = null; + this.units = units; + } + + @Override + protected boolean condition(Object value) { + // don't know if this is the right thing to do, but assume the value was optional. + // if there is no value or its empty, assume that is OK and will be considered a 0 + if (value == null || value.toString().trim().length() == 0) { + return true; + } + + MeasurementUnits unitsToUse = this.units; + + if (unitsToUse == null) { + // units weren't directly given to us, find it from the selected metric definition + try { + String idString = metricDropDownMenu.getValueAsString(); + Integer id = Integer.parseInt(idString); + for (MeasurementDefinition metricDef : this.metricDefs) { + if (metricDef.getId() == id.intValue()) { + unitsToUse = metricDef.getUnits(); + break; + } + } + } catch (Exception e) { + unitsToUse = null; + } + } + + if (unitsToUse != null) { + try { + if (MeasurementParser.parse(value.toString(), unitsToUse) != null) { + return true; + } else { + return false; + } + } catch (Exception e) { + return false; + } + } else { + // no units? just see if its a valid floating point number + try { + Double.parseDouble(value.toString()); + return true; + } catch (Exception e) { + return false; + } + } + } +} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestNumberFormatView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestNumberFormatView.java new file mode 100644 index 0000000..30b11d4 --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestNumberFormatView.java @@ -0,0 +1,78 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2011 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +package org.rhq.enterprise.gui.coregui.client.test; + +import java.util.EnumSet; +import java.util.LinkedHashMap; + +import com.smartgwt.client.widgets.form.fields.ButtonItem; +import com.smartgwt.client.widgets.form.fields.SelectItem; +import com.smartgwt.client.widgets.form.fields.StaticTextItem; +import com.smartgwt.client.widgets.form.fields.TextItem; +import com.smartgwt.client.widgets.form.fields.events.ClickEvent; +import com.smartgwt.client.widgets.form.fields.events.ClickHandler; + +import org.rhq.core.domain.measurement.MeasurementUnits; +import org.rhq.core.domain.measurement.composite.MeasurementNumericValueAndUnits; +import org.rhq.enterprise.gui.coregui.client.util.measurement.MeasurementParser; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; + +public class TestNumberFormatView extends LocatableVLayout { + + public TestNumberFormatView(String locatorId) { + super(locatorId); + } + + @Override + protected void onDraw() { + super.onDraw(); + + LinkedHashMap<String, String> unitsChoices = new LinkedHashMap<String, String>(); + for (MeasurementUnits unit : EnumSet.allOf(MeasurementUnits.class)) { + unitsChoices.put(unit.name(), unit.name()); + } + + final SelectItem unitsMenu = new SelectItem("unitsItem", "Units"); + unitsMenu.setValueMap(unitsChoices); + unitsMenu.setDefaultValue(MeasurementUnits.BYTES.name()); + + final TextItem textItem = new TextItem("valueItem", "Value"); + + final StaticTextItem resultsValueItem = new StaticTextItem("resultsValue", "Results Value"); + final StaticTextItem resultsUnitItem = new StaticTextItem("resultsUnits", "Results Units"); + + ButtonItem button = new ButtonItem("convertItem", "Convert"); + button.addClickHandler(new ClickHandler() { + public void onClick(ClickEvent event) { + MeasurementUnits units = MeasurementUnits.valueOf(unitsMenu.getValueAsString()); + String value = textItem.getValueAsString(); + MeasurementNumericValueAndUnits vu = MeasurementParser.parse(value, units); + resultsValueItem.setValue(vu.getValue().toString()); + resultsUnitItem.setValue(vu.getUnits().name()); + } + }); + + LocatableDynamicForm form = new LocatableDynamicForm(extendLocatorId("form")); + form.setItems(unitsMenu, textItem, button, resultsValueItem, resultsUnitItem); + + addMember(form); + } +} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestTopView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestTopView.java index a9e131b..94bdd1e 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestTopView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestTopView.java @@ -78,6 +78,7 @@ public class TestTopView extends AbstractSectionedLeftNavigationView { // view IDs for Misc section private static final ViewName MISC_SECTION_VIEW_ID = new ViewName("Misc"); private static final ViewName PAGE_PLURALIZATION_TEST = new ViewName("PluralizationTest"); + private static final ViewName PAGE_NUMBER_FORMAT_TEST = new ViewName("NumberFormatTest"); private static final ViewName PAGE_ASYNC = new ViewName("Async"); private static final ViewName PAGE_RPC = new ViewName("Rpc");
@@ -224,6 +225,12 @@ public class TestTopView extends AbstractSectionedLeftNavigationView { }
private NavigationSection buildMiscSection() { + NavigationItem numberFormatItem = new NavigationItem(PAGE_NUMBER_FORMAT_TEST, null, new ViewFactory() { + public Canvas createView() { + return new TestNumberFormatView(extendLocatorId(PAGE_NUMBER_FORMAT_TEST.getName())); + } + }); + NavigationItem pluralizationItem = new NavigationItem(PAGE_PLURALIZATION_TEST, null, new ViewFactory() { public Canvas createView() { return new TestPluralizationView(extendLocatorId(PAGE_PLURALIZATION_TEST.getName())); @@ -242,7 +249,7 @@ public class TestTopView extends AbstractSectionedLeftNavigationView { } });
- return new NavigationSection(MISC_SECTION_VIEW_ID, pluralizationItem, asyncItem, rpcItem); + return new NavigationSection(MISC_SECTION_VIEW_ID, numberFormatItem, pluralizationItem, asyncItem, rpcItem); }
} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/measurement/MeasurementParser.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/measurement/MeasurementParser.java new file mode 100644 index 0000000..8ce0777 --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/measurement/MeasurementParser.java @@ -0,0 +1,121 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2011 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +package org.rhq.enterprise.gui.coregui.client.util.measurement; + +import com.google.gwt.i18n.client.NumberFormat; + +import org.rhq.core.domain.measurement.MeasurementUnits; +import org.rhq.core.domain.measurement.composite.MeasurementNumericValueAndUnits; +import org.rhq.core.domain.measurement.util.MeasurementConversionException; +import org.rhq.enterprise.gui.coregui.client.util.MeasurementConverterClient; + +/** + * Parses measurement strings given in the typical form of "[sign] magnitude [units]" such as: + * + * -1.0 + * +1.0s + * 200MB + * + * This is purposefully written without java.text and java.util.regex classes so GWT 2.0 + * can use this class. + * + * @author Greg Hinkle + * @author John Mazzitelli + */ +public class MeasurementParser { + + public static MeasurementNumericValueAndUnits parse(String input, MeasurementUnits targetUnits) + throws MeasurementConversionException { + + if (input == null) { + return new MeasurementNumericValueAndUnits(Double.valueOf(0.0), targetUnits); + } + + input = input.trim(); + + if (input.length() == 0) { + return new MeasurementNumericValueAndUnits(Double.valueOf(0.0), targetUnits); + } + + int i = 0; + + // skip over the sign, we'll deal with that later + if (input.startsWith("+") || input.startsWith("-")) { + i = 1; + } + + // find the end of the magnitude (i.e. the number itself) + // note we allow for decimals - and we allow for either "." or "," as the decimal point for i18n purposes + for (; i < input.length(); i++) { + char ch = input.charAt(i); + if (!(Character.isDigit(ch) || ch == '.' || ch == ',')) { + break; + } + } + + String magnitude = input.substring(0, i); + String units = ""; + + if (i <= input.length()) { + // gobble everything after the magnitude and consider it the units + units = input.substring(i); + units = units.trim(); + } + + MeasurementUnits fromUnits; + if (units.equals("")) { + /* + * no units is valid, and we assume the passed targetUnits; however, we will + * still need to check that the number is well-formed, so continue processing. + */ + fromUnits = targetUnits; + } else { + fromUnits = MeasurementUnits.getUsingDisplayUnits(units, targetUnits.getFamily()); + + if ((fromUnits == null) || (!fromUnits.isComparableTo(targetUnits))) { + throw new MeasurementConversionException("The units in '" + input + "' were not valid, " + "expected '" + + targetUnits.getFamily() + "' units, received '" + units + "' units"); + } + } + + try { + if (magnitude.startsWith("+")) { + magnitude = magnitude.substring(1); + } + + Number convertedMagnitude = NumberFormat.getDecimalFormat().parse(magnitude); + Double scaledMagnitude; + + // apply relative scale if applicable, otherwise perform standard scaling + if (MeasurementUnits.Family.RELATIVE == targetUnits.getFamily()) { + scaledMagnitude = MeasurementUnits.scaleDown(convertedMagnitude.doubleValue(), targetUnits); + } else { + MeasurementNumericValueAndUnits valueAndUnits = new MeasurementNumericValueAndUnits(convertedMagnitude + .doubleValue(), fromUnits); + scaledMagnitude = MeasurementConverterClient.scale(valueAndUnits, targetUnits); + } + + return new MeasurementNumericValueAndUnits(scaledMagnitude, targetUnits); + } catch (Exception e) { + throw new MeasurementConversionException("The magnitude in '" + input + "' did not parse correctly " + + "as a valid, localized, stringified number "); + } + + } +}
commit 99a931748c2a9017880fb8b82cf19102743ae11a Author: John Mazzitelli mazz@redhat.com Date: Thu Sep 15 01:09:17 2011 -0400
trivial - clean up imports, add TODO to mark a possible duplicate class
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/MeasurementConverterClient.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/MeasurementConverterClient.java index c538e2b..5842729 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/MeasurementConverterClient.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/MeasurementConverterClient.java @@ -29,7 +29,6 @@ import com.google.gwt.i18n.client.NumberFormat;
import org.rhq.core.domain.measurement.MeasurementSchedule; import org.rhq.core.domain.measurement.MeasurementUnits; -import org.rhq.core.domain.measurement.MeasurementUnits.Family; import org.rhq.core.domain.measurement.composite.MeasurementNumericValueAndUnits; import org.rhq.core.domain.measurement.util.MeasurementConversionException; import org.rhq.enterprise.gui.coregui.client.CoreGUI; diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/measurement/GwtMeasurementConverter.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/measurement/GwtMeasurementConverter.java index a8577e3..6833d07 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/measurement/GwtMeasurementConverter.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/measurement/GwtMeasurementConverter.java @@ -5,7 +5,6 @@ import java.util.HashSet; import java.util.Set;
import com.google.gwt.i18n.client.NumberFormat; -import com.google.gwt.i18n.client.TimeZone;
import org.rhq.core.domain.measurement.MeasurementSchedule; import org.rhq.core.domain.measurement.MeasurementUnits; @@ -17,10 +16,9 @@ import org.rhq.core.domain.measurement.util.MeasurementConversionException; * * @author Simeon Pinder */ +// TODO: what is different here vs. MeasurementConverterClient? we should combine the two public class GwtMeasurementConverter {
- public static TimeZone tz = null; - private static final int MAX_PRECISION_DIGITS = 4; private static final String NULL_OR_NAN_FORMATTED_VALUE = "--no data available--";
commit de2e667b239e40f261e9de116c5149889f217e64 Author: Stefan Negrea snegrea@redhat.com Date: Wed Sep 14 21:26:23 2011 -0500
More wildcard updates propagated upwards from the agent api.
diff --git a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java index ec0dee8..03dcec0 100644 --- a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java +++ b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java @@ -24,7 +24,6 @@ import java.util.Arrays; import java.util.Collection; import java.util.Date; import java.util.HashSet; -import java.util.LinkedHashMap; import java.util.List; import java.util.Set;
@@ -68,7 +67,7 @@ import org.rhq.plugins.augeas.helper.AugeasNode; * @author Ian Springer * @author Lukas Krejci */ -public class AugeasConfigurationComponent<T extends ResourceComponent> implements ResourceComponent<T>, +public class AugeasConfigurationComponent<T extends ResourceComponent<?>> implements ResourceComponent<T>, ConfigurationFacet, CreateChildResourceFacet, DeleteResourceFacet { /* Plugin config prop names */ public static final String INCLUDE_GLOBS_PROP = "configurationFilesInclusionPatterns"; @@ -78,7 +77,7 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement public static final String AUGEAS_ROOT_PATH_PROP = "augeasRootPath";
private static final boolean IS_WINDOWS = (File.separatorChar == '\'); - public static final String DEFAULT_AUGEAS_ROOT_PATH = (IS_WINDOWS) ? "C:/" : "/"; + public static final String DEFAULT_AUGEAS_ROOT_PATH = (IS_WINDOWS) ? "C:/" : "/";
private final Log log = LogFactory.getLog(this.getClass());
@@ -90,7 +89,7 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement private AugeasNode resourceConfigRootNode; private String augeasRootPath; private String augeasLoadPath; - + protected String getAugeasRootPath() { return augeasRootPath; } @@ -102,7 +101,7 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement protected String getAugeasLoadPath() { return augeasLoadPath; } - + public void start(ResourceContext<T> resourceContext) throws InvalidPluginConfigurationException, Exception { this.resourceContext = resourceContext; this.resourceDescription = this.resourceContext.getResourceType() + " Resource with key [" @@ -112,9 +111,10 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement Configuration pluginConfig = this.resourceContext.getPluginConfiguration(); this.augeasRootPath = pluginConfig.getSimpleValue(AUGEAS_ROOT_PATH_PROP, DEFAULT_AUGEAS_ROOT_PATH); log.debug("Augeas Root Path = "" + this.augeasRootPath + """); - - augeasLoadPath = resourceContext.getDataDirectory().getAbsolutePath() + File.separator + AugeasPluginLifecycleListener.LENSES_SUBDIRECTORY_NAME; - + + augeasLoadPath = resourceContext.getDataDirectory().getAbsolutePath() + File.separator + + AugeasPluginLifecycleListener.LENSES_SUBDIRECTORY_NAME; + if (isAugeasAvailable()) { initAugeas(); } else { @@ -755,16 +755,16 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement } } } - + private void checkModuleErrors(Augeas augeas) { List<String> errors = augeas.match("/augeas/load//error"); if (errors != null && errors.size() > 0) { StringBuilder errorMessage = new StringBuilder(); - for(String nodePath : errors) { + for (String nodePath : errors) { AugeasNode node = new AugeasNode(nodePath); String moduleName = node.getParent().getName(); String errorText = augeas.get(nodePath); - + errorMessage.append("Module '").append(moduleName).append("' failed with the following errors:\n"); errorMessage.append(errorText); errorMessage.append("\n\n"); @@ -772,7 +772,7 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement throw new IllegalStateException("Augeas modules didn't load cleanly.\n" + errorMessage); } } - + /* (non-Javadoc) * @see java.lang.Object#finalize() */ diff --git a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationDiscoveryComponent.java b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationDiscoveryComponent.java index 292e6df..5bc1d1d 100644 --- a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationDiscoveryComponent.java +++ b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationDiscoveryComponent.java @@ -28,6 +28,7 @@ import java.util.Set; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory;
+import org.rhq.augeas.util.Glob; import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.domain.resource.ResourceType; @@ -37,13 +38,12 @@ import org.rhq.core.pluginapi.inventory.ManualAddFacet; import org.rhq.core.pluginapi.inventory.ResourceComponent; import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent; import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; -import org.rhq.augeas.util.Glob;
/** * @author Ian Springer * @author Lukas Krejci */ -public class AugeasConfigurationDiscoveryComponent<T extends ResourceComponent> implements +public class AugeasConfigurationDiscoveryComponent<T extends ResourceComponent<?>> implements ResourceDiscoveryComponent<T>, ManualAddFacet<T> { private final Log log = LogFactory.getLog(this.getClass());
@@ -87,8 +87,8 @@ public class AugeasConfigurationDiscoveryComponent<T extends ResourceComponent> Configuration pluginConfig) { ResourceType resourceType = discoveryContext.getResourceType(); String resourceKey = composeResourceKey(pluginConfig); - DiscoveredResourceDetails resource = new DiscoveredResourceDetails(resourceType, resourceKey, resourceType - .getName(), null, resourceType.getDescription(), pluginConfig, null); + DiscoveredResourceDetails resource = new DiscoveredResourceDetails(resourceType, resourceKey, + resourceType.getName(), null, resourceType.getDescription(), pluginConfig, null); return resource; }
@@ -122,7 +122,7 @@ public class AugeasConfigurationDiscoveryComponent<T extends ResourceComponent> .getSimple(AugeasConfigurationComponent.EXCLUDE_GLOBS_PROP);
String augeasRootPath = pluginConfiguration.getSimpleValue(AugeasConfigurationComponent.AUGEAS_ROOT_PATH_PROP, - AugeasConfigurationComponent.DEFAULT_AUGEAS_ROOT_PATH); + AugeasConfigurationComponent.DEFAULT_AUGEAS_ROOT_PATH); File root = new File(augeasRootPath);
List<String> includeGlobs = getGlobList(includeGlobsProp); diff --git a/modules/plugins/database/src/main/java/org/rhq/plugins/database/AbstractDatabaseComponent.java b/modules/plugins/database/src/main/java/org/rhq/plugins/database/AbstractDatabaseComponent.java index 498270a..1170668 100644 --- a/modules/plugins/database/src/main/java/org/rhq/plugins/database/AbstractDatabaseComponent.java +++ b/modules/plugins/database/src/main/java/org/rhq/plugins/database/AbstractDatabaseComponent.java @@ -19,13 +19,14 @@ package org.rhq.plugins.database;
import java.sql.Connection; + import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException; import org.rhq.core.pluginapi.inventory.ResourceContext;
/** * @author Greg Hinkle */ -public abstract class AbstractDatabaseComponent<T extends DatabaseComponent> implements DatabaseComponent { +public abstract class AbstractDatabaseComponent<T extends DatabaseComponent<?>> implements DatabaseComponent { protected ResourceContext<T> resourceContext;
public void start(ResourceContext resourceContext) throws InvalidPluginConfigurationException, Exception { diff --git a/modules/plugins/database/src/main/java/org/rhq/plugins/database/CustomTableComponent.java b/modules/plugins/database/src/main/java/org/rhq/plugins/database/CustomTableComponent.java index f8ddcd8..d8906f7 100644 --- a/modules/plugins/database/src/main/java/org/rhq/plugins/database/CustomTableComponent.java +++ b/modules/plugins/database/src/main/java/org/rhq/plugins/database/CustomTableComponent.java @@ -26,6 +26,7 @@ import java.util.Set;
import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.rhq.core.domain.measurement.AvailabilityType; import org.rhq.core.domain.measurement.MeasurementDataNumeric; import org.rhq.core.domain.measurement.MeasurementReport; @@ -41,13 +42,13 @@ import org.rhq.core.util.jdbc.JDBCUtil; * * @author Greg Hinkle */ -public class CustomTableComponent implements DatabaseComponent<DatabaseComponent>, MeasurementFacet { - private ResourceContext<DatabaseComponent> context; +public class CustomTableComponent implements DatabaseComponent<DatabaseComponent<?>>, MeasurementFacet { + private ResourceContext<DatabaseComponent<?>> context;
private static final Log log = LogFactory.getLog(CustomTableComponent.class); - - public void start(ResourceContext<DatabaseComponent> resourceContext) throws InvalidPluginConfigurationException, - Exception { + + public void start(ResourceContext<DatabaseComponent<?>> resourceContext) + throws InvalidPluginConfigurationException, Exception { this.context = resourceContext; }
@@ -73,16 +74,22 @@ public class CustomTableComponent implements DatabaseComponent<DatabaseComponent
public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> metrics) throws Exception { String query = this.context.getPluginConfiguration().getSimpleValue("metricQuery", null); - + if (query == null) { ResourceType type = this.context.getResourceType(); String resourceKey = this.context.getResourceKey(); - log.info("Resource " + resourceKey + " (" + type.getName() + ", plugin " + type.getPlugin() + log.info("Resource " + + resourceKey + + " (" + + type.getName() + + ", plugin " + + type.getPlugin() + "): The plugin configuration doesn't specify 'metricQuery' property. Ignoring the measurement request."); return; } - - query = CustomTableRowDiscoveryComponent.formatMessage(query, this.context.getPluginConfiguration().getSimpleValue("key",null)); + + query = CustomTableRowDiscoveryComponent.formatMessage(query, this.context.getPluginConfiguration() + .getSimpleValue("key", null));
Map<String, Double> values = DatabaseQueryUtility.getNumericQueryValues(this, query); for (MeasurementScheduleRequest request : metrics) { diff --git a/modules/plugins/database/src/main/java/org/rhq/plugins/database/CustomTableDiscoveryComponent.java b/modules/plugins/database/src/main/java/org/rhq/plugins/database/CustomTableDiscoveryComponent.java index 633c28c..f25a8b1 100644 --- a/modules/plugins/database/src/main/java/org/rhq/plugins/database/CustomTableDiscoveryComponent.java +++ b/modules/plugins/database/src/main/java/org/rhq/plugins/database/CustomTableDiscoveryComponent.java @@ -39,9 +39,9 @@ import org.rhq.core.util.jdbc.JDBCUtil; * * @author Greg Hinkle */ -public class CustomTableDiscoveryComponent implements ManualAddFacet<DatabaseComponent>, ResourceDiscoveryComponent<DatabaseComponent> { +public class CustomTableDiscoveryComponent implements ManualAddFacet<DatabaseComponent<?>>, ResourceDiscoveryComponent<DatabaseComponent<?>> { public Set<DiscoveredResourceDetails> discoverResources( - ResourceDiscoveryContext<DatabaseComponent> resourceDiscoveryContext) + ResourceDiscoveryContext<DatabaseComponent<?>> resourceDiscoveryContext) throws InvalidPluginConfigurationException, Exception { Statement statement = null; try { @@ -75,7 +75,7 @@ public class CustomTableDiscoveryComponent implements ManualAddFacet<DatabaseCom return Collections.emptySet(); }
- public DiscoveredResourceDetails discoverResource(Configuration pluginConfiguration, ResourceDiscoveryContext<DatabaseComponent> discoveryContext) + public DiscoveredResourceDetails discoverResource(Configuration pluginConfiguration, ResourceDiscoveryContext<DatabaseComponent<?>> discoveryContext) throws InvalidPluginConfigurationException {
Configuration config = pluginConfiguration; diff --git a/modules/plugins/database/src/main/java/org/rhq/plugins/database/CustomTableRowDiscoveryComponent.java b/modules/plugins/database/src/main/java/org/rhq/plugins/database/CustomTableRowDiscoveryComponent.java index 4b40d86..e4d9392 100644 --- a/modules/plugins/database/src/main/java/org/rhq/plugins/database/CustomTableRowDiscoveryComponent.java +++ b/modules/plugins/database/src/main/java/org/rhq/plugins/database/CustomTableRowDiscoveryComponent.java @@ -40,9 +40,9 @@ import org.rhq.core.util.jdbc.JDBCUtil; * * @author Greg Hinkle */ -public class CustomTableRowDiscoveryComponent implements ResourceDiscoveryComponent<DatabaseComponent> { +public class CustomTableRowDiscoveryComponent implements ResourceDiscoveryComponent<DatabaseComponent<?>> { public Set<DiscoveredResourceDetails> discoverResources( - ResourceDiscoveryContext<DatabaseComponent> resourceDiscoveryContext) + ResourceDiscoveryContext<DatabaseComponent<?>> resourceDiscoveryContext) throws InvalidPluginConfigurationException, Exception { Statement statement = null; ResultSet resultSet = null; diff --git a/modules/plugins/database/src/main/java/org/rhq/plugins/database/DatabaseComponent.java b/modules/plugins/database/src/main/java/org/rhq/plugins/database/DatabaseComponent.java index 336554c..5b8ad5f 100644 --- a/modules/plugins/database/src/main/java/org/rhq/plugins/database/DatabaseComponent.java +++ b/modules/plugins/database/src/main/java/org/rhq/plugins/database/DatabaseComponent.java @@ -19,12 +19,13 @@ package org.rhq.plugins.database;
import java.sql.Connection; + import org.rhq.core.pluginapi.inventory.ResourceComponent;
/** * @author Greg Hinkle */ -public interface DatabaseComponent<T extends ResourceComponent> extends ResourceComponent<T> { +public interface DatabaseComponent<T extends ResourceComponent<?>> extends ResourceComponent<T> { Connection getConnection();
void removeConnection(); diff --git a/modules/plugins/hibernate/src/main/java/org/rhq/plugins/hibernate/EntityComponent.java b/modules/plugins/hibernate/src/main/java/org/rhq/plugins/hibernate/EntityComponent.java index 0803ed6..2ed80c8 100644 --- a/modules/plugins/hibernate/src/main/java/org/rhq/plugins/hibernate/EntityComponent.java +++ b/modules/plugins/hibernate/src/main/java/org/rhq/plugins/hibernate/EntityComponent.java @@ -1,25 +1,25 @@ - /* - * Jopr Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, as - * published by the Free Software Foundation, and/or the GNU Lesser - * General Public License, version 2.1, also as published by the Free - * Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License and the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * and the GNU Lesser General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* + * Jopr Management Platform + * Copyright (C) 2005-2008 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ package org.rhq.plugins.hibernate;
import java.util.Set; @@ -38,12 +38,12 @@ import org.rhq.plugins.jmx.MBeanResourceComponent; * @author Greg Hinkle * @author John Mazzitelli */ -public class EntityComponent extends MBeanResourceComponent<MBeanResourceComponent> { +public class EntityComponent extends MBeanResourceComponent<MBeanResourceComponent<?>> { @Override protected EmsBean loadBean() { return getResourceContext().getParentResourceComponent().getEmsBean(); } - + @Override public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> requests) { EmsOperation operation = getEmsBean().getOperation("getEntityStatistics"); diff --git a/modules/plugins/hibernate/src/main/java/org/rhq/plugins/hibernate/EntityDiscoveryComponent.java b/modules/plugins/hibernate/src/main/java/org/rhq/plugins/hibernate/EntityDiscoveryComponent.java index c21cde7..2bc5191 100644 --- a/modules/plugins/hibernate/src/main/java/org/rhq/plugins/hibernate/EntityDiscoveryComponent.java +++ b/modules/plugins/hibernate/src/main/java/org/rhq/plugins/hibernate/EntityDiscoveryComponent.java @@ -1,30 +1,32 @@ - /* - * Jopr Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, as - * published by the Free Software Foundation, and/or the GNU Lesser - * General Public License, version 2.1, also as published by the Free - * Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License and the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * and the GNU Lesser General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* + * Jopr Management Platform + * Copyright (C) 2005-2008 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ package org.rhq.plugins.hibernate;
import java.util.HashSet; import java.util.Set; + import org.mc4j.ems.connection.bean.EmsBean; + import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails; import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent; import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; @@ -35,8 +37,8 @@ import org.rhq.plugins.jmx.MBeanResourceComponent; * * @author Greg Hinkle */ -public class EntityDiscoveryComponent implements ResourceDiscoveryComponent<MBeanResourceComponent> { - public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<MBeanResourceComponent> context) { +public class EntityDiscoveryComponent implements ResourceDiscoveryComponent<MBeanResourceComponent<?>> { + public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<MBeanResourceComponent<?>> context) { Set<DiscoveredResourceDetails> entities = new HashSet<DiscoveredResourceDetails>();
EmsBean statsBean = context.getParentResourceComponent().getEmsBean(); diff --git a/modules/plugins/hibernate/src/main/java/org/rhq/plugins/hibernate/StatisticsComponent.java b/modules/plugins/hibernate/src/main/java/org/rhq/plugins/hibernate/StatisticsComponent.java index b42c966..bb00686 100644 --- a/modules/plugins/hibernate/src/main/java/org/rhq/plugins/hibernate/StatisticsComponent.java +++ b/modules/plugins/hibernate/src/main/java/org/rhq/plugins/hibernate/StatisticsComponent.java @@ -1,25 +1,25 @@ - /* - * Jopr Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, as - * published by the Free Software Foundation, and/or the GNU Lesser - * General Public License, version 2.1, also as published by the Free - * Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License and the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * and the GNU Lesser General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* + * Jopr Management Platform + * Copyright (C) 2005-2008 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ package org.rhq.plugins.hibernate;
import org.rhq.core.domain.configuration.Configuration; @@ -48,16 +48,16 @@ public class StatisticsComponent extends MBeanResourceComponent { Object queryStatistics = getEmsBean().getOperation("getQueryStatistics").invoke( new Object[] { queryString });
- Long executionCount = (Long) queryStatistics.getClass().getMethod("getExecutionCount").invoke( - queryStatistics); + Long executionCount = (Long) queryStatistics.getClass().getMethod("getExecutionCount") + .invoke(queryStatistics); Long executionRowCount = (Long) queryStatistics.getClass().getMethod("getExecutionRowCount") .invoke(queryStatistics); - Long executionMinTime = (Long) queryStatistics.getClass().getMethod("getExecutionMinTime").invoke( - queryStatistics); - Long executionMaxTime = (Long) queryStatistics.getClass().getMethod("getExecutionMaxTime").invoke( - queryStatistics); - Long executionAvgTime = (Long) queryStatistics.getClass().getMethod("getExecutionAvgTime").invoke( - queryStatistics); + Long executionMinTime = (Long) queryStatistics.getClass().getMethod("getExecutionMinTime") + .invoke(queryStatistics); + Long executionMaxTime = (Long) queryStatistics.getClass().getMethod("getExecutionMaxTime") + .invoke(queryStatistics); + Long executionAvgTime = (Long) queryStatistics.getClass().getMethod("getExecutionAvgTime") + .invoke(queryStatistics);
PropertyMap query = new PropertyMap("query", new PropertySimple("query", queryString), new PropertySimple("executionCount", executionCount), new PropertySimple("executionRowCount", diff --git a/modules/plugins/hudson/src/main/java/org/rhq/plugins/hudson/HudsonServerComponent.java b/modules/plugins/hudson/src/main/java/org/rhq/plugins/hudson/HudsonServerComponent.java index 17bcee7..f565052 100644 --- a/modules/plugins/hudson/src/main/java/org/rhq/plugins/hudson/HudsonServerComponent.java +++ b/modules/plugins/hudson/src/main/java/org/rhq/plugins/hudson/HudsonServerComponent.java @@ -18,21 +18,21 @@ */ package org.rhq.plugins.hudson;
+import java.util.HashMap; +import java.util.Map; + import org.json.JSONArray; import org.json.JSONObject; + import org.rhq.core.domain.measurement.AvailabilityType; import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException; import org.rhq.core.pluginapi.inventory.ResourceComponent; import org.rhq.core.pluginapi.inventory.ResourceContext;
-import java.util.HashMap; -import java.util.Map; - /** * @author Greg Hinkle */ -public class HudsonServerComponent implements ResourceComponent { - +public class HudsonServerComponent implements ResourceComponent<ResourceComponent<?>> {
private ResourceContext resourceContext; private Map<String, JSONArray> healthMap = new HashMap<String, JSONArray>(); @@ -46,8 +46,8 @@ public class HudsonServerComponent implements ResourceComponent {
public AvailabilityType getAvailability() { try { - JSONObject server = HudsonJSONUtility.getData(this.resourceContext.getPluginConfiguration().getSimple("urlBase").getStringValue(), 1); - + JSONObject server = HudsonJSONUtility.getData( + this.resourceContext.getPluginConfiguration().getSimple("urlBase").getStringValue(), 1);
JSONArray jobs = server.getJSONArray("jobs"); for (int i = 0; i < jobs.length(); i++) { diff --git a/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISServerComponent.java b/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISServerComponent.java index 67d7621..83495fc 100644 --- a/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISServerComponent.java +++ b/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISServerComponent.java @@ -46,7 +46,8 @@ import org.rhq.plugins.iis.util.Win32ServiceControlDelegate; * @author Greg Hinkle * @author Joseph Marques */ -public class IISServerComponent implements ResourceComponent, MeasurementFacet, OperationFacet { +public class IISServerComponent<T extends ResourceComponent<?>> implements ResourceComponent<T>, MeasurementFacet, + OperationFacet {
private static final String WINDOWS_SERVICE_NAME = "W3SVC"; private static final long SERVICE_CONTROL_TIMEOUT = 30000L; diff --git a/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISVHostComponent.java b/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISVHostComponent.java index 9d264b9..8c2b92f 100644 --- a/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISVHostComponent.java +++ b/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISVHostComponent.java @@ -40,15 +40,15 @@ import org.rhq.core.pluginapi.util.ResponseTimeConfiguration; * @author Greg Hinkle * @author Joseph Marques */ -public class IISVHostComponent implements ResourceComponent<IISServerComponent>, MeasurementFacet { +public class IISVHostComponent implements ResourceComponent<IISServerComponent<?>>, MeasurementFacet {
- private ResourceContext<IISServerComponent> resourceContext; + private ResourceContext<IISServerComponent<?>> resourceContext; private IISResponseTimeDelegate responseTimeDelegate;
private Log log = LogFactory.getLog(IISVHostComponent.class);
- public void start(ResourceContext<IISServerComponent> resourceContext) throws InvalidPluginConfigurationException, - Exception { + public void start(ResourceContext<IISServerComponent<?>> resourceContext) + throws InvalidPluginConfigurationException, Exception { this.resourceContext = resourceContext;
String logDirectory = getLogDirectory(); @@ -59,7 +59,7 @@ public class IISVHostComponent implements ResourceComponent<IISServerComponent>, if (logFormat == null) { throw new InvalidPluginConfigurationException("The 'responseTimeLogFormat' property must be specified."); } - + responseTimeDelegate = new IISResponseTimeDelegate(logDirectory, logFormat, responseTimeConfiguration /*,collectionTZ.equals("true")*/); } diff --git a/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISVHostDiscoveryComponent.java b/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISVHostDiscoveryComponent.java index 0cd5cd8..be3bd15 100644 --- a/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISVHostDiscoveryComponent.java +++ b/modules/plugins/iis/src/main/java/org/rhq/plugins/iis/IISVHostDiscoveryComponent.java @@ -38,13 +38,13 @@ import org.rhq.plugins.iis.util.IISMetaBase; * * @author Greg Hinkle */ -public class IISVHostDiscoveryComponent implements ResourceDiscoveryComponent<IISServerComponent> { +public class IISVHostDiscoveryComponent implements ResourceDiscoveryComponent<IISServerComponent<?>> {
private static final String PDH_WEB_SERVICE = "Web Service"; private static final String PDH_TOTAL = "_Total";
public Set<DiscoveredResourceDetails> discoverResources( - ResourceDiscoveryContext<IISServerComponent> resourceDiscoveryContext) + ResourceDiscoveryContext<IISServerComponent<?>> resourceDiscoveryContext) throws InvalidPluginConfigurationException, Exception {
List<String> vhosts = new ArrayList<String>(); diff --git a/modules/plugins/irc/src/main/java/org/rhq/plugins/irc/IRCServerComponent.java b/modules/plugins/irc/src/main/java/org/rhq/plugins/irc/IRCServerComponent.java index 5f169e8..b29293d 100644 --- a/modules/plugins/irc/src/main/java/org/rhq/plugins/irc/IRCServerComponent.java +++ b/modules/plugins/irc/src/main/java/org/rhq/plugins/irc/IRCServerComponent.java @@ -24,7 +24,7 @@ import org.jibble.pircbot.PircBot; /** * @author Greg Hinkle */ -public class IRCServerComponent implements ResourceComponent, OperationFacet { +public class IRCServerComponent implements ResourceComponent<ResourceComponent<?>>, OperationFacet { private final Log log = LogFactory.getLog(this.getClass());
private Bot bot; diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/AbstractManagedComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/AbstractManagedComponent.java index bde5b37..d463007 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/AbstractManagedComponent.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/AbstractManagedComponent.java @@ -30,35 +30,29 @@ import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection; /** * @author Ian Springer */ -public abstract class AbstractManagedComponent implements ProfileServiceComponent<ProfileServiceComponent> -{ - private ResourceContext<ProfileServiceComponent> resourceContext; +public abstract class AbstractManagedComponent implements ProfileServiceComponent<ProfileServiceComponent<?>> { + private ResourceContext<ProfileServiceComponent<?>> resourceContext; private String resourceDescription;
- public void start(ResourceContext<ProfileServiceComponent> resourceContext) throws Exception - { + public void start(ResourceContext<ProfileServiceComponent<?>> resourceContext) throws Exception { this.resourceContext = resourceContext; - this.resourceDescription = this.resourceContext.getResourceType() - + " Resource with key [" + this.resourceContext.getResourceKey() + "]"; + this.resourceDescription = this.resourceContext.getResourceType() + " Resource with key [" + + this.resourceContext.getResourceKey() + "]"; }
- public void stop() - { + public void stop() { return; - } + }
- public ResourceContext<ProfileServiceComponent> getResourceContext() - { + public ResourceContext<ProfileServiceComponent<?>> getResourceContext() { return this.resourceContext; }
- public ProfileServiceConnection getConnection() - { + public ProfileServiceConnection getConnection() { return this.resourceContext.getParentResourceComponent().getConnection(); }
- protected String getResourceDescription() - { + protected String getResourceDescription() { return this.resourceDescription; }
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/AbstractManagedDeploymentComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/AbstractManagedDeploymentComponent.java index 1703036..f554f60 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/AbstractManagedDeploymentComponent.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/AbstractManagedDeploymentComponent.java @@ -83,7 +83,7 @@ public abstract class AbstractManagedDeploymentComponent extends AbstractManaged
// ----------- ResourceComponent Implementation ------------
- public void start(ResourceContext<ProfileServiceComponent> resourceContext) throws Exception { + public void start(ResourceContext<ProfileServiceComponent<?>> resourceContext) throws Exception { super.start(resourceContext); Configuration pluginConfig = getResourceContext().getPluginConfiguration(); this.deploymentName = pluginConfig.getSimple(DEPLOYMENT_NAME_PROPERTY).getStringValue(); @@ -96,10 +96,9 @@ public abstract class AbstractManagedDeploymentComponent extends AbstractManaged try { getManagedDeployment(); } catch (Exception e) { - log - .warn("The underlying file [" - + this.deploymentFile - + "] no longer exists. It may have been deleted from the filesystem external to RHQ. If you wish to remove this Resource from inventory, you may add &debug=true to the URL for the Browse Resources > Services page and then click the UNINVENTORY button next to this Resource."); + log.warn("The underlying file [" + + this.deploymentFile + + "] no longer exists. It may have been deleted from the filesystem external to RHQ. If you wish to remove this Resource from inventory, you may add &debug=true to the URL for the Browse Resources > Services page and then click the UNINVENTORY button next to this Resource."); } }
@@ -112,16 +111,16 @@ public abstract class AbstractManagedDeploymentComponent extends AbstractManaged + e.getLocalizedMessage()); return AvailabilityType.DOWN; } catch (Throwable t) { - log.debug("Could not get deployment state for " + this.deploymentType + " deployment '" - + this.deploymentName + "', cause: ", t); + log.debug("Could not get deployment state for " + this.deploymentType + " deployment '" + + this.deploymentName + "', cause: ", t); return AvailabilityType.DOWN; }
if (deploymentState == DeploymentState.STARTED) { return AvailabilityType.UP; } else { - log.debug(this.deploymentType + " deployment '" + this.deploymentName + - "' was not running, state was: " + deploymentState); + log.debug(this.deploymentType + " deployment '" + this.deploymentName + "' was not running, state was: " + + deploymentState); return AvailabilityType.DOWN; } } diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/AbstractManagedDeploymentDiscoveryComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/AbstractManagedDeploymentDiscoveryComponent.java index 9ab49b7..c3084fb 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/AbstractManagedDeploymentDiscoveryComponent.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/AbstractManagedDeploymentDiscoveryComponent.java @@ -30,13 +30,19 @@ import java.util.Set;
import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + +import org.jboss.deployers.spi.management.KnownDeploymentTypes; +import org.jboss.deployers.spi.management.ManagementView; import org.jboss.deployers.spi.management.deploy.DeploymentManager; import org.jboss.deployers.spi.management.deploy.DeploymentProgress; import org.jboss.deployers.spi.management.deploy.DeploymentStatus; import org.jboss.managed.api.DeploymentState; +import org.jboss.managed.api.ManagedDeployment; +import org.jboss.profileservice.spi.NoSuchDeploymentException; import org.jboss.profileservice.spi.Profile; import org.jboss.profileservice.spi.ProfileKey; import org.jboss.profileservice.spi.ProfileService; + import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.domain.resource.ResourceType; import org.rhq.core.domain.resource.ResourceUpgradeReport; @@ -47,64 +53,54 @@ import org.rhq.core.pluginapi.upgrade.ResourceUpgradeContext; import org.rhq.core.pluginapi.upgrade.ResourceUpgradeFacet; import org.rhq.plugins.jbossas5.util.ConversionUtils;
-import org.jboss.deployers.spi.management.KnownDeploymentTypes; -import org.jboss.deployers.spi.management.ManagementView; -import org.jboss.managed.api.ManagedDeployment; -import org.jboss.profileservice.spi.NoSuchDeploymentException; - /** * Discovery component for discovering JBAS 5.x/6.x deployments (EARs, WARs, EJB-JARs, etc.). * * @author Mark Spritzler * @author Ian Springer */ -public abstract class AbstractManagedDeploymentDiscoveryComponent - implements ResourceDiscoveryComponent<ProfileServiceComponent>, ResourceUpgradeFacet<ProfileServiceComponent> -{ +public abstract class AbstractManagedDeploymentDiscoveryComponent implements + ResourceDiscoveryComponent<ProfileServiceComponent<?>>, ResourceUpgradeFacet<ProfileServiceComponent<?>> {
private final Log log = LogFactory.getLog(this.getClass());
public Set<DiscoveredResourceDetails> discoverResources( - ResourceDiscoveryContext<ProfileServiceComponent> discoveryContext) - { + ResourceDiscoveryContext<ProfileServiceComponent<?>> discoveryContext) { ResourceType resourceType = discoveryContext.getResourceType(); log.trace("Discovering " + resourceType.getName() + " Resources..."); KnownDeploymentTypes deploymentType = ConversionUtils.getDeploymentType(resourceType); String deploymentTypeString = deploymentType.getType();
- ManagementView managementView = discoveryContext.getParentResourceComponent().getConnection().getManagementView(); + ManagementView managementView = discoveryContext.getParentResourceComponent().getConnection() + .getManagementView(); // TODO (ips): Only refresh the ManagementView *once* per runtime discovery scan, rather than every time this // method is called. Do this by providing a runtime scan id in the ResourceDiscoveryContext. managementView.load();
Set<String> deploymentNames = null; - try - { + try { deploymentNames = managementView.getDeploymentNamesForType(deploymentTypeString); - } - catch (Exception e) - { + } catch (Exception e) { log.error("Unable to get deployment names for type " + deploymentTypeString, e); }
- Set<DiscoveredResourceDetails> discoveredResources = new HashSet<DiscoveredResourceDetails>(deploymentNames.size()); + Set<DiscoveredResourceDetails> discoveredResources = new HashSet<DiscoveredResourceDetails>( + deploymentNames.size());
- ProfileService profileService = discoveryContext.getParentResourceComponent().getConnection().getProfileService(); + ProfileService profileService = discoveryContext.getParentResourceComponent().getConnection() + .getProfileService();
// Create a resource details for each managed deployment found. - for (String deploymentName : deploymentNames) - { + for (String deploymentName : deploymentNames) { // example of a deployment name: vfszip:/C:/opt/jboss-6.0.0.Final/server/default/deploy/http-invoker.sar/invoker.war/ - try - { + try { ManagedDeployment managedDeployment = managementView.getDeployment(deploymentName); if (!accept(managedDeployment)) { continue; } String resourceName = managedDeployment.getSimpleName(); // @TODO remove this when AS5 actually implements this for sars, and some other DeploymentTypes that haven't implemented getSimpleName() - if (resourceName.equals("%Generated%")) - { + if (resourceName.equals("%Generated%")) { resourceName = getResourceName(deploymentName); }
@@ -113,26 +109,17 @@ public abstract class AbstractManagedDeploymentDiscoveryComponent
managedDeployment.getSimpleName(); String version = null; // TODO (ManagedDeployment "version" property?) - DiscoveredResourceDetails resource = - new DiscoveredResourceDetails(resourceType, - resourceKey, - resourceName, - version, - resourceType.getDescription(), - discoveryContext.getDefaultPluginConfiguration(), - null); + DiscoveredResourceDetails resource = new DiscoveredResourceDetails(resourceType, resourceKey, + resourceName, version, resourceType.getDescription(), + discoveryContext.getDefaultPluginConfiguration(), null); resource.getPluginConfiguration().put( - new PropertySimple(AbstractManagedDeploymentComponent.DEPLOYMENT_NAME_PROPERTY, deploymentName)); + new PropertySimple(AbstractManagedDeploymentComponent.DEPLOYMENT_NAME_PROPERTY, deploymentName)); discoveredResources.add(resource); - } - catch (NoSuchDeploymentException e) - { + } catch (NoSuchDeploymentException e) { // This is a bug in the profile service that occurs often, so don't log the stack trace. log.error("ManagementView.getDeploymentNamesForType() returned [" + deploymentName - + "] as a deployment name, but calling getDeployment() with that name failed."); - } - catch (Exception e) - { + + "] as a deployment name, but calling getDeployment() with that name failed."); + } catch (Exception e) { log.error("An error occurred while discovering " + resourceType + " Resources.", e); } } @@ -142,7 +129,7 @@ public abstract class AbstractManagedDeploymentDiscoveryComponent }
@Override - public ResourceUpgradeReport upgrade(ResourceUpgradeContext<ProfileServiceComponent> upgradeContext) { + public ResourceUpgradeReport upgrade(ResourceUpgradeContext<ProfileServiceComponent<?>> upgradeContext) { String inventoriedResourceKey = upgradeContext.getResourceKey();
// check if the inventoried resource already has the new resource key format. @@ -182,8 +169,7 @@ public abstract class AbstractManagedDeploymentDiscoveryComponent deploymentAncestrySimpleNames.add(0, parentDeployment.getSimpleName()); } while ((parentDeployment = parentDeployment.getParent()) != null);
- for (int i = 0, deploymentAncestrySimpleNamesSize = deploymentAncestrySimpleNames.size(); - i < deploymentAncestrySimpleNamesSize; i++) { + for (int i = 0, deploymentAncestrySimpleNamesSize = deploymentAncestrySimpleNames.size(); i < deploymentAncestrySimpleNamesSize; i++) { String deploymentSimpleName = deploymentAncestrySimpleNames.get(i); resourceKey.append(deploymentSimpleName); if (i != (deploymentAncestrySimpleNamesSize - 1)) { @@ -234,8 +220,7 @@ public abstract class AbstractManagedDeploymentDiscoveryComponent
protected abstract boolean accept(ManagedDeployment managedDeployment);
- private static String getResourceName(String fullPath) - { + private static String getResourceName(String fullPath) { int lastSlashIndex = fullPath.lastIndexOf("/"); return fullPath.substring(lastSlashIndex + 1); } diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerComponent.java index 5bacccb..299bdcd 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerComponent.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerComponent.java @@ -100,8 +100,9 @@ import org.rhq.plugins.jbossas5.util.ManagedComponentUtils; * @author Mark Spritzler * @author Ian Springer */ -public class ApplicationServerComponent implements ResourceComponent, ProfileServiceComponent, - CreateChildResourceFacet, MeasurementFacet, ConfigurationFacet, ProgressListener, ContentFacet, OperationFacet { +public class ApplicationServerComponent<T extends ResourceComponent<?>> implements ResourceComponent<T>, + ProfileServiceComponent<T>, CreateChildResourceFacet, MeasurementFacet, ConfigurationFacet, ProgressListener, + ContentFacet, OperationFacet {
private static final Pattern METRIC_NAME_PATTERN = Pattern.compile("(.*)\|(.*)\|(.*)\|(.*)");
@@ -148,8 +149,8 @@ public class ApplicationServerComponent implements ResourceComponent, ProfileSer //this component represents. This is to prevent 2 servers //with the same JNP URL to be reported as UP when just one //of them can be up at a time. - ManagedComponent serverConfig = managementView.getComponentsForType( - new ComponentType("MCBean", "ServerConfig")).iterator().next(); + ManagedComponent serverConfig = managementView + .getComponentsForType(new ComponentType("MCBean", "ServerConfig")).iterator().next();
String reportedServerHomeDirPath = (String) ((SimpleValue) serverConfig.getProperty("serverHomeDir") .getValue()).getValue(); @@ -464,8 +465,8 @@ public class ApplicationServerComponent implements ResourceComponent, ProfileSer public OperationResult invokeOperation(String name, Configuration parameters) throws InterruptedException, Exception {
- ApplicationServerSupportedOperations operation = Enum.valueOf(ApplicationServerSupportedOperations.class, name - .toUpperCase()); + ApplicationServerSupportedOperations operation = Enum.valueOf(ApplicationServerSupportedOperations.class, + name.toUpperCase()); return this.operationDelegate.invoke(operation, parameters); }
@@ -509,8 +510,8 @@ public class ApplicationServerComponent implements ResourceComponent, ProfileSer private JBPMWorkflowManager createJbpmWorkflowManager(ResourceContext resourceContext) { ContentContext contentContext = resourceContext.getContentContext(); ControlActionFacade controlActionFacade = initControlActionFacade(); - JBPMWorkflowManager workflowManager = new JBPMWorkflowManager(contentContext, controlActionFacade, this - .getJBossASPaths()); + JBPMWorkflowManager workflowManager = new JBPMWorkflowManager(contentContext, controlActionFacade, + this.getJBossASPaths()); return workflowManager; }
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JBossMessagingComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JBossMessagingComponent.java index af47587..e864117 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JBossMessagingComponent.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JBossMessagingComponent.java @@ -22,6 +22,8 @@ */ package org.rhq.plugins.jbossas5;
+import java.util.Set; + import org.rhq.core.domain.measurement.AvailabilityType; import org.rhq.core.domain.measurement.MeasurementReport; import org.rhq.core.domain.measurement.MeasurementScheduleRequest; @@ -31,23 +33,21 @@ import org.rhq.core.pluginapi.inventory.ResourceContext; import org.rhq.core.pluginapi.measurement.MeasurementFacet; import org.rhq.plugins.jbossas5.helper.CreateChildResourceFacetDelegate;
-import java.util.Set; - /** * The ResourceComponent for the singleton JBoss Messaging ResourceType, which supports creation of two child * ResourceTypes - Queue and Topic. * * @author Ian Springer */ -public class JBossMessagingComponent extends ManagedComponentComponent - implements CreateChildResourceFacet, MeasurementFacet { +public class JBossMessagingComponent extends ManagedComponentComponent implements CreateChildResourceFacet, + MeasurementFacet { private CreateChildResourceFacetDelegate createChildResourceDelegate;
public AvailabilityType getAvailability() { return super.getAvailability(); }
- public void start(ResourceContext resourceContext) throws Exception { + public void start(ResourceContext<ProfileServiceComponent<?>> resourceContext) throws Exception { super.start(resourceContext); this.createChildResourceDelegate = new CreateChildResourceFacetDelegate(this); } diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JBossMessagingDiscoveryComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JBossMessagingDiscoveryComponent.java index a88ac44..b953599 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JBossMessagingDiscoveryComponent.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JBossMessagingDiscoveryComponent.java @@ -34,11 +34,11 @@ import java.util.Set; * * @author Ian Springer */ -public class JBossMessagingDiscoveryComponent extends ManagedComponentDiscoveryComponent<ApplicationServerComponent> { +public class JBossMessagingDiscoveryComponent extends ManagedComponentDiscoveryComponent<ApplicationServerComponent<?>> { private static final String DEFAULT_RESOURCE_NAME = "JBoss Messaging";
@Override - public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<ApplicationServerComponent> discoveryContext) + public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<ApplicationServerComponent<?>> discoveryContext) throws Exception { return super.discoverResources(discoveryContext); } diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JBossWebComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JBossWebComponent.java index 9ac7274..2cdce10 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JBossWebComponent.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JBossWebComponent.java @@ -23,42 +23,38 @@ package org.rhq.plugins.jbossas5;
import org.jetbrains.annotations.NotNull; +import org.mc4j.ems.connection.EmsConnection; + import org.rhq.core.domain.measurement.AvailabilityType; import org.rhq.core.pluginapi.inventory.ResourceContext; import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection; -import org.mc4j.ems.connection.EmsConnection;
/** * A ResourceComponent for managing the JBoss Web servlet container within a JBoss AS instance. * * @author Ian Springer */ -public class JBossWebComponent implements ProfileServiceComponent<ProfileServiceComponent> -{ - private ResourceContext<ProfileServiceComponent> resourceContext; +public class JBossWebComponent implements ProfileServiceComponent<ProfileServiceComponent<?>> { + private ResourceContext<ProfileServiceComponent<?>> resourceContext;
- public void start(ResourceContext<ProfileServiceComponent> resourceContext) throws Exception - { + public void start(ResourceContext<ProfileServiceComponent<?>> resourceContext) throws Exception { this.resourceContext = resourceContext; }
- public void stop() - { + public void stop() { return; }
- public AvailabilityType getAvailability() - { + public AvailabilityType getAvailability() { return AvailabilityType.UP; }
@NotNull - public ResourceContext<ProfileServiceComponent> getResourceContext() { + public ResourceContext<ProfileServiceComponent<?>> getResourceContext() { return this.resourceContext; }
- public ProfileServiceConnection getConnection() - { + public ProfileServiceConnection getConnection() { return this.resourceContext.getParentResourceComponent().getConnection(); }
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JBossWebDiscoveryComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JBossWebDiscoveryComponent.java index bdabf9d..1e19e4e 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JBossWebDiscoveryComponent.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JBossWebDiscoveryComponent.java @@ -37,12 +37,12 @@ import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; * * @author Ian Springer */ -public class JBossWebDiscoveryComponent implements ResourceDiscoveryComponent<ProfileServiceComponent> +public class JBossWebDiscoveryComponent implements ResourceDiscoveryComponent<ProfileServiceComponent<?>> { private final Log log = LogFactory.getLog(this.getClass());
public Set<DiscoveredResourceDetails> discoverResources( - ResourceDiscoveryContext<ProfileServiceComponent> discoveryContext) + ResourceDiscoveryContext<ProfileServiceComponent<?>> discoveryContext) { Set<DiscoveredResourceDetails> discoveredResources = new HashSet<DiscoveredResourceDetails>(); ResourceType resourceType = discoveryContext.getResourceType(); diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JmsDestinationDiscoveryComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JmsDestinationDiscoveryComponent.java index 43a1722..02c5bed 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JmsDestinationDiscoveryComponent.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/JmsDestinationDiscoveryComponent.java @@ -31,7 +31,7 @@ import org.rhq.plugins.jbossas5.util.ManagedComponentUtils; * * @author Ian Springer */ -public class JmsDestinationDiscoveryComponent extends ManagedComponentDiscoveryComponent<ApplicationServerComponent> { +public class JmsDestinationDiscoveryComponent extends ManagedComponentDiscoveryComponent<ApplicationServerComponent<?>> { private static final String NAME_MANAGED_PROPERTY = "name";
@Override diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedComponentComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedComponentComponent.java index bca27da..23f8b2d 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedComponentComponent.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedComponentComponent.java @@ -129,7 +129,7 @@ public class ManagedComponentComponent extends AbstractManagedComponent implemen } }
- public void start(ResourceContext<ProfileServiceComponent> resourceContext) throws Exception { + public void start(ResourceContext<ProfileServiceComponent<?>> resourceContext) throws Exception { super.start(resourceContext); this.componentType = ConversionUtils.getComponentType(getResourceContext().getResourceType()); Configuration pluginConfig = resourceContext.getPluginConfiguration(); @@ -271,8 +271,8 @@ public class ManagedComponentComponent extends AbstractManagedComponent implemen if (null == isRuntimeMetric) { //log.info("\nADDING MAP ENTRY FOR METRIC=" + request.getName()); ManagedProperty managedProp = getManagedProperty(managedComponent, request); - runtimeMetricMap.put(request.getName(), Boolean.valueOf((null == managedProp || managedProp - .hasViewUse(ViewUse.RUNTIME)))); + runtimeMetricMap.put(request.getName(), + Boolean.valueOf((null == managedProp || managedProp.hasViewUse(ViewUse.RUNTIME)))); }
if (Boolean.FALSE.equals(runtimeMetricMap.get(request.getName()))) { @@ -284,7 +284,7 @@ public class ManagedComponentComponent extends AbstractManagedComponent implemen
return getManagedComponent(forceRefresh); } - + protected String getMeasurement(ManagedComponent component, String metricName) throws Exception { if ("runState".equals(metricName)) { return component.getRunState().name(); @@ -293,7 +293,7 @@ public class ManagedComponentComponent extends AbstractManagedComponent implemen return value == null ? null : toString(value); } } - + protected void updateComponent(ManagedComponent managedComponent) throws Exception { log.trace("Updating " + getResourceDescription() + " with component " + toString(managedComponent) + "..."); ManagementView managementView = getConnection().getManagementView(); @@ -340,7 +340,7 @@ public class ManagedComponentComponent extends AbstractManagedComponent implemen } return getInnerValue(metaValue); } - + /** * The name of the measurement schedule request (i.e. the metric name) can be in one of two forms: * <p/> diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedComponentDiscoveryComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedComponentDiscoveryComponent.java index a0a62ea..573f62c 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedComponentDiscoveryComponent.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedComponentDiscoveryComponent.java @@ -27,9 +27,11 @@ import java.util.Set;
import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.jboss.deployers.spi.management.ManagementView; import org.jboss.managed.api.ComponentType; import org.jboss.managed.api.ManagedComponent; + import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.domain.resource.ResourceType; import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails; @@ -45,7 +47,7 @@ import org.rhq.plugins.jbossas5.util.ConversionUtils; * @author Mark Spritzer * @author Ian Springer */ -public class ManagedComponentDiscoveryComponent<P extends ProfileServiceComponent> implements +public class ManagedComponentDiscoveryComponent<P extends ProfileServiceComponent<?>> implements ResourceDiscoveryComponent<P> { private final Log log = LogFactory.getLog(this.getClass());
@@ -68,9 +70,8 @@ public class ManagedComponentDiscoveryComponent<P extends ProfileServiceComponen throw new IllegalStateException("Failed to get component types for " + resourceType + ".", e); } if (resourceType.isSingleton() && components.size() > 1) { - throw new IllegalStateException("Discovered multiple [" + componentType - + "] managed components during [" + resourceType - + "] discovery, but expected to find no more than one - components were: " + components); + throw new IllegalStateException("Discovered multiple [" + componentType + "] managed components during [" + + resourceType + "] discovery, but expected to find no more than one - components were: " + components); }
Set<DiscoveredResourceDetails> discoveredResources = new HashSet<DiscoveredResourceDetails>(components.size()); @@ -92,8 +93,8 @@ public class ManagedComponentDiscoveryComponent<P extends ProfileServiceComponen String version = getResourceVersion(component);
DiscoveredResourceDetails resource = new DiscoveredResourceDetails(resourceType, resourceKey, - resourceName, version, resourceType.getDescription(), discoveryContext - .getDefaultPluginConfiguration(), null); + resourceName, version, resourceType.getDescription(), + discoveryContext.getDefaultPluginConfiguration(), null);
resource.getPluginConfiguration().put( new PropertySimple(ManagedComponentComponent.Config.COMPONENT_NAME, resourceKey)); diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedDeploymentDiscoveryComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedDeploymentDiscoveryComponent.java index 946120d..edac239 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedDeploymentDiscoveryComponent.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ManagedDeploymentDiscoveryComponent.java @@ -45,12 +45,12 @@ import org.jboss.profileservice.spi.NoSuchDeploymentException; * @author Mark Spritzler * @author Ian Springer */ -public abstract class ManagedDeploymentDiscoveryComponent implements ResourceDiscoveryComponent<ApplicationServerComponent> +public abstract class ManagedDeploymentDiscoveryComponent implements ResourceDiscoveryComponent<ApplicationServerComponent<?>> { private final Log log = LogFactory.getLog(this.getClass());
public Set<DiscoveredResourceDetails> discoverResources( - ResourceDiscoveryContext<ApplicationServerComponent> discoveryContext) + ResourceDiscoveryContext<ApplicationServerComponent<?>> discoveryContext) { Set<DiscoveredResourceDetails> discoveredResources = new HashSet<DiscoveredResourceDetails>(); ResourceType resourceType = discoveryContext.getResourceType(); diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/PlatformComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/PlatformComponent.java index 2c8e6d9..acfdb06 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/PlatformComponent.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/PlatformComponent.java @@ -7,6 +7,9 @@ import java.util.Set;
import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.jetbrains.annotations.NotNull; +import org.mc4j.ems.connection.EmsConnection; + import org.jboss.deployers.spi.management.ManagementView; import org.jboss.managed.api.ManagedComponent; import org.jboss.managed.api.ManagedDeployment; @@ -16,7 +19,7 @@ import org.jboss.managed.api.ManagedProperty; import org.jboss.metatype.api.types.MetaType; import org.jboss.metatype.api.values.MetaValue; import org.jboss.profileservice.spi.NoSuchDeploymentException; -import org.jetbrains.annotations.NotNull; + import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.domain.measurement.AvailabilityType; import org.rhq.core.domain.measurement.DataType; @@ -40,240 +43,214 @@ import org.rhq.plugins.jbossas5.adapter.impl.measurement.SimpleMetaValueMeasurem import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection; import org.rhq.plugins.jbossas5.util.ConversionUtils; import org.rhq.plugins.jbossas5.util.ResourceTypeUtils; -import org.mc4j.ems.connection.EmsConnection;
-public class PlatformComponent implements - ProfileServiceComponent<ProfileServiceComponent>, MeasurementFacet, - OperationFacet, ConfigurationFacet { - private final Log log = LogFactory.getLog(this.getClass()); - private ResourceContext<ProfileServiceComponent> context; - private String deployName; - private String componentName; +public class PlatformComponent implements ProfileServiceComponent<ProfileServiceComponent<?>>, MeasurementFacet, + OperationFacet, ConfigurationFacet { + private final Log log = LogFactory.getLog(this.getClass()); + private ResourceContext<ProfileServiceComponent<?>> context; + private String deployName; + private String componentName;
- public PlatformComponent() { - } + public PlatformComponent() { + }
- public void start(ResourceContext<ProfileServiceComponent> context) - throws InvalidPluginConfigurationException, Exception { - this.context = context; - } + public void start(ResourceContext<ProfileServiceComponent<?>> context) throws InvalidPluginConfigurationException, + Exception { + this.context = context; + }
- public void stop() { - return; - } + public void stop() { + return; + }
@NotNull - public ResourceContext<ProfileServiceComponent> getResourceContext() { + public ResourceContext<ProfileServiceComponent<?>> getResourceContext() { return this.context; }
public ProfileServiceConnection getConnection() { - ApplicationServerComponent component = (ApplicationServerComponent) context - .getParentResourceComponent(); - return component.getConnection(); + ApplicationServerComponent component = (ApplicationServerComponent) context.getParentResourceComponent(); + return component.getConnection();
- } + }
public EmsConnection getEmsConnection() { return context.getParentResourceComponent().getEmsConnection(); }
public CreateResourceReport createResource(CreateResourceReport report) { - // TODO Auto-generated method stub - return null; - } + // TODO Auto-generated method stub + return null; + } + + // ------------ MeasurementFacet Implementation ------------ + + public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> requests) { + try { + ManagedComponent component = loadComponent(); + String[] propertyName;
- // ------------ MeasurementFacet Implementation ------------ + for (MeasurementScheduleRequest request : requests) { + String metricName = request.getName();
- public void getValues(MeasurementReport report, - Set<MeasurementScheduleRequest> requests) { - try { - ManagedComponent component = loadComponent(); - String[] propertyName; + propertyName = parsePropertyName(metricName); + if (propertyName.length == 0) + continue;
- for (MeasurementScheduleRequest request : requests) { - String metricName = request.getName(); + ManagedProperty prop = component.getProperties().get(propertyName[0]);
- propertyName = parsePropertyName(metricName); - if (propertyName.length == 0) - continue; + if (prop != null) { + MetaType type = prop.getMetaType(); + MetaValue value = prop.getValue();
- ManagedProperty prop = component.getProperties().get( - propertyName[0]); + if (value != null) { + MeasurementDefinition measurementDefinition = ResourceTypeUtils.getMeasurementDefinition( + context.getResourceType(), metricName);
- if (prop != null) { - MetaType type = prop.getMetaType(); - MetaValue value = prop.getValue(); + if (type.isSimple()) { + MeasurementAdapter measurementAdapter = new SimpleMetaValueMeasurementAdapter(); + if (measurementDefinition != null & measurementAdapter != null) + measurementAdapter.setMeasurementData(report, value, request, measurementDefinition); + } + if (type.isComposite()) {
- if (value != null) { - MeasurementDefinition measurementDefinition = ResourceTypeUtils - .getMeasurementDefinition(context - .getResourceType(), metricName); + ManagedObject obj = prop.getManagedObject(); + Object attachment = obj.getAttachment(); + + for (int i = 0; i < propertyName.length; i++) { + attachment = getObjectProperty(attachment, propertyName[i]); + } + + setMeasurementData(report, attachment, request, measurementDefinition); + + } + + } + } + } + + } catch (NoSuchDeploymentException e) { + log.error("Loaded component does not exist: " + e); + } catch (SecurityException e) { + log.error("Security Exception: " + e); + + } + } + + public Configuration loadResourceConfiguration() throws Exception { + // TODO Auto-generated method stub + return null; + } + + public void updateResourceConfiguration(ConfigurationUpdateReport report) { + // TODO Auto-generated method stub + + }
- if (type.isSimple()) { - MeasurementAdapter measurementAdapter = new SimpleMetaValueMeasurementAdapter(); - if (measurementDefinition != null - & measurementAdapter != null) - measurementAdapter.setMeasurementData(report, - value, request, measurementDefinition); - } - if (type.isComposite()) { + private ManagedComponent loadComponent() throws NoSuchDeploymentException {
- ManagedObject obj = prop.getManagedObject(); - Object attachment = obj.getAttachment(); + deployName = context.getPluginConfiguration().getSimple(PlatformDiscoveryComponent.PLATFORM_DEPLOYMENT_NAME) + .getStringValue();
- for (int i = 0; i < propertyName.length; i++) { - attachment = getObjectProperty(attachment, - propertyName[i]); - } - - setMeasurementData(report, attachment, request, - measurementDefinition); - - } - - } - } - } - - } catch (NoSuchDeploymentException e) { - log.error("Loaded component does not exist: " + e); - } catch (SecurityException e) { - log.error("Security Exception: " + e); - - } - } - - public Configuration loadResourceConfiguration() throws Exception { - // TODO Auto-generated method stub - return null; - } - - public void updateResourceConfiguration(ConfigurationUpdateReport report) { - // TODO Auto-generated method stub - - } - - private ManagedComponent loadComponent() throws NoSuchDeploymentException { - - deployName = context.getPluginConfiguration().getSimple( - PlatformDiscoveryComponent.PLATFORM_DEPLOYMENT_NAME) - .getStringValue(); - - componentName = context.getPluginConfiguration().getSimple( - PlatformDiscoveryComponent.PLATFORM_COMPONENT_NAME) - .getStringValue(); - - ProfileServiceConnection connection = context - .getParentResourceComponent().getConnection(); - - ManagementView managementView = connection.getManagementView(); - - ManagedDeployment deploy = managementView.getDeployment(deployName); - if (deploy != null) { - Map<String, ManagedComponent> components = deploy.getComponents(); - - return components.get(componentName); - } - - return null; - } - - public AvailabilityType getAvailability() { - // TODO Auto-generated method stub - return null; - } - - public String[] parsePropertyName(String name) { - - String[] ps; - - if (name.indexOf('{') == -1) { - ps = new String[1]; - ps[0] = name; - return ps; - } - name = name.substring(name.indexOf('{') + 1, name.indexOf('}')); - ps = name.split("\."); - - return ps; - } - - protected Object getObjectProperty(Object value, String property) { - - try { - PropertyDescriptor[] pds = Introspector.getBeanInfo( - value.getClass()).getPropertyDescriptors(); - for (PropertyDescriptor pd : pds) { - if (pd.getName().equals(property)) { - pd.getReadMethod().setAccessible(true); - value = pd.getReadMethod().invoke(value); - } - } - } catch (Exception e) { - log.error("Object " + value.toString() - + " does not contain property " + property, e); - } - - return value; - } - - public void setMeasurementData(MeasurementReport report, Object value, - MeasurementScheduleRequest request, - MeasurementDefinition measurementDefinition) { - - DataType dataType = measurementDefinition.getDataType(); - switch (dataType) { - case MEASUREMENT: - try { - MeasurementDataNumeric dataNumeric = new MeasurementDataNumeric( - request, new Double(value.toString())); - report.addData(dataNumeric); - } catch (NumberFormatException e) { - log - .warn( - "Measurement request: " - + request.getName() - + " did not return a numeric value from the Profile Service", - e); - } - break; - case TRAIT: - MeasurementDataTrait dataTrait = new MeasurementDataTrait(request, - String.valueOf(value)); - report.addData(dataTrait); - break; - default: - throw new IllegalStateException( - "Unsupported measurement data type: " + dataType); - } - } - - public OperationResult invokeOperation(String name, Configuration parameters) - throws InterruptedException, Exception { - - ResourceType resourceType = context.getResourceType(); - OperationDefinition operationDefinition = ResourceTypeUtils - .getOperationDefinition(resourceType, name); - - ManagedComponent component = loadComponent(); - Set<ManagedOperation> operations = component.getOperations(); - - for (ManagedOperation operation : operations) { - if (operation.getName().equals(name)) { - MetaValue[] params = ConversionUtils - .convertOperationsParametersToMetaValues(operation, - parameters, operationDefinition); - MetaValue operationResult = operation.invoke(params); - - OperationResult result = new OperationResult(); - ConversionUtils.convertManagedOperationResults(operation, - operationResult, result.getComplexResults(), - operationDefinition); - - return result; - } - } - return null; - } + componentName = context.getPluginConfiguration().getSimple(PlatformDiscoveryComponent.PLATFORM_COMPONENT_NAME) + .getStringValue(); + + ProfileServiceConnection connection = context.getParentResourceComponent().getConnection(); + + ManagementView managementView = connection.getManagementView(); + + ManagedDeployment deploy = managementView.getDeployment(deployName); + if (deploy != null) { + Map<String, ManagedComponent> components = deploy.getComponents(); + + return components.get(componentName); + } + + return null; + } + + public AvailabilityType getAvailability() { + // TODO Auto-generated method stub + return null; + } + + public String[] parsePropertyName(String name) { + + String[] ps; + + if (name.indexOf('{') == -1) { + ps = new String[1]; + ps[0] = name; + return ps; + } + name = name.substring(name.indexOf('{') + 1, name.indexOf('}')); + ps = name.split("\."); + + return ps; + } + + protected Object getObjectProperty(Object value, String property) { + + try { + PropertyDescriptor[] pds = Introspector.getBeanInfo(value.getClass()).getPropertyDescriptors(); + for (PropertyDescriptor pd : pds) { + if (pd.getName().equals(property)) { + pd.getReadMethod().setAccessible(true); + value = pd.getReadMethod().invoke(value); + } + } + } catch (Exception e) { + log.error("Object " + value.toString() + " does not contain property " + property, e); + } + + return value; + } + + public void setMeasurementData(MeasurementReport report, Object value, MeasurementScheduleRequest request, + MeasurementDefinition measurementDefinition) { + + DataType dataType = measurementDefinition.getDataType(); + switch (dataType) { + case MEASUREMENT: + try { + MeasurementDataNumeric dataNumeric = new MeasurementDataNumeric(request, new Double(value.toString())); + report.addData(dataNumeric); + } catch (NumberFormatException e) { + log.warn("Measurement request: " + request.getName() + + " did not return a numeric value from the Profile Service", e); + } + break; + case TRAIT: + MeasurementDataTrait dataTrait = new MeasurementDataTrait(request, String.valueOf(value)); + report.addData(dataTrait); + break; + default: + throw new IllegalStateException("Unsupported measurement data type: " + dataType); + } + } + + public OperationResult invokeOperation(String name, Configuration parameters) throws InterruptedException, + Exception { + + ResourceType resourceType = context.getResourceType(); + OperationDefinition operationDefinition = ResourceTypeUtils.getOperationDefinition(resourceType, name); + + ManagedComponent component = loadComponent(); + Set<ManagedOperation> operations = component.getOperations(); + + for (ManagedOperation operation : operations) { + if (operation.getName().equals(name)) { + MetaValue[] params = ConversionUtils.convertOperationsParametersToMetaValues(operation, parameters, + operationDefinition); + MetaValue operationResult = operation.invoke(params); + + OperationResult result = new OperationResult(); + ConversionUtils.convertManagedOperationResults(operation, operationResult, result.getComplexResults(), + operationDefinition); + + return result; + } + } + return null; + } } diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/PlatformDiscoveryComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/PlatformDiscoveryComponent.java index eddbd23..d930ebf 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/PlatformDiscoveryComponent.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/PlatformDiscoveryComponent.java @@ -5,11 +5,13 @@ import java.util.Set;
import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.jboss.deployers.spi.management.ManagementView; import org.jboss.managed.api.ComponentType; import org.jboss.managed.api.ManagedComponent; import org.jboss.managed.api.ManagedDeployment; import org.jboss.profileservice.spi.NoSuchDeploymentException; + import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.domain.resource.ResourceType; @@ -20,98 +22,82 @@ import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection; import org.rhq.plugins.jbossas5.util.ManagedComponentUtils;
-public class PlatformDiscoveryComponent implements - ResourceDiscoveryComponent<ApplicationServerComponent> { +public class PlatformDiscoveryComponent implements ResourceDiscoveryComponent<ApplicationServerComponent<?>> {
- private final Log log = LogFactory.getLog(this.getClass()); - public static String PLATFORM_DEPLOYMENT_NAME = "deployment"; - public static String PLATFORM_COMPONENT_NAME = "componentName"; + private final Log log = LogFactory.getLog(this.getClass()); + public static String PLATFORM_DEPLOYMENT_NAME = "deployment"; + public static String PLATFORM_COMPONENT_NAME = "componentName";
- public Set discoverResources( - ResourceDiscoveryContext<ApplicationServerComponent> context) - throws InvalidPluginConfigurationException, Exception { + public Set discoverResources(ResourceDiscoveryContext<ApplicationServerComponent<?>> context) + throws InvalidPluginConfigurationException, Exception {
- log.trace("Discovering " + context.getResourceType().getName() - + " Resources..."); + log.trace("Discovering " + context.getResourceType().getName() + " Resources...");
- Set<DiscoveredResourceDetails> resources = new HashSet<DiscoveredResourceDetails>(); - ResourceType resourceType = context.getResourceType(); + Set<DiscoveredResourceDetails> resources = new HashSet<DiscoveredResourceDetails>(); + ResourceType resourceType = context.getResourceType();
- Set<ManagedComponent> components = new HashSet<ManagedComponent>(); + Set<ManagedComponent> components = new HashSet<ManagedComponent>();
- Configuration config = context.getDefaultPluginConfiguration(); + Configuration config = context.getDefaultPluginConfiguration();
- String deployName = config.getSimple( - PlatformDiscoveryComponent.PLATFORM_DEPLOYMENT_NAME) - .getStringValue(); + String deployName = config.getSimple(PlatformDiscoveryComponent.PLATFORM_DEPLOYMENT_NAME).getStringValue();
- String componentName = config.getSimple( - PlatformDiscoveryComponent.PLATFORM_COMPONENT_NAME) - .getStringValue(); + String componentName = config.getSimple(PlatformDiscoveryComponent.PLATFORM_COMPONENT_NAME).getStringValue();
- components.addAll(addManagedDeploymentComponent(deployName, - componentName, context)); + components.addAll(addManagedDeploymentComponent(deployName, componentName, context));
- for (ManagedComponent component : components) { + for (ManagedComponent component : components) {
- ComponentType type = component.getType(); - String displayName; + ComponentType type = component.getType(); + String displayName;
- try { - displayName = (String) ManagedComponentUtils - .getSimplePropertyValue(component, "name"); - } catch (IllegalStateException il) { - displayName = component.getName(); - } + try { + displayName = (String) ManagedComponentUtils.getSimplePropertyValue(component, "name"); + } catch (IllegalStateException il) { + displayName = component.getName(); + }
- try { - String resourceName = (String) component.getName(); + try { + String resourceName = (String) component.getName();
- String resourceKey = component.getType() + "|" - + type.getSubtype() + "|" + resourceName; + String resourceKey = component.getType() + "|" + type.getSubtype() + "|" + resourceName;
- String version = ""; - Configuration pluginConfig = new Configuration(); - pluginConfig.put(new PropertySimple(PLATFORM_DEPLOYMENT_NAME, - deployName)); - pluginConfig.put(new PropertySimple(PLATFORM_COMPONENT_NAME, - resourceName)); + String version = ""; + Configuration pluginConfig = new Configuration(); + pluginConfig.put(new PropertySimple(PLATFORM_DEPLOYMENT_NAME, deployName)); + pluginConfig.put(new PropertySimple(PLATFORM_COMPONENT_NAME, resourceName));
- resources.add(new DiscoveredResourceDetails(context - .getResourceType(), resourceKey, displayName, version, - resourceType.getDescription(), pluginConfig, null)); - } catch (Exception e) { - log.error("failed discovering the platform Mbeans", e); - } - } + resources.add(new DiscoveredResourceDetails(context.getResourceType(), resourceKey, displayName, + version, resourceType.getDescription(), pluginConfig, null)); + } catch (Exception e) { + log.error("failed discovering the platform Mbeans", e); + } + }
- return resources; - } + return resources; + }
- private Set<ManagedComponent> addManagedDeploymentComponent( - String deployName, String componentName, - ResourceDiscoveryContext<ApplicationServerComponent> context) - throws NoSuchDeploymentException { + private Set<ManagedComponent> addManagedDeploymentComponent(String deployName, String componentName, + ResourceDiscoveryContext<ApplicationServerComponent<?>> context) throws NoSuchDeploymentException {
- ProfileServiceConnection connection = context - .getParentResourceComponent().getConnection(); + ProfileServiceConnection connection = context.getParentResourceComponent().getConnection();
- ManagementView managementView = connection.getManagementView(); + ManagementView managementView = connection.getManagementView();
- Set<ManagedComponent> components = new HashSet<ManagedComponent>(); - ManagedDeployment deploy = managementView.getDeployment(deployName); - if (deploy != null) { - if (componentName == null || componentName.equals("*")) - components.addAll(deploy.getComponents().values()); - else { - for (ManagedComponent comp : deploy.getComponents().values()) { - if (comp.getName().equals(componentName)) - components.add(comp); - } - } - } + Set<ManagedComponent> components = new HashSet<ManagedComponent>(); + ManagedDeployment deploy = managementView.getDeployment(deployName); + if (deploy != null) { + if (componentName == null || componentName.equals("*")) + components.addAll(deploy.getComponents().values()); + else { + for (ManagedComponent comp : deploy.getComponents().values()) { + if (comp.getName().equals(componentName)) + components.add(comp); + } + } + }
- return components; - } + return components; + }
} diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ProfileServiceComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ProfileServiceComponent.java index 4e13a96..afd73a3 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ProfileServiceComponent.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ProfileServiceComponent.java @@ -33,7 +33,7 @@ import org.rhq.plugins.jmx.JMXComponent; /** * @author Ian Springer */ -public interface ProfileServiceComponent<T extends ResourceComponent> extends ResourceComponent<T>, JMXComponent<T> { +public interface ProfileServiceComponent<T extends ResourceComponent<?>> extends ResourceComponent<T>, JMXComponent<T> { @Nullable ProfileServiceConnection getConnection();
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/WebApplicationContextComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/WebApplicationContextComponent.java index 9c5f938..0d96b2b 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/WebApplicationContextComponent.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/WebApplicationContextComponent.java @@ -23,7 +23,6 @@ package org.rhq.plugins.jbossas5;
import java.io.File; -import java.util.LinkedHashSet; import java.util.Set;
import org.apache.commons.logging.Log; @@ -53,8 +52,7 @@ import org.rhq.plugins.jbossas5.util.ResourceComponentUtils; * * @author Ian Springer */ -public class WebApplicationContextComponent extends ManagedComponentComponent -{ +public class WebApplicationContextComponent extends ManagedComponentComponent { public static final String VIRTUAL_HOST_PROPERTY = "virtualHost"; public static final String CONTEXT_PATH_PROPERTY = "contextPath";
@@ -65,12 +63,10 @@ public class WebApplicationContextComponent extends ManagedComponentComponent
private static final String CLUSTERED_TRAIT = "clustered"; private static final String DISTRIBUTABLE_MANAGED_PROPERTY = "Distributable"; - + // A regex for the names of all MBean:Servlet components for a WAR. - private static final String SERVLET_COMPONENT_NAMES_REGEX_TEMPLATE = - "jboss.web:J2EEApplication=none,J2EEServer=none," - + "WebModule=//%" + VIRTUAL_HOST_PROPERTY + "%" - + "%" + CONTEXT_PATH_PROPERTY + "%,j2eeType=Servlet,name=[^,]+"; + private static final String SERVLET_COMPONENT_NAMES_REGEX_TEMPLATE = "jboss.web:J2EEApplication=none,J2EEServer=none," + + "WebModule=//%" + VIRTUAL_HOST_PROPERTY + "%" + "%" + CONTEXT_PATH_PROPERTY + "%,j2eeType=Servlet,name=[^,]+";
private static final String SERVLET_METRIC_PREFIX = "Servlet.";
@@ -87,15 +83,13 @@ public class WebApplicationContextComponent extends ManagedComponentComponent private ResponseTimeLogParser logParser;
private boolean clustered; - + @Override - public void start(ResourceContext<ProfileServiceComponent> resourceContext) throws Exception - { + public void start(ResourceContext<ProfileServiceComponent<?>> resourceContext) throws Exception { super.start(resourceContext); Configuration pluginConfig = getResourceContext().getPluginConfiguration(); - this.servletComponentNamesRegex = - ResourceComponentUtils.replacePropertyExpressionsInTemplate(SERVLET_COMPONENT_NAMES_REGEX_TEMPLATE, - pluginConfig); + this.servletComponentNamesRegex = ResourceComponentUtils.replacePropertyExpressionsInTemplate( + SERVLET_COMPONENT_NAMES_REGEX_TEMPLATE, pluginConfig); ResponseTimeConfiguration responseTimeConfig = new ResponseTimeConfiguration(pluginConfig); File logFile = responseTimeConfig.getLogFile(); if (logFile != null) { @@ -111,80 +105,67 @@ public class WebApplicationContextComponent extends ManagedComponentComponent clustered = distributable != null && distributable.booleanValue(); } } catch (Exception e) { - log.warn("Failed to determine whether the web app context " + resourceContext.getResourceKey() + " is clustered or not.", e); + log.warn("Failed to determine whether the web app context " + resourceContext.getResourceKey() + + " is clustered or not.", e); } }
@Override - public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> requests) - throws Exception - { + public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> requests) throws Exception { ProfileServiceComponent warComponent = getResourceContext().getParentResourceComponent(); ManagementView managementView = warComponent.getConnection().getManagementView(); - + ManagedComponent component = prepareForMetricCollection(requests); - for (MeasurementScheduleRequest request : requests) - { + for (MeasurementScheduleRequest request : requests) { String metricName = request.getName(); - try - { - if (metricName.startsWith(SERVLET_METRIC_PREFIX)) - { + try { + if (metricName.startsWith(SERVLET_METRIC_PREFIX)) { Double value = getServletMetric(managementView, metricName); MeasurementDataNumeric metric = new MeasurementDataNumeric(request, value); report.addData(metric); - } - else if (metricName.equals(VIRTUAL_HOST_TRAIT)) - { + } else if (metricName.equals(VIRTUAL_HOST_TRAIT)) { Configuration pluginConfig = getResourceContext().getPluginConfiguration(); String virtualHost = pluginConfig.getSimple(VIRTUAL_HOST_PROPERTY).getStringValue(); MeasurementDataTrait trait = new MeasurementDataTrait(request, virtualHost); report.addData(trait); - } - else if (metricName.equals(RESPONSE_TIME_METRIC)) { - if (this.logParser != null) { - try { - CallTimeData callTimeData = new CallTimeData(request); - this.logParser.parseLog(callTimeData); - report.addData(callTimeData); - } catch (Exception e) { - log.error("Failed to retrieve HTTP call-time data.", e); - } - } else { - log.error("The '" + RESPONSE_TIME_METRIC + "' metric is enabled for WAR resource '" - + getComponentName() + "', but no value is defined for the '" - + RESPONSE_TIME_LOG_FILE_CONFIG_PROP + "' connection property."); - // TODO: Communicate this error back to the server for display in the GUI. - } - } - else if (metricName.equals(CLUSTERED_TRAIT)) - { + } else if (metricName.equals(RESPONSE_TIME_METRIC)) { + if (this.logParser != null) { + try { + CallTimeData callTimeData = new CallTimeData(request); + this.logParser.parseLog(callTimeData); + report.addData(callTimeData); + } catch (Exception e) { + log.error("Failed to retrieve HTTP call-time data.", e); + } + } else { + log.error("The '" + RESPONSE_TIME_METRIC + "' metric is enabled for WAR resource '" + + getComponentName() + "', but no value is defined for the '" + + RESPONSE_TIME_LOG_FILE_CONFIG_PROP + "' connection property."); + // TODO: Communicate this error back to the server for display in the GUI. + } + } else if (metricName.equals(CLUSTERED_TRAIT)) { MeasurementDataTrait trait = new MeasurementDataTrait(request, Boolean.toString(clustered)); report.addData(trait); - } - else - { + } else { String metricNameToUse = metricName; if (clustered && !"runState".equals(metricName)) { metricNameToUse = toUpperCaseFirstLetter(metricName); } - + String value = getMeasurement(component, metricNameToUse); - + if (clustered && !"runState".equals(metricName) && value == null) { //hmm... so it looks like https://issues.jboss.org/browse/JBPAPP-7172 has been fixed //and we're getting the metric names in lower case even for clustered contexts value = getMeasurement(component, metricName); } - + addValueToMeasurementReport(report, request, value); } - } - catch (Exception e) - { + } catch (Exception e) { // Don't let one bad apple spoil the barrel. log.error("Failed to collect metric '" + metricName + "' for " + getResourceContext().getResourceType() - + " Resource with key " + getResourceContext().getResourceKey() + ".", e); + + " Resource with key " + getResourceContext().getResourceKey() + ".", e); } } } @@ -192,99 +173,78 @@ public class WebApplicationContextComponent extends ManagedComponentComponent public boolean isClustered() { return clustered; } - - private Double getServletMetric(ManagementView managementView, String metricName) throws Exception - { + + private Double getServletMetric(ManagementView managementView, String metricName) throws Exception { ComponentType servletComponentType = MoreKnownComponentTypes.MBean.Servlet.getType(); //Set<ManagedComponent> servletComponents = managementView.getMatchingComponents(this.servletComponentNamesRegex, // servletComponentType, new RegularExpressionNameMatcher()); Set<ManagedComponent> servletComponents = ManagedComponentUtils.getManagedComponents(managementView, - servletComponentType, this.servletComponentNamesRegex, new RegularExpressionNameMatcher()); + servletComponentType, this.servletComponentNamesRegex, new RegularExpressionNameMatcher());
long min = Long.MAX_VALUE; long max = 0; long processingTime = 0; int requestCount = 0; int errorCount = 0; - for (ManagedComponent servletComponent : servletComponents) - { - if (metricName.equals(SERVLET_MINIMUM_RESPONSE_TIME_METRIC)) - { - Long longValue = (Long)ManagedComponentUtils.getSimplePropertyValue(servletComponent, "minTime"); + for (ManagedComponent servletComponent : servletComponents) { + if (metricName.equals(SERVLET_MINIMUM_RESPONSE_TIME_METRIC)) { + Long longValue = (Long) ManagedComponentUtils.getSimplePropertyValue(servletComponent, "minTime"); if (longValue < min) min = longValue; - } - else if (metricName.equals(SERVLET_MAXIMUM_RESPONSE_TIME_METRIC)) - { - Long longValue = (Long)ManagedComponentUtils.getSimplePropertyValue(servletComponent, "maxTime"); + } else if (metricName.equals(SERVLET_MAXIMUM_RESPONSE_TIME_METRIC)) { + Long longValue = (Long) ManagedComponentUtils.getSimplePropertyValue(servletComponent, "maxTime"); if (longValue > max) max = longValue; - } - else if (metricName.equals(SERVLET_AVERAGE_RESPONSE_TIME_METRIC)) - { - Long longValue = (Long)ManagedComponentUtils.getSimplePropertyValue(servletComponent, "processingTime"); + } else if (metricName.equals(SERVLET_AVERAGE_RESPONSE_TIME_METRIC)) { + Long longValue = (Long) ManagedComponentUtils + .getSimplePropertyValue(servletComponent, "processingTime"); processingTime += longValue; - Integer intValue = (Integer)ManagedComponentUtils.getSimplePropertyValue(servletComponent, "requestCount"); + Integer intValue = (Integer) ManagedComponentUtils.getSimplePropertyValue(servletComponent, + "requestCount"); requestCount += intValue; - } - else if (metricName.equals(SERVLET_REQUEST_COUNT_METRIC)) - { - Integer intValue = (Integer)ManagedComponentUtils.getSimplePropertyValue(servletComponent, "requestCount"); + } else if (metricName.equals(SERVLET_REQUEST_COUNT_METRIC)) { + Integer intValue = (Integer) ManagedComponentUtils.getSimplePropertyValue(servletComponent, + "requestCount"); requestCount += intValue; - } - else if (metricName.equals(SERVLET_ERROR_COUNT_METRIC)) - { - Integer intValue = (Integer)ManagedComponentUtils.getSimplePropertyValue(servletComponent, "errorCount"); + } else if (metricName.equals(SERVLET_ERROR_COUNT_METRIC)) { + Integer intValue = (Integer) ManagedComponentUtils.getSimplePropertyValue(servletComponent, + "errorCount"); errorCount += intValue; - } - else if (metricName.equals(SERVLET_TOTAL_RESPONSE_TIME_METRIC)) - { - Long longValue = (Long)ManagedComponentUtils.getSimplePropertyValue(servletComponent, "processingTime"); + } else if (metricName.equals(SERVLET_TOTAL_RESPONSE_TIME_METRIC)) { + Long longValue = (Long) ManagedComponentUtils + .getSimplePropertyValue(servletComponent, "processingTime"); processingTime += longValue; } }
Double result; - if (metricName.equals(SERVLET_AVERAGE_RESPONSE_TIME_METRIC)) - { - result = (requestCount > 0) ? ((double)processingTime / (double)requestCount) : Double.NaN; - } - else if (metricName.equals(SERVLET_MINIMUM_RESPONSE_TIME_METRIC)) - { - result = (min != Long.MAX_VALUE) ? (double)min : Double.NaN; - } - else if (metricName.equals(SERVLET_MAXIMUM_RESPONSE_TIME_METRIC)) - { - result = (max != 0) ? (double)max : Double.NaN; - } - else if (metricName.equals(SERVLET_ERROR_COUNT_METRIC)) - { - result = (double)errorCount; - } - else if (metricName.equals(SERVLET_REQUEST_COUNT_METRIC)) - { - result = (double)requestCount; - } - else if (metricName.equals(SERVLET_TOTAL_RESPONSE_TIME_METRIC)) - { - result = (double)processingTime; - } - else - { + if (metricName.equals(SERVLET_AVERAGE_RESPONSE_TIME_METRIC)) { + result = (requestCount > 0) ? ((double) processingTime / (double) requestCount) : Double.NaN; + } else if (metricName.equals(SERVLET_MINIMUM_RESPONSE_TIME_METRIC)) { + result = (min != Long.MAX_VALUE) ? (double) min : Double.NaN; + } else if (metricName.equals(SERVLET_MAXIMUM_RESPONSE_TIME_METRIC)) { + result = (max != 0) ? (double) max : Double.NaN; + } else if (metricName.equals(SERVLET_ERROR_COUNT_METRIC)) { + result = (double) errorCount; + } else if (metricName.equals(SERVLET_REQUEST_COUNT_METRIC)) { + result = (double) requestCount; + } else if (metricName.equals(SERVLET_TOTAL_RESPONSE_TIME_METRIC)) { + result = (double) processingTime; + } else { // fallback result = Double.NaN; }
return result; } - + private static String toUpperCaseFirstLetter(String name) { if (name == null || name.length() == 0) { return name; } - + char first = name.charAt(0); - + return Character.toUpperCase(first) + name.substring(1); } } \ No newline at end of file diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/script/ScriptComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/script/ScriptComponent.java index fd283f5..36682c4 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/script/ScriptComponent.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/script/ScriptComponent.java @@ -40,6 +40,7 @@ import java.util.regex.Pattern; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jetbrains.annotations.NotNull; + import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.domain.content.PackageDetailsKey; @@ -66,7 +67,6 @@ import org.rhq.core.util.MessageDigestGenerator; import org.rhq.plugins.jbossas5.ApplicationServerComponent; import org.rhq.plugins.jbossas5.ApplicationServerPluginConfigurationProperties; import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection; -import org.rhq.plugins.jbossas5.deploy.Deployer; import org.rhq.plugins.jbossas5.deploy.RemoteDownloader; import org.rhq.plugins.jbossas5.deploy.ScriptDeployer;
@@ -76,13 +76,14 @@ import org.rhq.plugins.jbossas5.deploy.ScriptDeployer; * @author Ian Springer * @author Lukas Krejci */ -public class ScriptComponent implements ResourceComponent<ApplicationServerComponent>, OperationFacet, DeleteResourceFacet, ContentFacet { +public class ScriptComponent implements ResourceComponent<ApplicationServerComponent<?>>, OperationFacet, + DeleteResourceFacet, ContentFacet { public static final String TYPE_NAME = "Script"; public static final String PACKAGE_TYPE = "script"; - + public static final String PATH_CONFIG_PROP = "path"; public static final String ENVIRONMENT_VARIABLES_CONFIG_PROP = "environmentVariables"; - + public static final String EXECUTE_OPERATION = "execute";
public static final String COMMAND_LINE_ARGUMENTS_PARAM_PROP = "commandLineArguments"; @@ -92,12 +93,12 @@ public class ScriptComponent implements ResourceComponent<ApplicationServerCompo
private static final String PACKAGE_VERSION = "none"; private static final String PACKAGE_ARCHITECTURE = "noarch"; - + private final Log log = LogFactory.getLog(this.getClass());
- private ResourceContext<ApplicationServerComponent> resourceContext; + private ResourceContext<ApplicationServerComponent<?>> resourceContext;
- public void start(ResourceContext<ApplicationServerComponent> resourceContext) { + public void start(ResourceContext<ApplicationServerComponent<?>> resourceContext) { this.resourceContext = resourceContext; }
@@ -160,14 +161,14 @@ public class ScriptComponent implements ResourceComponent<ApplicationServerCompo
public void deleteResource() throws Exception { String path = resourceContext.getPluginConfiguration().getSimpleValue(PATH_CONFIG_PROP, null); - + File f = new File(path); - + if (!f.delete()) { throw new IOException("Failed to delete the file on the configured path: " + path); } } - + public List<DeployPackageStep> generateInstallationSteps(ResourcePackageDetails packageDetails) { return null; } @@ -180,24 +181,28 @@ public class ScriptComponent implements ResourceComponent<ApplicationServerCompo response.setOverallRequestErrorMessage("Only one script can be updated at a time."); return response; } - + try { - String jbossHomeDir = resourceContext.getParentResourceComponent().getResourceContext().getPluginConfiguration().getSimpleValue(ApplicationServerPluginConfigurationProperties.HOME_DIR, null); + String jbossHomeDir = resourceContext.getParentResourceComponent().getResourceContext() + .getPluginConfiguration().getSimpleValue(ApplicationServerPluginConfigurationProperties.HOME_DIR, null); SystemInfo systemInfo = resourceContext.getSystemInformation(); - ProfileServiceConnection profileServiceConnection = resourceContext.getParentResourceComponent().getConnection(); - - ScriptDeployer deployer = new ScriptDeployer(jbossHomeDir, systemInfo, new RemoteDownloader(resourceContext, true, profileServiceConnection)); + ProfileServiceConnection profileServiceConnection = resourceContext.getParentResourceComponent() + .getConnection(); + + ScriptDeployer deployer = new ScriptDeployer(jbossHomeDir, systemInfo, new RemoteDownloader( + resourceContext, true, profileServiceConnection)); ResourcePackageDetails packageDetails = packages.iterator().next(); - - DeployIndividualPackageResponse scriptUpdateResult = deployer.update(packageDetails, resourceContext.getResourceType()); - - response.setOverallRequestResult(scriptUpdateResult.getResult()); - response.addPackageResponse(scriptUpdateResult); + + DeployIndividualPackageResponse scriptUpdateResult = deployer.update(packageDetails, + resourceContext.getResourceType()); + + response.setOverallRequestResult(scriptUpdateResult.getResult()); + response.addPackageResponse(scriptUpdateResult); } catch (Exception e) { response.setOverallRequestErrorMessage(e.getMessage()); response.setOverallRequestResult(ContentResponseResult.FAILURE); } - + return response; }
@@ -209,8 +214,9 @@ public class ScriptComponent implements ResourceComponent<ApplicationServerCompo Set<ResourcePackageDetails> results = new HashSet<ResourcePackageDetails>(); if (PACKAGE_TYPE.equals(type.getName())) { File scriptFile = new File(resourceContext.getResourceKey()); - - PackageDetailsKey key = new PackageDetailsKey(scriptFile.getName(), PACKAGE_VERSION, PACKAGE_TYPE, PACKAGE_ARCHITECTURE); + + PackageDetailsKey key = new PackageDetailsKey(scriptFile.getName(), PACKAGE_VERSION, PACKAGE_TYPE, + PACKAGE_ARCHITECTURE); ResourcePackageDetails details = new ResourcePackageDetails(key); details.setDisplayName(scriptFile.getName()); details.setFileName(scriptFile.getAbsolutePath()); @@ -219,24 +225,26 @@ public class ScriptComponent implements ResourceComponent<ApplicationServerCompo details.setFileCreatedDate(scriptFile.lastModified()); details.setInstallationTimestamp(System.currentTimeMillis()); try { - details.setSHA256(new MessageDigestGenerator(MessageDigestGenerator.SHA_256).calcDigestString(scriptFile)); + details.setSHA256(new MessageDigestGenerator(MessageDigestGenerator.SHA_256) + .calcDigestString(scriptFile)); } catch (IOException e) { log.warn("Failed to compute the SHA256 digest of the script: " + scriptFile.getAbsolutePath(), e); } results.add(details); } - + return results; }
public InputStream retrievePackageBits(ResourcePackageDetails packageDetails) { - String jbossHomeDir = resourceContext.getParentResourceComponent().getResourceContext().getPluginConfiguration().getSimpleValue(ApplicationServerPluginConfigurationProperties.HOME_DIR, null); + String jbossHomeDir = resourceContext.getParentResourceComponent().getResourceContext() + .getPluginConfiguration().getSimpleValue(ApplicationServerPluginConfigurationProperties.HOME_DIR, null); File binDir = new File(jbossHomeDir, "bin");
String scriptName = packageDetails.getKey().getName(); - + File script = new File(binDir, scriptName); - + try { return new FileInputStream(script); } catch (FileNotFoundException e) { diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/script/ScriptDiscoveryComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/script/ScriptDiscoveryComponent.java index 8010081..a9d6166 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/script/ScriptDiscoveryComponent.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/script/ScriptDiscoveryComponent.java @@ -31,6 +31,7 @@ import java.util.Set;
import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.domain.resource.ResourceUpgradeReport; @@ -50,18 +51,18 @@ import org.rhq.plugins.jbossas5.ApplicationServerComponent; * * @author Ian Springer */ -public class ScriptDiscoveryComponent implements ResourceDiscoveryComponent<ApplicationServerComponent>, - ManualAddFacet<ApplicationServerComponent>, ResourceUpgradeFacet<ApplicationServerComponent> { +public class ScriptDiscoveryComponent implements ResourceDiscoveryComponent<ApplicationServerComponent<?>>, + ManualAddFacet<ApplicationServerComponent<?>>, ResourceUpgradeFacet<ApplicationServerComponent<?>> {
private final Log log = LogFactory.getLog(this.getClass()); static final String SERVER_HOME_DIR = "homeDir";
public Set<DiscoveredResourceDetails> discoverResources( - ResourceDiscoveryContext<ApplicationServerComponent> discoveryContext) + ResourceDiscoveryContext<ApplicationServerComponent<?>> discoveryContext) throws InvalidPluginConfigurationException { Set<DiscoveredResourceDetails> resources = new HashSet<DiscoveredResourceDetails>();
- ResourceContext parentResourceContext = discoveryContext.getParentResourceContext(); + ResourceContext<?> parentResourceContext = discoveryContext.getParentResourceContext(); File binDir = getServerBinDirectory(parentResourceContext); log.debug("Searching for scripts beneath JBossAS server bin directory (" + binDir + ")..."); ScriptFileFinder scriptFileFinder = new ScriptFileFinder(discoveryContext.getSystemInformation(), binDir); @@ -81,8 +82,8 @@ public class ScriptDiscoveryComponent implements ResourceDiscoveryComponent<Appl }
public DiscoveredResourceDetails discoverResource(Configuration pluginConfig, - ResourceDiscoveryContext<ApplicationServerComponent> discoveryContext) - throws InvalidPluginConfigurationException { + ResourceDiscoveryContext<ApplicationServerComponent<?>> discoveryContext) + throws InvalidPluginConfigurationException {
File path = new File(pluginConfig.getSimple(ScriptComponent.PATH_CONFIG_PROP).getStringValue()); validatePath(path); @@ -90,12 +91,12 @@ public class ScriptDiscoveryComponent implements ResourceDiscoveryComponent<Appl File binDir = getServerBinDirectory(parentResourceContext); DiscoveredResourceDetails resource = createResourceDetails(discoveryContext, pluginConfig, binDir); log.debug("Manually added script service: " + resource); - + return resource; }
@Override - public ResourceUpgradeReport upgrade(ResourceUpgradeContext<ApplicationServerComponent> upgradeContext) { + public ResourceUpgradeReport upgrade(ResourceUpgradeContext<ApplicationServerComponent<?>> upgradeContext) { String inventoriedResourceKey = upgradeContext.getResourceKey();
ResourceContext<?> parentResourceContext = upgradeContext.getParentResourceContext(); @@ -124,8 +125,8 @@ public class ScriptDiscoveryComponent implements ResourceDiscoveryComponent<Appl }
private static String buildResourceKey(String scriptPath, File binDir) { - return (scriptPath.startsWith(binDir.getPath())) ? scriptPath.substring(binDir.getPath().length() + 1) : - scriptPath; + return (scriptPath.startsWith(binDir.getPath())) ? scriptPath.substring(binDir.getPath().length() + 1) + : scriptPath; }
private void validatePath(File path) { @@ -164,7 +165,7 @@ public class ScriptDiscoveryComponent implements ResourceDiscoveryComponent<Appl }
private DiscoveredResourceDetails createResourceDetails( - ResourceDiscoveryContext<ApplicationServerComponent> discoveryContext, Configuration pluginConfig, + ResourceDiscoveryContext<ApplicationServerComponent<?>> discoveryContext, Configuration pluginConfig, File binDir) { String path = pluginConfig.getSimple(ScriptComponent.PATH_CONFIG_PROP).getStringValue(); String key = buildResourceKey(path, binDir); diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java index daa0447..49fabef 100644 --- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java +++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java @@ -40,7 +40,7 @@ import org.rhq.core.system.ProcessInfo; * in the area of processes and host.xml * @author Heiko W. Rupp */ -public abstract class AbstractBaseDiscovery<T extends ResourceComponent> implements ResourceDiscoveryComponent<T> { +public abstract class AbstractBaseDiscovery<T extends ResourceComponent<?>> implements ResourceDiscoveryComponent<T> { static final String DORG_JBOSS_BOOT_LOG_FILE = "-Dorg.jboss.boot.log.file="; private static final String DJBOSS_SERVER_HOME_DIR = "-Djboss.home.dir"; static final int DEFAULT_MGMT_PORT = 9990; diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java index 0eb49db..0ad794c 100644 --- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java +++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java @@ -70,7 +70,7 @@ import java.util.List; import java.util.Map; import java.util.Set;
-public class BaseComponent implements ResourceComponent, MeasurementFacet, ConfigurationFacet, DeleteResourceFacet, +public class BaseComponent<T extends ResourceComponent<?>> implements ResourceComponent<T>, MeasurementFacet, ConfigurationFacet, DeleteResourceFacet, CreateChildResourceFacet, OperationFacet { private static final String INTERNAL = "_internal:"; diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java index 7584a68..9b3e3a3 100644 --- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java +++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java @@ -18,16 +18,6 @@ */ package org.rhq.modules.plugins.jbossas7;
-import org.rhq.core.domain.configuration.Configuration; -import org.rhq.core.domain.configuration.PropertySimple; -import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails; -import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent; -import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; -import org.rhq.modules.plugins.jbossas7.json.Address; -import org.rhq.modules.plugins.jbossas7.json.ReadChildrenNames; -import org.rhq.modules.plugins.jbossas7.json.ReadResource; -import org.rhq.modules.plugins.jbossas7.json.Result; - import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; @@ -39,6 +29,16 @@ import org.apache.commons.logging.LogFactory; import org.codehaus.jackson.map.DeserializationConfig; import org.codehaus.jackson.map.ObjectMapper;
+import org.rhq.core.domain.configuration.Configuration; +import org.rhq.core.domain.configuration.PropertySimple; +import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails; +import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent; +import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; +import org.rhq.modules.plugins.jbossas7.json.Address; +import org.rhq.modules.plugins.jbossas7.json.ReadChildrenNames; +import org.rhq.modules.plugins.jbossas7.json.ReadResource; +import org.rhq.modules.plugins.jbossas7.json.Result; + /** * Discover subsystems. We need to distinguish two cases denoted by the path * plugin config: @@ -55,28 +55,26 @@ import org.codehaus.jackson.map.ObjectMapper; * * @author Heiko W. Rupp */ -@SuppressWarnings("unused") -public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseComponent> { +public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseComponent<?>> {
private final Log log = LogFactory.getLog(this.getClass());
- public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<BaseComponent> context) - throws Exception { + public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<BaseComponent<?>> context) + throws Exception {
Set<DiscoveredResourceDetails> details = new HashSet<DiscoveredResourceDetails>();
ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES,false); - mapper.configure(DeserializationConfig.Feature.READ_ENUMS_USING_TO_STRING,true); + mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapper.configure(DeserializationConfig.Feature.READ_ENUMS_USING_TO_STRING, true);
BaseComponent parentComponent = context.getParentResourceComponent(); ASConnection connection = parentComponent.getASConnection();
- Configuration config = context.getDefaultPluginConfiguration(); String confPath = config.getSimpleValue("path", ""); - if (confPath==null || confPath.isEmpty()) { - log.error("Path plugin config is null for ResourceType [" + context.getResourceType().getName() +"]."); + if (confPath == null || confPath.isEmpty()) { + log.error("Path plugin config is null for ResourceType [" + context.getResourceType().getName() + "]."); return details; }
@@ -89,7 +87,7 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon // Construct the full path including the parent String path; String parentPath = parentComponent.getPath(); - if (parentPath==null || parentPath.isEmpty()) + if (parentPath == null || parentPath.isEmpty()) path = ""; else path = parentPath; @@ -97,7 +95,6 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon if (Boolean.getBoolean("as7plugin.verbose")) log.info("total path: [" + path + "]");
- if (lookForChildren) { // Looking for multiple resource of type 'childType'
@@ -105,11 +102,9 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon List<String> subTypes = new ArrayList<String>(); if (confPath.contains("|")) { subTypes.addAll(Arrays.asList(confPath.split("\|"))); - } - else + } else subTypes.add(confPath);
- for (String cpath : subTypes) {
Address addr = new Address(parentPath); @@ -128,31 +123,28 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon
String resKey;
- if (path==null||path.isEmpty()) + if (path == null || path.isEmpty()) resKey = newPath; else { if (path.startsWith(",")) path = path.substring(1); - resKey = path + "," +cpath + "=" + val; + resKey = path + "," + cpath + "=" + val; }
- PropertySimple pathProp = new PropertySimple("path",resKey); + PropertySimple pathProp = new PropertySimple("path", resKey); config2.put(pathProp);
- DiscoveredResourceDetails detail = new DiscoveredResourceDetails( - context.getResourceType(), // DataType - resKey, // Key - val, // Name - null, // Version - context.getResourceType().getDescription(), // subsystem.description - config2, - null); + DiscoveredResourceDetails detail = new DiscoveredResourceDetails(context.getResourceType(), // DataType + resKey, // Key + val, // Name + null, // Version + context.getResourceType().getDescription(), // subsystem.description + config2, null); details.add(detail); } } } - } - else { + } else { // Single subsystem path += "," + confPath; if (path.startsWith(",")) @@ -163,17 +155,15 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon String resKey = path; String name = resKey.substring(resKey.lastIndexOf("=") + 1); Configuration config2 = context.getDefaultPluginConfiguration(); - PropertySimple pathProp = new PropertySimple("path",path); + PropertySimple pathProp = new PropertySimple("path", path); config2.put(pathProp);
- DiscoveredResourceDetails detail = new DiscoveredResourceDetails( - context.getResourceType(), // DataType - path, // Key - name, // Name - null, // Version - context.getResourceType().getDescription(), // Description - config2, - null); + DiscoveredResourceDetails detail = new DiscoveredResourceDetails(context.getResourceType(), // DataType + path, // Key + name, // Name + null, // Version + context.getResourceType().getDescription(), // Description + config2, null); details.add(detail); } } diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/AbstractMessagingComponent.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/AbstractMessagingComponent.java index 7c48ed4..01077c9 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/AbstractMessagingComponent.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/AbstractMessagingComponent.java @@ -1,25 +1,25 @@ - /* - * Jopr Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, as - * published by the Free Software Foundation, and/or the GNU Lesser - * General Public License, version 2.1, also as published by the Free - * Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License and the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * and the GNU Lesser General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* + * Jopr Management Platform + * Copyright (C) 2005-2008 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */
package org.rhq.plugins.jbossas;
@@ -59,7 +59,7 @@ import org.rhq.plugins.jmx.MBeanResourceComponent; * Common base class for Messaging related stuff * @author Heiko W. Rupp */ -public abstract class AbstractMessagingComponent extends MBeanResourceComponent<JBossASServerComponent> implements +public abstract class AbstractMessagingComponent extends MBeanResourceComponent<JBossASServerComponent<?>> implements CreateChildResourceFacet {
private static final Pattern PROPERTY_PATTERN = Pattern.compile("^(.*:.*):(.*)$"); @@ -73,7 +73,7 @@ public abstract class AbstractMessagingComponent extends MBeanResourceComponent<
protected Log LOG = null;
- public void start(ResourceContext<JBossASServerComponent> resourceContext, XMLConfigurationEditor editor) { + public void start(ResourceContext<JBossASServerComponent<?>> resourceContext, XMLConfigurationEditor editor) { super.start(resourceContext); this.resourceType = resourceContext.getResourceType(); xmlEditor = editor; @@ -126,7 +126,7 @@ public abstract class AbstractMessagingComponent extends MBeanResourceComponent< JBossASServerComponent jasco = getOurJBossASComponent(); File deploymentFile = jasco.getDeploymentFilePath(resourceKey); Configuration loadedConfiguration = xmlEditor.loadConfiguration(deploymentFile, this.name); - if (loadedConfiguration==null) + if (loadedConfiguration == null) return null; String boundJNDIName = DeploymentUtility.getJndiNameBinding(getEmsBean()); loadedConfiguration.put(new PropertySimple("JNDIBinding", boundJNDIName)); @@ -158,9 +158,8 @@ public abstract class AbstractMessagingComponent extends MBeanResourceComponent< String mBeanName = report.getConfiguration().getSimpleValue(MBEAN_NAME_PROP, null); boolean mBeanNameChanged = false; if (!mBeanName.equals(this.name)) { - LOG - .info("The MBEan Name for this Topic/Queue has been changed. This change will appear in the <mbean> tag for" - + "this Topic/Queue."); + LOG.info("The MBEan Name for this Topic/Queue has been changed. This change will appear in the <mbean> tag for" + + "this Topic/Queue.");
// User has changed the name, so update the plugin configuration. PropertySimple nameProp = getResourceContext().getPluginConfiguration().getSimple(PLUGIN_CONFIG_NAME_PROP); @@ -169,8 +168,7 @@ public abstract class AbstractMessagingComponent extends MBeanResourceComponent< }
if ((deploymentFile == null) || !deploymentFile.exists()) { - deploymentFile = new File(jasco.getConfigurationPath(), name - + ".xml"); + deploymentFile = new File(jasco.getConfigurationPath(), name + ".xml"); }
xmlEditor.updateConfiguration(deploymentFile, this.name, report); diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/AbstractMessagingDiscoveryComponent.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/AbstractMessagingDiscoveryComponent.java index 6c247aa..4d1d19d 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/AbstractMessagingDiscoveryComponent.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/AbstractMessagingDiscoveryComponent.java @@ -44,7 +44,7 @@ import org.rhq.plugins.jmx.ObjectNameQueryUtility; * Abstract base class to discover JBossMessaging and JBossMQ related stuff * @author Heiko W. Rupp */ -public abstract class AbstractMessagingDiscoveryComponent extends MBeanResourceDiscoveryComponent<JMXComponent> { +public abstract class AbstractMessagingDiscoveryComponent extends MBeanResourceDiscoveryComponent<JMXComponent<?>> {
/** * Do the real discovery @@ -55,7 +55,7 @@ public abstract class AbstractMessagingDiscoveryComponent extends MBeanResourceD * @param versionSource A string that determines how to obtain the version. See {@link #getVersionFromSource(org.mc4j.ems.connection.EmsConnection, String)} * @return The details of a discovered resource. */ - protected Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent> context, String objectName, String resourceName, String resourceDescription, String versionSource) { + protected Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent<?>> context, String objectName, String resourceName, String resourceDescription, String versionSource) {
Set<DiscoveredResourceDetails> result = new HashSet<DiscoveredResourceDetails>();
diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/ApplicationComponent.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/ApplicationComponent.java index 0bde101..a7c70db 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/ApplicationComponent.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/ApplicationComponent.java @@ -64,7 +64,7 @@ import org.rhq.plugins.jmx.MBeanResourceComponent; * * @author Ian Springer */ -public class ApplicationComponent extends MBeanResourceComponent<JBossASServerComponent> implements ContentFacet, +public class ApplicationComponent extends MBeanResourceComponent<JBossASServerComponent<?>> implements ContentFacet, DeleteResourceFacet, OperationFacet { private static final String BACKUP_FILE_EXTENSION = ".rej"; public static final String RHQ_SHA256 = "RHQ-Sha256"; diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/ApplicationDiscoveryComponent.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/ApplicationDiscoveryComponent.java index 5f56681..5368d1d 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/ApplicationDiscoveryComponent.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/ApplicationDiscoveryComponent.java @@ -31,6 +31,7 @@ import java.util.Map; import java.util.Set;
import org.mc4j.ems.connection.EmsConnection; + import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.domain.resource.ResourceType; @@ -46,10 +47,10 @@ import org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent; * * @author Jason Dobies */ -public class ApplicationDiscoveryComponent extends MBeanResourceDiscoveryComponent<JMXComponent> { +public class ApplicationDiscoveryComponent extends MBeanResourceDiscoveryComponent<JMXComponent<?>> { // ResourceDiscoveryComponent Implementation --------------------------------------------
- public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent> context) { + public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent<?>> context) { // Parent will discover deployed applications through JMX Set<DiscoveredResourceDetails> jmxResources = super.discoverResources(context);
@@ -57,7 +58,8 @@ public class ApplicationDiscoveryComponent extends MBeanResourceDiscoveryCompone JMXComponent parentComponent = context.getParentResourceComponent(); ApplicationServerComponent applicationServerComponent = (ApplicationServerComponent) parentComponent; EmsConnection emsConnection = parentComponent.getEmsConnection(); - String deployDirectoryPath = generateDeployDirectory(applicationServerComponent.getConfigurationPath().getPath()); + String deployDirectoryPath = generateDeployDirectory(applicationServerComponent.getConfigurationPath() + .getPath());
List<String> earNames = new ArrayList<String>(); for (DiscoveredResourceDetails jmxResource : jmxResources) { @@ -95,14 +97,15 @@ public class ApplicationDiscoveryComponent extends MBeanResourceDiscoveryCompone * @return set of all applications discovered on the file system; this should include at least some of the * applications discovered through JMX as well */ - private Set<DiscoveredResourceDetails> discoverFileSystem(ResourceDiscoveryContext<JMXComponent> context) { + private Set<DiscoveredResourceDetails> discoverFileSystem(ResourceDiscoveryContext<JMXComponent<?>> context) { Configuration defaultConfiguration = context.getDefaultPluginConfiguration();
// Find the location of the deploy directory JMXComponent parentComponent = context.getParentResourceComponent(); ApplicationServerComponent applicationServerComponent = (ApplicationServerComponent) parentComponent;
- String deployDirectoryPath = generateDeployDirectory(applicationServerComponent.getConfigurationPath().getPath()); + String deployDirectoryPath = generateDeployDirectory(applicationServerComponent.getConfigurationPath() + .getPath()); File deployDirectory = new File(deployDirectoryPath);
// Set up filter for application type @@ -120,7 +123,8 @@ public class ApplicationDiscoveryComponent extends MBeanResourceDiscoveryCompone String resourceName = file.getName(); String description = defaultConfiguration.getSimple("descriptionTemplate").getStringValue();
- DiscoveredResourceDetails resource = new DiscoveredResourceDetails(resourceType, resourceKey, resourceName, "", description, null, null); + DiscoveredResourceDetails resource = new DiscoveredResourceDetails(resourceType, resourceKey, resourceName, + "", description, null, null); Configuration resourcePluginConfiguration = resource.getPluginConfiguration(); resourcePluginConfiguration.put(new PropertySimple("name", resourceName)); resourcePluginConfiguration.put(new PropertySimple("objectName", objectName)); diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/ConnectionFactoryComponent.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/ConnectionFactoryComponent.java index 90473ae..5db0679 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/ConnectionFactoryComponent.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/ConnectionFactoryComponent.java @@ -42,7 +42,7 @@ import java.util.Set; /** * @author Mark Spritzler */ -public class ConnectionFactoryComponent extends MBeanResourceComponent<JBossASServerComponent> implements ConfigurationFacet, +public class ConnectionFactoryComponent extends MBeanResourceComponent<JBossASServerComponent<?>> implements ConfigurationFacet, DeleteResourceFacet { private static final String CONNECTION_POOL_OBJECT_NAME = "jboss.jca:name=%NAME%,service=ManagedConnectionPool";
@@ -56,7 +56,7 @@ public class ConnectionFactoryComponent extends MBeanResourceComponent<JBossASSe }
@Override - public void start(ResourceContext<JBossASServerComponent> resourceContext) { + public void start(ResourceContext<JBossASServerComponent<?>> resourceContext) { super.start(resourceContext);
this.name = getResourceContext().getPluginConfiguration().getSimpleValue("name", null); diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/DatasourceComponent.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/DatasourceComponent.java index 7e1bfd1..f98dce8 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/DatasourceComponent.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/DatasourceComponent.java @@ -45,7 +45,7 @@ import org.rhq.plugins.jmx.MBeanResourceComponent; /** * @author Greg Hinkle */ -public class DatasourceComponent extends MBeanResourceComponent<JBossASServerComponent> implements ConfigurationFacet, +public class DatasourceComponent extends MBeanResourceComponent<JBossASServerComponent<?>> implements ConfigurationFacet, DeleteResourceFacet, OperationFacet { private static final String CONNECTION_POOL_OBJECT_NAME = "jboss.jca:name=%NAME%,service=ManagedConnectionPool"; @@ -62,7 +62,7 @@ public class DatasourceComponent extends MBeanResourceComponent<JBossASServerCom }
@Override - public void start(ResourceContext<JBossASServerComponent> resourceContext) + public void start(ResourceContext<JBossASServerComponent<?>> resourceContext) { super.start(resourceContext); this.name = getResourceContext().getPluginConfiguration().getSimpleValue("name", null); diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/EJB2BeanComponent.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/EJB2BeanComponent.java index 07fa732..2865441 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/EJB2BeanComponent.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/EJB2BeanComponent.java @@ -48,7 +48,7 @@ import org.rhq.plugins.jmx.MBeanResourceComponent; * @author Ian Springer * @author John Mazzitelli */ -public class EJB2BeanComponent extends MBeanResourceComponent<JBossASServerComponent> { +public class EJB2BeanComponent extends MBeanResourceComponent<JBossASServerComponent<?>> { private final Log log = LogFactory.getLog(EJB2BeanComponent.class);
private Map<Integer, CallTimeData> previousRawCallTimeDatas = new HashMap<Integer, CallTimeData>(); diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/EJB3BeanComponent.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/EJB3BeanComponent.java index af96d54..302440a 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/EJB3BeanComponent.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/EJB3BeanComponent.java @@ -53,7 +53,7 @@ import org.rhq.plugins.jmx.MBeanResourceComponent; * @author Greg Hinkle * @author Ian Springer */ -public class EJB3BeanComponent extends MBeanResourceComponent<JBossASServerComponent> { +public class EJB3BeanComponent extends MBeanResourceComponent<JBossASServerComponent<?>> { private final Log log = LogFactory.getLog(EJB3BeanComponent.class);
private Map<Integer, CallTimeData> previousRawCallTimeDatas = new HashMap<Integer, CallTimeData>(); diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/EmbeddedWarDiscoveryComponent.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/EmbeddedWarDiscoveryComponent.java index cbd027d..18a6b38 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/EmbeddedWarDiscoveryComponent.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/EmbeddedWarDiscoveryComponent.java @@ -39,37 +39,42 @@ import org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent; * @author Jason Dobies * @author Ian Springer */ -public class EmbeddedWarDiscoveryComponent extends MBeanResourceDiscoveryComponent<JMXComponent> { +public class EmbeddedWarDiscoveryComponent extends MBeanResourceDiscoveryComponent<JMXComponent<?>> { // ResourceDiscoveryComponent Implementation --------------------------------------------
@Override - public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent> context) { + public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent<?>> context) { // Generate object name based on the parent EAR with the following format. // jboss.management.local:J2EEApplication=rhq.ear,J2EEServer=Local,j2eeType=WebModule,name=on-portal.war
ApplicationComponent parentEarComponent = (ApplicationComponent) context.getParentResourceComponent(); String parentEar = parentEarComponent.getApplicationName();
- String objectName = "jboss.management.local:J2EEApplication=" + parentEar + ",J2EEServer=Local,j2eeType=WebModule,name=%name%"; + String objectName = "jboss.management.local:J2EEApplication=" + parentEar + + ",J2EEServer=Local,j2eeType=WebModule,name=%name%";
// Stuff the object name into the default plugin configuration to look like any other JMX discovery // where the objectName is read from the default plugin configuration Configuration defaultPluginConfiguration = context.getDefaultPluginConfiguration(); - defaultPluginConfiguration.put(new PropertySimple(MBeanResourceDiscoveryComponent.PROPERTY_OBJECT_NAME, objectName)); + defaultPluginConfiguration.put(new PropertySimple(MBeanResourceDiscoveryComponent.PROPERTY_OBJECT_NAME, + objectName));
// Call the base MBean discovery method to perform the actual discovery - Set<DiscoveredResourceDetails> resourceDetails = super.performDiscovery(defaultPluginConfiguration, parentEarComponent, context.getResourceType()); + Set<DiscoveredResourceDetails> resourceDetails = super.performDiscovery(defaultPluginConfiguration, + parentEarComponent, context.getResourceType());
// Once we've finished making sure the plugin configurations have the data we need: // 1) First the stuff generic to all WARs... JBossASServerComponent grandparentJBossASComponent = parentEarComponent.getParentResourceComponent(); - resourceDetails = WarDiscoveryHelper.initPluginConfigurations(grandparentJBossASComponent, resourceDetails,parentEarComponent); + resourceDetails = WarDiscoveryHelper.initPluginConfigurations(grandparentJBossASComponent, resourceDetails, + parentEarComponent);
// 2) Then the stuff specific to embedded WARs... String parentEarFullFileName = parentEarComponent.getFileName() + File.separator; for (DiscoveredResourceDetails resource : resourceDetails) { Configuration pluginConfiguration = resource.getPluginConfiguration(); - pluginConfiguration.put(new PropertySimple(WarComponent.FILE_NAME, parentEarFullFileName + resource.getResourceName())); + pluginConfiguration.put(new PropertySimple(WarComponent.FILE_NAME, parentEarFullFileName + + resource.getResourceName())); }
return resourceDetails; diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBMDestinationDiscoveryComponent.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBMDestinationDiscoveryComponent.java index ba4d76e..7d71e7b 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBMDestinationDiscoveryComponent.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBMDestinationDiscoveryComponent.java @@ -35,10 +35,10 @@ import org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent; * @author Heiko W. Rupp * */ -public class JBMDestinationDiscoveryComponent extends MBeanResourceDiscoveryComponent<JMXComponent> { +public class JBMDestinationDiscoveryComponent extends MBeanResourceDiscoveryComponent<JMXComponent<?>> {
@Override - public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent> context) { + public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent<?>> context) {
// Discover Queues and Topics via JMX Set<DiscoveredResourceDetails> results = super.discoverResources(context); diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASServerComponent.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASServerComponent.java index f241200..a8481cc 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASServerComponent.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASServerComponent.java @@ -90,6 +90,7 @@ import org.rhq.core.pluginapi.inventory.ApplicationServerComponent; import org.rhq.core.pluginapi.inventory.CreateChildResourceFacet; import org.rhq.core.pluginapi.inventory.CreateResourceReport; import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException; +import org.rhq.core.pluginapi.inventory.ResourceComponent; import org.rhq.core.pluginapi.inventory.ResourceContext; import org.rhq.core.pluginapi.measurement.MeasurementFacet; import org.rhq.core.pluginapi.operation.OperationFacet; @@ -122,8 +123,8 @@ import org.rhq.plugins.jmx.ObjectNameQueryUtility; * @author Jason Dobies * @author Ian Springer */ -public class JBossASServerComponent implements MeasurementFacet, OperationFacet, JMXComponent, - CreateChildResourceFacet, ApplicationServerComponent, ContentFacet, SupportFacet { +public class JBossASServerComponent<T extends ResourceComponent<?>> implements MeasurementFacet, OperationFacet, + JMXComponent<T>, CreateChildResourceFacet, ApplicationServerComponent, ContentFacet, SupportFacet { // Constants --------------------------------------------
private static final String LOCALHOST = "localhost"; @@ -404,8 +405,8 @@ public class JBossASServerComponent implements MeasurementFacet, OperationFacet, // OperationFacet Implementation --------------------------------------------
public OperationResult invokeOperation(String name, Configuration configuration) throws InterruptedException { - JBossASServerSupportedOperations operation = Enum.valueOf(JBossASServerSupportedOperations.class, name - .toUpperCase()); + JBossASServerSupportedOperations operation = Enum.valueOf(JBossASServerSupportedOperations.class, + name.toUpperCase()); return operationsDelegate.invoke(operation, configuration); }
@@ -1149,14 +1150,15 @@ public class JBossASServerComponent implements MeasurementFacet, OperationFacet, // Since the connection is attempted each time it's used, failure to connect could result in log // file spamming. Log it once for every 10 consecutive times it's encountered. if (consecutiveConnectionErrors % 10 == 0) { - log.warn("Could not establish connection to the JBoss AS instance [" - + (consecutiveConnectionErrors + 1) + "] times for resource [" - + resourceContext.getResourceKey() + "]", e); + log.warn( + "Could not establish connection to the JBoss AS instance [" + (consecutiveConnectionErrors + 1) + + "] times for resource [" + resourceContext.getResourceKey() + "]", e); }
if (log.isDebugEnabled()) - log.debug("Could not connect to the JBoss AS instance for resource [" - + resourceContext.getResourceKey() + "]", e); + log.debug( + "Could not connect to the JBoss AS instance for resource [" + resourceContext.getResourceKey() + + "]", e);
consecutiveConnectionErrors++;
diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatConnectorDiscoveryComponent.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatConnectorDiscoveryComponent.java index 1603c37..30068e8 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatConnectorDiscoveryComponent.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatConnectorDiscoveryComponent.java @@ -33,6 +33,7 @@ import org.apache.commons.logging.LogFactory; import org.mc4j.ems.connection.EmsConnection; import org.mc4j.ems.connection.bean.EmsBean; import org.mc4j.ems.connection.bean.EmsBeanName; + import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails; @@ -48,13 +49,13 @@ import org.rhq.plugins.jmx.ObjectNameQueryUtility; * @author Jason Dobies * @author Ian Springer */ -public class JBossASTomcatConnectorDiscoveryComponent extends MBeanResourceDiscoveryComponent<JMXComponent> { +public class JBossASTomcatConnectorDiscoveryComponent extends MBeanResourceDiscoveryComponent<JMXComponent<?>> { private final Log log = LogFactory.getLog(this.getClass());
// MBeanResourceDiscoveryComponent Overridden Methods --------------------------------------------
@Override - public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent> context) { + public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent<?>> context) { Set<DiscoveredResourceDetails> resourceDetails = super.discoverResources(context);
/* @@ -62,7 +63,8 @@ public class JBossASTomcatConnectorDiscoveryComponent extends MBeanResourceDisco * corresponding jboss.web:type=Connector,* primary connector MBeans. */ EmsConnection connection = context.getParentResourceComponent().getEmsConnection(); - ObjectNameQueryUtility queryUtility = new ObjectNameQueryUtility("jboss.web:type=GlobalRequestProcessor,name=%name%"); + ObjectNameQueryUtility queryUtility = new ObjectNameQueryUtility( + "jboss.web:type=GlobalRequestProcessor,name=%name%"); List<EmsBean> beans = connection.queryBeans(queryUtility.getTranslatedQuery());
// We can't populate the name and scheme in the plugin config if the GlobalRequestProcessor MBeans aren't @@ -104,7 +106,8 @@ public class JBossASTomcatConnectorDiscoveryComponent extends MBeanResourceDisco for (DiscoveredResourceDetails resource : resourceDetails) { Configuration pluginConfiguration = resource.getPluginConfiguration();
- String dirtyAddress = pluginConfiguration.getSimple(JBossASTomcatConnectorComponent.PROPERTY_ADDRESS).getStringValue(); + String dirtyAddress = pluginConfiguration.getSimple(JBossASTomcatConnectorComponent.PROPERTY_ADDRESS) + .getStringValue();
String cleanAddress; if (dirtyAddress.startsWith("%2F")) { @@ -119,21 +122,20 @@ public class JBossASTomcatConnectorDiscoveryComponent extends MBeanResourceDisco }
String port = pluginConfiguration.getSimple(JBossASTomcatConnectorComponent.PROPERTY_PORT).getStringValue(); - + // Add the address to the Resource name (e.g. "Tomcat Connector (127.0.0.1:8080)"). - - String resourceName = resource.getResourceName(); - //resourceName = resourceName.replace("(", "(" + cleanAddress + ":"); - resource.setResourceName(resourceName);
- + String resourceName = resource.getResourceName(); + //resourceName = resourceName.replace("(", "(" + cleanAddress + ":"); + resource.setResourceName(resourceName);
String scheme = schemeMap.get(port); pluginConfiguration.put(new PropertySimple(JBossASTomcatConnectorComponent.PROPERTY_SCHEMA, scheme));
// Update the "address" and "dash" plugin config props, or remove them if not needed. if (addressPresentMap.containsKey(port)) { - pluginConfiguration.put(new PropertySimple(JBossASTomcatConnectorComponent.PROPERTY_ADDRESS, cleanAddress)); + pluginConfiguration.put(new PropertySimple(JBossASTomcatConnectorComponent.PROPERTY_ADDRESS, + cleanAddress)); pluginConfiguration.put(new PropertySimple(JBossASTomcatConnectorComponent.PROPERTY_DASH, "-")); } else { pluginConfiguration.put(new PropertySimple(JBossASTomcatConnectorComponent.PROPERTY_ADDRESS, "")); diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatDiscoveryComponent.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatDiscoveryComponent.java index 4966c49..8283423 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatDiscoveryComponent.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatDiscoveryComponent.java @@ -1,25 +1,25 @@ - /* - * Jopr Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, as - * published by the Free Software Foundation, and/or the GNU Lesser - * General Public License, version 2.1, also as published by the Free - * Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License and the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * and the GNU Lesser General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* + * Jopr Management Platform + * Copyright (C) 2005-2008 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ package org.rhq.plugins.jbossas;
import java.io.File; @@ -48,14 +48,14 @@ import org.rhq.core.system.ProcessInfo; * @author Greg Hinkle * @author Ian Springer */ -public class JBossASTomcatDiscoveryComponent implements ResourceDiscoveryComponent<JBossASServerComponent> { +public class JBossASTomcatDiscoveryComponent implements ResourceDiscoveryComponent<JBossASServerComponent<?>> { private final Log log = LogFactory.getLog(JBossASTomcatDiscoveryComponent.class);
public static final String EMBEDDED_TOMCAT_PRE42_DIR = "jbossweb-tomcat"; public static final String EMBEDDED_TOMCAT_42_DIR = "jboss-web."; private static final String SERVER_INFO_PROPERTIES_RESOURCE = "org/apache/catalina/util/ServerInfo.properties";
- public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JBossASServerComponent> context) + public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JBossASServerComponent<?>> context) throws InvalidPluginConfigurationException, Exception { log.debug("Discovering Tomcat servers embedded in JBossAS server...");
@@ -86,8 +86,8 @@ public class JBossASTomcatDiscoveryComponent implements ResourceDiscoveryCompone + File.separator + ")"; Configuration pluginConfig = null; ProcessInfo processInfo = null; - DiscoveredResourceDetails resource = new DiscoveredResourceDetails(context.getResourceType(), key, getResourceName(pre42), - version, description, pluginConfig, processInfo); + DiscoveredResourceDetails resource = new DiscoveredResourceDetails(context.getResourceType(), key, + getResourceName(pre42), version, description, pluginConfig, processInfo); set.add(resource); }
@@ -97,7 +97,7 @@ public class JBossASTomcatDiscoveryComponent implements ResourceDiscoveryCompone private String getResourceName(boolean pre42) { return pre42 ? "Embedded Tomcat Server" : "Embedded JBossWeb Server"; } - + private String getVersion(File jbossWebDir) throws IOException { boolean pre42 = jbossWebDir.getName().startsWith(EMBEDDED_TOMCAT_PRE42_DIR); String jarFileName = (pre42) ? "catalina.jar" : "jbossweb.jar"; diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatServerComponent.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatServerComponent.java index 62b5b31..f240650 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatServerComponent.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatServerComponent.java @@ -48,12 +48,12 @@ import org.rhq.plugins.jmx.JMXComponent; * @author John Mazzitelli */ public class JBossASTomcatServerComponent implements MeasurementFacet, OperationFacet, ConfigurationFacet, - JMXComponent<JMXComponent> { + JMXComponent<JMXComponent<?>> { private static Log log = LogFactory.getLog(JBossASTomcatServerComponent.class);
- private ResourceContext<JMXComponent> resourceContext; + private ResourceContext<JMXComponent<?>> resourceContext;
- public void start(ResourceContext<JMXComponent> context) { + public void start(ResourceContext<JMXComponent<?>> context) { resourceContext = context; }
@@ -99,7 +99,7 @@ public class JBossASTomcatServerComponent implements MeasurementFacet, Operation return this.resourceContext.getParentResourceComponent().getEmsConnection(); }
- ResourceContext<JMXComponent> getResourceContext() { + ResourceContext<JMXComponent<?>> getResourceContext() { return resourceContext; } } \ No newline at end of file diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatVHostDiscoveryService.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatVHostDiscoveryService.java index cafe78c..59989b6 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatVHostDiscoveryService.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatVHostDiscoveryService.java @@ -37,12 +37,12 @@ import org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent; * @author Heiko W. Rupp * */ -public class JBossASTomcatVHostDiscoveryService extends MBeanResourceDiscoveryComponent<JMXComponent> { +public class JBossASTomcatVHostDiscoveryService extends MBeanResourceDiscoveryComponent<JMXComponent<?>> {
static Pattern pattern = Pattern.compile(".*host=([\w.]+).*");
@Override - public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent> discoveryContext) { + public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent<?>> discoveryContext) {
Set<DiscoveredResourceDetails> resources = super.discoverResources(discoveryContext);
diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatVHostService.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatVHostService.java index e17f7a6..35411a5 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatVHostService.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASTomcatVHostService.java @@ -1,25 +1,25 @@ - /* - * Jopr Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, as - * published by the Free Software Foundation, and/or the GNU Lesser - * General Public License, version 2.1, also as published by the Free - * Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License and the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * and the GNU Lesser General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* + * Jopr Management Platform + * Copyright (C) 2005-2008 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */
package org.rhq.plugins.jbossas;
@@ -41,7 +41,7 @@ import org.rhq.plugins.jmx.MBeanResourceComponent; * @author Heiko W. Rupp * */ -public class JBossASTomcatVHostService extends MBeanResourceComponent<JMXComponent> implements MeasurementFacet { +public class JBossASTomcatVHostService extends MBeanResourceComponent<JMXComponent<?>> implements MeasurementFacet {
/* (non-Javadoc) * @see org.rhq.core.pluginapi.inventory.ResourceComponent#getAvailability() diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossMQDiscoveryComponent.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossMQDiscoveryComponent.java index 65844b6..7ac105e 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossMQDiscoveryComponent.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossMQDiscoveryComponent.java @@ -41,7 +41,7 @@ public class JBossMQDiscoveryComponent extends AbstractMessagingDiscoveryCompone private static final String VERSION_SOURCE = "jboss.mq:service=DestinationManager;Interceptor";
@Override - public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent> context) { + public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent<?>> context) { String objectNameQueryTemplate = "jboss.mq:service=DestinationManager"; Set<DiscoveredResourceDetails> result = super.discoverResources(context, objectNameQueryTemplate, DEFAULT_RESOURCE_NAME, DEFAULT_RESOURCE_DESCRIPTION, diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossMessagingComponent.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossMessagingComponent.java index e06b5cf..bf8d94f 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossMessagingComponent.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossMessagingComponent.java @@ -1,25 +1,25 @@ - /* - * Jopr Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, as - * published by the Free Software Foundation, and/or the GNU Lesser - * General Public License, version 2.1, also as published by the Free - * Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License and the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * and the GNU Lesser General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* + * Jopr Management Platform + * Copyright (C) 2005-2008 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */
package org.rhq.plugins.jbossas;
@@ -67,7 +67,7 @@ public class JBossMessagingComponent extends AbstractMessagingComponent implemen }
@Override - public void start(ResourceContext<JBossASServerComponent> context) { + public void start(ResourceContext<JBossASServerComponent<?>> context) { super.start(context, new JBossMessagingConfigurationEditor(context.getResourceType().getName())); }
@@ -111,8 +111,7 @@ public class JBossMessagingComponent extends AbstractMessagingComponent implemen xmlEditor.updateConfiguration(deploymentFile, name, report); try { parentResourceComponent.deployFile(deploymentFile); - } - catch (Exception e) { + } catch (Exception e) { JBossASServerComponent.setErrorOnCreateResourceReport(report, e.getLocalizedMessage(), e); return report; } diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossMessagingDiscoveryComponent.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossMessagingDiscoveryComponent.java index 9feeb42..975d668 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossMessagingDiscoveryComponent.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossMessagingDiscoveryComponent.java @@ -39,7 +39,7 @@ public class JBossMessagingDiscoveryComponent extends AbstractMessagingDiscovery private static final String DEFAULT_RESOURCE_DESCRIPTION = "JBoss Messaging subsystem";
@Override - public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent> context) { + public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent<?>> context) { String objectNameQueryTemplate = "jboss.messaging:service=PostOffice"; Set<DiscoveredResourceDetails> result = super.discoverResources(context, objectNameQueryTemplate, DEFAULT_RESOURCE_NAME, DEFAULT_RESOURCE_DESCRIPTION, diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JMSComponent.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JMSComponent.java index a4cb1c7..9bdc4ab 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JMSComponent.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JMSComponent.java @@ -1,25 +1,25 @@ - /* - * Jopr Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, as - * published by the Free Software Foundation, and/or the GNU Lesser - * General Public License, version 2.1, also as published by the Free - * Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License and the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * and the GNU Lesser General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* + * Jopr Management Platform + * Copyright (C) 2005-2008 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ package org.rhq.plugins.jbossas;
import java.io.File; @@ -72,7 +72,7 @@ public class JMSComponent extends AbstractMessagingComponent implements Configur }
@Override - public void start(ResourceContext<JBossASServerComponent> context) { + public void start(ResourceContext<JBossASServerComponent<?>> context) { super.start(context, new JMSConfigurationEditor(context.getResourceType().getName())); }
@@ -115,8 +115,7 @@ public class JMSComponent extends AbstractMessagingComponent implements Configur xmlEditor.updateConfiguration(deploymentFile, name, report); try { parentResourceComponent.deployFile(deploymentFile); - } - catch (Exception e) { + } catch (Exception e) { JBossASServerComponent.setErrorOnCreateResourceReport(report, e.getLocalizedMessage(), e); return report; } @@ -124,7 +123,7 @@ public class JMSComponent extends AbstractMessagingComponent implements Configur // This key needs to be the same as the object name string used in discovery, defined in the plugin descriptor // jboss.mq.destination:service=<Queue|Topic,name=%name% String serviceString = (isTopic ? "Topic" : "Queue"); - + String objectName = "jboss.mq.destination:name=" + name + ",service=" + serviceString; try { // IMPORTANT: The object name must be canonicalized so it matches the resource key that @@ -136,7 +135,7 @@ public class JMSComponent extends AbstractMessagingComponent implements Configur return report; } report.setResourceName(rName); - + try { Thread.sleep(5000L); } catch (InterruptedException e) { diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/WarDiscoveryComponent.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/WarDiscoveryComponent.java index 179859d..059f90e 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/WarDiscoveryComponent.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/WarDiscoveryComponent.java @@ -36,7 +36,7 @@ import org.rhq.plugins.jmx.JMXComponent; */ public class WarDiscoveryComponent extends ApplicationDiscoveryComponent { @Override - public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent> discoveryContext) { + public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent<?>> discoveryContext) { Set<DiscoveredResourceDetails> resources = super.discoverResources(discoveryContext); JBossASServerComponent parentJBossASComponent = (JBossASServerComponent) discoveryContext .getParentResourceComponent(); diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/script/ScriptComponent.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/script/ScriptComponent.java index f62b3aa..736f0eb 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/script/ScriptComponent.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/script/ScriptComponent.java @@ -34,6 +34,7 @@ import java.util.regex.Pattern; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jetbrains.annotations.NotNull; + import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.domain.measurement.AvailabilityType; @@ -52,7 +53,7 @@ import org.rhq.plugins.jbossas.JBossASServerComponent; * * @author Ian Springer */ -public class ScriptComponent implements ResourceComponent<JBossASServerComponent>, OperationFacet { +public class ScriptComponent implements ResourceComponent<JBossASServerComponent<?>>, OperationFacet { public static final String PATH_CONFIG_PROP = "path"; public static final String ENVIRONMENT_VARIABLES_CONFIG_PROP = "environmentVariables";
@@ -65,9 +66,9 @@ public class ScriptComponent implements ResourceComponent<JBossASServerComponent
private final Log log = LogFactory.getLog(this.getClass());
- private ResourceContext<JBossASServerComponent> resourceContext; + private ResourceContext<JBossASServerComponent<?>> resourceContext;
- public void start(ResourceContext<JBossASServerComponent> resourceContext) { + public void start(ResourceContext<JBossASServerComponent<?>> resourceContext) { this.resourceContext = resourceContext; }
diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/script/ScriptDiscoveryComponent.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/script/ScriptDiscoveryComponent.java index 667d10f..93a768a 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/script/ScriptDiscoveryComponent.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/script/ScriptDiscoveryComponent.java @@ -1,25 +1,25 @@ - /* - * Jopr Management Platform - * Copyright (C) 2005-2011 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, as - * published by the Free Software Foundation, and/or the GNU Lesser - * General Public License, version 2.1, also as published by the Free - * Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License and the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * and the GNU Lesser General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* + * Jopr Management Platform + * Copyright (C) 2005-2011 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ package org.rhq.plugins.jbossas.script;
import java.io.File; @@ -28,16 +28,18 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.domain.resource.ResourceUpgradeReport; import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails; +import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException; import org.rhq.core.pluginapi.inventory.ResourceContext; import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent; import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; -import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException; import org.rhq.core.pluginapi.upgrade.ResourceUpgradeContext; import org.rhq.core.pluginapi.upgrade.ResourceUpgradeFacet; import org.rhq.core.system.ProcessInfo; @@ -48,14 +50,14 @@ import org.rhq.plugins.jbossas.JBossASServerComponent; * * @author Ian Springer */ -public class ScriptDiscoveryComponent implements ResourceDiscoveryComponent<JBossASServerComponent>, - ResourceUpgradeFacet<JBossASServerComponent> { +public class ScriptDiscoveryComponent implements ResourceDiscoveryComponent<JBossASServerComponent<?>>, + ResourceUpgradeFacet<JBossASServerComponent<?>> {
private final Log log = LogFactory.getLog(this.getClass());
public Set<DiscoveredResourceDetails> discoverResources( - ResourceDiscoveryContext<JBossASServerComponent> discoveryContext) - throws InvalidPluginConfigurationException { + ResourceDiscoveryContext<JBossASServerComponent<?>> discoveryContext) + throws InvalidPluginConfigurationException { Set<DiscoveredResourceDetails> resources = new HashSet<DiscoveredResourceDetails>(); // TODO: Upgrade to new manual discovery API. List<Configuration> pluginConfigs = discoveryContext.getPluginConfigurations(); @@ -68,7 +70,7 @@ public class ScriptDiscoveryComponent implements ResourceDiscoveryComponent<JBos }
@Override - public ResourceUpgradeReport upgrade(ResourceUpgradeContext<JBossASServerComponent> upgradeContext) { + public ResourceUpgradeReport upgrade(ResourceUpgradeContext<JBossASServerComponent<?>> upgradeContext) { String inventoriedResourceKey = upgradeContext.getResourceKey();
ResourceContext parentResourceContext = upgradeContext.getParentResourceContext(); @@ -92,17 +94,18 @@ public class ScriptDiscoveryComponent implements ResourceDiscoveryComponent<JBos
private File getServerBinDirectory(ResourceContext parentResourceContext) { Configuration parentPluginConfig = parentResourceContext.getPluginConfiguration(); - String homeDir = parentPluginConfig.getSimple(JBossASServerComponent.JBOSS_HOME_DIR_CONFIG_PROP).getStringValue(); + String homeDir = parentPluginConfig.getSimple(JBossASServerComponent.JBOSS_HOME_DIR_CONFIG_PROP) + .getStringValue(); return new File(homeDir, "bin"); }
private static String buildResourceKey(String scriptPath, File binDir) { - return (scriptPath.startsWith(binDir.getPath())) ? scriptPath.substring(binDir.getPath().length() + 1) : - scriptPath; + return (scriptPath.startsWith(binDir.getPath())) ? scriptPath.substring(binDir.getPath().length() + 1) + : scriptPath; }
- private void processAutoDiscoveredResources(ResourceDiscoveryContext<JBossASServerComponent> discoveryContext, - Set<DiscoveredResourceDetails> resources) { + private void processAutoDiscoveredResources(ResourceDiscoveryContext<JBossASServerComponent<?>> discoveryContext, + Set<DiscoveredResourceDetails> resources) { ResourceContext parentResourceContext = discoveryContext.getParentResourceContext(); File binDir = getServerBinDirectory(parentResourceContext); log.debug("Searching for scripts beneath JBossAS server bin directory (" + binDir + ")..."); @@ -120,8 +123,8 @@ public class ScriptDiscoveryComponent implements ResourceDiscoveryComponent<JBos } }
- private void processManuallyAddedResources(ResourceDiscoveryContext<JBossASServerComponent> discoveryContext, - Set<DiscoveredResourceDetails> resources, List<Configuration> pluginConfigs) { + private void processManuallyAddedResources(ResourceDiscoveryContext<JBossASServerComponent<?>> discoveryContext, + Set<DiscoveredResourceDetails> resources, List<Configuration> pluginConfigs) { ResourceContext parentResourceContext = discoveryContext.getParentResourceContext(); File binDir = getServerBinDirectory(parentResourceContext); for (Configuration pluginConfig : pluginConfigs) { @@ -167,7 +170,7 @@ public class ScriptDiscoveryComponent implements ResourceDiscoveryComponent<JBos }
private DiscoveredResourceDetails createResourceDetails( - ResourceDiscoveryContext<JBossASServerComponent> discoveryContext, Configuration pluginConfig, File homeDir) { + ResourceDiscoveryContext<JBossASServerComponent<?>> discoveryContext, Configuration pluginConfig, File homeDir) { String path = pluginConfig.getSimple(ScriptComponent.PATH_CONFIG_PROP).getStringValue(); String key = buildResourceKey(path, homeDir); String name = new File(path).getName(); diff --git a/modules/plugins/jboss-cache-v3/src/main/java/org/rhq/plugins/jbosscache3/JBossCacheComponent.java b/modules/plugins/jboss-cache-v3/src/main/java/org/rhq/plugins/jbosscache3/JBossCacheComponent.java index 17a2b1e..883c49d 100644 --- a/modules/plugins/jboss-cache-v3/src/main/java/org/rhq/plugins/jbosscache3/JBossCacheComponent.java +++ b/modules/plugins/jboss-cache-v3/src/main/java/org/rhq/plugins/jbosscache3/JBossCacheComponent.java @@ -27,6 +27,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jetbrains.annotations.NotNull; import org.mc4j.ems.connection.EmsConnection; + import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.domain.measurement.AvailabilityType; import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException; @@ -39,54 +40,51 @@ import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection; * @author Filip Drabek * */ -public class JBossCacheComponent implements - ProfileServiceComponent<ProfileServiceComponent> { +public class JBossCacheComponent implements ProfileServiceComponent<ProfileServiceComponent<?>> {
- private final Log log = LogFactory.getLog(this.getClass()); + private final Log log = LogFactory.getLog(this.getClass());
- public static String CACHE_SEARCH_STRING = "searchString"; + public static String CACHE_SEARCH_STRING = "searchString";
- private ProfileServiceComponent parentComp; + private ProfileServiceComponent<?> parentComp;
- private String beanName; + private String beanName;
- private ResourceContext<ProfileServiceComponent> resourceContext; + private ResourceContext<ProfileServiceComponent<?>> resourceContext;
- public void start(ResourceContext<ProfileServiceComponent> context) - throws InvalidPluginConfigurationException, Exception { + public void start(ResourceContext<ProfileServiceComponent<?>> context) throws InvalidPluginConfigurationException, + Exception {
resourceContext = context; - parentComp = context.getParentResourceComponent(); + parentComp = context.getParentResourceComponent();
- Configuration configuration = context.getPluginConfiguration(); + Configuration configuration = context.getPluginConfiguration();
- if (configuration.get(JBossCacheComponent.CACHE_SEARCH_STRING) != null) - beanName = configuration.getSimple( - JBossCacheComponent.CACHE_SEARCH_STRING).getStringValue(); - else - throw new InvalidPluginConfigurationException( - "Invalid plugin configuration in JBossCache component."); + if (configuration.get(JBossCacheComponent.CACHE_SEARCH_STRING) != null) + beanName = configuration.getSimple(JBossCacheComponent.CACHE_SEARCH_STRING).getStringValue(); + else + throw new InvalidPluginConfigurationException("Invalid plugin configuration in JBossCache component.");
- } + }
- public void stop() { - return; - } + public void stop() { + return; + }
- public AvailabilityType getAvailability() { - return parentComp.getAvailability(); - } + public AvailabilityType getAvailability() { + return parentComp.getAvailability(); + }
- public ProfileServiceConnection getConnection() { - return parentComp.getConnection(); - } + public ProfileServiceConnection getConnection() { + return parentComp.getConnection(); + }
- public EmsConnection getEmsConnection() { - return parentComp.getEmsConnection(); - } + public EmsConnection getEmsConnection() { + return parentComp.getEmsConnection(); + }
@NotNull - public ResourceContext<ProfileServiceComponent> getResourceContext() { + public ResourceContext<ProfileServiceComponent<?>> getResourceContext() { return resourceContext; } } diff --git a/modules/plugins/jboss-cache-v3/src/main/java/org/rhq/plugins/jbosscache3/JBossCacheDetailComponent.java b/modules/plugins/jboss-cache-v3/src/main/java/org/rhq/plugins/jbosscache3/JBossCacheDetailComponent.java index 844da14..281ce80 100644 --- a/modules/plugins/jboss-cache-v3/src/main/java/org/rhq/plugins/jbosscache3/JBossCacheDetailComponent.java +++ b/modules/plugins/jboss-cache-v3/src/main/java/org/rhq/plugins/jbosscache3/JBossCacheDetailComponent.java @@ -53,16 +53,16 @@ import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection; * */ public class JBossCacheDetailComponent implements MeasurementFacet, - OperationFacet, ProfileServiceComponent<ProfileServiceComponent> { + OperationFacet, ProfileServiceComponent<ProfileServiceComponent<?>> {
public static String JMX_NAME = "jmx-name"; public static String CACHE_DETAIL_BEAN_NAME = "bean-name"; public ProfileServiceComponent parentComponent; private String beanName; private final Log log = LogFactory.getLog(this.getClass()); - private ResourceContext<ProfileServiceComponent> resourceContext; + private ResourceContext<ProfileServiceComponent<?>> resourceContext;
- public void start(ResourceContext<ProfileServiceComponent> context) + public void start(ResourceContext<ProfileServiceComponent<?>> context) throws InvalidPluginConfigurationException, Exception {
resourceContext = context; @@ -104,7 +104,7 @@ public class JBossCacheDetailComponent implements MeasurementFacet, }
@NotNull - public ResourceContext<ProfileServiceComponent> getResourceContext() { + public ResourceContext<ProfileServiceComponent<?>> getResourceContext() { return resourceContext; }
diff --git a/modules/plugins/jboss-cache-v3/src/main/java/org/rhq/plugins/jbosscache3/JBossCacheDetailDiscoveryComponent.java b/modules/plugins/jboss-cache-v3/src/main/java/org/rhq/plugins/jbosscache3/JBossCacheDetailDiscoveryComponent.java index 764bf64..5d522de 100644 --- a/modules/plugins/jboss-cache-v3/src/main/java/org/rhq/plugins/jbosscache3/JBossCacheDetailDiscoveryComponent.java +++ b/modules/plugins/jboss-cache-v3/src/main/java/org/rhq/plugins/jbosscache3/JBossCacheDetailDiscoveryComponent.java @@ -45,7 +45,7 @@ import org.rhq.plugins.jbossas5.ProfileServiceComponent; * */ public class JBossCacheDetailDiscoveryComponent implements - ResourceDiscoveryComponent<ProfileServiceComponent> { + ResourceDiscoveryComponent<ProfileServiceComponent<?>> { public static String CACHE_JMX_NAME = "jmx-resource";
private final Log log = LogFactory.getLog(this.getClass()); @@ -53,7 +53,7 @@ public class JBossCacheDetailDiscoveryComponent implements private ProfileServiceComponent parentComponent;
public Set<DiscoveredResourceDetails> discoverResources( - ResourceDiscoveryContext<ProfileServiceComponent> context) + ResourceDiscoveryContext<ProfileServiceComponent<?>> context) throws InvalidPluginConfigurationException, Exception {
ResourceType resourceType = context.getResourceType(); diff --git a/modules/plugins/jboss-cache-v3/src/main/java/org/rhq/plugins/jbosscache3/JBossCacheDiscoveryComponent.java b/modules/plugins/jboss-cache-v3/src/main/java/org/rhq/plugins/jbosscache3/JBossCacheDiscoveryComponent.java index 88fd836..86bd02f 100644 --- a/modules/plugins/jboss-cache-v3/src/main/java/org/rhq/plugins/jbosscache3/JBossCacheDiscoveryComponent.java +++ b/modules/plugins/jboss-cache-v3/src/main/java/org/rhq/plugins/jbosscache3/JBossCacheDiscoveryComponent.java @@ -48,13 +48,13 @@ import org.rhq.plugins.jmx.ObjectNameQueryUtility; * */ public class JBossCacheDiscoveryComponent implements - ResourceDiscoveryComponent<ProfileServiceComponent> { + ResourceDiscoveryComponent<ProfileServiceComponent<?>> { private String REGEX = "(,|:)jmx-resource=[^,]*(,|\z)"; private static String[] RESOURCE_NAME_KEY_PROPS = { "cluster", "config" }; private static final String DEFAULT_RESOURCE_DESCRIPTION = "JBoss Cache";
public Set<DiscoveredResourceDetails> discoverResources( - ResourceDiscoveryContext<ProfileServiceComponent> context) + ResourceDiscoveryContext<ProfileServiceComponent<?>> context) throws InvalidPluginConfigurationException, Exception {
ProfileServiceComponent parentComponent = context diff --git a/modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheComponent.java b/modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheComponent.java index daa7cdb..1ee8500 100644 --- a/modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheComponent.java +++ b/modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheComponent.java @@ -69,7 +69,7 @@ import org.rhq.plugins.jmx.ObjectNameQueryUtility; * @author Heiko W. Rupp * */ -public class JBossCacheComponent implements ResourceComponent<JMXComponent>, MeasurementFacet, OperationFacet, +public class JBossCacheComponent implements ResourceComponent<JMXComponent<?>>, MeasurementFacet, OperationFacet, ConfigurationFacet {
private final static Log log = LogFactory.getLog(JBossCacheComponent.class); @@ -86,7 +86,7 @@ public class JBossCacheComponent implements ResourceComponent<JMXComponent>, Mea this.context = context;
PropertySimple tcProp = context.getPluginConfiguration().getSimple("isTreeCache"); - if (tcProp==null || tcProp.getBooleanValue()==null) + if (tcProp == null || tcProp.getBooleanValue() == null) throw new InvalidPluginConfigurationException("Cache flavour not provided"); else isTreeCache = tcProp.getBooleanValue(); @@ -200,7 +200,7 @@ public class JBossCacheComponent implements ResourceComponent<JMXComponent>, Mea public Configuration loadResourceConfiguration() throws Exception {
File file = DeploymentUtility.getDescriptorFile(parentServer.getEmsConnection(), context.getResourceKey()); - if (file==null) { + if (file == null) { log.warn("Can not find the deployment descriptor for this cache "); return null; } @@ -286,7 +286,7 @@ public class JBossCacheComponent implements ResourceComponent<JMXComponent>, Mea report.setErrorMessage("Failed to determine the deployment descriptor file for mbean '" + mbeanName + "'."); return; } - + CacheConfigurationHelper helper = new CacheConfigurationHelper(); try { helper.writeConfig(file, newOne, mbeanName, true); diff --git a/modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheDiscoveryComponent.java b/modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheDiscoveryComponent.java index f37099e..4d1eecf 100644 --- a/modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheDiscoveryComponent.java +++ b/modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheDiscoveryComponent.java @@ -49,7 +49,7 @@ import org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent; * * @author Heiko W. Rupp */ -public class JBossCacheDiscoveryComponent extends MBeanResourceDiscoveryComponent<JMXComponent> { +public class JBossCacheDiscoveryComponent extends MBeanResourceDiscoveryComponent<JMXComponent<?>> {
private static final Log log = LogFactory.getLog(JBossCacheDiscoveryComponent.class);
@@ -57,10 +57,10 @@ public class JBossCacheDiscoveryComponent extends MBeanResourceDiscoveryComponen * @see org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent#discoverResources(org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext) */ @Override - public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent> context) { + public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent<?>> context) {
ResourceContext parentCtx = context.getParentResourceContext(); - JMXComponent<JBossASServerComponent> gparentComponent = (JMXComponent<JBossASServerComponent>) parentCtx.getParentResourceComponent(); + JMXComponent<JBossASServerComponent<?>> gparentComponent = (JMXComponent<JBossASServerComponent<?>>) parentCtx.getParentResourceComponent();
Set<DiscoveredResourceDetails> discovered = super.performDiscovery(context.getDefaultPluginConfiguration(), gparentComponent, context.getResourceType(), false);
diff --git a/modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheSubsystemComponent.java b/modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheSubsystemComponent.java index 13acbec..d167d51 100644 --- a/modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheSubsystemComponent.java +++ b/modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheSubsystemComponent.java @@ -47,7 +47,7 @@ import org.rhq.plugins.jmx.JMXComponent; * * @author Heiko W. Rupp */ -public class JBossCacheSubsystemComponent<T extends JMXComponent<JBossASServerComponent>> implements +public class JBossCacheSubsystemComponent<T extends JMXComponent<JBossASServerComponent<?>>> implements ResourceComponent<T>, CreateChildResourceFacet {
private final Log log = LogFactory.getLog(JBossCacheSubsystemComponent.class); diff --git a/modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheSubsystemDiscovery.java b/modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheSubsystemDiscovery.java index 9a0a3ce..514d390 100644 --- a/modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheSubsystemDiscovery.java +++ b/modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheSubsystemDiscovery.java @@ -28,7 +28,7 @@ import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; * * @author Heiko W. Rupp */ -public class JBossCacheSubsystemDiscovery implements ResourceDiscoveryComponent<JBossCacheSubsystemComponent> +public class JBossCacheSubsystemDiscovery implements ResourceDiscoveryComponent<JBossCacheSubsystemComponent<?>> {
private static final String JBOSS_CACHE_SUBSYSTEM = "JBoss Cache subsystem"; @@ -38,7 +38,7 @@ public class JBossCacheSubsystemDiscovery implements ResourceDiscoveryComponent< * * @see org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent#discoverResources(org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext) */ - public Set<DiscoveredResourceDetails> discoverResources( ResourceDiscoveryContext<JBossCacheSubsystemComponent> context) + public Set<DiscoveredResourceDetails> discoverResources( ResourceDiscoveryContext<JBossCacheSubsystemComponent<?>> context) throws InvalidPluginConfigurationException, Exception {
Set<DiscoveredResourceDetails> subsystem = new HashSet<DiscoveredResourceDetails>(1); diff --git a/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/EmbeddedJMXServerDiscoveryComponent.java b/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/EmbeddedJMXServerDiscoveryComponent.java index f79daed..4b48067 100644 --- a/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/EmbeddedJMXServerDiscoveryComponent.java +++ b/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/EmbeddedJMXServerDiscoveryComponent.java @@ -22,9 +22,9 @@ */ package org.rhq.plugins.jmx;
+import java.lang.reflect.Method; import java.util.HashSet; import java.util.Set; -import java.lang.reflect.Method;
import org.mc4j.ems.connection.EmsConnection; import org.mc4j.ems.connection.bean.EmsBean; @@ -47,8 +47,8 @@ import org.rhq.core.system.ProcessInfo; * * @author Greg Hinkle */ -public class EmbeddedJMXServerDiscoveryComponent implements ResourceDiscoveryComponent<JMXComponent> { - public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent> context) +public class EmbeddedJMXServerDiscoveryComponent implements ResourceDiscoveryComponent<JMXComponent<?>> { + public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent<?>> context) throws Exception { Set<DiscoveredResourceDetails> discoveredServers = new HashSet<DiscoveredResourceDetails>();
@@ -98,8 +98,8 @@ public class EmbeddedJMXServerDiscoveryComponent implements ResourceDiscoveryCom if (runtimeMBean != null) { String version = getSystemProperty(runtimeMBean, "java.version"); DiscoveredResourceDetails server = new DiscoveredResourceDetails(context.getResourceType(), "JVM", - ParentDefinedJMXServerNamingUtility.getJVMName(context), version, context.getResourceType().getDescription(), - configuration, null); + ParentDefinedJMXServerNamingUtility.getJVMName(context), version, context.getResourceType() + .getDescription(), configuration, null); discoveredServers.add(server); }
@@ -111,11 +111,11 @@ public class EmbeddedJMXServerDiscoveryComponent implements ResourceDiscoveryCom // ClassCastExceptions due to EMS having used a different classloader than us to load them. Object tabularDataObj = runtimeMBean.getAttribute("systemProperties").refresh(); Method getMethod = tabularDataObj.getClass().getMethod("get", - new Class[] { Class.forName("[Ljava.lang.Object;") }); + new Class[] { Class.forName("[Ljava.lang.Object;") }); // varargs don't work out when the arg itself is an array, so specify the parameters explicitly using arrays. - Object compositeDataObj = getMethod.invoke(tabularDataObj, new Object[] { new Object[] { propertyName }}); + Object compositeDataObj = getMethod.invoke(tabularDataObj, new Object[] { new Object[] { propertyName } }); getMethod = compositeDataObj.getClass().getMethod("get", String.class); - String version = (String)getMethod.invoke(compositeDataObj, "value"); + String version = (String) getMethod.invoke(compositeDataObj, "value"); return version; } } \ No newline at end of file diff --git a/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/InternalJMXServerDiscoveryComponent.java b/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/InternalJMXServerDiscoveryComponent.java index 8973b54..fcd16fc 100644 --- a/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/InternalJMXServerDiscoveryComponent.java +++ b/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/InternalJMXServerDiscoveryComponent.java @@ -42,8 +42,8 @@ public class InternalJMXServerDiscoveryComponent implements ResourceDiscoveryCom Set<DiscoveredResourceDetails> found = new HashSet<DiscoveredResourceDetails>();
DiscoveredResourceDetails localVM = new DiscoveredResourceDetails(context.getResourceType(), "InternalVM", - ParentDefinedJMXServerNamingUtility.getJVMName(context), System.getProperty("java.version"), "VM of plugin container", null, - null); + ParentDefinedJMXServerNamingUtility.getJVMName(context), System.getProperty("java.version"), + "VM of plugin container", null, null); Configuration configuration = localVM.getPluginConfiguration(); configuration.put(new PropertySimple(JMXDiscoveryComponent.CONNECTOR_ADDRESS_CONFIG_PROPERTY, "Local Connection")); diff --git a/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/JMXServerComponent.java b/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/JMXServerComponent.java index 29b36e8..1f77f48 100644 --- a/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/JMXServerComponent.java +++ b/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/JMXServerComponent.java @@ -44,6 +44,7 @@ import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.domain.measurement.AvailabilityType; import org.rhq.core.domain.resource.Resource; import org.rhq.core.domain.resource.ResourceType; +import org.rhq.core.pluginapi.inventory.ResourceComponent; import org.rhq.core.pluginapi.inventory.ResourceContext;
/** @@ -59,7 +60,7 @@ import org.rhq.core.pluginapi.inventory.ResourceContext; * @author Greg Hinkle * @author John Mazzitelli */ -public class JMXServerComponent implements JMXComponent { +public class JMXServerComponent<T extends ResourceComponent<?>> implements JMXComponent<T> { private static Log log = LogFactory.getLog(JMXServerComponent.class);
private EmsConnection connection; diff --git a/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/MBeanResourceComponent.java b/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/MBeanResourceComponent.java index 8da6a2d..f10c150 100644 --- a/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/MBeanResourceComponent.java +++ b/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/MBeanResourceComponent.java @@ -75,7 +75,7 @@ import org.rhq.core.util.exception.ThrowableUtil; * @author Greg Hinkle * @author John Mazzitelli */ -public class MBeanResourceComponent<T extends JMXComponent> implements MeasurementFacet, OperationFacet, +public class MBeanResourceComponent<T extends JMXComponent<?>> implements MeasurementFacet, OperationFacet, ConfigurationFacet, JMXComponent<T> {
/** diff --git a/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/MBeanResourceDiscoveryComponent.java b/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/MBeanResourceDiscoveryComponent.java index 94bc89c..c4e1c5d 100644 --- a/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/MBeanResourceDiscoveryComponent.java +++ b/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/MBeanResourceDiscoveryComponent.java @@ -50,7 +50,7 @@ import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; * * @author Greg Hinkle */ -public class MBeanResourceDiscoveryComponent<T extends JMXComponent> implements ResourceDiscoveryComponent<T> { +public class MBeanResourceDiscoveryComponent<T extends JMXComponent<?>> implements ResourceDiscoveryComponent<T> { // Constants --------------------------------------------
/** @@ -93,8 +93,8 @@ public class MBeanResourceDiscoveryComponent<T extends JMXComponent> implements public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<T> context, boolean skipUnknownProps) { this.discoveryContext = context; - return performDiscovery(context.getDefaultPluginConfiguration(), context.getParentResourceComponent(), context - .getResourceType(), skipUnknownProps); + return performDiscovery(context.getDefaultPluginConfiguration(), context.getParentResourceComponent(), + context.getResourceType(), skipUnknownProps); }
/** @@ -161,12 +161,10 @@ public class MBeanResourceDiscoveryComponent<T extends JMXComponent> implements String resourceKey = bean.getBeanName().getCanonicalName(); // The detected object name
String nameTemplate = (pluginConfiguration.getSimple(PROPERTY_NAME_TEMPLATE) != null) ? pluginConfiguration - .getSimple(PROPERTY_NAME_TEMPLATE).getStringValue() - : null; + .getSimple(PROPERTY_NAME_TEMPLATE).getStringValue() : null;
String descriptionTemplate = (pluginConfiguration.getSimple(PROPERTY_DESCRIPTION_TEMPLATE) != null) ? pluginConfiguration - .getSimple(PROPERTY_DESCRIPTION_TEMPLATE).getStringValue() - : null; + .getSimple(PROPERTY_DESCRIPTION_TEMPLATE).getStringValue() : null;
String name = resourceKey; if (nameTemplate != null) { diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ClassNameMBeanComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ClassNameMBeanComponent.java index fc8b818..2d0b55e 100644 --- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ClassNameMBeanComponent.java +++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ClassNameMBeanComponent.java @@ -30,8 +30,8 @@ import org.rhq.plugins.jmx.MBeanResourceComponent; * @author Stefan Negrea * */ -@SuppressWarnings({ "rawtypes", "deprecation" }) -public class ClassNameMBeanComponent extends MBeanResourceComponent<JMXComponent> { +@SuppressWarnings({ "deprecation" }) +public class ClassNameMBeanComponent extends MBeanResourceComponent<JMXComponent<?>> { private static final Log log = LogFactory.getLog(WebappContextComponent.class);
private static final String CLASS_NAME = "className"; diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ClassNameMBeanDiscoveryComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ClassNameMBeanDiscoveryComponent.java index 686642a..8487704 100644 --- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ClassNameMBeanDiscoveryComponent.java +++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ClassNameMBeanDiscoveryComponent.java @@ -35,8 +35,7 @@ import org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent; * * @author Stefan Negrea */ -@SuppressWarnings("rawtypes") -public class ClassNameMBeanDiscoveryComponent<T extends JMXComponent> extends MBeanResourceDiscoveryComponent<T> { +public class ClassNameMBeanDiscoveryComponent<T extends JMXComponent<?>> extends MBeanResourceDiscoveryComponent<T> {
private static final Log log = LogFactory.getLog(FileConfiguredMBeanResourceComponent.class);
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/LoadMetricDiscoveryComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/LoadMetricDiscoveryComponent.java index 31530d7..1c5f894 100644 --- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/LoadMetricDiscoveryComponent.java +++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/LoadMetricDiscoveryComponent.java @@ -33,11 +33,10 @@ import org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent; * @author Stefan Negrea * */ -@SuppressWarnings("rawtypes") -public class LoadMetricDiscoveryComponent extends MBeanResourceDiscoveryComponent<JMXComponent> { +public class LoadMetricDiscoveryComponent extends MBeanResourceDiscoveryComponent<JMXComponent<?>> {
@Override - public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent> context, + public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent<?>> context, boolean skipUnknownProps) {
Set<DiscoveredResourceDetails> results = super.discoverResources(context, skipUnknownProps); @@ -83,7 +82,7 @@ public class LoadMetricDiscoveryComponent extends MBeanResourceDiscoveryComponen * @param objectName * @return */ - private String getBeanConfiguredClassName(ResourceDiscoveryContext<JMXComponent> context, String objectName) { + private String getBeanConfiguredClassName(ResourceDiscoveryContext<JMXComponent<?>> context, String objectName) { EmsConnection connection = context.getParentResourceComponent().getEmsConnection(); EmsBean emsBean = loadBean(connection, objectName);
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/WebappContextComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/WebappContextComponent.java index 6131578..f7010a0 100644 --- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/WebappContextComponent.java +++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/WebappContextComponent.java @@ -36,8 +36,8 @@ import org.rhq.plugins.modcluster.model.ProxyInfo; * * @author Stefan Negrea */ -@SuppressWarnings({ "rawtypes", "deprecation" }) -public class WebappContextComponent extends MBeanResourceComponent<MBeanResourceComponent> { +@SuppressWarnings({ "deprecation" }) +public class WebappContextComponent extends MBeanResourceComponent<MBeanResourceComponent<?>> {
private static final Log log = LogFactory.getLog(WebappContextComponent.class);
diff --git a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/WebappContextDiscoveryComponent.java b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/WebappContextDiscoveryComponent.java index 559e1b6..faa9795 100644 --- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/WebappContextDiscoveryComponent.java +++ b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/WebappContextDiscoveryComponent.java @@ -37,8 +37,7 @@ import org.rhq.plugins.modcluster.model.ProxyInfo; * * @author Stefan Negrea */ -@SuppressWarnings("rawtypes") -public class WebappContextDiscoveryComponent implements ResourceDiscoveryComponent<MBeanResourceComponent> { +public class WebappContextDiscoveryComponent implements ResourceDiscoveryComponent<MBeanResourceComponent<?>> {
private static final String JVM_ROUTE_PROPERTY = "jvmRoute"; private static final String ENGINE_OBJECT_NAME = "engineObjectName"; @@ -46,7 +45,7 @@ public class WebappContextDiscoveryComponent implements ResourceDiscoveryCompone /* (non-Javadoc) * @see org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent#discoverResources(org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext) */ - public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<MBeanResourceComponent> context) { + public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<MBeanResourceComponent<?>> context) { String jvmRoute = this.getJvmRoute(context);
EmsBean configBean = context.getParentResourceComponent().getEmsBean(); @@ -72,7 +71,7 @@ public class WebappContextDiscoveryComponent implements ResourceDiscoveryCompone * @param context the discovery context * @return node's jvm route */ - private String getJvmRoute(ResourceDiscoveryContext<MBeanResourceComponent> context) { + private String getJvmRoute(ResourceDiscoveryContext<MBeanResourceComponent<?>> context) { Configuration pluginConfig = context.getParentResourceComponent().getResourceContext().getPluginConfiguration(); String engineObjectName = pluginConfig.getSimple(ENGINE_OBJECT_NAME).getStringValue(); EmsBean engineBean = this.loadBean(engineObjectName, context.getParentResourceComponent()); diff --git a/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlComponent.java b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlComponent.java index 325ed20..f1a16e4 100644 --- a/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlComponent.java +++ b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlComponent.java @@ -50,7 +50,8 @@ import org.rhq.plugins.database.DatabaseQueryUtility; * @author Greg Hinkle * @author Steve Millidge */ -public class MySqlComponent implements DatabaseComponent, ResourceComponent, MeasurementFacet { +public class MySqlComponent implements DatabaseComponent<ResourceComponent<?>>, + ResourceComponent<ResourceComponent<?>>, MeasurementFacet {
private ResourceContext resourceContext; private AggregateProcessInfo aggregateProcessInfo; diff --git a/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/FileSystemDiscoveryComponent.java b/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/FileSystemDiscoveryComponent.java index b1367b6..b213063 100644 --- a/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/FileSystemDiscoveryComponent.java +++ b/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/FileSystemDiscoveryComponent.java @@ -1,25 +1,25 @@ - /* - * RHQ Management Platform - * Copyright (C) 2005-2011 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, as - * published by the Free Software Foundation, and/or the GNU Lesser - * General Public License, version 2.1, also as published by the Free - * Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License and the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * and the GNU Lesser General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ +/* + * RHQ Management Platform + * Copyright (C) 2005-2011 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ package org.rhq.plugins.platform;
import java.util.LinkedHashSet; @@ -40,7 +40,6 @@ import org.rhq.core.system.SystemInfo; * @author Greg Hinkle * @author Ian Springer */ -@SuppressWarnings({"UnusedDeclaration"}) public class FileSystemDiscoveryComponent implements ResourceDiscoveryComponent<PlatformComponent> {
private static final String SYS_TYPE_NAME_LOFS = "lofs"; @@ -65,21 +64,20 @@ public class FileSystemDiscoveryComponent implements ResourceDiscoveryComponent< int fsType = fs.getType(); // We only support local, network (nfs), lofs, or tmpfs filesystems - skip any other types. switch (fsType) { - case FileSystem.TYPE_LOCAL_DISK: - case FileSystem.TYPE_NETWORK: - break; - default: - String sysTypeName = fs.getSysTypeName(); - if (!(SYS_TYPE_NAME_LOFS.equals(sysTypeName) || SYS_TYPE_NAME_TMPFS.equals(sysTypeName))) { - continue; - } + case FileSystem.TYPE_LOCAL_DISK: + case FileSystem.TYPE_NETWORK: + break; + default: + String sysTypeName = fs.getSysTypeName(); + if (!(SYS_TYPE_NAME_LOFS.equals(sysTypeName) || SYS_TYPE_NAME_TMPFS.equals(sysTypeName))) { + continue; + } }
try { String key = fsInfo.getMountPoint(); String name = fsInfo.getMountPoint(); - String description = fsInfo.getFileSystem().getDevName() + ": " - + fsInfo.getFileSystem().getDirName(); + String description = fsInfo.getFileSystem().getDevName() + ": " + fsInfo.getFileSystem().getDirName(); Configuration pluginConfig = discoveryContext.getDefaultPluginConfiguration(); DiscoveredResourceDetails details = new DiscoveredResourceDetails(discoveryContext.getResourceType(), key, name, null, description, pluginConfig, null); diff --git a/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/PlatformComponent.java b/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/PlatformComponent.java index 4cf56a3..757c812 100644 --- a/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/PlatformComponent.java +++ b/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/PlatformComponent.java @@ -65,7 +65,8 @@ import org.rhq.core.system.SystemInfo; * * @author John Mazzitelli */ -public class PlatformComponent implements ResourceComponent, ConfigurationFacet, MeasurementFacet, OperationFacet { +public class PlatformComponent implements ResourceComponent<PlatformComponent>, ConfigurationFacet, MeasurementFacet, + OperationFacet {
private final Log log = LogFactory.getLog(PlatformComponent.class);
@@ -229,9 +230,7 @@ public class PlatformComponent implements ResourceComponent, ConfigurationFacet, pm.put(new PropertySimple("name", process.getBaseName())); pm.put(new PropertySimple("size", (process.getMemory() != null) ? process.getMemory().getSize() : "0")); pm.put(new PropertySimple("userTime", (process.getTime() != null) ? process.getTime().getUser() : "0")); - pm - .put(new PropertySimple("kernelTime", (process.getTime() != null) ? process.getTime().getSys() - : "0")); + pm.put(new PropertySimple("kernelTime", (process.getTime() != null) ? process.getTime().getSys() : "0")); processList.add(pm); }
diff --git a/modules/plugins/postfix/src/main/java/org/rhq/plugins/postfix/PostfixAccessDiscoveryComponent.java b/modules/plugins/postfix/src/main/java/org/rhq/plugins/postfix/PostfixAccessDiscoveryComponent.java index 0a34baa..8102eb6 100644 --- a/modules/plugins/postfix/src/main/java/org/rhq/plugins/postfix/PostfixAccessDiscoveryComponent.java +++ b/modules/plugins/postfix/src/main/java/org/rhq/plugins/postfix/PostfixAccessDiscoveryComponent.java @@ -26,6 +26,7 @@ import java.util.Set; import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails; import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException; +import org.rhq.core.pluginapi.inventory.ResourceComponent; import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; import org.rhq.plugins.augeas.AugeasConfigurationDiscoveryComponent;
@@ -33,11 +34,11 @@ import org.rhq.plugins.augeas.AugeasConfigurationDiscoveryComponent; * @author paji * */ -public class PostfixAccessDiscoveryComponent extends AugeasConfigurationDiscoveryComponent<PostfixAccessComponent> { +public class PostfixAccessDiscoveryComponent extends AugeasConfigurationDiscoveryComponent<ResourceComponent<?>> { public static final String RESOURCE_KEY = "Access";
public Set<DiscoveredResourceDetails> discoverResources( - ResourceDiscoveryContext<PostfixAccessComponent> discoveryContext) throws InvalidPluginConfigurationException, + ResourceDiscoveryContext<ResourceComponent<?>> discoveryContext) throws InvalidPluginConfigurationException, Exception {
Set<DiscoveredResourceDetails> details = new HashSet<DiscoveredResourceDetails>(); diff --git a/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresDatabaseComponent.java b/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresDatabaseComponent.java index fec4c0f..d6380b7 100644 --- a/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresDatabaseComponent.java +++ b/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresDatabaseComponent.java @@ -46,11 +46,11 @@ import org.rhq.core.pluginapi.operation.OperationResult; import org.rhq.core.util.jdbc.JDBCUtil; import org.rhq.plugins.database.DatabaseComponent;
-public class PostgresDatabaseComponent implements DatabaseComponent<PostgresServerComponent>, MeasurementFacet, +public class PostgresDatabaseComponent implements DatabaseComponent<PostgresServerComponent<?>>, MeasurementFacet, CreateChildResourceFacet, OperationFacet { private Log log = LogFactory.getLog(PostgresDatabaseComponent.class);
- private ResourceContext<PostgresServerComponent> resourceContext; + private ResourceContext<PostgresServerComponent<?>> resourceContext;
private Connection databaseConnection;
@@ -89,7 +89,7 @@ public class PostgresDatabaseComponent implements DatabaseComponent<PostgresServ this.databaseConnection = null; }
- public void start(ResourceContext<PostgresServerComponent> context) { + public void start(ResourceContext<PostgresServerComponent<?>> context) { this.resourceContext = context; }
diff --git a/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresDatabaseDiscoveryComponent.java b/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresDatabaseDiscoveryComponent.java index 5236fd3..f7f6f56 100644 --- a/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresDatabaseDiscoveryComponent.java +++ b/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresDatabaseDiscoveryComponent.java @@ -22,6 +22,7 @@ import java.sql.ResultSet; import java.sql.Statement; import java.util.HashSet; import java.util.Set; + import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails; import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent; @@ -31,8 +32,8 @@ import org.rhq.core.util.jdbc.JDBCUtil; /** * @author Greg Hinkle */ -public class PostgresDatabaseDiscoveryComponent implements ResourceDiscoveryComponent<PostgresServerComponent> { - public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<PostgresServerComponent> context) +public class PostgresDatabaseDiscoveryComponent implements ResourceDiscoveryComponent<PostgresServerComponent<?>> { + public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<PostgresServerComponent<?>> context) throws Exception { Set<DiscoveredResourceDetails> databases = new HashSet<DiscoveredResourceDetails>();
@@ -45,8 +46,7 @@ public class PostgresDatabaseDiscoveryComponent implements ResourceDiscoveryComp while (resultSet.next()) { String databaseName = resultSet.getString("datname"); DiscoveredResourceDetails database = new DiscoveredResourceDetails(context.getResourceType(), - databaseName, databaseName, null, "The " + databaseName - + " Postgres Database Instance", null, null); + databaseName, databaseName, null, "The " + databaseName + " Postgres Database Instance", null, null); database.getPluginConfiguration().put(new PropertySimple("databaseName", databaseName)); databases.add(database); } diff --git a/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresServerComponent.java b/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresServerComponent.java index 8308a23..f80f288 100644 --- a/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresServerComponent.java +++ b/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresServerComponent.java @@ -55,6 +55,7 @@ import org.rhq.core.pluginapi.configuration.ConfigurationFacet; import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport; import org.rhq.core.pluginapi.inventory.CreateChildResourceFacet; import org.rhq.core.pluginapi.inventory.CreateResourceReport; +import org.rhq.core.pluginapi.inventory.ResourceComponent; import org.rhq.core.pluginapi.inventory.ResourceContext; import org.rhq.core.pluginapi.measurement.MeasurementFacet; import org.rhq.core.pluginapi.operation.OperationFacet; @@ -70,7 +71,7 @@ import org.rhq.plugins.postgres.util.PostgresqlConfFile; * * @author Greg Hinkle */ -public class PostgresServerComponent implements DatabaseComponent, ConfigurationFacet, MeasurementFacet, +public class PostgresServerComponent<T extends ResourceComponent<?>> implements DatabaseComponent<T>, ConfigurationFacet, MeasurementFacet, OperationFacet, CreateChildResourceFacet { private static Log log = LogFactory.getLog(PostgresServerComponent.class);
diff --git a/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresUserComponent.java b/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresUserComponent.java index 6312c4d..92a5203 100644 --- a/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresUserComponent.java +++ b/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresUserComponent.java @@ -44,11 +44,11 @@ import org.rhq.plugins.database.DatabaseQueryUtility; /** * @author Greg Hinkle */ -public class PostgresUserComponent implements DatabaseComponent<PostgresServerComponent>, MeasurementFacet, +public class PostgresUserComponent implements DatabaseComponent<PostgresServerComponent<?>>, MeasurementFacet, ConfigurationFacet, DeleteResourceFacet { - private ResourceContext<PostgresServerComponent> resourceContext; + private ResourceContext<PostgresServerComponent<?>> resourceContext;
- public void start(ResourceContext<PostgresServerComponent> resourceContext) { + public void start(ResourceContext<PostgresServerComponent<?>> resourceContext) { this.resourceContext = resourceContext; }
diff --git a/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresUserDiscoveryComponent.java b/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresUserDiscoveryComponent.java index c0d0273..4eab143 100644 --- a/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresUserDiscoveryComponent.java +++ b/modules/plugins/postgres/src/main/java/org/rhq/plugins/postgres/PostgresUserDiscoveryComponent.java @@ -23,8 +23,10 @@ import java.sql.ResultSet; import java.sql.Statement; import java.util.HashSet; import java.util.Set; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails; import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent; @@ -36,12 +38,12 @@ import org.rhq.core.util.jdbc.JDBCUtil; * * @author Greg Hinkle */ -public class PostgresUserDiscoveryComponent implements ResourceDiscoveryComponent<PostgresServerComponent> { +public class PostgresUserDiscoveryComponent implements ResourceDiscoveryComponent<PostgresServerComponent<?>> { private static final Log log = LogFactory.getLog(PostgresTableDiscoveryComponent.class);
public static final String USERS_QUERY = "select * from pg_roles";
- public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<PostgresServerComponent> context) + public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<PostgresServerComponent<?>> context) throws Exception { log.info("Discovering postgres users"); Set<DiscoveredResourceDetails> discoveredUsers = new HashSet<DiscoveredResourceDetails>(); diff --git a/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentEnvironmentScriptComponent.java b/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentEnvironmentScriptComponent.java index 8b8e1f9..e21a456 100644 --- a/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentEnvironmentScriptComponent.java +++ b/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentEnvironmentScriptComponent.java @@ -47,12 +47,12 @@ import org.rhq.enterprise.agent.EnvironmentScriptFileUpdate.NameValuePair; * * @author John Mazzitelli */ -public class AgentEnvironmentScriptComponent implements ResourceComponent<AgentServerComponent>, ConfigurationFacet { +public class AgentEnvironmentScriptComponent implements ResourceComponent<AgentServerComponent<?>>, ConfigurationFacet { private Log log = LogFactory.getLog(AgentEnvironmentScriptComponent.class);
private File script;
- public void start(ResourceContext<AgentServerComponent> resourceContext) throws Exception { + public void start(ResourceContext<AgentServerComponent<?>> resourceContext) throws Exception { Configuration pc = resourceContext.getPluginConfiguration(); PropertySimple pathnameProp = pc.getSimple(AgentEnvironmentScriptDiscoveryComponent.PLUGINCONFIG_PATHNAME); if (pathnameProp == null) { diff --git a/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentEnvironmentScriptDiscoveryComponent.java b/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentEnvironmentScriptDiscoveryComponent.java index ff312f8..31523d8 100644 --- a/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentEnvironmentScriptDiscoveryComponent.java +++ b/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentEnvironmentScriptDiscoveryComponent.java @@ -39,7 +39,7 @@ import org.rhq.enterprise.agent.Version; * * @author John Mazzitelli */ -public class AgentEnvironmentScriptDiscoveryComponent implements ResourceDiscoveryComponent<AgentServerComponent> { +public class AgentEnvironmentScriptDiscoveryComponent implements ResourceDiscoveryComponent<AgentServerComponent<?>> { private final Log log = LogFactory.getLog(AgentEnvironmentScriptDiscoveryComponent.class);
/** @@ -53,7 +53,7 @@ public class AgentEnvironmentScriptDiscoveryComponent implements ResourceDiscove * * @see ResourceDiscoveryComponent#discoverResources(ResourceDiscoveryContext) */ - public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<AgentServerComponent> context) { + public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<AgentServerComponent<?>> context) { log.info("Discovering RHQ Agent's environment setup script...");
HashSet<DiscoveredResourceDetails> set = new HashSet<DiscoveredResourceDetails>(); @@ -90,7 +90,7 @@ public class AgentEnvironmentScriptDiscoveryComponent implements ResourceDiscove * * @return <code>true</code> if this method discovers the script; <code>false</code> if not */ - private boolean findInAgentHome(ResourceDiscoveryContext<AgentServerComponent> context, String version, + private boolean findInAgentHome(ResourceDiscoveryContext<AgentServerComponent<?>> context, String version, String baseName, HashSet<DiscoveredResourceDetails> discoveries) {
try { @@ -111,7 +111,7 @@ public class AgentEnvironmentScriptDiscoveryComponent implements ResourceDiscove } }
- private DiscoveredResourceDetails createDetails(ResourceDiscoveryContext<AgentServerComponent> context, + private DiscoveredResourceDetails createDetails(ResourceDiscoveryContext<AgentServerComponent<?>> context, String version, File discoveredScript) {
String key = "environment-setup-script"; // this is a singleton resource; only ever one of these diff --git a/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentJavaServiceWrapperComponent.java b/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentJavaServiceWrapperComponent.java index 2b5b041..cff8181 100644 --- a/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentJavaServiceWrapperComponent.java +++ b/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentJavaServiceWrapperComponent.java @@ -54,19 +54,19 @@ import org.rhq.enterprise.agent.EnvironmentScriptFileUpdate.NameValuePair; * * @author John Mazzitelli */ -public class AgentJavaServiceWrapperComponent implements ResourceComponent<AgentServerComponent>, ConfigurationFacet, - OperationFacet { +public class AgentJavaServiceWrapperComponent implements ResourceComponent<AgentServerComponent<?>>, + ConfigurationFacet, OperationFacet {
private Log log = LogFactory.getLog(AgentJavaServiceWrapperComponent.class);
- private ResourceContext<AgentServerComponent> resourceContext; + private ResourceContext<AgentServerComponent<?>> resourceContext;
private File launcherScript; private File configFile; private File environmentFile; private File includeFile;
- public void start(ResourceContext<AgentServerComponent> rc) throws Exception { + public void start(ResourceContext<AgentServerComponent<?>> rc) throws Exception {
this.resourceContext = rc;
diff --git a/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentJavaServiceWrapperDiscoveryComponent.java b/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentJavaServiceWrapperDiscoveryComponent.java index fd9c4bc..85fa609 100644 --- a/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentJavaServiceWrapperDiscoveryComponent.java +++ b/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentJavaServiceWrapperDiscoveryComponent.java @@ -41,7 +41,7 @@ import org.rhq.enterprise.agent.Version; * * @author John Mazzitelli */ -public class AgentJavaServiceWrapperDiscoveryComponent implements ResourceDiscoveryComponent<AgentServerComponent> { +public class AgentJavaServiceWrapperDiscoveryComponent implements ResourceDiscoveryComponent<AgentServerComponent<?>> { private final Log log = LogFactory.getLog(AgentJavaServiceWrapperDiscoveryComponent.class);
/** @@ -73,7 +73,7 @@ public class AgentJavaServiceWrapperDiscoveryComponent implements ResourceDiscov * * @see ResourceDiscoveryComponent#discoverResources(ResourceDiscoveryContext) */ - public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<AgentServerComponent> context) { + public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<AgentServerComponent<?>> context) { log.info("Discovering RHQ Agent's JSW service...");
HashSet<DiscoveredResourceDetails> set = new HashSet<DiscoveredResourceDetails>(); @@ -115,7 +115,7 @@ public class AgentJavaServiceWrapperDiscoveryComponent implements ResourceDiscov * * @return <code>true</code> if this method discovers the JSW; <code>false</code> if not */ - private boolean findInAgentHome(ResourceDiscoveryContext<AgentServerComponent> context, String version, + private boolean findInAgentHome(ResourceDiscoveryContext<AgentServerComponent<?>> context, String version, String baseName, HashSet<DiscoveredResourceDetails> discoveries) {
try { @@ -136,7 +136,7 @@ public class AgentJavaServiceWrapperDiscoveryComponent implements ResourceDiscov } }
- private DiscoveredResourceDetails createDetails(ResourceDiscoveryContext<AgentServerComponent> context, + private DiscoveredResourceDetails createDetails(ResourceDiscoveryContext<AgentServerComponent<?>> context, String version, File discoveredLocation) {
String key = "jsw"; // this is a singleton resource; only ever one of these diff --git a/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentLauncherScriptComponent.java b/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentLauncherScriptComponent.java index 6cefec8..f51febf 100644 --- a/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentLauncherScriptComponent.java +++ b/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentLauncherScriptComponent.java @@ -42,15 +42,15 @@ import org.rhq.core.system.SystemInfo; * * @author John Mazzitelli */ -public class AgentLauncherScriptComponent implements ResourceComponent<AgentServerComponent>, OperationFacet { +public class AgentLauncherScriptComponent implements ResourceComponent<AgentServerComponent<?>>, OperationFacet {
private Log log = LogFactory.getLog(AgentLauncherScriptComponent.class);
- private ResourceContext<AgentServerComponent> resourceContext; + private ResourceContext<AgentServerComponent<?>> resourceContext;
private File launcherScript;
- public void start(ResourceContext<AgentServerComponent> rc) throws Exception { + public void start(ResourceContext<AgentServerComponent<?>> rc) throws Exception {
this.resourceContext = rc; Configuration pc = this.resourceContext.getPluginConfiguration(); diff --git a/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentLauncherScriptDiscoveryComponent.java b/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentLauncherScriptDiscoveryComponent.java index b386f59..ddbdbeb 100644 --- a/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentLauncherScriptDiscoveryComponent.java +++ b/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentLauncherScriptDiscoveryComponent.java @@ -43,7 +43,7 @@ import org.rhq.enterprise.agent.Version; * * @author John Mazzitelli */ -public class AgentLauncherScriptDiscoveryComponent implements ResourceDiscoveryComponent<AgentServerComponent> { +public class AgentLauncherScriptDiscoveryComponent implements ResourceDiscoveryComponent<AgentServerComponent<?>> { private final Log log = LogFactory.getLog(AgentLauncherScriptDiscoveryComponent.class);
/** @@ -57,7 +57,7 @@ public class AgentLauncherScriptDiscoveryComponent implements ResourceDiscoveryC * * @see ResourceDiscoveryComponent#discoverResources(ResourceDiscoveryContext) */ - public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<AgentServerComponent> context) { + public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<AgentServerComponent<?>> context) { log.info("Discovering RHQ Agent's launcher script service...");
HashSet<DiscoveredResourceDetails> set = new HashSet<DiscoveredResourceDetails>(); @@ -99,7 +99,7 @@ public class AgentLauncherScriptDiscoveryComponent implements ResourceDiscoveryC * * @return <code>true</code> if this method discovers the launcher script; <code>false</code> if not */ - private boolean findInAgentHome(ResourceDiscoveryContext<AgentServerComponent> context, String version, + private boolean findInAgentHome(ResourceDiscoveryContext<AgentServerComponent<?>> context, String version, String baseName, HashSet<DiscoveredResourceDetails> discoveries) {
try { @@ -120,7 +120,7 @@ public class AgentLauncherScriptDiscoveryComponent implements ResourceDiscoveryC } }
- private DiscoveredResourceDetails createDetails(ResourceDiscoveryContext<AgentServerComponent> context, + private DiscoveredResourceDetails createDetails(ResourceDiscoveryContext<AgentServerComponent<?>> context, String version, File discoveredLocation) {
String key = "launcherscript"; // this is a singleton resource; only ever one of these diff --git a/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentServerComponent.java b/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentServerComponent.java index d352ae9..82179ab 100644 --- a/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentServerComponent.java +++ b/modules/plugins/rhq-agent/src/main/java/org/rhq/plugins/agent/AgentServerComponent.java @@ -50,6 +50,7 @@ import org.rhq.core.domain.measurement.MeasurementScheduleRequest; import org.rhq.core.pluginapi.configuration.ConfigurationFacet; import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport; import org.rhq.core.pluginapi.event.log.LogFileEventResourceComponentHelper; +import org.rhq.core.pluginapi.inventory.ResourceComponent; import org.rhq.core.pluginapi.inventory.ResourceContext; import org.rhq.core.pluginapi.measurement.MeasurementFacet; import org.rhq.core.pluginapi.operation.OperationFacet; @@ -70,8 +71,8 @@ import org.rhq.plugins.jmx.JMXServerComponent; * * @author John Mazzitelli */ -public class AgentServerComponent extends JMXServerComponent implements JMXComponent, MeasurementFacet, OperationFacet, - ConfigurationFacet, SupportFacet { +public class AgentServerComponent<T extends ResourceComponent<?>> extends JMXServerComponent<T> implements + JMXComponent<T>, MeasurementFacet, OperationFacet, ConfigurationFacet, SupportFacet { private static Log log = LogFactory.getLog(AgentServerComponent.class);
/** diff --git a/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaServerComponent.java b/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaServerComponent.java index d50f324..f9f2648 100644 --- a/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaServerComponent.java +++ b/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaServerComponent.java @@ -18,9 +18,13 @@ */ package org.rhq.plugins.samba;
+import java.util.List; +import java.util.Set; + import net.augeas.Augeas;
-import org.rhq.core.domain.configuration.*; +import org.rhq.core.domain.configuration.Configuration; +import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple; import org.rhq.core.domain.measurement.AvailabilityType; import org.rhq.core.domain.measurement.MeasurementDataNumeric; @@ -30,23 +34,25 @@ import org.rhq.core.domain.resource.ResourceType; import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport; import org.rhq.core.pluginapi.inventory.CreateResourceReport; import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException; +import org.rhq.core.pluginapi.inventory.ResourceComponent; import org.rhq.core.pluginapi.inventory.ResourceContext; import org.rhq.core.pluginapi.measurement.MeasurementFacet; import org.rhq.core.pluginapi.operation.OperationFacet; import org.rhq.core.pluginapi.operation.OperationResult; import org.rhq.core.pluginapi.util.ObjectUtil; -import org.rhq.core.system.*; +import org.rhq.core.system.NetworkStats; +import org.rhq.core.system.ProcessExecution; +import org.rhq.core.system.ProcessExecutionResults; +import org.rhq.core.system.ProcessInfo; +import org.rhq.core.system.SystemInfo; import org.rhq.plugins.augeas.AugeasConfigurationComponent; import org.rhq.plugins.augeas.helper.AugeasNode;
-import java.util.List; -import java.util.Set; - - /** * TODO */ -public class SambaServerComponent extends AugeasConfigurationComponent implements OperationFacet, MeasurementFacet { +public class SambaServerComponent extends AugeasConfigurationComponent<ResourceComponent<?>> implements OperationFacet, + MeasurementFacet {
static final String ENABLE_RECYCLING = "enableRecycleBin"; static final String AUTHCONFIG_PATH = "/usr/bin/authconfig"; @@ -57,7 +63,6 @@ public class SambaServerComponent extends AugeasConfigurationComponent implement
private ResourceContext resourceContext;
- public void start(ResourceContext resourceContext) throws Exception { this.resourceContext = resourceContext; super.start(resourceContext); @@ -141,8 +146,8 @@ public class SambaServerComponent extends AugeasConfigurationComponent implement
private void getProcess() {
- List<ProcessInfo> procs = - resourceContext.getSystemInformation().getProcesses("process|basename|match=smbd,process|basename|nomatch|parent=smbd"); + List<ProcessInfo> procs = resourceContext.getSystemInformation().getProcesses( + "process|basename|match=smbd,process|basename|nomatch|parent=smbd");
if (procs.size() == 1) { this.processInfo = procs.get(0).getAggregateProcessTree(); @@ -153,7 +158,7 @@ public class SambaServerComponent extends AugeasConfigurationComponent implement
NetworkStats stats = resourceContext.getSystemInformation().getNetworkStats("localhost", PORT);
- if (processInfo!=null) { + if (processInfo != null) { processInfo.refresh();
for (MeasurementScheduleRequest request : metrics) { @@ -161,7 +166,8 @@ public class SambaServerComponent extends AugeasConfigurationComponent implement int val = stats.getByName(request.getName().substring("NetworkStat.".length())); report.addData(new MeasurementDataNumeric(request, (double) val)); } else if (request.getName().startsWith("Process.")) { - Double value = ObjectUtil.lookupDeepNumericAttributeProperty(processInfo, request.getName().substring("Process.".length())); + Double value = ObjectUtil.lookupDeepNumericAttributeProperty(processInfo, request.getName() + .substring("Process.".length())); report.addData(new MeasurementDataNumeric(request, value)); } } @@ -173,10 +179,9 @@ public class SambaServerComponent extends AugeasConfigurationComponent implement OperationResult result = null;
if (name.equals("join")) { - result = updateSmbAds(params); - } - else if (name.equals("disconnect")) { - result = disconnectSmbAds(params); + result = updateSmbAds(params); + } else if (name.equals("disconnect")) { + result = disconnectSmbAds(params); } return result; } @@ -279,6 +284,6 @@ public class SambaServerComponent extends AugeasConfigurationComponent implement ProcessExecutionResults results = sysInfo.executeProcess(processExecution);
return results; - } + }
} diff --git a/modules/plugins/snmptrapd/src/main/java/org/rhq/plugins/snmptrapd/SnmpTrapdComponent.java b/modules/plugins/snmptrapd/src/main/java/org/rhq/plugins/snmptrapd/SnmpTrapdComponent.java index 9e0de67..7967e15 100644 --- a/modules/plugins/snmptrapd/src/main/java/org/rhq/plugins/snmptrapd/SnmpTrapdComponent.java +++ b/modules/plugins/snmptrapd/src/main/java/org/rhq/plugins/snmptrapd/SnmpTrapdComponent.java @@ -47,7 +47,7 @@ import org.rhq.core.util.exception.ThrowableUtil; * @author Heiko W. Rupp * */ -public class SnmpTrapdComponent implements ResourceComponent, MeasurementFacet { +public class SnmpTrapdComponent implements ResourceComponent<ResourceComponent<?>>, MeasurementFacet {
private final Log log = LogFactory.getLog(SnmpTrapdComponent.class);
diff --git a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatConnectorComponent.java b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatConnectorComponent.java index 0265123..4f334a4 100644 --- a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatConnectorComponent.java +++ b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatConnectorComponent.java @@ -54,7 +54,7 @@ import org.rhq.plugins.jmx.ObjectNameQueryUtility; * @author Jay Shaughnessy * @author Jason Dobies */ -public class TomcatConnectorComponent extends MBeanResourceComponent<TomcatServerComponent> { +public class TomcatConnectorComponent extends MBeanResourceComponent<TomcatServerComponent<?>> {
/** * property name for the protocol of the connector @@ -103,7 +103,7 @@ public class TomcatConnectorComponent extends MBeanResourceComponent<TomcatServe }
@Override - public void start(ResourceContext<TomcatServerComponent> context) { + public void start(ResourceContext<TomcatServerComponent<?>> context) { if (UNKNOWN.equals(context.getPluginConfiguration().getSimple(PLUGIN_CONFIG_HANDLER).getStringValue())) { throw new InvalidPluginConfigurationException( "The connector is not listening for requests on the configured port. This is most likely due to the configured port being in use at Tomcat startup. In some cases (AJP connectors) Tomcat will assign an open port. This happens most often when there are multiple Tomcat servers running on the same platform. Check your Tomcat configuration for conflicts: " @@ -206,7 +206,7 @@ public class TomcatConnectorComponent extends MBeanResourceComponent<TomcatServe public void updateResourceConfiguration(ConfigurationUpdateReport report) {
// When starting the component get the connector type specific property keys - ResourceContext<TomcatServerComponent> context = getResourceContext(); + ResourceContext<TomcatServerComponent<?>> context = getResourceContext(); ConfigurationDefinition configDef = context.getResourceType().getResourceConfigurationDefinition(); String protocol = report.getConfiguration().getSimpleValue(CONFIG_PROTOCOL, null); if ((null == protocol) || protocol.toUpperCase().contains("HTTP")) { diff --git a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatConnectorDiscoveryComponent.java b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatConnectorDiscoveryComponent.java index f6ad696..0940910 100644 --- a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatConnectorDiscoveryComponent.java +++ b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatConnectorDiscoveryComponent.java @@ -33,6 +33,7 @@ import org.apache.commons.logging.LogFactory; import org.mc4j.ems.connection.EmsConnection; import org.mc4j.ems.connection.bean.EmsBean; import org.mc4j.ems.connection.bean.EmsBeanName; + import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails; @@ -48,13 +49,13 @@ import org.rhq.plugins.jmx.ObjectNameQueryUtility; * @author Jason Dobies * @author Ian Springer */ -public class TomcatConnectorDiscoveryComponent extends MBeanResourceDiscoveryComponent<TomcatServerComponent> { +public class TomcatConnectorDiscoveryComponent extends MBeanResourceDiscoveryComponent<TomcatServerComponent<?>> { private final Log log = LogFactory.getLog(this.getClass());
// MBeanResourceDiscoveryComponent Overridden Methods --------------------------------------------
@Override - public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<TomcatServerComponent> context) { + public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<TomcatServerComponent<?>> context) {
// Connector objectNames can have two formats: // Catalina:type=Connector,port=%port% (this is the default for the connector type in the plugin desc) diff --git a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatServerComponent.java b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatServerComponent.java index d67f072..bc843ef 100644 --- a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatServerComponent.java +++ b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatServerComponent.java @@ -48,6 +48,7 @@ import org.rhq.core.domain.measurement.MeasurementDataTrait; import org.rhq.core.domain.measurement.MeasurementReport; import org.rhq.core.domain.measurement.MeasurementScheduleRequest; import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException; +import org.rhq.core.pluginapi.inventory.ResourceComponent; import org.rhq.core.pluginapi.inventory.ResourceContext; import org.rhq.core.pluginapi.measurement.MeasurementFacet; import org.rhq.core.pluginapi.operation.OperationFacet; @@ -60,8 +61,8 @@ import org.rhq.plugins.jmx.JMXDiscoveryComponent; * * @author Jay Shaughnessy */ -@SuppressWarnings("unchecked") -public class TomcatServerComponent implements JMXComponent, MeasurementFacet, OperationFacet { +public class TomcatServerComponent<T extends ResourceComponent<?>> implements JMXComponent<T>, MeasurementFacet, + OperationFacet {
public enum SupportedOperations { /** @@ -251,14 +252,15 @@ public class TomcatServerComponent implements JMXComponent, MeasurementFacet, Op // Since the connection is attempted each time it's used, failure to connect could result in log // file spamming. Log it once for every 10 consecutive times it's encountered. if (consecutiveConnectionErrors % 10 == 0) { - log.warn("Could not establish connection to the Tomcat instance [" - + (consecutiveConnectionErrors + 1) + "] times for resource [" - + resourceContext.getResourceKey() + "]", e); + log.warn( + "Could not establish connection to the Tomcat instance [" + (consecutiveConnectionErrors + 1) + + "] times for resource [" + resourceContext.getResourceKey() + "]", e); }
if (log.isDebugEnabled()) - log.debug("Could not connect to the Tomcat instance for resource [" - + resourceContext.getResourceKey() + "]", e); + log.debug( + "Could not connect to the Tomcat instance for resource [" + resourceContext.getResourceKey() + + "]", e);
consecutiveConnectionErrors++;
diff --git a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatUserDatabaseComponent.java b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatUserDatabaseComponent.java index 880ecc5..bb13097 100644 --- a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatUserDatabaseComponent.java +++ b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatUserDatabaseComponent.java @@ -24,6 +24,7 @@ package org.jboss.on.plugins.tomcat;
import org.jboss.on.plugins.tomcat.helper.CreateResourceHelper; + import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.domain.resource.CreateResourceStatus; import org.rhq.core.pluginapi.inventory.CreateChildResourceFacet; @@ -35,7 +36,8 @@ import org.rhq.plugins.jmx.MBeanResourceComponent; * * @author Jay Shaughnessy */ -public class TomcatUserDatabaseComponent extends MBeanResourceComponent<TomcatServerComponent> implements CreateChildResourceFacet { +public class TomcatUserDatabaseComponent extends MBeanResourceComponent<TomcatServerComponent<?>> implements + CreateChildResourceFacet {
public CreateResourceReport createResource(CreateResourceReport report) { String resourceTypeName = report.getResourceType().getName(); diff --git a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostComponent.java b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostComponent.java index 2746c5b..7f600a7 100644 --- a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostComponent.java +++ b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostComponent.java @@ -64,7 +64,7 @@ import org.rhq.plugins.jmx.MBeanResourceComponent; * @author Heiko W. Rupp * */ -public class TomcatVHostComponent extends MBeanResourceComponent<TomcatServerComponent> implements +public class TomcatVHostComponent extends MBeanResourceComponent<TomcatServerComponent<?>> implements ApplicationServerComponent, CreateChildResourceFacet {
public static final String CONFIG_ALIASES = "aliases"; @@ -358,9 +358,8 @@ public class TomcatVHostComponent extends MBeanResourceComponent<TomcatServerCom deployer = new TomcatApplicationDeployer(connection, getName()); } } catch (Throwable e) { - log - .error("Unable to access Deployer MBean required for creation and deletion of managed resources - this should never happen. Cause: " - + e); + log.error("Unable to access Deployer MBean required for creation and deletion of managed resources - this should never happen. Cause: " + + e); }
return deployer; diff --git a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostDiscoveryComponent.java b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostDiscoveryComponent.java index 7b3f0a1..5cf6143 100644 --- a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostDiscoveryComponent.java +++ b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostDiscoveryComponent.java @@ -37,16 +37,17 @@ import org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent; * @author Jay Shaughnessy * @author Heiko W. Rupp */ -public class TomcatVHostDiscoveryComponent extends MBeanResourceDiscoveryComponent<TomcatServerComponent> { - - static Pattern pattern = Pattern.compile(".*host=([\w.]+).*"); +public class TomcatVHostDiscoveryComponent extends MBeanResourceDiscoveryComponent<TomcatServerComponent<?>> { + + static Pattern pattern = Pattern.compile(".*host=([\w.]+).*");
@Override - public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<TomcatServerComponent> discoveryContext) { + public Set<DiscoveredResourceDetails> discoverResources( + ResourceDiscoveryContext<TomcatServerComponent<?>> discoveryContext) {
Set<DiscoveredResourceDetails> resources = super.discoverResources(discoveryContext);
- for (DiscoveredResourceDetails detail : resources) { + for (DiscoveredResourceDetails detail : resources) { String name = detail.getResourceName(); Matcher m = pattern.matcher(name); if (m.matches()) { diff --git a/modules/plugins/twitter/src/main/java/org/rhq/plugins/twitter/TwitterComponent.java b/modules/plugins/twitter/src/main/java/org/rhq/plugins/twitter/TwitterComponent.java index eab4634..f6283ce 100644 --- a/modules/plugins/twitter/src/main/java/org/rhq/plugins/twitter/TwitterComponent.java +++ b/modules/plugins/twitter/src/main/java/org/rhq/plugins/twitter/TwitterComponent.java @@ -54,7 +54,7 @@ import org.rhq.core.pluginapi.operation.OperationResult; * * @author Heiko W. Rupp */ -public class TwitterComponent implements ResourceComponent, OperationFacet, MeasurementFacet +public class TwitterComponent implements ResourceComponent<ResourceComponent<?>>, OperationFacet, MeasurementFacet { private final Log log = LogFactory.getLog(this.getClass());
diff --git a/modules/plugins/virt/src/main/java/org/rhq/plugins/virt/VirtualizationHostComponent.java b/modules/plugins/virt/src/main/java/org/rhq/plugins/virt/VirtualizationHostComponent.java index 0c9b9cd..33f0478 100644 --- a/modules/plugins/virt/src/main/java/org/rhq/plugins/virt/VirtualizationHostComponent.java +++ b/modules/plugins/virt/src/main/java/org/rhq/plugins/virt/VirtualizationHostComponent.java @@ -47,7 +47,7 @@ import org.rhq.plugins.virt.LibVirtConnection.HVInfo; * * @author Greg Hinkle */ -public class VirtualizationHostComponent implements ResourceComponent, MeasurementFacet, ConfigurationFacet, +public class VirtualizationHostComponent implements ResourceComponent<ResourceComponent<?>>, MeasurementFacet, ConfigurationFacet, CreateChildResourceFacet {
private Log log = LogFactory.getLog(VirtualizationDomainComponent.class);
rhq-commits@lists.fedorahosted.org