Author: tejones
Date: 2010-07-14 14:29:05 -0400 (Wed, 14 Jul 2010)
New Revision: 2344
Modified:
trunk/console/pom.xml
trunk/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java
trunk/console/src/main/java/org/teiid/rhq/plugin/Facet.java
trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java
trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformDiscoveryComponent.java
trunk/console/src/main/java/org/teiid/rhq/plugin/TranslatorComponent.java
trunk/console/src/main/java/org/teiid/rhq/plugin/TranslatorDiscoveryComponent.java
trunk/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java
trunk/console/src/main/java/org/teiid/rhq/plugin/VDBDiscoveryComponent.java
trunk/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java
trunk/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java
Log:
TEIID-1152 - Changed to use the ProfileServiceConnection from the JBossAs5 plugin
Modified: trunk/console/pom.xml
===================================================================
--- trunk/console/pom.xml 2010-07-14 17:25:17 UTC (rev 2343)
+++ trunk/console/pom.xml 2010-07-14 18:29:05 UTC (rev 2344)
@@ -1,7 +1,5 @@
<?xml version="1.0"?>
-<project
-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd"
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>teiid</artifactId>
<groupId>org.jboss.teiid</groupId>
@@ -18,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>
@@ -59,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>
@@ -129,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>
@@ -152,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: trunk/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java 2010-07-14
17:25:17 UTC (rev 2343)
+++ trunk/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java 2010-07-14
18:29:05 UTC (rev 2344)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
package org.teiid.rhq.admin;
import java.lang.reflect.Method;
@@ -22,6 +43,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 +58,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 +70,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 +111,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 +148,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 +201,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 +212,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 +225,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 +234,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 +270,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 +287,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 +305,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 +325,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 +342,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 +358,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 +377,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 +401,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 +409,10 @@
* @param mc
* @return
*/
- private static ManagedComponent getDQPManagementView(ManagedComponent mc) {
+ private static ManagedComponent getDQPManagementView(
+ ProfileServiceConnection connection, ManagedComponent mc) {
try {
- mc = ProfileServiceUtil.getDQPManagementView();
+ mc = ProfileServiceUtil.getDQPManagementView(connection);
} catch (NamingException e) {
final String msg = "NamingException getting the DQPManagementView";
//$NON-NLS-1$
LOG.error(msg, e);
@@ -391,10 +423,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 +436,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 +457,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 +470,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 +490,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 +501,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 +511,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 +540,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 +566,8 @@
list.add(transaction);
} else {
throw new IllegalStateException(pValue
- + " is not a Composite type");
- }
+ + " is not a Composite type"); //$NON-NLS-1$
+ }
}
}
}
@@ -551,7 +584,7 @@
list.add(Session);
} else {
throw new IllegalStateException(pValue
- + " is not a Composite type");
+ + " is not a Composite type"); //$NON-NLS-1$
}
}
}
@@ -571,7 +604,7 @@
}
} else {
throw new IllegalStateException(pValue
- + " is not a Composite type");
+ + " is not a Composite type"); //$NON-NLS-1$
}
}
}
Modified: trunk/console/src/main/java/org/teiid/rhq/plugin/Facet.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/Facet.java 2010-07-14 17:25:17 UTC
(rev 2343)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/Facet.java 2010-07-14 18:29:05 UTC
(rev 2344)
@@ -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: trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java 2010-07-14
17:25:17 UTC (rev 2343)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java 2010-07-14
18:29:05 UTC (rev 2344)
@@ -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;
@@ -86,7 +92,7 @@
RunState runState;
try {
- runState = ProfileServiceUtil.getDQPManagementView().getRunState();
+ runState = ProfileServiceUtil.getDQPManagementView(getConnection()).getRunState();
} catch (NamingException e) {
LOG
.error("Naming exception getting: "
@@ -138,7 +144,7 @@
// Initialize any parameters to be used in the retrieval of
// metric values
- Object metricReturnObject = view.getMetric(getComponentType(),
+ Object metricReturnObject = view.getMetric(getConnection(), getComponentType(),
this.getComponentIdentifier(), name, valueMap);
try {
@@ -210,8 +216,7 @@
report.setStatus(ConfigurationUpdateStatus.SUCCESS);
try {
- managementView = ProfileServiceUtil.getManagementView(
- ProfileServiceUtil.getProfileService(), true);
+ managementView = getConnection().getManagementView();
for (String serviceName : PLATFORM_SERVICES_NAMES) {
@@ -270,7 +275,7 @@
Set<ManagedComponent> mcSet = null;
try {
mcSet = ProfileServiceUtil
- .getManagedComponents(new org.jboss.managed.api.ComponentType(
+ .getManagedComponents(getConnection(),new org.jboss.managed.api.ComponentType(
PluginConstants.ComponentType.Platform.TEIID_TYPE,
PluginConstants.ComponentType.Platform.TEIID_SUB_TYPE));
} catch (NamingException e) {
@@ -307,4 +312,15 @@
}
}
+ @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:
trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformDiscoveryComponent.java
===================================================================
---
trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformDiscoveryComponent.java 2010-07-14
17:25:17 UTC (rev 2343)
+++
trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformDiscoveryComponent.java 2010-07-14
18:29:05 UTC (rev 2344)
@@ -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;
@@ -56,14 +58,20 @@
throws InvalidPluginConfigurationException, Exception {
Set<DiscoveredResourceDetails> discoveredResources = new
HashSet<DiscoveredResourceDetails>();
-
- ManagedComponent mc = ProfileServiceUtil.getManagedComponent(
+ ProfileServiceConnection connection = ((ApplicationServerComponent)
discoveryContext.getParentResourceComponent()).getConnection();
+
+ ManagedComponent mc = ProfileServiceUtil.getManagedComponent(connection,
new ComponentType(
PluginConstants.ComponentType.Platform.TEIID_TYPE,
PluginConstants.ComponentType.Platform.TEIID_SUB_TYPE),
- PluginConstants.ComponentType.Platform.TEIID_RUNTIME_ENGINE);
+ PluginConstants.ComponentType.Platform.TEIID_RUNTIME_ENGINE);
- String version = ProfileServiceUtil.getSimpleValue(mc, "runtimeVersion",
String.class);
+ if (mc==null){
+ //No Teiid instance found
+ return discoveredResources;
+ }
+
+ String version = ProfileServiceUtil.getSimpleValue(mc, "runtimeVersion",
String.class); //$NON-NLS-1$
/**
*
@@ -88,7 +96,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: trunk/console/src/main/java/org/teiid/rhq/plugin/TranslatorComponent.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/TranslatorComponent.java 2010-07-14
17:25:17 UTC (rev 2343)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/TranslatorComponent.java 2010-07-14
18:29:05 UTC (rev 2344)
@@ -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:
trunk/console/src/main/java/org/teiid/rhq/plugin/TranslatorDiscoveryComponent.java
===================================================================
---
trunk/console/src/main/java/org/teiid/rhq/plugin/TranslatorDiscoveryComponent.java 2010-07-14
17:25:17 UTC (rev 2343)
+++
trunk/console/src/main/java/org/teiid/rhq/plugin/TranslatorDiscoveryComponent.java 2010-07-14
18:29:05 UTC (rev 2344)
@@ -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: trunk/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java 2010-07-14 17:25:17
UTC (rev 2343)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java 2010-07-14 18:29:05
UTC (rev 2344)
@@ -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: trunk/console/src/main/java/org/teiid/rhq/plugin/VDBDiscoveryComponent.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/VDBDiscoveryComponent.java 2010-07-14
17:25:17 UTC (rev 2343)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/VDBDiscoveryComponent.java 2010-07-14
18:29:05 UTC (rev 2344)
@@ -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: trunk/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java 2010-07-14
17:25:17 UTC (rev 2343)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java 2010-07-14
18:29:05 UTC (rev 2344)
@@ -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,7 @@
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 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: trunk/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java
===================================================================
---
trunk/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java 2010-07-14
17:25:17 UTC (rev 2343)
+++
trunk/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java 2010-07-14
18:29:05 UTC (rev 2344)
@@ -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;
@@ -79,15 +79,13 @@
public class ProfileServiceUtil {
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";
+ .getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
+ 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"; //$NON-NLS-1$
- protected static final String PLUGIN = "ProfileService";
-
public static ComponentType getComponentType(
@NotNull ResourceType resourceType) {
String resourceTypeName = resourceType.getName();
@@ -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 '"
- + TranslatorComponent.Config.COMPONENT_SUBTYPE
- + "' is not defined in default template.");
+ "Required plugin configuration property '" //$NON-NLS-1$
+ + TranslatorComponent.Config.COMPONENT_SUBTYPE
+ + "' 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;
}
@@ -173,13 +170,11 @@
* , Exception
* @throws Exception
*/
- public static Set<ManagedComponent> getManagedComponents(
+ public static Set<ManagedComponent> getManagedComponents(ProfileServiceConnection
connection,
ComponentType componentType) throws NamingException, Exception {
- ProfileService ps = getProfileService();
- ManagementView mv = getManagementView(ps, true);
+
+ Set<ManagedComponent> mcSet =
connection.getManagementView().getComponentsForType(componentType);
- Set<ManagedComponent> mcSet = mv.getComponentsForType(componentType);
-
return mcSet;
}
@@ -203,37 +198,21 @@
* @throws NamingException
* @throws Exception
*/
- public static DeploymentManager getDeploymentManager()
+ public static DeploymentManager getDeploymentManager(ProfileServiceConnection
connection)
throws NamingException, Exception {
- ProfileService ps = getProfileService();
- DeploymentManager deploymentManager = ps.getDeploymentManager();
- 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
+ warDeployments = connection.getManagementView()
.getDeploymentsForType(KnownDeploymentTypes.JavaEEWebApplication
.getType());
} catch (Exception e) {
@@ -261,10 +240,11 @@
return deployDir;
}
- public static ManagedComponent getDQPManagementView()
- throws NamingException, Exception {
+ public static ManagedComponent getDQPManagementView(
+ ProfileServiceConnection connection) throws NamingException,
+ Exception {
- return getManagedComponent(DQPTYPE, DQPNAME);
+ return getManagedComponent(connection, DQPTYPE, DQPNAME);
}
public static String stringValue(MetaValue v1) throws Exception {
@@ -274,7 +254,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 +266,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 +285,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 +347,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,13 +372,13 @@
.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() + "'.");
- continue;
+ + "] for ResourceType '" //$NON-NLS-1$
+ + resourceType.getName() + "'."); //$NON-NLS-1$
+ continue;
}
Property property = propertyAdapter.convertToProperty(metaValue,
propertyDefinition);
@@ -414,19 +396,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 +421,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 +453,17 @@
@NotNull MetaValue defaultValue) {
if (!(propertyDefinition instanceof PropertyDefinitionSimple)) {
LOG
- .debug("Cannot update default value on non-simple property definition "
+ .debug("Cannot update default value on non-simple property definition "
//$NON-NLS-1$
+ propertyDefinition
- + "(default value is "
- + defaultValue + ").");
+ + "(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 +510,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$
+ }
-
}