Author: tejones
Date: 2010-07-27 19:06:31 -0400 (Tue, 27 Jul 2010)
New Revision: 2381
Modified:
branches/7.0.x/console/pom.xml
branches/7.0.x/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java
branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/Facet.java
branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java
branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/PlatformDiscoveryComponent.java
branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/TranslatorComponent.java
branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/TranslatorDiscoveryComponent.java
branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java
branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/VDBDiscoveryComponent.java
branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java
branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java
Log:
TEIID-1169: Changed discovery of the Teiid RuntimeEngineDeployer and services to use the
Component Name instead of the "name" value for all components of type Teiid and
subtype DQP.
Modified: branches/7.0.x/console/pom.xml
===================================================================
--- branches/7.0.x/console/pom.xml 2010-07-27 17:38:29 UTC (rev 2380)
+++ branches/7.0.x/console/pom.xml 2010-07-27 23:06:31 UTC (rev 2381)
@@ -16,10 +16,11 @@
<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>
- <org.jboss.jopr.version>1.2.0.GA</org.jboss.jopr.version>
<apache.ant.version>1.7.0</apache.ant.version>
+
</properties>
<dependencies>
@@ -57,14 +58,14 @@
<artifactId>rhq-jmx-plugin</artifactId>
<version>${org.rhq.version}</version>
</dependency>
-
- <dependency>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-core-util</artifactId>
- <version>${org.rhq.version}</version>
- </dependency>
<dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-util</artifactId>
+ <version>${org.rhq.version}</version>
+ </dependency>
+
+ <dependency>
<groupId>mc4j</groupId>
<artifactId>org-mc4j-ems</artifactId>
<version>1.2.6</version>
@@ -127,19 +128,18 @@
</dependency>
<dependency>
- <groupId>org.jboss.jopr</groupId>
- <artifactId>jopr-embedded-jbas5</artifactId>
- <type>war</type>
- <version>${org.jboss.jopr.as5.version}</version>
- </dependency>
-
- <dependency>
<groupId>org.jboss.integration</groupId>
<artifactId>jboss-profileservice-spi</artifactId>
<version>5.1.0.CR2</version>
</dependency>
<dependency>
+ <groupId>org.jboss.on</groupId>
+ <artifactId>jopr-jboss-as-5-plugin</artifactId>
+ <version>${jopr.jboss.as5.plugin.version}</version>
+ </dependency>
+
+ <dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
</dependency>
@@ -150,35 +150,31 @@
<version>1.3.2</version>
</dependency>
- <!-- <dependency>
- <groupId>org.jboss.on</groupId>
- <artifactId>jopr-jboss-as-5-plugin</artifactId>
- <version>2.3.0.EmbJopr.1.2.0-1</version>
- </dependency> -->
+
</dependencies>
-
+
<build>
- <outputDirectory>target/classes</outputDirectory>
- <resources>
- <resource>
- <directory>src/main/resources</directory>
- <filtering>true</filtering>
- <includes>
- <include>**/*.xml</include>
- <include>**/*.properties</include>
- </includes>
- </resource>
- <resource>
- <directory>src/main/resources</directory>
- <filtering>false</filtering>
- <excludes>
- <exclude>**/*.xml</exclude>
- <exclude>**/*.properties</exclude>
- </excludes>
- </resource>
- </resources>
- </build>
+ <outputDirectory>target/classes</outputDirectory>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>**/*.xml</include>
+ <include>**/*.properties</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>false</filtering>
+ <excludes>
+ <exclude>**/*.xml</exclude>
+ <exclude>**/*.properties</exclude>
+ </excludes>
+ </resource>
+ </resources>
+ </build>
</project>
\ No newline at end of file
Modified: branches/7.0.x/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java
===================================================================
---
branches/7.0.x/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java 2010-07-27
17:38:29 UTC (rev 2380)
+++
branches/7.0.x/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java 2010-07-27
23:06:31 UTC (rev 2381)
@@ -22,6 +22,7 @@
import org.jboss.metatype.api.values.GenericValueSupport;
import org.jboss.metatype.api.values.MetaValue;
import org.jboss.metatype.api.values.MetaValueFactory;
+import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection;
import org.teiid.adminapi.Request;
import org.teiid.adminapi.Session;
import org.teiid.adminapi.Transaction;
@@ -36,7 +37,8 @@
public class DQPManagementView implements PluginConstants {
private static ManagedComponent mc = null;
- private static final Log LOG =
LogFactory.getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
+ private static final Log LOG = LogFactory
+ .getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
private static final MetaValueFactory metaValueFactory = MetaValueFactory
.getInstance();
@@ -47,37 +49,38 @@
/*
* Metric methods
*/
- public Object getMetric(String componentType, String identifier,
- String metric, Map<String, Object> valueMap) {
+ public Object getMetric(ProfileServiceConnection connection,
+ String componentType, String identifier, String metric,
+ Map<String, Object> valueMap) {
Object resultObject = new Object();
if (componentType.equals(PluginConstants.ComponentType.Platform.NAME)) {
- resultObject = getPlatformMetric(componentType, metric, valueMap);
+ resultObject = getPlatformMetric(connection, componentType, metric, valueMap);
} else if (componentType.equals(PluginConstants.ComponentType.VDB.NAME)) {
- resultObject = getVdbMetric(componentType, identifier, metric,
- valueMap);
+ resultObject = getVdbMetric(connection, componentType, identifier,
+ metric, valueMap);
}
return resultObject;
}
- private Object getPlatformMetric(String componentType, String metric,
+ private Object getPlatformMetric(ProfileServiceConnection connection, String
componentType, String metric,
Map<String, Object> valueMap) {
Object resultObject = new Object();
if (metric
.equals(PluginConstants.ComponentType.Platform.Metrics.QUERY_COUNT)) {
- resultObject = new Double(getQueryCount().doubleValue());
+ resultObject = new Double(getQueryCount(connection).doubleValue());
} else {
if (metric
.equals(PluginConstants.ComponentType.Platform.Metrics.SESSION_COUNT)) {
- resultObject = new Double(getSessionCount().doubleValue());
+ resultObject = new Double(getSessionCount(connection).doubleValue());
} else {
if (metric
.equals(PluginConstants.ComponentType.Platform.Metrics.LONG_RUNNING_QUERIES)) {
Collection<Request> longRunningQueries = new ArrayList<Request>();
- getRequestCollectionValue(getLongRunningQueries(),
+ getRequestCollectionValue(getLongRunningQueries(connection),
longRunningQueries);
resultObject = new Double(longRunningQueries.size());
}
@@ -87,29 +90,31 @@
return resultObject;
}
- private Object getVdbMetric(String componentType, String identifier,
- String metric, Map<String, Object> valueMap) {
+ private Object getVdbMetric(ProfileServiceConnection connection,
+ String componentType, String identifier, String metric,
+ Map<String, Object> valueMap) {
Object resultObject = new Object();
if (metric
.equals(PluginConstants.ComponentType.VDB.Metrics.ERROR_COUNT)) {
// TODO remove version parameter after AdminAPI is changed
- resultObject = getErrorCount((String) valueMap.get(VDB.NAME));
+ resultObject = getErrorCount(connection, (String) valueMap.get(VDB.NAME));
} else if (metric
.equals(PluginConstants.ComponentType.VDB.Metrics.STATUS)) {
// TODO remove version parameter after AdminAPI is changed
- resultObject = getVDBStatus((String) valueMap.get(VDB.NAME), 1);
+ resultObject = getVDBStatus(connection, (String) valueMap
+ .get(VDB.NAME), 1);
} else if (metric
.equals(PluginConstants.ComponentType.VDB.Metrics.QUERY_COUNT)) {
- resultObject = new Double(getQueryCount().doubleValue());
+ resultObject = new Double(getQueryCount(connection).doubleValue());
} else if (metric
.equals(PluginConstants.ComponentType.VDB.Metrics.SESSION_COUNT)) {
- resultObject = new Double(getSessionCount().doubleValue());
+ resultObject = new Double(getSessionCount(connection).doubleValue());
} else if (metric
.equals(PluginConstants.ComponentType.VDB.Metrics.LONG_RUNNING_QUERIES)) {
Collection<Request> longRunningQueries = new ArrayList<Request>();
- getRequestCollectionValue(getLongRunningQueries(),
+ getRequestCollectionValue(getLongRunningQueries(connection),
longRunningQueries);
resultObject = new Double(longRunningQueries.size());
@@ -122,48 +127,49 @@
* Operation methods
*/
- public void executeOperation(ExecutedResult operationResult,
- final Map<String, Object> valueMap) {
+ public void executeOperation(ProfileServiceConnection connection,
+ ExecutedResult operationResult, final Map<String, Object> valueMap) {
if (operationResult.getComponentType().equals(
PluginConstants.ComponentType.Platform.NAME)) {
- executePlatformOperation(operationResult, operationResult
- .getOperationName(), valueMap);
+ executePlatformOperation(connection, operationResult,
+ operationResult.getOperationName(), valueMap);
} else if (operationResult.getComponentType().equals(
PluginConstants.ComponentType.VDB.NAME)) {
- executeVdbOperation(operationResult, operationResult
+ executeVdbOperation(connection, operationResult, operationResult
.getOperationName(), valueMap);
}
}
- private void executePlatformOperation(ExecutedResult operationResult,
- final String operationName, final Map<String, Object> valueMap) {
+ private void executePlatformOperation(ProfileServiceConnection connection,
+ ExecutedResult operationResult, final String operationName,
+ final Map<String, Object> valueMap) {
Collection<Request> resultObject = new ArrayList<Request>();
Collection<Session> activeSessionsCollection = new ArrayList<Session>();
Collection<Transaction> transactionsCollection = new
ArrayList<Transaction>();
if (operationName.equals(Platform.Operations.GET_LONGRUNNINGQUERIES)) {
List<String> fieldNameList = operationResult.getFieldNameList();
- getRequestCollectionValue(getLongRunningQueries(), resultObject);
+ getRequestCollectionValue(getLongRunningQueries(connection), resultObject);
operationResult.setContent(createReportResultList(fieldNameList,
resultObject.iterator()));
} else if (operationName.equals(Platform.Operations.GET_SESSIONS)) {
List<String> fieldNameList = operationResult.getFieldNameList();
- MetaValue sessionMetaValue = getSessions();
+ MetaValue sessionMetaValue = getSessions(connection);
getSessionCollectionValue(sessionMetaValue,
activeSessionsCollection);
operationResult.setContent(createReportResultList(fieldNameList,
activeSessionsCollection.iterator()));
} else if (operationName.equals(Platform.Operations.GET_REQUESTS)) {
List<String> fieldNameList = operationResult.getFieldNameList();
- MetaValue requestMetaValue = getRequests();
+ MetaValue requestMetaValue = getRequests(connection);
getRequestCollectionValue(requestMetaValue, resultObject);
operationResult.setContent(createReportResultList(fieldNameList,
resultObject.iterator()));
} else if (operationName.equals(Platform.Operations.GET_TRANSACTIONS)) {
List<String> fieldNameList = operationResult.getFieldNameList();
- MetaValue transactionMetaValue = getTransactions();
+ MetaValue transactionMetaValue = getTransactions(connection);
getTransactionCollectionValue(transactionMetaValue,
transactionsCollection);
operationResult.setContent(createReportResultList(fieldNameList,
@@ -174,7 +180,7 @@
MetaValue[] args = new MetaValue[] { metaValueFactory
.create(sessionID) };
try {
- executeManagedOperation(mc,
+ executeManagedOperation(connection, mc,
Platform.Operations.KILL_TRANSACTION, args);
} catch (Exception e) {
final String msg = "Exception executing operation: " +
Platform.Operations.KILL_TRANSACTION; //$NON-NLS-1$
@@ -185,7 +191,7 @@
MetaValue[] args = new MetaValue[] { metaValueFactory
.create(sessionID) };
try {
- executeManagedOperation(mc, Platform.Operations.KILL_SESSION,
+ executeManagedOperation(connection, mc, Platform.Operations.KILL_SESSION,
args);
} catch (Exception e) {
final String msg = "Exception executing operation: " +
Platform.Operations.KILL_SESSION; //$NON-NLS-1$
@@ -198,7 +204,7 @@
metaValueFactory.create(requestID),
metaValueFactory.create(sessionID) };
try {
- executeManagedOperation(mc, Platform.Operations.KILL_REQUEST,
+ executeManagedOperation(connection, mc, Platform.Operations.KILL_REQUEST,
args);
} catch (Exception e) {
final String msg = "Exception executing operation: " +
Platform.Operations.KILL_REQUEST; //$NON-NLS-1$
@@ -207,30 +213,31 @@
}
}
- private void executeVdbOperation(ExecutedResult operationResult,
+ private void executeVdbOperation(ProfileServiceConnection connection, ExecutedResult
operationResult,
final String operationName, final Map<String, Object> valueMap) {
Collection<Request> resultObject = new ArrayList<Request>();
Collection<Session> activeSessionsCollection = new ArrayList<Session>();
String vdbName = (String) valueMap
.get(PluginConstants.ComponentType.VDB.NAME);
String vdbVersion = (String) valueMap
- .get(PluginConstants.ComponentType.VDB.VERSION);
+ .get(PluginConstants.ComponentType.VDB.VERSION);
if (operationName.equals(VDB.Operations.GET_PROPERTIES)) {
List<String> fieldNameList = operationResult.getFieldNameList();
- getProperties(PluginConstants.ComponentType.VDB.NAME);
+ getProperties(connection, PluginConstants.ComponentType.VDB.NAME);
operationResult.setContent(createReportResultList(fieldNameList,
resultObject.iterator()));
} else if (operationName.equals(VDB.Operations.GET_SESSIONS)) {
List<String> fieldNameList = operationResult.getFieldNameList();
- MetaValue sessionMetaValue = getSessions();
+ MetaValue sessionMetaValue = getSessions(connection);
getSessionCollectionValueForVDB(sessionMetaValue,
activeSessionsCollection, vdbName);
operationResult.setContent(createReportResultList(fieldNameList,
activeSessionsCollection.iterator()));
} else if (operationName.equals(VDB.Operations.GET_REQUESTS)) {
List<String> fieldNameList = operationResult.getFieldNameList();
- MetaValue requestMetaValue = getRequestsForVDB(vdbName,
Integer.parseInt(vdbVersion));
+ MetaValue requestMetaValue = getRequestsForVDB(connection, vdbName, Integer
+ .parseInt(vdbVersion));
getRequestCollectionValue(requestMetaValue, resultObject);
operationResult.setContent(createReportResultList(fieldNameList,
resultObject.iterator()));
@@ -242,13 +249,13 @@
* Helper methods
*/
- public MetaValue getProperties(final String component) {
+ public MetaValue getProperties(ProfileServiceConnection connection, final String
component) {
MetaValue propertyValue = null;
MetaValue args = null;
try {
- propertyValue = executeManagedOperation(mc,
+ propertyValue = executeManagedOperation(connection, mc,
PluginConstants.Operation.GET_PROPERTIES, args);
} catch (Exception e) {
final String msg = "Exception executing operation: " +
Platform.Operations.GET_PROPERTIES; //$NON-NLS-1$
@@ -259,13 +266,14 @@
}
- protected MetaValue getRequests() {
+ protected MetaValue getRequests(ProfileServiceConnection connection) {
MetaValue requestsCollection = null;
MetaValue args = null;
try {
- requestsCollection = executeManagedOperation(mc,
+ requestsCollection = executeManagedOperation(connection, mc,
+
PluginConstants.Operation.GET_REQUESTS, args);
} catch (Exception e) {
final String msg = "Exception executing operation: " +
Platform.Operations.GET_REQUESTS; //$NON-NLS-1$
@@ -276,15 +284,15 @@
}
- protected MetaValue getRequestsForVDB(String vdbName, int vdbVersion) {
+ protected MetaValue getRequestsForVDB(ProfileServiceConnection connection, String
vdbName, int vdbVersion) {
MetaValue requestsCollection = null;
MetaValue[] args = new MetaValue[] {
MetaValueFactory.getInstance().create(vdbName),
- MetaValueFactory.getInstance().create(vdbVersion)};
+ MetaValueFactory.getInstance().create(vdbVersion) };
try {
- requestsCollection = executeManagedOperation(mc,
+ requestsCollection = executeManagedOperation(connection, mc,
PluginConstants.ComponentType.VDB.Operations.GET_REQUESTS,
args);
} catch (Exception e) {
@@ -296,13 +304,13 @@
}
- protected MetaValue getTransactions() {
+ protected MetaValue getTransactions(ProfileServiceConnection connection) {
MetaValue transactionsCollection = null;
MetaValue args = null;
try {
- transactionsCollection = executeManagedOperation(mc,
+ transactionsCollection = executeManagedOperation(connection, mc,
Platform.Operations.GET_TRANSACTIONS, args);
} catch (Exception e) {
final String msg = "Exception executing operation: " +
Platform.Operations.GET_TRANSACTIONS; //$NON-NLS-1$
@@ -313,13 +321,13 @@
}
- public MetaValue getSessions() {
+ public MetaValue getSessions(ProfileServiceConnection connection) {
MetaValue sessionCollection = null;
MetaValue args = null;
try {
- sessionCollection = executeManagedOperation(mc,
+ sessionCollection = executeManagedOperation(connection, mc,
PluginConstants.Operation.GET_SESSIONS, args);
} catch (Exception e) {
final String msg = "Exception executing operation: " +
Platform.Operations.GET_SESSIONS; //$NON-NLS-1$
@@ -329,12 +337,13 @@
}
- public static String getVDBStatus(String vdbName, int version) {
+ public static String getVDBStatus(ProfileServiceConnection connection,
+ String vdbName, int version) {
ManagedComponent mcVdb = null;
try {
mcVdb = ProfileServiceUtil
- .getManagedComponent(
+ .getManagedComponent(connection,
new org.jboss.managed.api.ComponentType(
PluginConstants.ComponentType.VDB.TYPE,
PluginConstants.ComponentType.VDB.SUBTYPE),
@@ -347,13 +356,14 @@
LOG.error(msg, e);
}
- return ProfileServiceUtil.getSimpleValue(mcVdb, "status", String.class);
+ return ProfileServiceUtil.getSimpleValue(mcVdb, "status", String.class);
//$NON-NLS-1$
}
- public static MetaValue executeManagedOperation(ManagedComponent mc,
+ public static MetaValue executeManagedOperation(
+ ProfileServiceConnection connection, ManagedComponent mc,
String operation, MetaValue... args) throws Exception {
- mc = getDQPManagementView(mc);
+ mc = getDQPManagementView(connection, mc);
for (ManagedOperation mo : mc.getOperations()) {
String opName = mo.getName();
@@ -370,7 +380,7 @@
}
}
}
- throw new Exception("No operation found with given name =" + operation);
+ throw new Exception("No operation found with given name =" + operation);
//$NON-NLS-1$
}
@@ -378,9 +388,10 @@
* @param mc
* @return
*/
- private static ManagedComponent getDQPManagementView(ManagedComponent mc) {
+ private static ManagedComponent getDQPManagementView(
+ ProfileServiceConnection connection, ManagedComponent mc) {
try {
- mc = ProfileServiceUtil.getDQPManagementView();
+ mc = ProfileServiceUtil.getTeiidEngineManagedComponent(connection);
} catch (NamingException e) {
final String msg = "NamingException getting the DQPManagementView";
//$NON-NLS-1$
LOG.error(msg, e);
@@ -391,10 +402,11 @@
return mc;
}
- public static MetaValue getManagedProperty(ManagedComponent mc,
+ public static MetaValue getManagedProperty(
+ ProfileServiceConnection connection, ManagedComponent mc,
String property, MetaValue... args) throws Exception {
- mc = getDQPManagementView(mc);
+ mc = getDQPManagementView(connection, mc);
try {
mc.getProperty(property);
@@ -403,17 +415,17 @@
LOG.error(msg, e);
}
- throw new Exception("No property found with given name =" + property);
+ throw new Exception("No property found with given name =" + property);
//$NON-NLS-1$
}
- private Integer getQueryCount() {
+ private Integer getQueryCount(ProfileServiceConnection connection) {
Integer count = new Integer(0);
MetaValue requests = null;
Collection<Request> requestsCollection = new ArrayList<Request>();
- requests = getRequests();
+ requests = getRequests(connection);
getRequestCollectionValue(requests, requestsCollection);
@@ -424,10 +436,10 @@
return count;
}
- private Integer getSessionCount() {
+ private Integer getSessionCount(ProfileServiceConnection connection) {
Collection<Session> activeSessionsCollection = new ArrayList<Session>();
- MetaValue sessionMetaValue = getSessions();
+ MetaValue sessionMetaValue = getSessions(connection);
getSessionCollectionValue(sessionMetaValue, activeSessionsCollection);
return activeSessionsCollection.size();
}
@@ -437,12 +449,12 @@
* @return count
* @throws Exception
*/
- private int getErrorCount(String vdbName) {
+ private int getErrorCount(ProfileServiceConnection connection, String vdbName) {
ManagedComponent mcVdb = null;
try {
mcVdb = ProfileServiceUtil
- .getManagedComponent(
+ .getManagedComponent(connection,
new org.jboss.managed.api.ComponentType(
PluginConstants.ComponentType.VDB.TYPE,
PluginConstants.ComponentType.VDB.SUBTYPE),
@@ -457,7 +469,7 @@
// Get models from VDB
int count = 0;
- ManagedProperty property = mcVdb.getProperty("models");
+ ManagedProperty property = mcVdb.getProperty("models"); //$NON-NLS-1$
CollectionValueSupport valueSupport = (CollectionValueSupport) property
.getValue();
MetaValue[] metaValues = valueSupport.getElements();
@@ -468,7 +480,7 @@
.getValue();
// Get any model errors/warnings
- MetaValue errors = managedObject.getProperty("errors").getValue();
+ MetaValue errors = managedObject.getProperty("errors").getValue();
//$NON-NLS-1$
if (errors != null) {
CollectionValueSupport errorValueSupport = (CollectionValueSupport) errors;
MetaValue[] errorArray = errorValueSupport.getElements();
@@ -478,13 +490,13 @@
return count;
}
- protected MetaValue getLongRunningQueries() {
+ protected MetaValue getLongRunningQueries(ProfileServiceConnection connection) {
MetaValue requestsCollection = null;
MetaValue args = null;
try {
- requestsCollection = executeManagedOperation(mc,
+ requestsCollection = executeManagedOperation(connection, mc,
Platform.Operations.GET_LONGRUNNINGQUERIES, args);
} catch (Exception e) {
final String msg = "Exception executing operation: " +
Platform.Operations.GET_LONGRUNNINGQUERIES; //$NON-NLS-1$
@@ -507,15 +519,15 @@
list.add(request);
} else {
throw new IllegalStateException(pValue
- + " is not a Composite type");
+ + " is not a Composite type"); //$NON-NLS-1$
}
}
}
}
- private Collection<Session> getSessionsForVDB(String vdbName) {
+ private Collection<Session> getSessionsForVDB(ProfileServiceConnection connection,
String vdbName) {
Collection<Session> activeSessionsCollection = Collections.emptyList();
- MetaValue sessionMetaValue = getSessions();
+ MetaValue sessionMetaValue = getSessions(connection);
getSessionCollectionValueForVDB(sessionMetaValue,
activeSessionsCollection, vdbName);
return activeSessionsCollection;
@@ -533,8 +545,8 @@
list.add(transaction);
} else {
throw new IllegalStateException(pValue
- + " is not a Composite type");
- }
+ + " is not a Composite type"); //$NON-NLS-1$
+ }
}
}
}
@@ -551,7 +563,7 @@
list.add(Session);
} else {
throw new IllegalStateException(pValue
- + " is not a Composite type");
+ + " is not a Composite type"); //$NON-NLS-1$
}
}
}
@@ -571,7 +583,7 @@
}
} else {
throw new IllegalStateException(pValue
- + " is not a Composite type");
+ + " is not a Composite type"); //$NON-NLS-1$
}
}
}
Modified: branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/Facet.java
===================================================================
--- branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/Facet.java 2010-07-27
17:38:29 UTC (rev 2380)
+++ branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/Facet.java 2010-07-27
23:06:31 UTC (rev 2381)
@@ -71,6 +71,8 @@
import org.rhq.core.pluginapi.measurement.MeasurementFacet;
import org.rhq.core.pluginapi.operation.OperationFacet;
import org.rhq.core.pluginapi.operation.OperationResult;
+import org.rhq.plugins.jbossas5.ProfileServiceComponent;
+import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection;
import org.teiid.rhq.admin.DQPManagementView;
import org.teiid.rhq.plugin.objects.ExecutedOperationResultImpl;
import org.teiid.rhq.plugin.objects.ExecutedResult;
@@ -82,7 +84,7 @@
* This class implements required RHQ interfaces and provides common logic used
* by all MetaMatrix components.
*/
-public abstract class Facet implements ResourceComponent, MeasurementFacet,
+public abstract class Facet implements ProfileServiceComponent<ResourceComponent>,
MeasurementFacet,
OperationFacet, ConfigurationFacet, ContentFacet, DeleteResourceFacet,
CreateChildResourceFacet {
@@ -146,6 +148,8 @@
deploymentName = context.getResourceKey();
}
+
+
/**
* This is called when the component is being stopped, usually due to the
* plugin container shutting down. You can perform some cleanup here; though
@@ -206,10 +210,10 @@
}
- protected void execute(final ExecutedResult result, final Map valueMap) {
+ protected void execute(final ProfileServiceConnection connection, final ExecutedResult
result, final Map valueMap) {
DQPManagementView dqp = new DQPManagementView();
- dqp.executeOperation(result, valueMap);
+ dqp.executeOperation(connection, result, valueMap);
}
@@ -267,7 +271,7 @@
setOperationArguments(name, configuration, valueMap);
- execute(result, valueMap);
+ execute(getConnection(), result, valueMap);
return ((ExecutedOperationResultImpl) result).getOperationResult();
@@ -328,8 +332,7 @@
report.setStatus(ConfigurationUpdateStatus.SUCCESS);
try {
- managementView = ProfileServiceUtil.getManagementView(
- ProfileServiceUtil.getProfileService(), true);
+ managementView = getConnection().getManagementView();
managedComponent = managementView.getComponent(this.name, componentType);
Map<String, ManagedProperty> managedProperties = managedComponent
.getProperties();
@@ -371,8 +374,7 @@
throws Exception {
log.trace("Updating " + this.name + " with component "
+ managedComponent.toString() + "...");
- ManagementView managementView = ProfileServiceUtil.getManagementView(
- ProfileServiceUtil.getProfileService(), false);
+ ManagementView managementView = getConnection().getManagementView();
managementView.updateComponent(managedComponent);
}
@@ -380,7 +382,7 @@
@Override
public void deleteResource() throws Exception {
- DeploymentManager deploymentManager = ProfileServiceUtil
+ DeploymentManager deploymentManager = getConnection()
.getDeploymentManager();
log.debug("Stopping deployment [" + this.deploymentName + "]...");
@@ -512,14 +514,9 @@
.getComponentType(resourceType);
ManagementView managementView = null;
;
- try {
- managementView = ProfileServiceUtil.getManagementView(
- ProfileServiceUtil.getProfileService(), true);
- } catch (NamingException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- if (ProfileServiceUtil.isManagedComponent(managementView, resourceName,
+ managementView = getConnection().getManagementView();
+
+ if (ProfileServiceUtil.isManagedComponent(getConnection(), resourceName,
componentType)) {
createResourceReport.setStatus(CreateResourceStatus.FAILURE);
createResourceReport.setErrorMessage("A " + resourceType.getName()
@@ -593,7 +590,7 @@
}
- DeploymentManager deploymentManager = ProfileServiceUtil
+ DeploymentManager deploymentManager = getConnection()
.getDeploymentManager();
DeploymentUtils
.deployArchive(deploymentManager, archiveFile, false);
Modified:
branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java
===================================================================
---
branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java 2010-07-27
17:38:29 UTC (rev 2380)
+++
branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java 2010-07-27
23:06:31 UTC (rev 2381)
@@ -34,6 +34,7 @@
import org.jboss.managed.api.ManagedComponent;
import org.jboss.managed.api.ManagedProperty;
import org.jboss.managed.api.RunState;
+import org.mc4j.ems.connection.EmsConnection;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
import org.rhq.core.domain.configuration.PropertySimple;
@@ -42,7 +43,12 @@
import org.rhq.core.domain.measurement.MeasurementReport;
import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
+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.ApplicationServerComponent;
+import org.rhq.plugins.jbossas5.ProfileServiceComponent;
+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;
@@ -53,10 +59,11 @@
*
*/
public class PlatformComponent extends Facet {
- private final Log LOG = LogFactory.getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
+ private final Log LOG = LogFactory
+ .getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
- String[] PLATFORM_SERVICES_NAMES = {
"org.teiid.jboss.deployers.RuntimeEngineDeployer",
- "org.teiid.services.BufferServiceImpl",
"org.teiid.services.SessionServiceImpl",
"org.teiid.transport.SocketConfiguration" };
+ String[] PLATFORM_SERVICES_NAMES = { "RuntimeEngineDeployer", //$NON-NLS-1$
+ "BufferService", "SessionService",
"JdbcSocketConfiguration" }; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
/*
* (non-Javadoc)
@@ -86,15 +93,17 @@
RunState runState;
try {
- runState = ProfileServiceUtil.getDQPManagementView().getRunState();
+ ManagedComponent mc = ProfileServiceUtil
+ .getTeiidEngineManagedComponent(getConnection());
+ runState = mc.getRunState();
} catch (NamingException e) {
LOG
- .error("Naming exception getting: "
+ .error("Naming exception getting: " //$NON-NLS-1$
+ PluginConstants.ComponentType.Platform.TEIID_RUNTIME_ENGINE);
return AvailabilityType.DOWN;
} catch (Exception e) {
LOG
- .error("Exception getting: "
+ .error("Exception getting: " //$NON-NLS-1$
+ PluginConstants.ComponentType.Platform.TEIID_RUNTIME_ENGINE);
return AvailabilityType.DOWN;
}
@@ -137,10 +146,11 @@
// Initialize any parameters to be used in the retrieval of
// metric values
-
- Object metricReturnObject = view.getMetric(getComponentType(),
- this.getComponentIdentifier(), name, valueMap);
+ Object metricReturnObject = view.getMetric(getConnection(),
+ getComponentType(), this.getComponentIdentifier(),
+ name, valueMap);
+
try {
if (request
.getName()
@@ -205,37 +215,44 @@
ComponentType componentType = new ComponentType(
PluginConstants.ComponentType.Platform.TEIID_TYPE,
PluginConstants.ComponentType.Platform.TEIID_SUB_TYPE);
-
- ManagedComponent managedComponent = null;
- report.setStatus(ConfigurationUpdateStatus.SUCCESS);
try {
+ Set<ManagedComponent> mcSet = ProfileServiceUtil
+ .getManagedComponents(getConnection(), componentType);
- managementView = ProfileServiceUtil.getManagementView(
- ProfileServiceUtil.getProfileService(), true);
+ report.setStatus(ConfigurationUpdateStatus.SUCCESS);
- for (String serviceName : PLATFORM_SERVICES_NAMES) {
+ managementView = getConnection().getManagementView();
- managedComponent = managementView.getComponent(serviceName,
- componentType);
- Map<String, ManagedProperty> managedProperties = managedComponent
- .getProperties();
+ for (ManagedComponent mc : mcSet) {
- ProfileServiceUtil.convertConfigurationToManagedProperties(
- managedProperties, resourceConfig, resourceContext
- .getResourceType());
+ for (String serviceName : PLATFORM_SERVICES_NAMES) {
- try {
- managementView.updateComponent(managedComponent);
- } catch (Exception e) {
- LOG.error("Unable to update component ["
- + managedComponent.getName() + "] of type "
- + componentType + ".", e);
- report.setStatus(ConfigurationUpdateStatus.FAILURE);
- report.setErrorMessageFromThrowable(e);
+ if (mc.getComponentName().equals(serviceName)) {
+ Map<String, ManagedProperty> managedProperties = mc
+ .getProperties();
+
+ ProfileServiceUtil.convertConfigurationToManagedProperties(
+ managedProperties, resourceConfig, resourceContext
+ .getResourceType());
+
+ try {
+ managementView.updateComponent(mc);
+ } catch (Exception e) {
+ LOG.error("Unable to update component [" //$NON-NLS-1$
+ + mc.getComponentName()
+ + "] of type " //$NON-NLS-1$
+ + componentType + ".", e); //$NON-NLS-1$
+ report.setStatus(ConfigurationUpdateStatus.FAILURE);
+ report.setErrorMessageFromThrowable(e);
+ }
+ break;
+ }else{
+ continue;
+ }
}
}
} catch (Exception e) {
- LOG.error("Unable to process update request", e);
+ LOG.error("Unable to process update request", e); //$NON-NLS-1$
report.setStatus(ConfigurationUpdateStatus.FAILURE);
report.setErrorMessageFromThrowable(e);
}
@@ -270,16 +287,18 @@
Set<ManagedComponent> mcSet = null;
try {
mcSet = ProfileServiceUtil
- .getManagedComponents(new org.jboss.managed.api.ComponentType(
- PluginConstants.ComponentType.Platform.TEIID_TYPE,
- PluginConstants.ComponentType.Platform.TEIID_SUB_TYPE));
+ .getManagedComponents(
+ getConnection(),
+ new org.jboss.managed.api.ComponentType(
+ PluginConstants.ComponentType.Platform.TEIID_TYPE,
+ PluginConstants.ComponentType.Platform.TEIID_SUB_TYPE));
} catch (NamingException e) {
LOG
- .error("NamingException getting components in Platform loadConfiguration():
"
+ .error("NamingException getting components in Platform loadConfiguration():
" //$NON-NLS-1$
+ e.getMessage());
} catch (Exception e) {
LOG
- .error("Exception getting components in Platform loadConfiguration(): "
+ .error("Exception getting components in Platform loadConfiguration(): "
//$NON-NLS-1$
+ e.getMessage());
}
@@ -293,7 +312,8 @@
* @param mcMap
* @param configuration
*/
- private void setProperties(Map<String, ManagedProperty> mcMap, Configuration
configuration) {
+ private void setProperties(Map<String, ManagedProperty> mcMap,
+ Configuration configuration) {
for (ManagedProperty mProp : mcMap.values()) {
try {
String value = ProfileServiceUtil.stringValue(mProp.getValue());
@@ -301,10 +321,22 @@
configuration.put(prop);
} catch (Exception e) {
LOG
- .error("Exception setting properties in Platform loadConfiguration(): "
+ .error("Exception setting properties in Platform loadConfiguration(): "
//$NON-NLS-1$
+ e.getMessage());
}
}
}
+ @Override
+ public ProfileServiceConnection getConnection() {
+ return ((ApplicationServerComponent) this.resourceContext
+ .getParentResourceComponent()).getConnection();
+ }
+
+ @Override
+ public EmsConnection getEmsConnection() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
}
\ No newline at end of file
Modified:
branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/PlatformDiscoveryComponent.java
===================================================================
---
branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/PlatformDiscoveryComponent.java 2010-07-27
17:38:29 UTC (rev 2380)
+++
branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/PlatformDiscoveryComponent.java 2010-07-27
23:06:31 UTC (rev 2381)
@@ -34,6 +34,8 @@
import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.plugins.jbossas5.ApplicationServerComponent;
+import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection;
import org.teiid.rhq.plugin.util.PluginConstants;
import org.teiid.rhq.plugin.util.ProfileServiceUtil;
@@ -42,7 +44,8 @@
*/
public class PlatformDiscoveryComponent implements ResourceDiscoveryComponent {
- private final Log log = LogFactory.getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
+ private final Log log = LogFactory
+ .getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
/**
* Review the javadoc for both {@link ResourceDiscoveryComponent} and
@@ -57,14 +60,13 @@
Set<DiscoveredResourceDetails> discoveredResources = new
HashSet<DiscoveredResourceDetails>();
- ManagedComponent mc = ProfileServiceUtil.getManagedComponent(
- new ComponentType(
- PluginConstants.ComponentType.Platform.TEIID_TYPE,
- PluginConstants.ComponentType.Platform.TEIID_SUB_TYPE),
- PluginConstants.ComponentType.Platform.TEIID_RUNTIME_ENGINE);
-
- String version = ProfileServiceUtil.getSimpleValue(mc, "runtimeVersion",
String.class);
-
+ ManagedComponent mc = ProfileServiceUtil
+ .getTeiidEngineManagedComponent(((ApplicationServerComponent) discoveryContext
+ .getParentResourceComponent()).getConnection());
+
+ String version = ProfileServiceUtil.getSimpleValue(mc,
+ "runtimeVersion", String.class); //$NON-NLS-1$
+
/**
*
* A discovered resource must have a unique key, that must stay the same
@@ -73,7 +75,8 @@
DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
discoveryContext.getResourceType(), // ResourceType
mc.getName(), // Resource Key
- PluginConstants.ComponentType.Platform.TEIID_ENGINE_RESOURCE_NAME, // Resource name
+ PluginConstants.ComponentType.Platform.TEIID_ENGINE_RESOURCE_NAME, // Resource
+ // name
version,
PluginConstants.ComponentType.Platform.TEIID_ENGINE_RESOURCE_DESCRIPTION, //
Description
discoveryContext.getDefaultPluginConfiguration(), // Plugin
@@ -88,7 +91,7 @@
// Add to return values
discoveredResources.add(detail);
- log.info("Discovered Teiid instance: " + mc.getName());
+ log.info("Discovered Teiid instance: " + mc.getName()); //$NON-NLS-1$
return discoveredResources;
}
Modified:
branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/TranslatorComponent.java
===================================================================
---
branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/TranslatorComponent.java 2010-07-27
17:38:29 UTC (rev 2380)
+++
branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/TranslatorComponent.java 2010-07-27
23:06:31 UTC (rev 2381)
@@ -34,6 +34,7 @@
import org.jboss.metatype.api.types.MetaType;
import org.jboss.metatype.api.values.MetaValue;
import org.jboss.metatype.api.values.MetaValueFactory;
+import org.mc4j.ems.connection.EmsConnection;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertyList;
import org.rhq.core.domain.configuration.PropertyMap;
@@ -43,11 +44,12 @@
import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.core.pluginapi.measurement.MeasurementFacet;
+import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection;
import org.teiid.rhq.plugin.util.PluginConstants;
import org.teiid.rhq.plugin.util.ProfileServiceUtil;
/**
- * Component class for the MetaMatrix Host Controller process.
+ * Component class for the Teiid Translator.
*
*/
public class TranslatorComponent extends Facet {
@@ -131,7 +133,7 @@
ManagedComponent translator = null;
try {
translator = ProfileServiceUtil
- .getManagedComponent(new ComponentType(
+ .getManagedComponent(getConnection(), new ComponentType(
PluginConstants.ComponentType.Translator.TYPE,
PluginConstants.ComponentType.Translator.SUBTYPE), this.name);
} catch (NamingException e) {
@@ -183,4 +185,16 @@
}
+ @Override
+ public ProfileServiceConnection getConnection() {
+ return
((PlatformComponent)this.resourceContext.getParentResourceComponent()).getConnection();
+ }
+
+
+ @Override
+ public EmsConnection getEmsConnection() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
}
\ No newline at end of file
Modified:
branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/TranslatorDiscoveryComponent.java
===================================================================
---
branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/TranslatorDiscoveryComponent.java 2010-07-27
17:38:29 UTC (rev 2380)
+++
branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/TranslatorDiscoveryComponent.java 2010-07-27
23:06:31 UTC (rev 2381)
@@ -41,6 +41,8 @@
import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.plugins.jbossas5.ApplicationServerComponent;
+import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection;
import org.teiid.rhq.plugin.util.PluginConstants;
import org.teiid.rhq.plugin.util.ProfileServiceUtil;
@@ -56,9 +58,11 @@
ResourceDiscoveryContext discoveryContext)
throws InvalidPluginConfigurationException, Exception {
Set<DiscoveredResourceDetails> discoveredResources = new
HashSet<DiscoveredResourceDetails>();
-
+ ProfileServiceConnection connection = ((PlatformComponent) discoveryContext
+ .getParentResourceComponent()).getConnection();
+
Set<ManagedComponent> translators = ProfileServiceUtil
- .getManagedComponents(new ComponentType(
+ .getManagedComponents(connection, new ComponentType(
PluginConstants.ComponentType.Translator.TYPE,
PluginConstants.ComponentType.Translator.SUBTYPE));
Modified: branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java
===================================================================
--- branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java 2010-07-27
17:38:29 UTC (rev 2380)
+++ branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java 2010-07-27
23:06:31 UTC (rev 2381)
@@ -50,6 +50,7 @@
import org.jboss.metatype.api.values.MetaValueFactory;
import org.jboss.metatype.api.values.SimpleValue;
import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.mc4j.ems.connection.EmsConnection;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
import org.rhq.core.domain.configuration.Property;
@@ -64,7 +65,10 @@
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.adminapi.impl.PropertyMetadata;
import org.teiid.rhq.admin.DQPManagementView;
import org.teiid.rhq.plugin.util.PluginConstants;
@@ -132,7 +136,7 @@
// TODO Remove vdb version after no longer viable in Teiid
String version = this.resourceConfiguration.getSimpleValue(
"version", null);
- String status = DQPManagementView.getVDBStatus(this.name, Integer.parseInt(version));
+ String status = DQPManagementView.getVDBStatus(getConnection(), this.name,
Integer.parseInt(version));
if (status.equals("ACTIVE")) {
return AvailabilityType.UP;
}
@@ -162,7 +166,7 @@
String name = request.getName();
LOG.debug("Measurement name = " + name); //$NON-NLS-1$
- Object metricReturnObject = view.getMetric(getComponentType(), this
+ Object metricReturnObject = view.getMetric(getConnection(), getComponentType(), this
.getComponentIdentifier(), name, valueMap);
try {
@@ -255,8 +259,7 @@
report.setStatus(ConfigurationUpdateStatus.SUCCESS);
try {
- managementView = ProfileServiceUtil.getManagementView(
- ProfileServiceUtil.getProfileService(), true);
+ managementView = getConnection().getManagementView();
managedComponent = managementView.getComponent(this.name,
componentType);
ManagedProperty mp = managedComponent.getProperty("models");//$NON-NLS-1$
@@ -343,7 +346,7 @@
ManagedComponent mcVdb = null;
try {
- mcVdb = ProfileServiceUtil.getManagedComponent(
+ mcVdb = ProfileServiceUtil.getManagedComponent( getConnection(),
new org.jboss.managed.api.ComponentType(
PluginConstants.ComponentType.VDB.TYPE,
PluginConstants.ComponentType.VDB.SUBTYPE),
@@ -643,4 +646,16 @@
}
}
+ @Override
+ public ProfileServiceConnection getConnection() {
+ return
((PlatformComponent)this.resourceContext.getParentResourceComponent()).getConnection();
+ }
+
+
+ @Override
+ public EmsConnection getEmsConnection() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
}
Modified:
branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/VDBDiscoveryComponent.java
===================================================================
---
branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/VDBDiscoveryComponent.java 2010-07-27
17:38:29 UTC (rev 2380)
+++
branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/VDBDiscoveryComponent.java 2010-07-27
23:06:31 UTC (rev 2381)
@@ -34,6 +34,7 @@
import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection;
import org.teiid.rhq.plugin.util.PluginConstants;
import org.teiid.rhq.plugin.util.ProfileServiceUtil;
@@ -43,15 +44,18 @@
*/
public class VDBDiscoveryComponent implements ResourceDiscoveryComponent {
- private final Log log = LogFactory.getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
+ private final Log log = LogFactory
+ .getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
public Set<DiscoveredResourceDetails> discoverResources(
ResourceDiscoveryContext discoveryContext)
throws InvalidPluginConfigurationException, Exception {
Set<DiscoveredResourceDetails> discoveredResources = new
HashSet<DiscoveredResourceDetails>();
+ ProfileServiceConnection connection = ((PlatformComponent) discoveryContext
+ .getParentResourceComponent()).getConnection();
Set<ManagedComponent> vdbs = ProfileServiceUtil
- .getManagedComponents(new ComponentType(
+ .getManagedComponents(connection, new ComponentType(
PluginConstants.ComponentType.VDB.TYPE,
PluginConstants.ComponentType.VDB.SUBTYPE));
@@ -104,6 +108,5 @@
return discoveredResources;
}
-
}
\ No newline at end of file
Modified:
branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java
===================================================================
---
branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java 2010-07-27
17:38:29 UTC (rev 2380)
+++
branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java 2010-07-27
23:06:31 UTC (rev 2381)
@@ -33,10 +33,6 @@
* getting a handle to a specific component related to Teiid.
*/
- // The system key is the value used to obtain a connection.
- // In embedded, its a predefined value
- // In enterprise, its the installation directory
- // public final static String INSTALL_DIR = "install.dir";
//$NON-NLS-1$
/**
* These are global properties used by all components
*/
@@ -63,7 +59,8 @@
public final static String TEIID_SUB_TYPE = "dqp"; //$NON-NLS-1$
public final static String TYPE = "ConnectionFactory"; //$NON-NLS-1$
public final static String SUBTYPE = "NoTx"; //$NON-NLS-1$
- public final static String TEIID_RUNTIME_ENGINE =
"org.teiid.jboss.deployers.RuntimeEngineDeployer"; //$NON-NLS-1$
+ public final static String COMPNAME = "compName"; //$NON-NLS-1$
+ public final static String TEIID_RUNTIME_ENGINE = "RuntimeEngineDeployer";
//$NON-NLS-1$
public final static String TEIID_ENGINE_RESOURCE_NAME = "Data Services";
//$NON-NLS-1$
public final static String TEIID_ENGINE_RESOURCE_DESCRIPTION = "Teiid Data
Service Runtime Engine"; //$NON-NLS-1$
Modified:
branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java
===================================================================
---
branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java 2010-07-27
17:38:29 UTC (rev 2380)
+++
branches/7.0.x/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java 2010-07-27
23:06:31 UTC (rev 2381)
@@ -36,7 +36,6 @@
import java.util.Map;
import java.util.Set;
-import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.apache.commons.logging.Log;
@@ -70,6 +69,7 @@
import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
import org.rhq.core.domain.configuration.definition.PropertySimpleType;
import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection;
import org.teiid.rhq.plugin.TranslatorComponent;
import org.teiid.rhq.plugin.adapter.api.PropertyAdapter;
import org.teiid.rhq.plugin.adapter.api.PropertyAdapterFactory;
@@ -80,13 +80,11 @@
protected final static Log LOG = LogFactory
.getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
- private static ComponentType DQPTYPE = new ComponentType("teiid",
"dqp");
- private static String DQPNAME =
"org.teiid.jboss.deployers.RuntimeEngineDeployer";
+ private static ComponentType DQPTYPE = new ComponentType("teiid",
"dqp"); //$NON-NLS-1$ //$NON-NLS-2$
+ private static String DQPNAME = "RuntimeEngineDeployer"; //$NON-NLS-1$
private static final Map<String, ComponentType> COMPONENT_TYPE_CACHE = new
HashMap<String, ComponentType>();
- private static final Map<String, KnownDeploymentTypes> DEPLOYMENT_TYPE_CACHE = new
HashMap<String, KnownDeploymentTypes>();
- private static final Map<String, Configuration> DEFAULT_PLUGIN_CONFIG_CACHE = new
HashMap<String, Configuration>();
- protected static final String PLUGIN = "ProfileService";
+ protected static final String PLUGIN = "ProfileService"; //$NON-NLS-1$
public static ComponentType getComponentType(
@NotNull ResourceType resourceType) {
@@ -96,18 +94,18 @@
Configuration defaultPluginConfig = getDefaultPluginConfiguration(resourceType);
String type = defaultPluginConfig.getSimpleValue(
TranslatorComponent.Config.COMPONENT_TYPE, null);
- if (type == null || type.equals(""))
+ if (type == null || type.equals("")) //$NON-NLS-1$
throw new IllegalStateException(
- "Required plugin configuration property '"
+ "Required plugin configuration property '" //$NON-NLS-1$
+ TranslatorComponent.Config.COMPONENT_TYPE
- + "' is not defined in default template.");
+ + "' is not defined in default template."); //$NON-NLS-1$
String subtype = defaultPluginConfig.getSimpleValue(
TranslatorComponent.Config.COMPONENT_SUBTYPE, null);
- if (subtype == null || subtype.equals(""))
+ if (subtype == null || subtype.equals("")) //$NON-NLS-1$
throw new IllegalStateException(
- "Required plugin configuration property '"
+ "Required plugin configuration property '" //$NON-NLS-1$
+ TranslatorComponent.Config.COMPONENT_SUBTYPE
- + "' is not defined in default template.");
+ + "' is not defined in default template."); //$NON-NLS-1$
ComponentType componentType = new ComponentType(type, subtype);
COMPONENT_TYPE_CACHE.put(resourceTypeName, componentType);
return componentType;
@@ -127,13 +125,14 @@
* @param componentType
* @return
*/
- public static boolean isManagedComponent(ManagementView managementView,
- String name, ComponentType componentType) {
+ public static boolean isManagedComponent(
+ ProfileServiceConnection connection, String name,
+ ComponentType componentType) {
boolean isDeployed = false;
if (name != null) {
try {
- ManagedComponent component = getManagedComponent(componentType,
- name);
+ ManagedComponent component = getManagedComponent(connection,
+ componentType, name);
if (component != null)
isDeployed = true;
} catch (Exception e) {
@@ -154,13 +153,11 @@
* @throws Exception
*/
public static ManagedComponent getManagedComponent(
- ComponentType componentType, String componentName)
- throws NamingException, Exception {
- ProfileService ps = getProfileService();
- ManagementView mv = getManagementView(ps, true);
+ ProfileServiceConnection connection, ComponentType componentType,
+ String componentName) throws NamingException, Exception {
+ ManagedComponent mc = connection.getManagementView().getComponent(
+ componentName, componentType);
- ManagedComponent mc = mv.getComponent(componentName, componentType);
-
return mc;
}
@@ -174,16 +171,52 @@
* @throws Exception
*/
public static Set<ManagedComponent> getManagedComponents(
- ComponentType componentType) throws NamingException, Exception {
- ProfileService ps = getProfileService();
- ManagementView mv = getManagementView(ps, true);
+ ProfileServiceConnection connection, ComponentType componentType)
+ throws NamingException, Exception {
- Set<ManagedComponent> mcSet = mv.getComponentsForType(componentType);
+ Set<ManagedComponent> mcSet = connection.getManagementView()
+ .getComponentsForType(componentType);
return mcSet;
}
/**
+ * Get the {@link ManagedComponent} for the {@link ComponentType} and sub
+ * type.
+ *
+ * @return Set of {@link ManagedComponent}s
+ * @throws NamingException
+ * @throws Exception
+ */
+ public static ManagedComponent getTeiidEngineManagedComponent(
+ ProfileServiceConnection connection) throws NamingException,
+ Exception {
+
+ ManagedComponent mc = null;
+
+ try {
+ Set<ManagedComponent> mcSet = ProfileServiceUtil.getManagedComponents(
+ connection, new ComponentType(
+ PluginConstants.ComponentType.Platform.TEIID_TYPE,
+ PluginConstants.ComponentType.Platform.TEIID_SUB_TYPE));
+
+ for (ManagedComponent mcInstance : mcSet) {
+ String compName = (String) mcInstance.getComponentName();
+ if (compName != null
+ && compName
+ .equals(PluginConstants.ComponentType.Platform.TEIID_RUNTIME_ENGINE)) {
+ mc = mcInstance;
+ break;
+ }
+ }
+ }catch(RuntimeException e){
+ throw new Exception("Exception getting Teiid Runtime Engine: "+
e.getMessage()); //$NON-NLS-1$
+ }
+
+ return mc;
+ }
+
+ /**
* @param {@link ManagementView}
* @return
*/
@@ -203,39 +236,26 @@
* @throws NamingException
* @throws Exception
*/
- public static DeploymentManager getDeploymentManager()
- throws NamingException, Exception {
- ProfileService ps = getProfileService();
- DeploymentManager deploymentManager = ps.getDeploymentManager();
+ public static DeploymentManager getDeploymentManager(
+ ProfileServiceConnection connection) throws NamingException,
+ Exception {
- return deploymentManager;
+ return connection.getDeploymentManager();
}
/**
- * @return {@link ProfileService}
- * @throws NamingException
- * , Exception
- */
- public static ProfileService getProfileService() throws NamingException {
- InitialContext ic = new InitialContext();
- ProfileService ps = (ProfileService) ic
- .lookup(PluginConstants.PROFILE_SERVICE);
- return ps;
- }
-
- /**
* @return {@link File}
* @throws NamingException
* , Exception
*/
- public static File getDeployDirectory() throws NamingException, Exception {
- ProfileService ps = getProfileService();
- ManagementView mv = getManagementView(ps, false);
+ public static File getDeployDirectory(ProfileServiceConnection connection)
+ throws NamingException, Exception {
Set<ManagedDeployment> warDeployments;
try {
- warDeployments = mv
- .getDeploymentsForType(KnownDeploymentTypes.JavaEEWebApplication
- .getType());
+ warDeployments = connection
+ .getManagementView()
+ .getDeploymentsForType(
+ KnownDeploymentTypes.JavaEEWebApplication.getType());
} catch (Exception e) {
throw new IllegalStateException(e);
}
@@ -261,12 +281,6 @@
return deployDir;
}
- public static ManagedComponent getDQPManagementView()
- throws NamingException, Exception {
-
- return getManagedComponent(DQPTYPE, DQPNAME);
- }
-
public static String stringValue(MetaValue v1) throws Exception {
if (v1 != null) {
MetaType type = v1.getMetaType();
@@ -274,7 +288,7 @@
SimpleValue simple = (SimpleValue) v1;
return simple.getValue().toString();
}
- throw new Exception("Failed to convert value to string value");
+ throw new Exception("Failed to convert value to string value");
//$NON-NLS-1$
}
return null;
}
@@ -286,7 +300,7 @@
SimpleValue simple = (SimpleValue) v1;
return Boolean.valueOf(simple.getValue().toString());
}
- throw new Exception("Failed to convert value to boolean value");
+ throw new Exception("Failed to convert value to boolean value");
//$NON-NLS-1$
}
return null;
}
@@ -305,41 +319,43 @@
return expectedType.cast((enumValue != null) ? enumValue
.getValue() : null);
}
- throw new IllegalStateException(prop + " is not a simple type");
+ throw new IllegalStateException(prop + " is not a simple type");
//$NON-NLS-1$
}
return null;
}
-
- public static <T> T getSimpleValue(ManagedCommon mc, String prop, Class<T>
expectedType) {
- ManagedProperty mp = mc.getProperty(prop);
- if (mp != null) {
- MetaType metaType = mp.getMetaType();
- if (metaType.isSimple()) {
- SimpleValue simpleValue = (SimpleValue)mp.getValue();
- return expectedType.cast((simpleValue != null) ? simpleValue.getValue() :
null);
- }
- else if (metaType.isEnum()) {
- EnumValue enumValue = (EnumValue)mp.getValue();
- return expectedType.cast((enumValue != null) ? enumValue.getValue() : null);
- }
- throw new IllegalArgumentException(prop+ " is not a simple type");
//$NON-NLS-1$
- }
- return null;
- }
+ public static <T> T getSimpleValue(ManagedCommon mc, String prop,
+ Class<T> expectedType) {
+ ManagedProperty mp = mc.getProperty(prop);
+ if (mp != null) {
+ MetaType metaType = mp.getMetaType();
+ if (metaType.isSimple()) {
+ SimpleValue simpleValue = (SimpleValue) mp.getValue();
+ return expectedType.cast((simpleValue != null) ? simpleValue
+ .getValue() : null);
+ } else if (metaType.isEnum()) {
+ EnumValue enumValue = (EnumValue) mp.getValue();
+ return expectedType.cast((enumValue != null) ? enumValue
+ .getValue() : null);
+ }
+ throw new IllegalArgumentException(prop + " is not a simple type");
//$NON-NLS-1$
+ }
+ return null;
+ }
+
public static Map<String, PropertySimple> getCustomProperties(
Configuration pluginConfig) {
Map<String, PropertySimple> customProperties = new LinkedHashMap<String,
PropertySimple>();
if (pluginConfig == null)
return customProperties;
- PropertyMap customPropsMap = pluginConfig.getMap("custom-properties");
+ PropertyMap customPropsMap = pluginConfig.getMap("custom-properties");
//$NON-NLS-1$
if (customPropsMap != null) {
Collection<Property> customProps = customPropsMap.getMap().values();
for (Property customProp : customProps) {
if (!(customProp instanceof PropertySimple)) {
LOG
- .error("Custom property definitions in plugin configuration must be simple
properties - property "
- + customProp + " is not - ignoring...");
+ .error("Custom property definitions in plugin configuration must be simple
properties - property " //$NON-NLS-1$
+ + customProp + " is not - ignoring..."); //$NON-NLS-1$
continue;
}
customProperties.put(customProp.getName(),
@@ -365,14 +381,14 @@
if (!managedProperty.hasViewUse(ViewUse.STATISTIC))
LOG
.debug(resourceType
- + " does not define a property corresponding to ManagedProperty
'"
- + propName + "'.");
+ + " does not define a property corresponding to ManagedProperty '"
//$NON-NLS-1$
+ + propName + "'."); //$NON-NLS-1$
continue;
}
if (managedProperty == null) {
// This should never happen, but don't let it blow us up.
- LOG.error("ManagedProperty '" + propName
- + "' has a null value in the ManagedProperties Map.");
+ LOG.error("ManagedProperty '" + propName //$NON-NLS-1$
+ + "' has a null value in the ManagedProperties Map."); //$NON-NLS-1$
continue;
}
MetaValue metaValue = managedProperty.getValue();
@@ -390,12 +406,12 @@
.getPropertyAdapter(metaValue);
if (propertyAdapter == null) {
LOG
- .error("Unable to find a PropertyAdapter for ManagedProperty '"
+ .error("Unable to find a PropertyAdapter for ManagedProperty '"
//$NON-NLS-1$
+ propName
- + "' with MetaType ["
+ + "' with MetaType [" //$NON-NLS-1$
+ metaValue.getMetaType()
- + "] for ResourceType '"
- + resourceType.getName() + "'.");
+ + "] for ResourceType '" //$NON-NLS-1$
+ + resourceType.getName() + "'."); //$NON-NLS-1$
continue;
}
Property property = propertyAdapter.convertToProperty(metaValue,
@@ -414,19 +430,20 @@
String propertyName = managedProperty.getName();
PropertyDefinition propertyDefinition = configDefinition
.get(propertyName);
- if (propertyDefinition==null){
- //The managed property is not defined in the configuration
+ if (propertyDefinition == null) {
+ // The managed property is not defined in the configuration
continue;
}
populateManagedPropertyFromProperty(managedProperty,
- propertyDefinition, configuration);
- }
+ propertyDefinition, configuration);
+ }
return;
}
- public static void populateManagedPropertyFromProperty(ManagedProperty managedProperty,
+ public static void populateManagedPropertyFromProperty(
+ ManagedProperty managedProperty,
PropertyDefinition propertyDefinition, Configuration configuration) {
- // If the ManagedProperty defines a default value, assume it's more
+ // If the ManagedProperty defines a default value, assume it's more
// definitive than any default value that may
// have been defined in the plugin descriptor, and update the
// PropertyDefinition to use that as its default
@@ -438,29 +455,31 @@
MetaValue metaValue = managedProperty.getValue();
PropertyAdapter propertyAdapter = null;
if (metaValue != null) {
- LOG.trace("Populating existing MetaValue of type "
- + metaValue.getMetaType() + " from Teiid property "
- + propertyDefinition.getName() + " with definition " + propertyDefinition
- + "...");
+ LOG.trace("Populating existing MetaValue of type " //$NON-NLS-1$
+ + metaValue.getMetaType() + " from Teiid property " //$NON-NLS-1$
+ + propertyDefinition.getName() + " with definition " //$NON-NLS-1$
+ + propertyDefinition + "..."); //$NON-NLS-1$
propertyAdapter = PropertyAdapterFactory
- .getPropertyAdapter(metaValue);
-
- propertyAdapter.populateMetaValueFromProperty(configuration.getSimple(propertyDefinition.getName()),
metaValue,
- propertyDefinition);
+ .getPropertyAdapter(metaValue);
+
+ propertyAdapter.populateMetaValueFromProperty(configuration
+ .getSimple(propertyDefinition.getName()), metaValue,
+ propertyDefinition);
managedProperty.setValue(metaValue);
} else {
- MetaType metaType = managedProperty.getMetaType();
+ MetaType metaType = managedProperty.getMetaType();
if (propertyAdapter == null)
propertyAdapter = PropertyAdapterFactory
.getPropertyAdapter(metaType);
- LOG.trace("Converting property " + propertyDefinition.getName() + "
with definition "
- + propertyDefinition + " to MetaValue of type " + metaType
- + "...");
- metaValue =
propertyAdapter.convertToMetaValue(configuration.getSimple(propertyDefinition.getName()),
- propertyDefinition, metaType);
+ LOG.trace("Converting property " + propertyDefinition.getName()
//$NON-NLS-1$
+ + " with definition " + propertyDefinition //$NON-NLS-1$
+ + " to MetaValue of type " + metaType + "..."); //$NON-NLS-1$
//$NON-NLS-2$
+ metaValue = propertyAdapter.convertToMetaValue(configuration
+ .getSimple(propertyDefinition.getName()),
+ propertyDefinition, metaType);
managedProperty.setValue(metaValue);
}
-
+
}
private static void updateDefaultValueOnPropertyDefinition(
@@ -468,17 +487,16 @@
@NotNull MetaValue defaultValue) {
if (!(propertyDefinition instanceof PropertyDefinitionSimple)) {
LOG
- .debug("Cannot update default value on non-simple property definition "
- + propertyDefinition
- + "(default value is "
- + defaultValue + ").");
+ .debug("Cannot update default value on non-simple property definition "
//$NON-NLS-1$
+ + propertyDefinition + "(default value is " //$NON-NLS-1$
+ + defaultValue + ")."); //$NON-NLS-1$
return;
}
MetaType metaType = defaultValue.getMetaType();
if (!metaType.isSimple() && !metaType.isEnum()) {
- LOG.debug("Cannot update default value on " + propertyDefinition
- + ", because default value's type (" + metaType
- + ") is not simple or enum.");
+ LOG.debug("Cannot update default value on " + propertyDefinition
//$NON-NLS-1$
+ + ", because default value's type (" + metaType //$NON-NLS-1$
+ + ") is not simple or enum."); //$NON-NLS-1$
return;
}
PropertyDefinitionSimple propertyDefinitionSimple = (PropertyDefinitionSimple)
propertyDefinition;
@@ -525,88 +543,91 @@
}
return memberMetaType;
}
-
- private static MetaType convertPropertySimpleTypeToSimpleMetaType(PropertySimpleType
memberSimpleType)
- {
- MetaType memberMetaType;
- Class memberClass;
- switch (memberSimpleType)
- {
- case BOOLEAN:
- memberClass = Boolean.class;
- break;
- case INTEGER:
- memberClass = Integer.class;
- break;
- case LONG:
- memberClass = Long.class;
- break;
- case FLOAT:
- memberClass = Float.class;
- break;
- case DOUBLE:
- memberClass = Double.class;
- break;
- default:
- memberClass = String.class;
- break;
- }
- memberMetaType = SimpleMetaType.resolve(memberClass.getName());
- return memberMetaType;
- }
-
- public static SimpleValue wrap(MetaType type, String value) throws Exception {
- if (type instanceof SimpleMetaType) {
- SimpleMetaType st = (SimpleMetaType)type;
-
- if (SimpleMetaType.BIGDECIMAL.equals(st)) {
- return new SimpleValueSupport(st, new BigDecimal(value));
- } else if (SimpleMetaType.BIGINTEGER.equals(st)) {
- return new SimpleValueSupport(st, new BigInteger(value));
- } else if (SimpleMetaType.BOOLEAN.equals(st)) {
- return new SimpleValueSupport(st, Boolean.valueOf(value));
- } else if (SimpleMetaType.BOOLEAN_PRIMITIVE.equals(st)) {
- return new SimpleValueSupport(st, Boolean.valueOf(value).booleanValue());
- } else if (SimpleMetaType.BYTE.equals(st)) {
- return new SimpleValueSupport(st, new Byte(value.getBytes()[0]));
- } else if (SimpleMetaType.BYTE_PRIMITIVE.equals(st)) {
- return new SimpleValueSupport(st, value.getBytes()[0]);
- } else if (SimpleMetaType.CHARACTER.equals(st)) {
- return new SimpleValueSupport(st, new Character(value.charAt(0)));
- } else if (SimpleMetaType.CHARACTER_PRIMITIVE.equals(st)) {
- return new SimpleValueSupport(st,value.charAt(0));
- } else if (SimpleMetaType.DATE.equals(st)) {
- try {
- return new SimpleValueSupport(st, SimpleDateFormat.getInstance().parse(value));
- } catch (ParseException e) {
- throw new Exception("Failed to convert value to SimpleValue", e);
//$NON-NLS-1$
- }
- } else if (SimpleMetaType.DOUBLE.equals(st)) {
- return new SimpleValueSupport(st, Double.valueOf(value));
- } else if (SimpleMetaType.DOUBLE_PRIMITIVE.equals(st)) {
- return new SimpleValueSupport(st, Double.parseDouble(value));
- } else if (SimpleMetaType.FLOAT.equals(st)) {
- return new SimpleValueSupport(st, Float.parseFloat(value));
- } else if (SimpleMetaType.FLOAT_PRIMITIVE.equals(st)) {
- return new SimpleValueSupport(st, Float.valueOf(value));
- } else if (SimpleMetaType.INTEGER.equals(st)) {
- return new SimpleValueSupport(st, Integer.valueOf(value));
- } else if (SimpleMetaType.INTEGER_PRIMITIVE.equals(st)) {
- return new SimpleValueSupport(st, Integer.parseInt(value));
- } else if (SimpleMetaType.LONG.equals(st)) {
- return new SimpleValueSupport(st, Long.valueOf(value));
- } else if (SimpleMetaType.LONG_PRIMITIVE.equals(st)) {
- return new SimpleValueSupport(st, Long.parseLong(value));
- } else if (SimpleMetaType.SHORT.equals(st)) {
- return new SimpleValueSupport(st, Short.valueOf(value));
- } else if (SimpleMetaType.SHORT_PRIMITIVE.equals(st)) {
- return new SimpleValueSupport(st, Short.parseShort(value));
- } else if (SimpleMetaType.STRING.equals(st)) {
- return new SimpleValueSupport(st,value);
+
+ private static MetaType convertPropertySimpleTypeToSimpleMetaType(
+ PropertySimpleType memberSimpleType) {
+ MetaType memberMetaType;
+ Class memberClass;
+ switch (memberSimpleType) {
+ case BOOLEAN:
+ memberClass = Boolean.class;
+ break;
+ case INTEGER:
+ memberClass = Integer.class;
+ break;
+ case LONG:
+ memberClass = Long.class;
+ break;
+ case FLOAT:
+ memberClass = Float.class;
+ break;
+ case DOUBLE:
+ memberClass = Double.class;
+ break;
+ default:
+ memberClass = String.class;
+ break;
+ }
+ memberMetaType = SimpleMetaType.resolve(memberClass.getName());
+ return memberMetaType;
+ }
+
+ public static SimpleValue wrap(MetaType type, String value)
+ throws Exception {
+ if (type instanceof SimpleMetaType) {
+ SimpleMetaType st = (SimpleMetaType) type;
+
+ if (SimpleMetaType.BIGDECIMAL.equals(st)) {
+ return new SimpleValueSupport(st, new BigDecimal(value));
+ } else if (SimpleMetaType.BIGINTEGER.equals(st)) {
+ return new SimpleValueSupport(st, new BigInteger(value));
+ } else if (SimpleMetaType.BOOLEAN.equals(st)) {
+ return new SimpleValueSupport(st, Boolean.valueOf(value));
+ } else if (SimpleMetaType.BOOLEAN_PRIMITIVE.equals(st)) {
+ return new SimpleValueSupport(st, Boolean.valueOf(value)
+ .booleanValue());
+ } else if (SimpleMetaType.BYTE.equals(st)) {
+ return new SimpleValueSupport(st, new Byte(value.getBytes()[0]));
+ } else if (SimpleMetaType.BYTE_PRIMITIVE.equals(st)) {
+ return new SimpleValueSupport(st, value.getBytes()[0]);
+ } else if (SimpleMetaType.CHARACTER.equals(st)) {
+ return new SimpleValueSupport(st,
+ new Character(value.charAt(0)));
+ } else if (SimpleMetaType.CHARACTER_PRIMITIVE.equals(st)) {
+ return new SimpleValueSupport(st, value.charAt(0));
+ } else if (SimpleMetaType.DATE.equals(st)) {
+ try {
+ return new SimpleValueSupport(st, SimpleDateFormat
+ .getInstance().parse(value));
+ } catch (ParseException e) {
+ throw new Exception(
+ "Failed to convert value to SimpleValue", e); //$NON-NLS-1$
}
+ } else if (SimpleMetaType.DOUBLE.equals(st)) {
+ return new SimpleValueSupport(st, Double.valueOf(value));
+ } else if (SimpleMetaType.DOUBLE_PRIMITIVE.equals(st)) {
+ return new SimpleValueSupport(st, Double.parseDouble(value));
+ } else if (SimpleMetaType.FLOAT.equals(st)) {
+ return new SimpleValueSupport(st, Float.parseFloat(value));
+ } else if (SimpleMetaType.FLOAT_PRIMITIVE.equals(st)) {
+ return new SimpleValueSupport(st, Float.valueOf(value));
+ } else if (SimpleMetaType.INTEGER.equals(st)) {
+ return new SimpleValueSupport(st, Integer.valueOf(value));
+ } else if (SimpleMetaType.INTEGER_PRIMITIVE.equals(st)) {
+ return new SimpleValueSupport(st, Integer.parseInt(value));
+ } else if (SimpleMetaType.LONG.equals(st)) {
+ return new SimpleValueSupport(st, Long.valueOf(value));
+ } else if (SimpleMetaType.LONG_PRIMITIVE.equals(st)) {
+ return new SimpleValueSupport(st, Long.parseLong(value));
+ } else if (SimpleMetaType.SHORT.equals(st)) {
+ return new SimpleValueSupport(st, Short.valueOf(value));
+ } else if (SimpleMetaType.SHORT_PRIMITIVE.equals(st)) {
+ return new SimpleValueSupport(st, Short.parseShort(value));
+ } else if (SimpleMetaType.STRING.equals(st)) {
+ return new SimpleValueSupport(st, value);
}
- throw new Exception("Failed to convert value to SimpleValue");
//$NON-NLS-1$
- }
+ }
+ throw new Exception("Failed to convert value to SimpleValue"); //$NON-NLS-1$
+ }
-
}