Author: tejones
Date: 2012-10-30 17:51:45 -0400 (Tue, 30 Oct 2012)
New Revision: 4522
Modified:
branches/7.7.x/console/pom.xml
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/DataRoleComponent.java
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/Facet.java
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/TranslatorComponent.java
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyMapToCompositeValueSupportAdapter.java
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyMapToGenericValueAdapter.java
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyMapToTableValueAdapter.java
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/objects/ConfigurationResultImpl.java
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/objects/ExecutedOperationResultImpl.java
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/objects/ExecutedResourceConfigurationResultImpl.java
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java
branches/7.7.x/documentation/javadocs/pom.xml
Log:
TEIID-2240: Upgraded RHQ plugin code to support RHQ 4.2 (JON 3.0) and RHQ 4.4 (JON 3.1).
Used reflection to account for different return types/missing methods between versions.
Modified: branches/7.7.x/console/pom.xml
===================================================================
--- branches/7.7.x/console/pom.xml 2012-10-26 16:19:46 UTC (rev 4521)
+++ branches/7.7.x/console/pom.xml 2012-10-30 21:51:45 UTC (rev 4522)
@@ -15,14 +15,15 @@
<!--
<org.jboss.jopr.as4.version>1.2.0.GA</org.jboss.jopr.as4.version>
-->
- <org.jboss.jopr.as5.version>1.2.0.GA</org.jboss.jopr.as5.version>
- <jopr.jboss.as5.plugin.version>1.4.0.B01</jopr.jboss.as5.plugin.version>
- <org.rhq.version>1.3.0.GA</org.rhq.version>
+ <jopr.jboss.as5.plugin.version>4.4.0</jopr.jboss.as5.plugin.version>
+ <org.rhq.version>4.4.0</org.rhq.version>
<apache.ant.version>1.7.0</apache.ant.version>
<teiid.version>${project.version}</teiid.version>
</properties>
+
+
<dependencies>
<!--
@@ -128,17 +129,11 @@
<artifactId>teiid-common-core</artifactId>
<type>test-jar</type>
</dependency>
- <dependency>
- <groupId>org.jboss.jopr</groupId>
- <artifactId>jopr-embedded-jbas5</artifactId>
- <type>war</type>
- <version>${org.jboss.jopr.as5.version}</version>
- </dependency>
-
- <dependency>
+
+ <dependency>
<groupId>org.jboss.integration</groupId>
<artifactId>jboss-profileservice-spi</artifactId>
- <version>5.1.0.CR2</version>
+ <version>5.1.0.SP1</version>
</dependency>
<dependency>
Modified:
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/DataRoleComponent.java
===================================================================
---
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/DataRoleComponent.java 2012-10-26
16:19:46 UTC (rev 4521)
+++
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/DataRoleComponent.java 2012-10-30
21:51:45 UTC (rev 4522)
@@ -59,6 +59,8 @@
import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
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.plugins.jbossas5.connection.ProfileServiceConnection;
import org.teiid.rhq.plugin.adapter.api.PropertyAdapter;
@@ -80,7 +82,6 @@
* @seeorg.teiid.rhq.plugin.Facet#start(org.rhq.core.pluginapi.inventory.
* ResourceContext)
*/
- @Override
public void start(ResourceContext context) {
this.resourceConfiguration = context.getPluginConfiguration();
this.componentType = PluginConstants.ComponentType.DATA_ROLE.NAME;
@@ -307,4 +308,11 @@
return null;
}
+ @Override
+ public ResourceContext getResourceContext() {
+ // TODO Auto-generated method stub
+ return this.getResourceContext();
+ }
+
+
}
Modified: branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/Facet.java
===================================================================
--- branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/Facet.java 2012-10-26
16:19:46 UTC (rev 4521)
+++ branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/Facet.java 2012-10-30
21:51:45 UTC (rev 4522)
@@ -95,7 +95,7 @@
* by all MetaMatrix components.
*/
public abstract class Facet implements
- ProfileServiceComponent<ResourceComponent>, MeasurementFacet,
+ ProfileServiceComponent, MeasurementFacet,
OperationFacet, ConfigurationFacet, ContentFacet, DeleteResourceFacet,
CreateChildResourceFacet {
@@ -112,7 +112,7 @@
* All AMPS plugins are stateful - this context contains information that
* your resource component can use when performing its processing.
*/
- protected ResourceContext<?> resourceContext;
+ protected ResourceContext resourceContext;
protected String name;
Modified:
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java
===================================================================
---
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java 2012-10-26
16:19:46 UTC (rev 4521)
+++
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java 2012-10-30
21:51:45 UTC (rev 4522)
@@ -48,9 +48,9 @@
import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection;
import org.teiid.rhq.admin.DQPManagementView;
import org.teiid.rhq.plugin.util.PluginConstants;
+import org.teiid.rhq.plugin.util.PluginConstants.ComponentType.Platform;
+import org.teiid.rhq.plugin.util.PluginConstants.Operation;
import org.teiid.rhq.plugin.util.ProfileServiceUtil;
-import org.teiid.rhq.plugin.util.PluginConstants.Operation;
-import org.teiid.rhq.plugin.util.PluginConstants.ComponentType.Platform;
/**
*
@@ -58,7 +58,6 @@
public class PlatformComponent extends Facet {
private final Log LOG = LogFactory.getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
- @Override
public void start(ResourceContext context) {
this.setComponentName(context.getPluginConfiguration().getSimpleValue( "name",
null)); //$NON-NLS-1$
this.resourceConfiguration = context.getPluginConfiguration();
@@ -267,4 +266,10 @@
return null;
}
+ @Override
+ public ResourceContext getResourceContext() {
+ return this.getResourceContext();
+ }
+
+
}
\ No newline at end of file
Modified:
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/TranslatorComponent.java
===================================================================
---
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/TranslatorComponent.java 2012-10-26
16:19:46 UTC (rev 4521)
+++
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/TranslatorComponent.java 2012-10-30
21:51:45 UTC (rev 4522)
@@ -63,7 +63,6 @@
String RESOURCE_NAME = "resourceName";
}
- @Override
public void start(ResourceContext context) {
this.setComponentName(context.getPluginConfiguration().getSimpleValue( "name",
null));
this.resourceConfiguration=context.getPluginConfiguration();
@@ -185,5 +184,11 @@
// TODO Auto-generated method stub
return null;
}
+
+ @Override
+ public ResourceContext getResourceContext() {
+ // TODO Auto-generated method stub
+ return this.getResourceContext();
+ }
}
\ No newline at end of file
Modified: branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java
===================================================================
--- branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java 2012-10-26
16:19:46 UTC (rev 4521)
+++ branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java 2012-10-30
21:51:45 UTC (rev 4522)
@@ -68,10 +68,10 @@
import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection;
import org.teiid.rhq.admin.DQPManagementView;
import org.teiid.rhq.plugin.util.PluginConstants;
-import org.teiid.rhq.plugin.util.ProfileServiceUtil;
-import org.teiid.rhq.plugin.util.PluginConstants.Operation;
import org.teiid.rhq.plugin.util.PluginConstants.ComponentType.Platform;
import org.teiid.rhq.plugin.util.PluginConstants.ComponentType.VDB;
+import org.teiid.rhq.plugin.util.PluginConstants.Operation;
+import org.teiid.rhq.plugin.util.ProfileServiceUtil;
/**
* Component class for a Teiid VDB
@@ -87,7 +87,6 @@
* @seeorg.teiid.rhq.plugin.Facet#start(org.rhq.core.pluginapi.inventory.
* ResourceContext)
*/
- @Override
public void start(ResourceContext context) {
this.setComponentName(context.getPluginConfiguration().getSimpleValue(
"fullName", null));
@@ -693,8 +692,12 @@
@Override
public EmsConnection getEmsConnection() {
- // TODO Auto-generated method stub
return null;
}
+ @Override
+ public ResourceContext getResourceContext() {
+ return this.getResourceContext();
+ }
+
}
Modified:
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyMapToCompositeValueSupportAdapter.java
===================================================================
---
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyMapToCompositeValueSupportAdapter.java 2012-10-26
16:19:46 UTC (rev 4521)
+++
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyMapToCompositeValueSupportAdapter.java 2012-10-30
21:51:45 UTC (rev 4522)
@@ -21,6 +21,8 @@
*/
package org.teiid.rhq.plugin.adapter.impl;
+import java.util.List;
+
import org.jboss.metatype.api.types.MetaType;
import org.jboss.metatype.api.values.CompositeValue;
import org.jboss.metatype.api.values.CompositeValueSupport;
@@ -47,7 +49,7 @@
compositeValueSupport.set(key, value);
}
- protected CompositeValue createCompositeValue(PropertyDefinitionMap propDefMap,
MetaType metaType)
+ protected CompositeValue createCompositeValue(PropertyDefinitionMap
propertyDefinitionMap, MetaType metaType)
{
MutableCompositeMetaType compositeMetaType;
if (metaType != null)
@@ -55,16 +57,20 @@
else
{
// TODO: See if this else block is actually necessary (I think it is needed
for creates).
- String name = (propDefMap != null) ?
- propDefMap.getName() : "CompositeMetaType";
- String desc = (propDefMap != null && propDefMap.getDescription() !=
null) ?
- propDefMap.getDescription() : "none";
+ String name = (propertyDefinitionMap != null) ?
+ propertyDefinitionMap.getName() : "CompositeMetaType";
+ String desc = (propertyDefinitionMap != null &&
propertyDefinitionMap.getDescription() != null) ?
+ propertyDefinitionMap.getDescription() : "none";
compositeMetaType = new MutableCompositeMetaType(name, desc);
- if (propDefMap != null)
+
+ //Need to handle RHQ 4.4 and 4.2.
+ List<PropertyDefinition> propDefList
=ProfileServiceUtil.reflectivelyInvokeGetMapMethod(propertyDefinitionMap);
+
+ if (propertyDefinitionMap != null)
{
- for (PropertyDefinition mapMemberPropDef :
propDefMap.getPropertyDefinitions().values())
+ for (PropertyDefinition mapMemberPropDef : propDefList)
{
- String mapMemberDesc = (propDefMap.getDescription() != null) ?
propDefMap.getDescription() : "none";
+ String mapMemberDesc = (propertyDefinitionMap.getDescription() !=
null) ? propertyDefinitionMap.getDescription() : "none";
MetaType mapMemberMetaType =
ProfileServiceUtil.convertPropertyDefinitionToMetaType(mapMemberPropDef);
compositeMetaType.addItem(mapMemberPropDef.getName(), mapMemberDesc,
mapMemberMetaType);
}
@@ -72,4 +78,6 @@
}
return new CompositeValueSupport(compositeMetaType);
}
-}
\ No newline at end of file
+
+}
+
Modified:
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyMapToGenericValueAdapter.java
===================================================================
---
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyMapToGenericValueAdapter.java 2012-10-26
16:19:46 UTC (rev 4521)
+++
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyMapToGenericValueAdapter.java 2012-10-30
21:51:45 UTC (rev 4522)
@@ -21,6 +21,9 @@
*/
package org.teiid.rhq.plugin.adapter.impl;
+import java.util.List;
+import java.util.Map;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.managed.api.ManagedObject;
@@ -84,31 +87,49 @@
}
}
- public MetaValue convertToMetaValue(PropertyMap propMap, PropertyDefinitionMap
propDefMap, MetaType metaType)
+ public MetaValue convertToMetaValue(PropertyMap propMap, PropertyDefinitionMap
propertyDefinitionMap, MetaType metaType)
{
//GenericMetaType genericMetaType = (GenericMetaType)metaType;
- ManagedObjectImpl managedObject = new ManagedObjectImpl(propDefMap.getName());
- for (PropertyDefinition mapMemberPropDef :
propDefMap.getPropertyDefinitions().values())
- {
- ManagedPropertyImpl managedProp = new
ManagedPropertyImpl(mapMemberPropDef.getName());
- MetaType managedPropMetaType =
ProfileServiceUtil.convertPropertyDefinitionToMetaType(mapMemberPropDef);
+ ManagedObjectImpl managedObject = new
ManagedObjectImpl(propertyDefinitionMap.getName());
+ //Need to handle RHQ 4.4 and 4.2. Return types changed for
PropertyDefinitionMap.getPropertyDefinitions()
+ //so we need to check types.
+ Object object = ((PropertyDefinitionMap)
propertyDefinitionMap).getPropertyDefinitions();
+ Iterable<PropertyDefinition> propDefIter = null;
+ List<PropertyDefinition> propDefList = null;
+
+ if (object instanceof Map){
+ propDefIter = (Iterable<PropertyDefinition>)
((Map)object).values().iterator();
+ }else{
+ propDefList = (List<PropertyDefinition>)object;
+ }
+
+ for (PropertyDefinition definition : propDefIter != null?propDefIter:propDefList) {
+ ManagedPropertyImpl managedProp = new
ManagedPropertyImpl(definition.getName());
+ MetaType managedPropMetaType =
ProfileServiceUtil.convertPropertyDefinitionToMetaType(definition);
managedProp.setMetaType(managedPropMetaType);
managedProp.setManagedObject(managedObject);
managedObject.getProperties().put(managedProp.getName(), managedProp);
}
- GenericValue genericValue = new GenericValueSupport(new
GenericMetaType(propDefMap.getName(),
- propDefMap.getDescription()), managedObject);
- populateMetaValueFromProperty(propMap, genericValue, propDefMap);
+ GenericValue genericValue = new GenericValueSupport(new
GenericMetaType(propertyDefinitionMap.getName(),
+ propertyDefinitionMap.getDescription()), managedObject);
+ populateMetaValueFromProperty(propMap, genericValue, propertyDefinitionMap);
return genericValue;
}
- public void populatePropertyFromMetaValue(PropertyMap propMap, MetaValue metaValue,
PropertyDefinitionMap propDefMap)
+ public void populatePropertyFromMetaValue(PropertyMap propMap, MetaValue metaValue,
PropertyDefinitionMap propertyDefinitionMap)
{
GenericValue genericValue = (GenericValue)metaValue;
ManagedObject managedObject = (ManagedObject)genericValue.getValue();
- for (String propName : propDefMap.getPropertyDefinitions().keySet())
- {
- ManagedProperty managedProp = managedObject.getProperty(propName);
+ //Need to handle RHQ 4.4 and 4.2. Return types changed for
PropertyDefinitionMap.getPropertyDefinitions()
+ //so we need to check types.
+ Object object = ((PropertyDefinitionMap)
propertyDefinitionMap).getPropertyDefinitions();
+ Iterable<PropertyDefinition> propDefIter = null;
+
+ //Need to handle RHQ 4.4 and 4.2.
+ List<PropertyDefinition> propDefList
=ProfileServiceUtil.reflectivelyInvokeGetMapMethod(propertyDefinitionMap);
+
+ for (PropertyDefinition definition : propDefList) {
+ ManagedProperty managedProp =
managedObject.getProperty(definition.getName());
if (managedProp != null)
{
MetaType metaType = managedProp.getMetaType();
@@ -129,7 +150,7 @@
+ "] is not a SimpleValue or EnumValue -
unsupported!");
continue;
}
- propMap.put(new PropertySimple(propName, value));
+ propMap.put(new PropertySimple(definition.getName(), value));
}
}
}
Modified:
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyMapToTableValueAdapter.java
===================================================================
---
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyMapToTableValueAdapter.java 2012-10-26
16:19:46 UTC (rev 4521)
+++
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/adapter/impl/PropertyMapToTableValueAdapter.java 2012-10-30
21:51:45 UTC (rev 4522)
@@ -22,6 +22,7 @@
package org.teiid.rhq.plugin.adapter.impl;
import java.util.Collection;
+import java.util.List;
import java.util.Map;
import org.jboss.metatype.api.types.MetaType;
@@ -37,6 +38,7 @@
import org.teiid.rhq.plugin.adapter.api.AbstractPropertyMapAdapter;
import org.teiid.rhq.plugin.adapter.api.PropertyAdapter;
import org.teiid.rhq.plugin.adapter.api.PropertyAdapterFactory;
+import org.teiid.rhq.plugin.util.ProfileServiceUtil;
/**
*
@@ -51,19 +53,19 @@
}
//@todo need to implement this like the other Map to Composite, but not until there
is an actual property that needs this
- public void populateMetaValueFromProperty(PropertyMap property, MetaValue metaValue,
PropertyDefinitionMap propertyDefinition)
+ public void populateMetaValueFromProperty(PropertyMap property, MetaValue metaValue,
PropertyDefinitionMap propertyDefinitionMap)
{
if (metaValue != null)
{
TableValueSupport tableValueSupport = (TableValueSupport)metaValue;
- Map<String, PropertyDefinition> map =
propertyDefinition.getPropertyDefinitions();
- Map<String, Property> properties = property.getMap();
- for (String key : map.keySet())
- {
- PropertyDefinition definition = map.get(key);
- MetaValue[] getKey = new MetaValue[]{SimpleValueSupport.wrap(key)};
+ //Need to handle RHQ 4.4 and 4.2.
+ List<PropertyDefinition> propDefList
=ProfileServiceUtil.reflectivelyInvokeGetMapMethod(propertyDefinitionMap);
+
+ Map<String, Property> properties = property.getMap();
+ for (PropertyDefinition definition : propDefList) {
+ MetaValue[] getKey = new
MetaValue[]{SimpleValueSupport.wrap(definition.getName())};
MetaValue value = tableValueSupport.get(getKey);
- Property innerProperty = properties.get(key);
+ Property innerProperty = properties.get(definition.getName());
PropertyAdapter adapter =
PropertyAdapterFactory.getPropertyAdapter(value);
adapter.populateMetaValueFromProperty(innerProperty, value, definition);
}
Modified:
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/objects/ConfigurationResultImpl.java
===================================================================
---
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/objects/ConfigurationResultImpl.java 2012-10-26
16:19:46 UTC (rev 4521)
+++
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/objects/ConfigurationResultImpl.java 2012-10-30
21:51:45 UTC (rev 4522)
@@ -25,6 +25,7 @@
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
@@ -32,9 +33,9 @@
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.definition.PropertyDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionList;
-import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.teiid.rhq.plugin.util.ProfileServiceUtil;
public class ConfigurationResultImpl {
@@ -60,20 +61,16 @@
properties.add(new PropertySimple(key, values.get(fieldName)));
}
} else if (pdef instanceof PropertyDefinitionList) {
+
PropertyDefinition propertyDefinitionMap = ((PropertyDefinitionList) pdef)
.getMemberDefinition();
- Map simpleProperties = ((PropertyDefinitionMap) propertyDefinitionMap)
- .getPropertyDefinitions();
- Iterator simplePropertiesIter = simpleProperties.values()
- .iterator();
-
- while (simplePropertiesIter.hasNext()) {
- PropertyDefinition simpleProp = (PropertyDefinition) simplePropertiesIter
- .next();
- String fieldName = ((PropertyDefinitionSimple) simpleProp)
- .getName();
+
+ //Need to handle RHQ 4.4 and 4.2.
+ List<PropertyDefinition> propDefList
=ProfileServiceUtil.reflectivelyInvokeGetMapMethod(propertyDefinitionMap);
+
+ for (PropertyDefinition definition : propDefList) {
+ String fieldName = definition.getName();
if (values.contains(fieldName)) {
-
properties.add(new PropertySimple(key, values.get(fieldName)));
}
}
Modified:
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/objects/ExecutedOperationResultImpl.java
===================================================================
---
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/objects/ExecutedOperationResultImpl.java 2012-10-26
16:19:46 UTC (rev 4521)
+++
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/objects/ExecutedOperationResultImpl.java 2012-10-30
21:51:45 UTC (rev 4522)
@@ -33,10 +33,9 @@
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.definition.PropertyDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionList;
-import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap;
-import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
import org.rhq.core.domain.operation.OperationDefinition;
import org.rhq.core.pluginapi.operation.OperationResult;
+import org.teiid.rhq.plugin.util.ProfileServiceUtil;
public class ExecutedOperationResultImpl implements ExecutedResult {
@@ -130,27 +129,19 @@
if (opDef.getName().equals(operationName)) {
if (opDef.getResultsConfigurationDefinition()==null) break;
- Map propDefs = opDef.getResultsConfigurationDefinition()
- .getPropertyDefinitions();
- PropertyDefinition listPropDefinition = (PropertyDefinition) propDefs
- .get(LISTNAME);
+ PropertyDefinitionList listPropDefinition =
opDef.getResultsConfigurationDefinition()
+ .getPropertyDefinitionList(LISTNAME);
if (listPropDefinition == null) {
continue;
}
-
- PropertyDefinition propertyDefinitionMap = ((PropertyDefinitionList)
listPropDefinition)
- .getMemberDefinition();
- Map simpleProperties = ((PropertyDefinitionMap) propertyDefinitionMap)
- .getPropertyDefinitions();
- Iterator simplePropertiesIter = simpleProperties.values()
- .iterator();
- while (simplePropertiesIter.hasNext()) {
- PropertyDefinition simpleProp = (PropertyDefinition) simplePropertiesIter
- .next();
- String fieldName = ((PropertyDefinitionSimple) simpleProp)
- .getName();
+ PropertyDefinition propertyDefinitionMap = listPropDefinition.getMemberDefinition();
+
+ List<PropertyDefinition> propDefList =
ProfileServiceUtil.reflectivelyInvokeGetMapMethod(propertyDefinitionMap);
+
+ for (PropertyDefinition definition : propDefList) {
+ String fieldName = definition.getName();
fieldNameList.add(fieldName);
}
@@ -158,4 +149,6 @@
}
}
}
+
+
}
Modified:
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/objects/ExecutedResourceConfigurationResultImpl.java
===================================================================
---
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/objects/ExecutedResourceConfigurationResultImpl.java 2012-10-26
16:19:46 UTC (rev 4521)
+++
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/objects/ExecutedResourceConfigurationResultImpl.java 2012-10-30
21:51:45 UTC (rev 4522)
@@ -32,8 +32,7 @@
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.definition.PropertyDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionList;
-import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap;
-import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
+import org.teiid.rhq.plugin.util.ProfileServiceUtil;
public class ExecutedResourceConfigurationResultImpl implements ExecutedResult {
@@ -122,16 +121,11 @@
PropertyDefinition propertyDefinitionMap = ((PropertyDefinitionList)
listPropDefinition)
.getMemberDefinition();
- Map simpleProperties = ((PropertyDefinitionMap) propertyDefinitionMap)
- .getPropertyDefinitions();
- Iterator simplePropertiesIter = simpleProperties.values()
- .iterator();
-
- while (simplePropertiesIter.hasNext()) {
- PropertyDefinition simpleProp = (PropertyDefinition) simplePropertiesIter
- .next();
- String fieldName = ((PropertyDefinitionSimple) simpleProp)
- .getName();
+ //Need to handle RHQ 4.4 and 4.2.
+ List<PropertyDefinition> propDefList
=ProfileServiceUtil.reflectivelyInvokeGetMapMethod(propertyDefinitionMap);
+
+ for (PropertyDefinition definition : propDefList) {
+ String fieldName = definition.getName();
fieldNameList.add(fieldName);
}
Modified:
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java
===================================================================
---
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java 2012-10-26
16:19:46 UTC (rev 4521)
+++
branches/7.7.x/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java 2012-10-30
21:51:45 UTC (rev 4522)
@@ -24,15 +24,19 @@
import java.io.File;
import java.io.Serializable;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.net.MalformedURLException;
import java.net.URL;
import java.text.ParseException;
import java.text.SimpleDateFormat;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -537,15 +541,24 @@
// at all common)
memberMetaType = null;
} else if (propDef instanceof PropertyDefinitionMap) {
- Map<String, PropertyDefinition> memberPropDefs = ((PropertyDefinitionMap)
propDef)
- .getPropertyDefinitions();
- if (memberPropDefs.isEmpty())
+ //Need to handle RHQ 4.4 and 4.2. Return types changed for
PropertyDefinitionMap.getPropertyDefinitions()
+ //so we need to check types.
+ Object object = ((PropertyDefinitionMap) propDef).getPropertyDefinitions();
+ Iterable<PropertyDefinition> propDefIter = null;
+ List<PropertyDefinition> propDefList = null;
+
+ if (object instanceof Map){
+ propDefIter = (Iterable<PropertyDefinition>)
((Map)object).values().iterator();
+ }else{
+ propDefList = (List<PropertyDefinition>)object;
+ }
+
+ if ((propDefIter != null &! propDefIter.iterator().hasNext()) || (propDefList !=
null && propDefList.isEmpty()))
throw new IllegalStateException(
"PropertyDefinitionMap doesn't contain any member
PropertyDefinitions."); //$NON-NLS-1$
// NOTE: We assume member prop defs are all of the same type, since
// for MapCompositeMetaTypes, they have to be.
- PropertyDefinition mapMemberPropDef = memberPropDefs.values()
- .iterator().next();
+ PropertyDefinition mapMemberPropDef = propDefIter !=
null?propDefIter.iterator().next():propDefList.listIterator().next();
MetaType mapMemberMetaType = convertPropertyDefinitionToMetaType(mapMemberPropDef);
memberMetaType = new MapCompositeMetaType(mapMemberMetaType);
} else {
@@ -641,5 +654,51 @@
}
throw new Exception("Failed to convert value to SimpleValue"); //$NON-NLS-1$
}
+
+ /**
+ * @return
+ */
+ public static List<PropertyDefinition>
reflectivelyInvokeGetMapMethod(PropertyDefinition propertyDefinitionMap) {
+ //Need to handle RHQ 4.4 and 4.2. Return types changed for
PropertyDefinitionMap.getPropertyDefinitions()
+ //so we need to check method availability. getMap() was added for 4.4, so if we can
find it via reflection, invoke it.
+ //Otherwise it is less than 4.4 so we will invoke getPropertyDefinitions which returned
a map in 4.2.
+ Method method = null;
+ Object object = null;
+
+ try {
+ method = PropertyDefinitionMap.class.getMethod("getMap", null);
+ } catch (SecurityException e) {
+ //Nothing to do here
+ } catch (NoSuchMethodException e) {
+ //This will happen if we are running a version of RHQ less that 4.4
+ }
+
+ try {
+ if (method == null){
+ method = PropertyDefinitionMap.class.getMethod("getPropertyDefinitions",
null);
+ }
+ object = method.invoke(propertyDefinitionMap, null);
+ } catch (IllegalArgumentException e) {
+ throwReflectionException(e);
+ } catch (IllegalAccessException e) {
+ throwReflectionException(e);
+ } catch (InvocationTargetException e) {
+ throwReflectionException(e);
+ } catch (SecurityException e) {
+ throwReflectionException(e);
+ } catch (NoSuchMethodException e) {
+ throwReflectionException(e);
+ }
+
+
+ return new ArrayList<PropertyDefinition>(((Map)object).values());
+ }
+ /**
+ * @param object
+ */
+ private static void throwReflectionException(Exception e) {
+ throw new RuntimeException("Error reflectively returning PropertyDefinition map:
" + e.getLocalizedMessage());
+ }
+
}
Modified: branches/7.7.x/documentation/javadocs/pom.xml
===================================================================
--- branches/7.7.x/documentation/javadocs/pom.xml 2012-10-26 16:19:46 UTC (rev 4521)
+++ branches/7.7.x/documentation/javadocs/pom.xml 2012-10-30 21:51:45 UTC (rev 4522)
@@ -467,13 +467,13 @@
<properties>
<org.jboss.jopr.as5.version>1.2.0.GA</org.jboss.jopr.as5.version>
<mysql.connector.version>5.1.5</mysql.connector.version>
- <org.rhq.version>1.3.0.GA</org.rhq.version>
+ <org.rhq.version>4.4.0</org.rhq.version>
<postgresql.version>8.4-702.jdbc4</postgresql.version>
<derby.version>10.2.1.6</derby.version>
<teiid.version>${project.version}</teiid.version>
<
site.url>http://www.jboss.org/teiid</site.url>
<ant.version>1.7.0</ant.version>
<apache.ant.version>1.7.0</apache.ant.version>
- <jopr.jboss.as5.plugin.version>1.4.0.B01</jopr.jboss.as5.plugin.version>
+ <jopr.jboss.as5.plugin.version>4.4.0</jopr.jboss.as5.plugin.version>
</properties>
</project>