Author: rareddy
Date: 2011-07-04 15:09:19 -0400 (Mon, 04 Jul 2011)
New Revision: 3301
Added:
branches/as7/client/src/main/java/org/teiid/adminapi/AdminPlugin.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/MetadataMapper.java
branches/as7/client/src/main/resources/org/teiid/adminapi/
branches/as7/client/src/main/resources/org/teiid/adminapi/i18n.properties
branches/as7/client/src/test/resources/vdb-describe.txt
Removed:
branches/as7/client/src/main/java/org/teiid/adminapi/impl/CacheStatisticsMetadataMapper.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/RequestMetadataMapper.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/SessionMetadataMapper.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/TransactionMetadataMapper.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/TranslatorMetaData.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/TranslatorPropertyFactory.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/WorkerPoolStatisticsMetadataMapper.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineModelHandler.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidSubsystemDescription.java
branches/as7/runtime/src/test/java/org/teiid/deployers/TestManagedPropertyUtil.java
branches/as7/runtime/src/test/java/org/teiid/deployers/TestTranslatorMetadata.java
Modified:
branches/as7/client/src/main/java/org/teiid/adminapi/impl/CacheStatisticsMetadata.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/RequestMetadata.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/SourceMappingMetadata.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/TransactionMetadata.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/VDBTranslatorMetaData.java
branches/as7/client/src/main/java/org/teiid/adminapi/impl/WorkerPoolStatisticsMetadata.java
branches/as7/client/src/main/java/org/teiid/net/TeiidURL.java
branches/as7/client/src/main/java/org/teiid/net/socket/SocketServerConnection.java
branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestRequestMetadata.java
branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestSessionMetadata.java
branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestTransactionMetadata.java
branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java
branches/as7/engine/src/main/java/org/teiid/dqp/internal/datamgr/TranslatorRepository.java
branches/as7/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java
branches/as7/jboss-integration/pom.xml
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/OperationsConstants.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineAdd.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineOperationHandler.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidExtension.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
branches/as7/pom.xml
branches/as7/runtime/pom.xml
branches/as7/runtime/src/main/java/org/teiid/deployers/TranslatorUtil.java
branches/as7/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java
branches/as7/runtime/src/main/java/org/teiid/services/TeiidLoginContext.java
branches/as7/runtime/src/main/java/org/teiid/transport/LogonImpl.java
Log:
created model nodes for all the admin api and vdb stuff
Added: branches/as7/client/src/main/java/org/teiid/adminapi/AdminPlugin.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/AdminPlugin.java
(rev 0)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/AdminPlugin.java 2011-07-04
19:09:19 UTC (rev 3301)
@@ -0,0 +1,32 @@
+/*
+ * 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.adminapi;
+
+import java.util.ResourceBundle;
+
+import org.teiid.core.BundleUtil;
+
+public class AdminPlugin {
+ public static final String PLUGIN_ID = "org.teiid.adminapi" ;
//$NON-NLS-1$
+ public static final BundleUtil Util = new BundleUtil(PLUGIN_ID, PLUGIN_ID +
".i18n", ResourceBundle.getBundle(PLUGIN_ID + ".i18n")); //$NON-NLS-1$
//$NON-NLS-2$
+}
Property changes on:
branches/as7/client/src/main/java/org/teiid/adminapi/AdminPlugin.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
branches/as7/client/src/main/java/org/teiid/adminapi/impl/CacheStatisticsMetadata.java
===================================================================
---
branches/as7/client/src/main/java/org/teiid/adminapi/impl/CacheStatisticsMetadata.java 2011-07-01
20:26:47 UTC (rev 3300)
+++
branches/as7/client/src/main/java/org/teiid/adminapi/impl/CacheStatisticsMetadata.java 2011-07-04
19:09:19 UTC (rev 3301)
@@ -21,11 +21,8 @@
*/
package org.teiid.adminapi.impl;
-import org.jboss.managed.api.annotation.ManagementProperty;
-import org.jboss.metatype.api.annotations.MetaMapping;
import org.teiid.adminapi.CacheStatistics;
-(a)MetaMapping(CacheStatisticsMetadataMapper.class)
public class CacheStatisticsMetadata extends AdminObjectImpl implements CacheStatistics{
private static final long serialVersionUID = -3514505497661004560L;
@@ -35,7 +32,6 @@
private int requestCount;
@Override
- @ManagementProperty(description="Number of total requests made to the cache",
readOnly=true)
public int getRequestCount() {
return requestCount;
}
@@ -45,13 +41,11 @@
}
@Override
- @ManagementProperty(description="Cache hit ratio", readOnly=true)
public double getHitRatio() {
return this.hitRatio;
}
@Override
- @ManagementProperty(description="Total number of cache entries",
readOnly=true)
public int getTotalEntries() {
return this.totalEntries;
}
Deleted:
branches/as7/client/src/main/java/org/teiid/adminapi/impl/CacheStatisticsMetadataMapper.java
===================================================================
---
branches/as7/client/src/main/java/org/teiid/adminapi/impl/CacheStatisticsMetadataMapper.java 2011-07-01
20:26:47 UTC (rev 3300)
+++
branches/as7/client/src/main/java/org/teiid/adminapi/impl/CacheStatisticsMetadataMapper.java 2011-07-04
19:09:19 UTC (rev 3301)
@@ -1,58 +0,0 @@
-/*
- * 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.adminapi.impl;
-
-import org.jboss.dmr.ModelNode;
-import org.jboss.dmr.ModelType;
-
-public class CacheStatisticsMetadataMapper {
- private static final String HITRATIO = "hitRatio"; //$NON-NLS-1$
- private static final String TOTAL_ENTRIES = "totalEntries"; //$NON-NLS-1$
- private static final String REQUEST_COUNT = "requestCount"; //$NON-NLS-1$
-
-
- public static ModelNode wrap(CacheStatisticsMetadata object) {
- if (object == null)
- return null;
-
- ModelNode cache = new ModelNode();
- cache.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
-
- cache.get(TOTAL_ENTRIES).set(object.getTotalEntries());
- cache.get(HITRATIO).set(object.getHitRatio());
- cache.get(REQUEST_COUNT).set(object.getRequestCount());
-
- return cache;
- }
-
- public static CacheStatisticsMetadata unwrap(ModelNode node) {
- if (node == null)
- return null;
-
- CacheStatisticsMetadata cache = new CacheStatisticsMetadata();
- cache.setTotalEntries(node.get(TOTAL_ENTRIES).asInt());
- cache.setHitRatio(node.get(HITRATIO).asDouble());
- cache.setRequestCount(node.get(REQUEST_COUNT).asInt());
- return cache;
- }
-
-}
Modified:
branches/as7/client/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java
===================================================================
---
branches/as7/client/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java 2011-07-01
20:26:47 UTC (rev 3300)
+++
branches/as7/client/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java 2011-07-04
19:09:19 UTC (rev 3301)
@@ -25,16 +25,8 @@
import java.util.ArrayList;
import java.util.List;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.*;
-import org.jboss.managed.api.annotation.ManagementObject;
-import org.jboss.managed.api.annotation.ManagementObjectID;
-import org.jboss.managed.api.annotation.ManagementProperties;
-import org.jboss.managed.api.annotation.ManagementProperty;
import org.teiid.adminapi.DataPolicy;
@@ -44,7 +36,6 @@
"permissions",
"mappedRoleNames"
})
-(a)ManagementObject(properties=ManagementProperties.EXPLICIT)
public class DataPolicyMetadata implements DataPolicy, Serializable {
private static final long serialVersionUID = -4119646357275977190L;
@@ -70,8 +61,6 @@
protected List<String> mappedRoleNames = new ArrayList<String>();
@Override
- @ManagementProperty(description="Policy Name")
- @ManagementObjectID(type="policy")
public String getName() {
return name;
}
@@ -81,7 +70,6 @@
}
@Override
- @ManagementProperty(description="Policy Description")
public String getDescription() {
return description;
}
@@ -91,7 +79,6 @@
}
@Override
- @ManagementProperty(description="Permissions in a Data Policy", managed=true)
public List<DataPermission> getPermissions() {
return new ArrayList<DataPermission>(this.permissions.getMap().values());
}
@@ -110,7 +97,6 @@
}
@Override
- @ManagementProperty(description="Mapped Container role names mapped to this
policy")
public List<String> getMappedRoleNames() {
return mappedRoleNames;
}
@@ -150,7 +136,6 @@
"allowExecute",
"allowAlter"
})
- @ManagementObject(properties=ManagementProperties.EXPLICIT)
public static class PermissionMetaData implements DataPermission, Serializable {
private static final long serialVersionUID = 7034744531663164277L;
@@ -170,8 +155,6 @@
protected Boolean allowAlter;
@Override
- @ManagementProperty(description="Resource Name, for which permission
defined")
- //@ManagementObjectID(type="permission")
@XmlElement(name = "resource-name", required = true)
public String getResourceName() {
return resourceName;
@@ -182,7 +165,6 @@
}
@Override
- @ManagementProperty(description="Allows Create")
public Boolean getAllowCreate() {
return allowCreate;
}
@@ -192,7 +174,6 @@
}
@Override
- @ManagementProperty(description="Allows Read")
public Boolean getAllowRead() {
return allowRead;
}
@@ -202,7 +183,6 @@
}
@Override
- @ManagementProperty(description="Allows Update")
public Boolean getAllowUpdate() {
return allowUpdate;
}
@@ -212,7 +192,6 @@
}
@Override
- @ManagementProperty(description="Allows Delete")
public Boolean getAllowDelete() {
return allowDelete;
}
@@ -265,13 +244,11 @@
}
@Override
- @ManagementProperty(description="Allows Alter")
public Boolean getAllowAlter() {
return allowAlter;
}
@Override
- @ManagementProperty(description="Allows Execute")
public Boolean getAllowExecute() {
return allowExecute;
}
@@ -303,7 +280,6 @@
}
@Override
- @ManagementProperty(description="Indicates if the role is mapped to any
authenticated user.")
public boolean isAnyAuthenticated() {
return this.anyAuthenticated;
}
Added: branches/as7/client/src/main/java/org/teiid/adminapi/impl/MetadataMapper.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/impl/MetadataMapper.java
(rev 0)
+++
branches/as7/client/src/main/java/org/teiid/adminapi/impl/MetadataMapper.java 2011-07-04
19:09:19 UTC (rev 3301)
@@ -0,0 +1,1074 @@
+/*
+ * 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.adminapi.impl;
+
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.dmr.ModelNode;
+import org.jboss.dmr.ModelType;
+import org.teiid.adminapi.AdminPlugin;
+import org.teiid.adminapi.DataPolicy;
+import org.teiid.adminapi.Model;
+import org.teiid.adminapi.Translator;
+import org.teiid.adminapi.Request.ProcessingState;
+import org.teiid.adminapi.Request.ThreadState;
+import org.teiid.adminapi.VDB.ConnectionType;
+import org.teiid.adminapi.VDB.Status;
+import org.teiid.adminapi.impl.DataPolicyMetadata.PermissionMetaData;
+import org.teiid.adminapi.impl.ModelMetaData.ValidationError;
+
+
+public class MetadataMapper {
+ private static final String VDBNAME = "vdb-name"; //$NON-NLS-1$
+ private static final String CONNECTIONTYPE = "connection-type"; //$NON-NLS-1$
+ private static final String STATUS = "status"; //$NON-NLS-1$
+ private static final String VERSION = "vdb-version"; //$NON-NLS-1$
+ private static final String URL = "url"; //$NON-NLS-1$
+ private static final String MODELS = "models"; //$NON-NLS-1$
+ private static final String OVERRIDE_TRANSLATORS = "override-translators";
//$NON-NLS-1$
+ private static final String DESCRIPTION = "description"; //$NON-NLS-1$
+ private static final String PROPERTIES = "properties"; //$NON-NLS-1$
+ private static final String DYNAMIC = "dynamic"; //$NON-NLS-1$
+ private static final String DATA_POLICIES = "data-policies"; //$NON-NLS-1$
+
+
+ public static ModelNode wrap(VDBMetaData vdb) {
+ if (vdb == null) {
+ return null;
+ }
+ ModelNode node = new ModelNode();
+ node.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
+
+ node.get(VDBNAME).set(vdb.getName());
+ node.get(CONNECTIONTYPE).set(vdb.getConnectionType().toString());
+ node.get(STATUS).set(vdb.getStatus().toString());
+ node.get(VERSION).set(vdb.getVersion());
+ if (vdb.getUrl() != null) {
+ }
+ if (vdb.getDescription() != null) {
+ node.get(DESCRIPTION).set(vdb.getDescription());
+ }
+ node.get(DYNAMIC).set(vdb.isDynamic());
+
+ //PROPERTIES
+ List<PropertyMetadata> properties = vdb.getJAXBProperties();
+ if (properties!= null && !properties.isEmpty()) {
+ ModelNode propsNode = node.get(CHILDREN, PROPERTIES);
+ for (PropertyMetadata prop:properties) {
+ propsNode.add(PropertyMetaDataMapper.wrap(prop));
+ }
+ }
+
+ // MODELS
+ Map<String, ModelMetaData> models = vdb.getModelMetaDatas();
+ if (models != null && !models.isEmpty()) {
+ ModelNode modelNodes = node.get(CHILDREN, MODELS);
+ for(ModelMetaData model:models.values()) {
+ modelNodes.add(ModelMetadataMapper.wrap(model));
+ }
+ }
+
+ // OVERRIDE_TRANSLATORS
+ List<Translator> translators = vdb.getOverrideTranslators();
+ if (translators != null && !translators.isEmpty()) {
+ ModelNode translatorNodes = node.get(CHILDREN, OVERRIDE_TRANSLATORS);
+ for (Translator translator:translators) {
+ translatorNodes.add(VDBTranslatorMetaDataMapper.wrap((VDBTranslatorMetaData)translator));
+ }
+ }
+
+ // DATA_POLICIES
+ List<DataPolicy> policies = vdb.getDataPolicies();
+ if (policies != null && !policies.isEmpty()) {
+ ModelNode dataPoliciesNodes = node.get(CHILDREN, DATA_POLICIES);
+ for (DataPolicy policy:policies) {
+ dataPoliciesNodes.add(DataPolicyMetadataMapper.wrap((DataPolicyMetadata)policy));
+ }
+ }
+ return node;
+ }
+
+ public static VDBMetaData unwrap(ModelNode node) {
+ if (node == null)
+ return null;
+
+ VDBMetaData vdb = new VDBMetaData();
+ if (node.has(VDBNAME)) {
+ vdb.setName(node.get(VDBNAME).asString());
+ }
+ if (node.has(CONNECTIONTYPE)) {
+ vdb.setConnectionType(node.get(CONNECTIONTYPE).asString());
+ }
+ if (node.has(STATUS)) {
+ vdb.setStatus(node.get(STATUS).asString());
+ }
+ if (node.has(VERSION)) {
+ vdb.setVersion(node.get(VERSION).asInt());
+ }
+ if (node.has(URL)) {
+ vdb.setUrl(node.get(URL).asString());
+ }
+ if(node.has(DESCRIPTION)) {
+ vdb.setDescription(node.get(DESCRIPTION).asString());
+ }
+ if (node.has(DYNAMIC)) {
+ vdb.setDynamic(node.get(DYNAMIC).asBoolean());
+ }
+
+ //PROPERTIES
+ if (node.get(CHILDREN, PROPERTIES).isDefined()) {
+ List<ModelNode> propNodes = node.get(CHILDREN, PROPERTIES).asList();
+ for (ModelNode propNode:propNodes) {
+ PropertyMetadata prop = PropertyMetaDataMapper.unwrap(propNode);
+ if (prop != null) {
+ vdb.addProperty(prop.getName(), prop.getValue());
+ }
+ }
+ }
+
+ // MODELS
+ if (node.get(CHILDREN, MODELS).isDefined()) {
+ List<ModelNode> modelNodes = node.get(CHILDREN, MODELS).asList();
+ for(ModelNode modelNode:modelNodes) {
+ ModelMetaData model = ModelMetadataMapper.unwrap(modelNode);
+ if (model != null) {
+ vdb.addModel(model);
+ }
+ }
+ }
+
+ // OVERRIDE_TRANSLATORS
+ if (node.get(CHILDREN, OVERRIDE_TRANSLATORS).isDefined()) {
+ List<ModelNode> translatorNodes = node.get(CHILDREN,
OVERRIDE_TRANSLATORS).asList();
+ for (ModelNode translatorNode:translatorNodes) {
+ VDBTranslatorMetaData translator =
VDBTranslatorMetaDataMapper.unwrap(translatorNode);
+ if (translator != null) {
+ vdb.addOverideTranslator(translator);
+ }
+ }
+ }
+
+ // DATA_POLICIES
+ if (node.get(CHILDREN, DATA_POLICIES).isDefined()) {
+ List<ModelNode> policiesNodes = node.get(CHILDREN, DATA_POLICIES).asList();
+ for (ModelNode policyNode:policiesNodes) {
+ DataPolicyMetadata policy = DataPolicyMetadataMapper.unwrap(policyNode);
+ if (policy != null) {
+ vdb.addDataPolicy(policy);
+ }
+
+ }
+ }
+ return vdb;
+ }
+
+ public static ModelNode describe(ModelNode node) {
+ node.get(TYPE).set(ModelType.OBJECT);
+ addAttribute(node, VDBNAME, ModelType.STRING, true);
+
+ ModelNode connectionsAllowed = new ModelNode();
+ connectionsAllowed.add(ConnectionType.NONE.toString());
+ connectionsAllowed.add(ConnectionType.ANY.toString());
+ connectionsAllowed.add(ConnectionType.BY_VERSION.toString());
+ addAttribute(node, CONNECTIONTYPE, ModelType.STRING,
false).get(ALLOWED).set(connectionsAllowed);
+
+ ModelNode statusAllowed = new ModelNode();
+ statusAllowed.add(Status.ACTIVE.toString());
+ statusAllowed.add(Status.INACTIVE.toString());
+ addAttribute(node, STATUS, ModelType.STRING, true).get(ALLOWED).set(statusAllowed);
+
+ addAttribute(node, VERSION,
ModelType.INT, true);
+ addAttribute(node, URL, ModelType.STRING, false);
+ addAttribute(node, DESCRIPTION, ModelType.STRING, false);
+ addAttribute(node, DYNAMIC, ModelType.BOOLEAN, false);
+
+ ModelNode props = node.get(CHILDREN, PROPERTIES);
+ props.get(DESCRIPTION).set(AdminPlugin.Util.getString(PROPERTIES+DOT_DESC));
+ PropertyMetaDataMapper.describe(props);
+
+ ModelNode models = node.get(CHILDREN, MODELS);
+ ModelMetadataMapper.describe(models);
+ models.get(DESCRIPTION).set(AdminPlugin.Util.getString(MODELS+DOT_DESC));
+ models.get(MIN_OCCURS).set(1);
+
+ ModelNode translators = node.get(CHILDREN, OVERRIDE_TRANSLATORS);
+ translators.get(DESCRIPTION).set(AdminPlugin.Util.getString(OVERRIDE_TRANSLATORS+DOT_DESC));
+ VDBTranslatorMetaDataMapper.describe(translators);
+
+ ModelNode dataPolicies = node.get(CHILDREN, DATA_POLICIES);
+ dataPolicies.get(DESCRIPTION).set(AdminPlugin.Util.getString(DATA_POLICIES+DOT_DESC));
+ DataPolicyMetadataMapper.describe(dataPolicies);
+ return node;
+ }
+
+ /**
+ * model metadata mapper
+ */
+ public static class ModelMetadataMapper {
+ private static final String MODEL_NAME = "model-name"; //$NON-NLS-1$
+ private static final String DESCRIPTION = "description"; //$NON-NLS-1$
+ private static final String VISIBLE = "visible"; //$NON-NLS-1$
+ private static final String MODEL_TYPE = "model-type"; //$NON-NLS-1$
+ private static final String MODELPATH = "model-path"; //$NON-NLS-1$
+ private static final String PROPERTIES = "properties"; //$NON-NLS-1$
+ private static final String SOURCE_MAPPINGS = "source-mappings";
//$NON-NLS-1$
+ private static final String VALIDITY_ERRORS = "validity-errors";
//$NON-NLS-1$
+
+ public static ModelNode wrap(ModelMetaData model) {
+ if (model == null) {
+ return null;
+ }
+ ModelNode node = new ModelNode();
+ node.get(TYPE).set(ModelType.OBJECT);
+
+ node.get(MODEL_NAME).set(model.getName());
+ if (model.getDescription() != null) {
+ node.get(DESCRIPTION).set(model.getDescription());
+ }
+ node.get(VISIBLE).set(model.isVisible());
+ node.get(MODEL_TYPE).set(model.getModelType().toString());
+ if (model.getPath() != null) {
+ node.get(MODELPATH).set(model.getPath());
+ }
+
+ List<PropertyMetadata> properties = model.getJAXBProperties();
+ if (properties!= null && !properties.isEmpty()) {
+ ModelNode propsNode = node.get(CHILDREN, PROPERTIES);
+ for (PropertyMetadata prop:properties) {
+ propsNode.add(PropertyMetaDataMapper.wrap(prop));
+ }
+ }
+
+ List<SourceMappingMetadata> sources = model.getSourceMappings();
+ if (sources != null && !sources.isEmpty()) {
+ ModelNode sourceMappingNode = node.get(CHILDREN, SOURCE_MAPPINGS);
+ for(SourceMappingMetadata source:sources) {
+ sourceMappingNode.add(SourceMappingMetadataMapper.wrap(source));
+ }
+ }
+
+ List<ValidationError> errors = model.getErrors();
+ if (errors != null && !errors.isEmpty()) {
+ ModelNode errorsNode = node.get(CHILDREN, VALIDITY_ERRORS);
+ for (ValidationError error:errors) {
+ errorsNode.add(ValidationErrorMapper.wrap(error));
+ }
+ }
+ return node;
+ }
+
+ public static ModelMetaData unwrap(ModelNode node) {
+ if (node == null) {
+ return null;
+ }
+
+ ModelMetaData model = new ModelMetaData();
+ if (node.has(MODEL_NAME)) {
+ model.setName(node.get(MODEL_NAME).asString());
+ }
+ if (node.has(DESCRIPTION)) {
+ model.setDescription(node.get(DESCRIPTION).asString());
+ }
+ if (node.has(VISIBLE)) {
+ model.setVisible(node.get(VISIBLE).asBoolean());
+ }
+ if(node.has(MODEL_TYPE)) {
+ model.setModelType(node.get(MODEL_TYPE).asString());
+ }
+ if(node.has(MODELPATH)) {
+ model.setPath(node.get(MODELPATH).asString());
+ }
+
+ if (node.get(CHILDREN, PROPERTIES).isDefined()) {
+ List<ModelNode> propNodes = node.get(CHILDREN, PROPERTIES).asList();
+ for (ModelNode propNode:propNodes) {
+ PropertyMetadata prop = PropertyMetaDataMapper.unwrap(propNode);
+ if (prop != null) {
+ model.addProperty(prop.getName(), prop.getValue());
+ }
+ }
+ }
+
+ if (node.get(CHILDREN, SOURCE_MAPPINGS).isDefined()) {
+ List<ModelNode> sourceMappingNodes = node.get(CHILDREN,
SOURCE_MAPPINGS).asList();
+ for (ModelNode sourceMapping:sourceMappingNodes) {
+ SourceMappingMetadata source = SourceMappingMetadataMapper.unwrap(sourceMapping);
+ if (source != null) {
+ model.addSourceMapping(source);
+ }
+ }
+ }
+
+ if (node.get(CHILDREN, VALIDITY_ERRORS).isDefined()) {
+ List<ModelNode> errorNodes = node.get(CHILDREN, VALIDITY_ERRORS).asList();
+ for(ModelNode errorNode:errorNodes) {
+ ValidationError error = ValidationErrorMapper.unwrap(errorNode);
+ if (error != null) {
+ model.addError(error);
+ }
+ }
+ }
+ return model;
+ }
+
+ public static ModelNode describe(ModelNode node) {
+ node.get(TYPE).set(ModelType.OBJECT);
+
+ ModelNode modelTypes = new ModelNode();
+ modelTypes.add(Model.Type.PHYSICAL.toString());
+ modelTypes.add(Model.Type.VIRTUAL.toString());
+ modelTypes.add(Model.Type.FUNCTION.toString());
+ modelTypes.add(Model.Type.OTHER.toString());
+ addAttribute(node, MODEL_NAME, ModelType.STRING, true).get(ALLOWED).set(modelTypes);
+
+ addAttribute(node, DESCRIPTION, ModelType.STRING, false);
+ addAttribute(node, VISIBLE, ModelType.BOOLEAN, false);
+ addAttribute(node, MODEL_TYPE, ModelType.STRING, true);
+ addAttribute(node, MODELPATH, ModelType.STRING, false);
+
+ ModelNode props = node.get(CHILDREN, PROPERTIES);
+ props.get(DESCRIPTION).set(AdminPlugin.Util.getString(PROPERTIES+DOT_DESC));
+ PropertyMetaDataMapper.describe(props);
+
+ ModelNode source = node.get(CHILDREN, SOURCE_MAPPINGS);
+ source.get(DESCRIPTION).set(AdminPlugin.Util.getString(SOURCE_MAPPINGS+DOT_DESC));
+ SourceMappingMetadataMapper.describe(source);
+
+ ModelNode errors = node.get(CHILDREN, VALIDITY_ERRORS);
+ errors.get(DESCRIPTION).set(AdminPlugin.Util.getString(VALIDITY_ERRORS+DOT_DESC));
+ ValidationErrorMapper.describe(errors);
+
+ return node;
+ }
+ }
+
+ /**
+ * validation error mapper
+ */
+ public static class ValidationErrorMapper {
+ private static final String ERROR_PATH = "error-path"; //$NON-NLS-1$
+ private static final String SEVERITY = "severity"; //$NON-NLS-1$
+ private static final String MESSAGE = "message"; //$NON-NLS-1$
+
+ public static ModelNode wrap(ValidationError error) {
+ if (error == null) {
+ return null;
+ }
+
+ ModelNode node = new ModelNode();
+ node.get(TYPE).set(ModelType.OBJECT);
+ if (error.getPath() != null) {
+ node.get(ERROR_PATH).set(error.getPath());
+ }
+ node.get(SEVERITY).set(error.getSeverity());
+ node.get(MESSAGE).set(error.getValue());
+
+ return node;
+ }
+
+ public static ValidationError unwrap(ModelNode node) {
+ if (node == null) {
+ return null;
+ }
+
+ ValidationError error = new ValidationError();
+ if (node.has(ERROR_PATH)) {
+ error.setPath(node.get(ERROR_PATH).asString());
+ }
+ if (node.has(SEVERITY)) {
+ error.setSeverity(node.get(SEVERITY).asString());
+ }
+ if(node.has(MESSAGE)) {
+ error.setValue(node.get(MESSAGE).asString());
+ }
+ return error;
+ }
+
+ public static ModelNode describe(ModelNode node) {
+ node.get(TYPE).set(ModelType.OBJECT);
+ addAttribute(node, ERROR_PATH, ModelType.STRING, false);
+ addAttribute(node, SEVERITY, ModelType.STRING, true);
+ addAttribute(node, MESSAGE, ModelType.STRING, true);
+ return node;
+ }
+ }
+
+ /**
+ * Source Mapping Metadata mapper
+ */
+ public static class SourceMappingMetadataMapper {
+ private static final String SOURCE_NAME = "source-name"; //$NON-NLS-1$
+ private static final String JNDI_NAME = "jndi-name"; //$NON-NLS-1$
+ private static final String TRANSLATOR_NAME = "translator-name";
//$NON-NLS-1$
+
+ public static ModelNode wrap(SourceMappingMetadata source) {
+ if (source == null) {
+ return null;
+ }
+
+ ModelNode node = new ModelNode();
+ node.get(TYPE).set(ModelType.OBJECT);
+
+ node.get(SOURCE_NAME).set(source.getName());
+ node.get(JNDI_NAME).set(source.getConnectionJndiName());
+ node.get(TRANSLATOR_NAME).set(source.getTranslatorName());
+ return node;
+ }
+
+ public static SourceMappingMetadata unwrap(ModelNode node) {
+ if (node == null) {
+ return null;
+ }
+ SourceMappingMetadata source = new SourceMappingMetadata();
+ if (node.has(SOURCE_NAME)) {
+ source.setName(node.get(SOURCE_NAME).asString());
+ }
+ if (node.has(JNDI_NAME)) {
+ source.setConnectionJndiName(node.get(JNDI_NAME).asString());
+ }
+ if (node.has(TRANSLATOR_NAME)) {
+ source.setTranslatorName(node.get(TRANSLATOR_NAME).asString());
+ }
+ return source;
+ }
+
+ public static ModelNode describe(ModelNode node) {
+ node.get(TYPE).set(ModelType.OBJECT);
+ addAttribute(node, SOURCE_NAME, ModelType.STRING, true);
+ addAttribute(node, JNDI_NAME, ModelType.STRING, true);
+ addAttribute(node, TRANSLATOR_NAME, ModelType.STRING, true);
+ return node;
+ }
+ }
+
+ /**
+ * Source Mapping Metadata mapper
+ */
+ public static class VDBTranslatorMetaDataMapper {
+ private static final String TRANSLATOR_NAME = "translator-name";
//$NON-NLS-1$
+ private static final String BASETYPE = "base-type"; //$NON-NLS-1$
+ private static final String DESCRIPTION = "description"; //$NON-NLS-1$
+ private static final String PROPERTIES = "properties"; //$NON-NLS-1$
+ private static final String MODULE_NAME = "module-name"; //$NON-NLS-1$
+
+ public static ModelNode wrap(VDBTranslatorMetaData translator) {
+ if (translator == null) {
+ return null;
+ }
+ ModelNode node = new ModelNode();
+ node.get(TYPE).set(ModelType.OBJECT);
+
+ node.get(TRANSLATOR_NAME).set(translator.getName());
+ node.get(BASETYPE).set(translator.getType());
+ if (translator.getDescription() != null) {
+ node.get(DESCRIPTION).set(translator.getDescription());
+ }
+
+ if (translator.getModuleName() != null) {
+ node.get(MODULE_NAME).set(translator.getModuleName());
+ }
+
+ List<PropertyMetadata> properties = translator.getJAXBProperties();
+ if (properties!= null && !properties.isEmpty()) {
+ ModelNode propsNode = node.get(CHILDREN, PROPERTIES);
+ for (PropertyMetadata prop:properties) {
+ propsNode.add(PropertyMetaDataMapper.wrap(prop));
+ }
+ }
+ return node;
+ }
+
+ public static VDBTranslatorMetaData unwrap(ModelNode node) {
+ if (node == null) {
+ return null;
+ }
+ VDBTranslatorMetaData translator = new VDBTranslatorMetaData();
+ if (node.has(TRANSLATOR_NAME)) {
+ translator.setName(node.get(TRANSLATOR_NAME).asString());
+ }
+ if (node.has(BASETYPE)) {
+ translator.setType(node.get(BASETYPE).asString());
+ }
+ if (node.has(DESCRIPTION)) {
+ translator.setDescription(node.get(DESCRIPTION).asString());
+ }
+ if (node.has(MODULE_NAME)) {
+ translator.setModuleName(node.get(MODULE_NAME).asString());
+ }
+
+ if (node.get(CHILDREN,PROPERTIES).isDefined()) {
+ List<ModelNode> propNodes = node.get(CHILDREN, PROPERTIES).asList();
+ for (ModelNode propNode:propNodes) {
+ PropertyMetadata prop = PropertyMetaDataMapper.unwrap(propNode);
+ if (prop != null) {
+ translator.addProperty(prop.getName(), prop.getValue());
+ }
+ }
+ }
+ return translator;
+ }
+
+ public static ModelNode describe(ModelNode node) {
+ node.get(TYPE).set(ModelType.OBJECT);
+ addAttribute(node, TRANSLATOR_NAME, ModelType.STRING, true);
+ addAttribute(node, BASETYPE, ModelType.STRING, true);
+ addAttribute(node, DESCRIPTION, ModelType.STRING, false);
+ addAttribute(node, MODULE_NAME, ModelType.STRING, false);
+
+ ModelNode props = node.get(CHILDREN, PROPERTIES);
+ props.get(DESCRIPTION).set(AdminPlugin.Util.getString(PROPERTIES+DOT_DESC));
+ PropertyMetaDataMapper.describe(props);
+ return node;
+ }
+ }
+
+ /**
+ * Property Metadata mapper
+ */
+ public static class PropertyMetaDataMapper {
+ private static final String PROPERTY_NAME = "property-name"; //$NON-NLS-1$
+ private static final String PROPERTY_VALUE = "property-value"; //$NON-NLS-1$
+
+ public static ModelNode wrap(PropertyMetadata property) {
+ if (property == null) {
+ return null;
+ }
+ ModelNode node = new ModelNode();
+ node.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
+
+ node.get(PROPERTY_NAME).set(property.getName());
+ node.get(PROPERTY_VALUE).set(property.getValue());
+
+ return node;
+ }
+
+ public static PropertyMetadata unwrap(ModelNode node) {
+ if(node == null) {
+ return null;
+ }
+ PropertyMetadata property = new PropertyMetadata();
+ if (node.has(PROPERTY_NAME)) {
+ property.setName(node.get(PROPERTY_NAME).asString());
+ }
+ if(node.has(PROPERTY_VALUE)) {
+ property.setValue(node.get(PROPERTY_VALUE).asString());
+ }
+ return property;
+ }
+
+ public static ModelNode describe(ModelNode node) {
+ node.get(TYPE).set(ModelType.OBJECT);
+ addAttribute(node, PROPERTY_NAME, ModelType.STRING, true);
+ addAttribute(node, PROPERTY_VALUE, ModelType.STRING, true);
+ return node;
+ }
+ }
+
+ /**
+ * DataPolicy Metadata mapper
+ */
+ public static class DataPolicyMetadataMapper {
+ private static final String POLICY_NAME = "policy-name"; //$NON-NLS-1$
+ private static final String DATA_PERMISSIONS = "data-permissions";
//$NON-NLS-1$
+ private static final String MAPPED_ROLE_NAMES = "mapped-role-names";
//$NON-NLS-1$
+ private static final String ALLOW_CREATE_TEMP_TABLES =
"allow-create-temp-tables"; //$NON-NLS-1$
+ private static final String ANY_AUTHENTICATED = "any-authenticated";
//$NON-NLS-1$
+
+ public static ModelNode wrap(DataPolicyMetadata policy) {
+ if (policy == null) {
+ return null;
+ }
+ ModelNode node = new ModelNode();
+ node.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
+
+ node.get(POLICY_NAME).set(policy.getName());
+ if (policy.getDescription() != null) {
+ node.get(DESCRIPTION).set(policy.getDescription());
+ }
+ if (policy.isAllowCreateTemporaryTables() != null) {
+ node.get(ALLOW_CREATE_TEMP_TABLES).set(policy.isAllowCreateTemporaryTables());
+ }
+ node.get(ANY_AUTHENTICATED).set(policy.isAnyAuthenticated());
+
+ //DATA_PERMISSIONS
+ List<DataPolicy.DataPermission> permissions = policy.getPermissions();
+ if (permissions != null && !permissions.isEmpty()) {
+ ModelNode permissionNodes = node.get(CHILDREN, DATA_PERMISSIONS);
+ for (DataPolicy.DataPermission dataPermission:permissions) {
+ permissionNodes.add(PermissionMetaDataMapper.wrap((PermissionMetaData)dataPermission));
+ }
+ }
+
+ //MAPPED_ROLE_NAMES
+ if (policy.getMappedRoleNames() != null &&
!policy.getMappedRoleNames().isEmpty()) {
+ ModelNode mappedRoleNodes = node.get(CHILDREN, MAPPED_ROLE_NAMES);
+ for (String role:policy.getMappedRoleNames()) {
+ mappedRoleNodes.add(role);
+ }
+ }
+ return node;
+ }
+
+ public static DataPolicyMetadata unwrap(ModelNode node) {
+ if(node == null) {
+ return null;
+ }
+ DataPolicyMetadata policy = new DataPolicyMetadata();
+ if (node.has(POLICY_NAME)) {
+ policy.setName(node.get(POLICY_NAME).asString());
+ }
+ if (node.has(DESCRIPTION)) {
+ policy.setDescription(node.get(DESCRIPTION).asString());
+ }
+ if (node.has(ALLOW_CREATE_TEMP_TABLES)) {
+ policy.setAllowCreateTemporaryTables(node.get(ALLOW_CREATE_TEMP_TABLES).asBoolean());
+ }
+ if (node.has(ANY_AUTHENTICATED)) {
+ policy.setAnyAuthenticated(node.get(ANY_AUTHENTICATED).asBoolean());
+ }
+
+ //DATA_PERMISSIONS
+ if (node.get(CHILDREN, DATA_PERMISSIONS).isDefined()) {
+ List<ModelNode> permissionNodes = node.get(CHILDREN,
DATA_PERMISSIONS).asList();
+ for (ModelNode permissionNode:permissionNodes) {
+ PermissionMetaData permission = PermissionMetaDataMapper.unwrap(permissionNode);
+ if (permission != null) {
+ policy.addPermission(permission);
+ }
+ }
+ }
+
+ //MAPPED_ROLE_NAMES
+ if (node.get(CHILDREN, MAPPED_ROLE_NAMES).isDefined()) {
+ List<ModelNode> roleNameNodes = node.get(CHILDREN,
MAPPED_ROLE_NAMES).asList();
+ for (ModelNode roleNameNode:roleNameNodes) {
+ policy.addMappedRoleName(roleNameNode.asString());
+ }
+ }
+ return policy;
+ }
+
+ public static ModelNode describe(ModelNode node) {
+ node.get(TYPE).set(ModelType.OBJECT);
+ addAttribute(node, POLICY_NAME, ModelType.STRING, true);
+ addAttribute(node, DESCRIPTION, ModelType.STRING, false);
+ addAttribute(node, ALLOW_CREATE_TEMP_TABLES, ModelType.BOOLEAN, false);
+ addAttribute(node, ANY_AUTHENTICATED, ModelType.BOOLEAN, false);
+
+ ModelNode permissions = node.get(CHILDREN, DATA_PERMISSIONS);
+ PropertyMetaDataMapper.describe(permissions);
+ permissions.get(DESCRIPTION).set(AdminPlugin.Util.getString(DATA_PERMISSIONS+DOT_DESC));
+ permissions.get(MIN_OCCURS).set(1);
+
+ ModelNode roleNames = node.get(CHILDREN, MAPPED_ROLE_NAMES);
+ roleNames.get(TYPE).set(ModelType.LIST);
+ roleNames.get(DESCRIPTION).set(AdminPlugin.Util.getString(MAPPED_ROLE_NAMES+DOT_DESC));
+ roleNames.get("value-type").set(ModelType.STRING); //$NON-NLS-1$
+ return node;
+ }
+ }
+
+ public static class PermissionMetaDataMapper{
+ private static final String RESOURCE_NAME = "resource-name"; //$NON-NLS-1$
+ private static final String ALLOW_CREATE = "allow-create"; //$NON-NLS-1$
+ private static final String ALLOW_DELETE = "allow-delete"; //$NON-NLS-1$
+ private static final String ALLOW_UPADTE = "allow-update"; //$NON-NLS-1$
+ private static final String ALLOW_READ = "allow-read"; //$NON-NLS-1$
+ private static final String ALLOW_EXECUTE = "allow-execute"; //$NON-NLS-1$
+ private static final String ALLOW_ALTER = "allow-alter"; //$NON-NLS-1$
+
+
+
+ public static ModelNode wrap(PermissionMetaData permission) {
+ if (permission == null) {
+ return null;
+ }
+
+ ModelNode node = new ModelNode();
+ node.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
+
+ node.get(RESOURCE_NAME).set(permission.getResourceName());
+ if (permission.getAllowCreate() != null) {
+ node.get(ALLOW_CREATE).set(permission.getAllowCreate().booleanValue());
+ }
+ if (permission.getAllowDelete() != null) {
+ node.get(ALLOW_DELETE).set(permission.getAllowDelete().booleanValue());
+ }
+ if (permission.getAllowUpdate() != null) {
+ node.get(ALLOW_UPADTE).set(permission.getAllowUpdate().booleanValue());
+ }
+ if (permission.getAllowRead() != null) {
+ node.get(ALLOW_READ).set(permission.getAllowRead().booleanValue());
+ }
+ if (permission.getAllowExecute() != null) {
+ node.get(ALLOW_EXECUTE).set(permission.getAllowExecute().booleanValue());
+ }
+ if(permission.getAllowAlter() != null) {
+ node.get(ALLOW_ALTER).set(permission.getAllowAlter().booleanValue());
+ }
+ return node;
+ }
+
+ public static PermissionMetaData unwrap(ModelNode node) {
+ if (node == null) {
+ return null;
+ }
+
+ PermissionMetaData permission = new PermissionMetaData();
+ if (node.get(RESOURCE_NAME) != null) {
+ permission.setResourceName(node.get(RESOURCE_NAME).asString());
+ }
+ if (node.has(ALLOW_CREATE)) {
+ permission.setAllowCreate(node.get(ALLOW_CREATE).asBoolean());
+ }
+ if (node.has(ALLOW_DELETE)) {
+ permission.setAllowDelete(node.get(ALLOW_DELETE).asBoolean());
+ }
+ if (node.has(ALLOW_UPADTE)) {
+ permission.setAllowUpdate(node.get(ALLOW_UPADTE).asBoolean());
+ }
+ if (node.has(ALLOW_READ)) {
+ permission.setAllowRead(node.get(ALLOW_READ).asBoolean());
+ }
+ if (node.has(ALLOW_EXECUTE)) {
+ permission.setAllowExecute(node.get(ALLOW_EXECUTE).asBoolean());
+ }
+ if (node.has(ALLOW_ALTER)) {
+ permission.setAllowAlter(node.get(ALLOW_ALTER).asBoolean());
+ }
+ return permission;
+ }
+ public static ModelNode describe(ModelNode node) {
+ addAttribute(node, RESOURCE_NAME, ModelType.STRING, true);
+ addAttribute(node, ALLOW_CREATE, ModelType.BOOLEAN, false);
+ addAttribute(node, ALLOW_DELETE, ModelType.BOOLEAN, false);
+ addAttribute(node, ALLOW_UPADTE, ModelType.BOOLEAN, false);
+ addAttribute(node, ALLOW_READ, ModelType.BOOLEAN, false);
+ addAttribute(node, ALLOW_EXECUTE, ModelType.BOOLEAN, false);
+ addAttribute(node, ALLOW_ALTER, ModelType.BOOLEAN, false);
+ return node;
+ }
+ }
+
+ public static class CacheStatisticsMetadataMapper {
+ private static final String HITRATIO = "hitRatio"; //$NON-NLS-1$
+ private static final String TOTAL_ENTRIES = "totalEntries"; //$NON-NLS-1$
+ private static final String REQUEST_COUNT = "requestCount"; //$NON-NLS-1$
+
+ public static ModelNode wrap(CacheStatisticsMetadata object) {
+ if (object == null)
+ return null;
+
+ ModelNode cache = new ModelNode();
+ cache.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
+
+ cache.get(TOTAL_ENTRIES).set(object.getTotalEntries());
+ cache.get(HITRATIO).set(object.getHitRatio());
+ cache.get(REQUEST_COUNT).set(object.getRequestCount());
+
+ return cache;
+ }
+
+ public static CacheStatisticsMetadata unwrap(ModelNode node) {
+ if (node == null)
+ return null;
+
+ CacheStatisticsMetadata cache = new CacheStatisticsMetadata();
+ cache.setTotalEntries(node.get(TOTAL_ENTRIES).asInt());
+ cache.setHitRatio(node.get(HITRATIO).asDouble());
+ cache.setRequestCount(node.get(REQUEST_COUNT).asInt());
+ return cache;
+ }
+
+ public static ModelNode describe(ModelNode node) {
+ node.get(TYPE).set(ModelType.OBJECT);
+ addAttribute(node, TOTAL_ENTRIES, ModelType.STRING, true);
+ addAttribute(node, HITRATIO, ModelType.STRING, true);
+ addAttribute(node, REQUEST_COUNT, ModelType.STRING, true);
+ return node;
+ }
+ }
+
+ public static class RequestMetadataMapper {
+ private static final String TRANSACTION_ID = "transaction-id"; //$NON-NLS-1$
+ private static final String NODE_ID = "node-id"; //$NON-NLS-1$
+ private static final String SOURCE_REQUEST = "source-request"; //$NON-NLS-1$
+ private static final String COMMAND = "command"; //$NON-NLS-1$
+ private static final String START_TIME = "start-time"; //$NON-NLS-1$
+ private static final String SESSION_ID = "session-id"; //$NON-NLS-1$
+ private static final String EXECUTION_ID = "execution-id"; //$NON-NLS-1$
+ private static final String STATE = "processing-state"; //$NON-NLS-1$
+ private static final String THREAD_STATE = "thread-state"; //$NON-NLS-1$
+
+
+ public static ModelNode wrap(RequestMetadata object) {
+ if (object == null) {
+ return null;
+ }
+ ModelNode request = new ModelNode();
+ request.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
+
+ request.get(EXECUTION_ID).set(object.getExecutionId());
+ request.get(SESSION_ID).set(object.getSessionId());
+ request.get(START_TIME).set(object.getStartTime());
+ request.get(COMMAND).set(object.getCommand());
+ request.get(SOURCE_REQUEST).set(object.sourceRequest());
+ if (object.getNodeId() != null) {
+ request.get(NODE_ID).set(object.getNodeId());
+ }
+ if (object.getTransactionId() != null) {
+ request.get(TRANSACTION_ID).set(object.getTransactionId());
+ }
+ request.get(STATE).set(object.getState().name());
+ request.get(THREAD_STATE).set(object.getThreadState().name());
+ return request;
+ }
+
+ public static RequestMetadata unwrap(ModelNode node) {
+ if (node == null)
+ return null;
+
+ RequestMetadata request = new RequestMetadata();
+ request.setExecutionId(node.get(EXECUTION_ID).asLong());
+ request.setSessionId(node.get(SESSION_ID).asString());
+ request.setStartTime(node.get(START_TIME).asLong());
+ request.setCommand(node.get(COMMAND).asString());
+ request.setSourceRequest(node.get(SOURCE_REQUEST).asBoolean());
+ if (node.has(NODE_ID)) {
+ request.setNodeId(node.get(NODE_ID).asInt());
+ }
+ if (node.has(TRANSACTION_ID)) {
+ request.setTransactionId(node.get(TRANSACTION_ID).asString());
+ }
+ request.setState(ProcessingState.valueOf(node.get(STATE).asString()));
+ request.setThreadState(ThreadState.valueOf(node.get(THREAD_STATE).asString()));
+ return request;
+ }
+
+ public static ModelNode describe(ModelNode node) {
+ node.get(TYPE).set(ModelType.OBJECT);
+ addAttribute(node, EXECUTION_ID, ModelType.LONG, true);
+ addAttribute(node, SESSION_ID, ModelType.STRING, true);
+ addAttribute(node, START_TIME, ModelType.LONG, true);
+ addAttribute(node, COMMAND, ModelType.STRING, true);
+ addAttribute(node, SOURCE_REQUEST, ModelType.BOOLEAN, true);
+ addAttribute(node, NODE_ID,
ModelType.INT, false);
+ addAttribute(node, TRANSACTION_ID, ModelType.STRING, false);
+ addAttribute(node, STATE, ModelType.STRING, true);
+ addAttribute(node, THREAD_STATE, ModelType.STRING, true);
+ return node;
+ }
+ }
+
+ public static class SessionMetadataMapper {
+ private static final String SECURITY_DOMAIN = "security-domain";
//$NON-NLS-1$
+ private static final String VDB_VERSION = "vdb-version"; //$NON-NLS-1$
+ private static final String VDB_NAME = "vdb-name"; //$NON-NLS-1$
+ private static final String USER_NAME = "user-name"; //$NON-NLS-1$
+ private static final String SESSION_ID = "session-id"; //$NON-NLS-1$
+ private static final String LAST_PING_TIME = "last-ping-time"; //$NON-NLS-1$
+ private static final String IP_ADDRESS = "ip-address"; //$NON-NLS-1$
+ private static final String CLIENT_HOST_NAME = "client-host-address";
//$NON-NLS-1$
+ private static final String CREATED_TIME = "created-time"; //$NON-NLS-1$
+ private static final String APPLICATION_NAME = "application-name";
//$NON-NLS-1$
+
+
+ public static ModelNode wrap(SessionMetadata session) {
+ if (session == null) {
+ return null;
+ }
+ ModelNode node = new ModelNode();
+ node.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
+
+ if (session.getApplicationName() != null) {
+ node.get(APPLICATION_NAME).set(session.getApplicationName());
+ }
+ node.get(CREATED_TIME).set(session.getCreatedTime());
+ node.get(CLIENT_HOST_NAME).set(session.getClientHostName());
+ node.get(IP_ADDRESS).set(session.getIPAddress());
+ node.get(LAST_PING_TIME).set(session.getLastPingTime());
+ node.get(SESSION_ID).set(session.getSessionId());
+ node.get(USER_NAME).set(session.getUserName());
+ node.get(VDB_NAME).set(session.getVDBName());
+ node.get(VDB_VERSION).set(session.getVDBVersion());
+ if (session.getSecurityDomain() != null){
+ node.get(SECURITY_DOMAIN).set(session.getSecurityDomain());
+ }
+ return node;
+ }
+
+ public static SessionMetadata unwrap(ModelNode node) {
+ if (node == null)
+ return null;
+
+ SessionMetadata session = new SessionMetadata();
+ if (node.has(APPLICATION_NAME)) {
+ session.setApplicationName(node.get(APPLICATION_NAME).asString());
+ }
+ session.setCreatedTime(node.get(CREATED_TIME).asLong());
+ session.setClientHostName(node.get(CLIENT_HOST_NAME).asString());
+ session.setIPAddress(node.get(IP_ADDRESS).asString());
+ session.setLastPingTime(node.get(LAST_PING_TIME).asLong());
+ session.setSessionId(node.get(SESSION_ID).asString());
+ session.setUserName(node.get(USER_NAME).asString());
+ session.setVDBName(node.get(VDB_NAME).asString());
+ session.setVDBVersion(node.get(VDB_VERSION).asInt());
+ if (node.has(SECURITY_DOMAIN)) {
+ session.setSecurityDomain(node.get(SECURITY_DOMAIN).asString());
+ }
+ return session;
+ }
+
+ public static ModelNode describe(ModelNode node) {
+ node.get(TYPE).set(ModelType.OBJECT);
+ addAttribute(node, APPLICATION_NAME, ModelType.STRING, false);
+ addAttribute(node, CREATED_TIME, ModelType.LONG, true);
+ addAttribute(node, CLIENT_HOST_NAME, ModelType.LONG, true);
+ addAttribute(node, IP_ADDRESS, ModelType.STRING, true);
+ addAttribute(node, LAST_PING_TIME, ModelType.LONG, true);
+ addAttribute(node, SESSION_ID, ModelType.STRING, true);
+ addAttribute(node, USER_NAME, ModelType.STRING, true);
+ addAttribute(node, VDB_NAME, ModelType.STRING, true);
+ addAttribute(node, VDB_VERSION,
ModelType.INT, true);
+ addAttribute(node, SECURITY_DOMAIN, ModelType.STRING, false);
+ return node;
+ }
+ }
+
+ public static class TransactionMetadataMapper {
+ private static final String ID = "txn-id"; //$NON-NLS-1$
+ private static final String SCOPE = "txn-scope"; //$NON-NLS-1$
+ private static final String CREATED_TIME = "txn-created-time"; //$NON-NLS-1$
+ private static final String ASSOCIATED_SESSION = "session-id"; //$NON-NLS-1$
+
+ public static ModelNode wrap(TransactionMetadata object) {
+ if (object == null)
+ return null;
+
+ ModelNode transaction = new ModelNode();
+ transaction.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
+ transaction.get(ASSOCIATED_SESSION).set(object.getAssociatedSession());
+ transaction.get(CREATED_TIME).set(object.getCreatedTime());
+ transaction.get(SCOPE).set(object.getScope());
+ transaction.get(ID).set(object.getId());
+
+ return transaction;
+ }
+
+ public static TransactionMetadata unwrap(ModelNode node) {
+ if (node == null)
+ return null;
+
+ TransactionMetadata transaction = new TransactionMetadata();
+ transaction.setAssociatedSession(node.get(ASSOCIATED_SESSION).asString());
+ transaction.setCreatedTime(node.get(CREATED_TIME).asLong());
+ transaction.setScope(node.get(SCOPE).asString());
+ transaction.setId(node.get(ID).asString());
+ return transaction;
+ }
+
+ public static ModelNode describe(ModelNode node) {
+ node.get(TYPE).set(ModelType.OBJECT);
+ addAttribute(node, ASSOCIATED_SESSION, ModelType.STRING, true);
+ addAttribute(node, CREATED_TIME, ModelType.LONG, true);
+ addAttribute(node, SCOPE, ModelType.LONG, true);
+ addAttribute(node, ID, ModelType.STRING, true);
+ return node;
+ }
+ }
+
+ public static class WorkerPoolStatisticsMetadataMapper {
+ private static final String MAX_THREADS = "max-threads"; //$NON-NLS-1$
+ private static final String HIGHEST_QUEUED = "highest-queued"; //$NON-NLS-1$
+ private static final String QUEUED = "queued"; //$NON-NLS-1$
+ private static final String QUEUE_NAME = "queue-name"; //$NON-NLS-1$
+ private static final String TOTAL_SUBMITTED = "total-submitted";
//$NON-NLS-1$
+ private static final String TOTAL_COMPLETED = "total-completed";
//$NON-NLS-1$
+ private static final String HIGHEST_ACTIVE_THREADS =
"highest-active-threads"; //$NON-NLS-1$
+ private static final String ACTIVE_THREADS = "active-threads"; //$NON-NLS-1$
+
+
+ public static ModelNode wrap(WorkerPoolStatisticsMetadata object) {
+ if (object == null)
+ return null;
+ ModelNode transaction = new ModelNode();
+ transaction.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
+
+ transaction.get(ACTIVE_THREADS).set(object.getActiveThreads());
+ transaction.get(HIGHEST_ACTIVE_THREADS).set(object.getHighestActiveThreads());
+ transaction.get(TOTAL_COMPLETED).set(object.getTotalCompleted());
+ transaction.get(TOTAL_SUBMITTED).set(object.getTotalSubmitted());
+ transaction.get(QUEUE_NAME).set(object.getQueueName());
+ transaction.get(QUEUED).set(object.getQueued());
+ transaction.get(HIGHEST_QUEUED).set(object.getHighestQueued());
+ transaction.get(MAX_THREADS).set(object.getMaxThreads());
+
+ return transaction;
+ }
+
+ public static WorkerPoolStatisticsMetadata unwrapMetaValue(ModelNode node) {
+ if (node == null)
+ return null;
+
+ WorkerPoolStatisticsMetadata stats = new WorkerPoolStatisticsMetadata();
+ stats.setActiveThreads(node.get(ACTIVE_THREADS).asInt());
+ stats.setHighestActiveThreads(node.get(HIGHEST_ACTIVE_THREADS).asInt());
+ stats.setTotalCompleted(node.get(TOTAL_COMPLETED).asLong());
+ stats.setTotalSubmitted(node.get(TOTAL_SUBMITTED).asLong());
+ stats.setQueueName(node.get(QUEUE_NAME).asString());
+ stats.setQueued(node.get(QUEUED).asInt());
+ stats.setHighestQueued(node.get(HIGHEST_QUEUED).asInt());
+ stats.setMaxThreads(node.get(MAX_THREADS).asInt());
+ return stats;
+ }
+
+ public static ModelNode describe(ModelNode node) {
+ node.get(TYPE).set(ModelType.OBJECT);
+ addAttribute(node, ACTIVE_THREADS,
ModelType.INT, true);
+ addAttribute(node, HIGHEST_ACTIVE_THREADS,
ModelType.INT, true);
+ addAttribute(node, TOTAL_COMPLETED, ModelType.LONG, true);
+ addAttribute(node, TOTAL_SUBMITTED, ModelType.LONG, true);
+ addAttribute(node, QUEUE_NAME, ModelType.STRING, true);
+ addAttribute(node, QUEUED,
ModelType.INT, true);
+ addAttribute(node, HIGHEST_QUEUED,
ModelType.INT, true);
+ addAttribute(node, MAX_THREADS,
ModelType.INT, true);
+ return node;
+ }
+ }
+
+ private static final String CHILDREN = "children"; //$NON-NLS-1$
+ private static final String ATTRIBUTES = "attributes"; //$NON-NLS-1$
+ private static final String DOT_DESC = ".describe"; //$NON-NLS-1$
+ private static final String TYPE = "type"; //$NON-NLS-1$
+ private static final String MIN_OCCURS = "min-occurs"; //$NON-NLS-1$
+ private static final String REQUIRED = "required"; //$NON-NLS-1$
+ private static final String ALLOWED = "allowed"; //$NON-NLS-1$
+ static ModelNode addAttribute(ModelNode node, String name, ModelType dataType, boolean
required) {
+ node.get(ATTRIBUTES, name, TYPE).set(dataType);
+ node.get(ATTRIBUTES, name,
DESCRIPTION).set(AdminPlugin.Util.getString(name+DOT_DESC));
+ node.get(ATTRIBUTES, name, REQUIRED).set(required);
+ return node;
+ }
+}
+
+
Property changes on:
branches/as7/client/src/main/java/org/teiid/adminapi/impl/MetadataMapper.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: branches/as7/client/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java
===================================================================
---
branches/as7/client/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java 2011-07-01
20:26:47 UTC (rev 3300)
+++
branches/as7/client/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java 2011-07-04
19:09:19 UTC (rev 3301)
@@ -28,17 +28,8 @@
import java.util.LinkedList;
import java.util.List;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlType;
-import javax.xml.bind.annotation.XmlValue;
+import javax.xml.bind.annotation.*;
-import org.jboss.managed.api.annotation.ManagementObject;
-import org.jboss.managed.api.annotation.ManagementObjectID;
-import org.jboss.managed.api.annotation.ManagementProperties;
-import org.jboss.managed.api.annotation.ManagementProperty;
import org.teiid.adminapi.Model;
import org.teiid.adminapi.impl.ModelMetaData.ValidationError.Severity;
@@ -50,7 +41,6 @@
"sources",
"errors"
})
-(a)ManagementObject(properties=ManagementProperties.EXPLICIT)
public class ModelMetaData extends AdminObjectImpl implements Model {
private static final int DEFAULT_ERROR_HISTORY = 10;
@@ -82,9 +72,7 @@
@XmlElement(name = "validation-error")
protected List<ValidationError> errors;
- @ManagementProperty(description="Model Name")
@XmlAttribute(name = "name", required = true)
- @ManagementObjectID(type="models")
public String getName() {
return super.getName();
}
@@ -95,7 +83,6 @@
}
@Override
- @ManagementProperty(description = "Model description")
public String getDescription() {
return description;
}
@@ -105,19 +92,16 @@
}
@Override
- @ManagementProperty(description = "Is Model Source model")
public boolean isSource() {
return getModelType() == Model.Type.PHYSICAL;
}
@Override
- @ManagementProperty(description = "Is Model Visible")
public boolean isVisible() {
return this.visible;
}
@Override
- @ManagementProperty(description = "Model Type")
public Type getModelType() {
try {
return Type.valueOf(modelType.toUpperCase());
@@ -126,7 +110,6 @@
}
}
- @ManagementProperty(description = "Path to model file inside the archive")
public String getPath() {
return path;
}
@@ -136,7 +119,6 @@
}
@Override
- @ManagementProperty(description = "Does Model supports multi-source
bindings")
public boolean isSupportsMultiSourceBindings() {
String supports = getPropertyValue(SUPPORTS_MULTI_SOURCE_BINDINGS_KEY);
return Boolean.parseBoolean(supports);
@@ -144,7 +126,6 @@
@Override
@XmlElement(name = "property", type = PropertyMetadata.class)
- @ManagementProperty(description = "Model Properties", managed=true)
public List<PropertyMetadata> getJAXBProperties(){
return super.getJAXBProperties();
}
@@ -169,7 +150,6 @@
this.visible = value;
}
- @ManagementProperty(description = "Source Mappings (defined by user)",
managed=true)
public List<SourceMappingMetadata> getSourceMappings(){
return new ArrayList<SourceMappingMetadata>(this.sources.getMap().values());
}
@@ -205,9 +185,12 @@
public void addSourceMapping(String name, String translatorName, String connJndiName) {
this.sources.getMap().put(name, new SourceMappingMetadata(name, translatorName,
connJndiName));
+ }
+
+ public void addSourceMapping(SourceMappingMetadata source) {
+ this.sources.getMap().put(source.getName(), new SourceMappingMetadata(source.getName(),
source.getTranslatorName(), source.getConnectionJndiName()));
}
- @ManagementProperty(description = "Model Validity Errors", readOnly=true,
managed=true)
public List<ValidationError> getErrors(){
return getValidationErrors(Severity.ERROR);
}
@@ -241,6 +224,18 @@
return ve;
}
+ public synchronized ValidationError addError(ValidationError ve) {
+ if (this.errors == null) {
+ this.errors = new LinkedList<ValidationError>();
+ }
+ this.errors.add(ve);
+ if (this.errors.size() > DEFAULT_ERROR_HISTORY) {
+ this.errors.remove(0);
+ }
+ return ve;
+ }
+
+
public synchronized boolean removeError(ValidationError remove) {
if (this.errors == null) {
return false;
@@ -256,7 +251,6 @@
@XmlType(name = "", propOrder = {
"value"
})
- @ManagementObject(properties=ManagementProperties.EXPLICIT)
public static class ValidationError implements Serializable{
private static final long serialVersionUID = 2044197069467559527L;
@@ -278,7 +272,6 @@
this.value = msg;
}
- @ManagementProperty (description="Error Message")
public String getValue() {
return value;
}
@@ -287,7 +280,6 @@
this.value = value;
}
- @ManagementProperty (description="Severity")
public String getSeverity() {
return severity;
}
@@ -296,7 +288,6 @@
this.severity = severity;
}
- @ManagementProperty (description="Path")
public String getPath() {
return path;
}
Modified: branches/as7/client/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java
===================================================================
---
branches/as7/client/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java 2011-07-01
20:26:47 UTC (rev 3300)
+++
branches/as7/client/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java 2011-07-04
19:09:19 UTC (rev 3301)
@@ -29,10 +29,6 @@
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlType;
-import org.jboss.managed.api.annotation.ManagementObject;
-import org.jboss.managed.api.annotation.ManagementProperties;
-import org.jboss.managed.api.annotation.ManagementProperty;
-
/**
* <pre>
* <complexType name="property">
@@ -49,7 +45,6 @@
*/
@XmlAccessorType(XmlAccessType.NONE)
@XmlType(name = "property")
-(a)ManagementObject(properties=ManagementProperties.EXPLICIT)
public class PropertyMetadata implements Serializable{
private static final long serialVersionUID = -5040224539939758816L;
@@ -66,12 +61,10 @@
this.value = value;
}
- @ManagementProperty(description="property key")
public String getName() {
return name;
}
- @ManagementProperty(description="property value")
public String getValue() {
return value;
}
Modified: branches/as7/client/src/main/java/org/teiid/adminapi/impl/RequestMetadata.java
===================================================================
---
branches/as7/client/src/main/java/org/teiid/adminapi/impl/RequestMetadata.java 2011-07-01
20:26:47 UTC (rev 3300)
+++
branches/as7/client/src/main/java/org/teiid/adminapi/impl/RequestMetadata.java 2011-07-04
19:09:19 UTC (rev 3301)
@@ -24,14 +24,11 @@
import java.util.Date;
-import org.jboss.managed.api.annotation.ManagementProperty;
-import org.jboss.metatype.api.annotations.MetaMapping;
import org.teiid.adminapi.Request;
import org.teiid.core.util.HashCodeUtil;
-(a)MetaMapping(RequestMetadataMapper.class)
public class RequestMetadata extends AdminObjectImpl implements Request {
private static final long serialVersionUID = -2779106368517784259L;
@@ -47,7 +44,6 @@
private ThreadState threadState = ThreadState.RUNNING;
@Override
- @ManagementProperty(description="Unique Identifier for Request",
readOnly=true)
public long getExecutionId() {
return executionId;
}
@@ -57,7 +53,6 @@
}
@Override
- @ManagementProperty(description="State of the Request", readOnly=true)
public ProcessingState getState() {
return processingState;
}
@@ -76,7 +71,6 @@
}
@Override
- @ManagementProperty(description="Session ID", readOnly=true)
public String getSessionId() {
return this.sessionId;
}
@@ -86,7 +80,6 @@
}
@Override
- @ManagementProperty(description="Start time for the request",
readOnly=true)
public long getStartTime() {
return this.startTime;
}
@@ -96,7 +89,6 @@
}
@Override
- @ManagementProperty(description="Executing Command", readOnly=true)
public String getCommand() {
return this.command;
}
@@ -106,7 +98,6 @@
}
@Override
- @ManagementProperty(description="Is this Connector level request",
readOnly=true)
public boolean sourceRequest() {
return sourceRequest;
}
@@ -116,7 +107,6 @@
}
@Override
- @ManagementProperty(description="Node Id", readOnly=true)
public Integer getNodeId() {
return this.nodeID;
}
@@ -126,7 +116,6 @@
}
@Override
- @ManagementProperty(description="Get Transaction XID if transaction involved",
readOnly=true)
public String getTransactionId() {
return this.transactionId;
}
Deleted:
branches/as7/client/src/main/java/org/teiid/adminapi/impl/RequestMetadataMapper.java
===================================================================
---
branches/as7/client/src/main/java/org/teiid/adminapi/impl/RequestMetadataMapper.java 2011-07-01
20:26:47 UTC (rev 3300)
+++
branches/as7/client/src/main/java/org/teiid/adminapi/impl/RequestMetadataMapper.java 2011-07-04
19:09:19 UTC (rev 3301)
@@ -1,79 +0,0 @@
-/*
- * 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.adminapi.impl;
-
-import org.jboss.dmr.ModelNode;
-import org.jboss.dmr.ModelType;
-import org.teiid.adminapi.Request.ProcessingState;
-import org.teiid.adminapi.Request.ThreadState;
-
-public class RequestMetadataMapper {
- private static final String TRANSACTION_ID = "transactionId"; //$NON-NLS-1$
- private static final String NODE_ID = "nodeId"; //$NON-NLS-1$
- private static final String SOURCE_REQUEST = "sourceRequest"; //$NON-NLS-1$
- private static final String COMMAND = "command"; //$NON-NLS-1$
- private static final String START_TIME = "startTime"; //$NON-NLS-1$
- private static final String SESSION_ID = "sessionId"; //$NON-NLS-1$
- private static final String EXECUTION_ID = "executionId"; //$NON-NLS-1$
- private static final String STATE = "processingState"; //$NON-NLS-1$
- private static final String THREAD_STATE = "threadState"; //$NON-NLS-1$
-
-
- public static ModelNode wrap(RequestMetadata object) {
-
- if (object == null) {
- return null;
- }
-
- ModelNode request = new ModelNode();
- request.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
-
- request.get(EXECUTION_ID).set(object.getExecutionId());
- request.get(SESSION_ID).set(object.getSessionId());
- request.get(START_TIME).set(object.getStartTime());
- request.get(COMMAND).set(object.getCommand());
- request.get(SOURCE_REQUEST).set(object.sourceRequest());
- request.get(NODE_ID).set(object.getNodeId());
- request.get(TRANSACTION_ID).set(object.getTransactionId());
- request.get(STATE).set(object.getState().name());
- request.get(THREAD_STATE).set(object.getThreadState().name());
- return request;
- }
-
- public static RequestMetadata unwrap(ModelNode node) {
- if (node == null)
- return null;
-
- RequestMetadata request = new RequestMetadata();
- request.setExecutionId(node.get(EXECUTION_ID).asLong());
- request.setSessionId(node.get(SESSION_ID).asString());
- request.setStartTime(node.get(START_TIME).asLong());
- request.setCommand(node.get(COMMAND).asString());
- request.setSourceRequest(node.get(SOURCE_REQUEST).asBoolean());
- request.setNodeId(node.get(NODE_ID).asInt());
- request.setTransactionId(node.get(TRANSACTION_ID).asString());
- request.setState(ProcessingState.valueOf(node.get(STATE).asString()));
- request.setThreadState(ThreadState.valueOf(node.get(THREAD_STATE).asString()));
- return request;
- }
-
-}
Modified: branches/as7/client/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java
===================================================================
---
branches/as7/client/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java 2011-07-01
20:26:47 UTC (rev 3300)
+++
branches/as7/client/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java 2011-07-04
19:09:19 UTC (rev 3301)
@@ -24,10 +24,7 @@
import java.util.Date;
import javax.security.auth.Subject;
-import javax.security.auth.login.LoginContext;
-import org.jboss.managed.api.annotation.ManagementProperty;
-import org.jboss.metatype.api.annotations.MetaMapping;
import org.teiid.adminapi.Session;
import org.teiid.client.security.SessionToken;
@@ -36,7 +33,6 @@
/**
* Add and delete properties also in the Mapper class for correct wrapping for profile
service.
*/
-(a)MetaMapping(SessionMetadataMapper.class)
public class SessionMetadata extends AdminObjectImpl implements Session {
private static final long serialVersionUID = 918638989081830034L;
@@ -54,12 +50,11 @@
//server session state
private transient VDBMetaData vdb;
private transient SessionToken sessionToken;
- private transient LoginContext loginContext;
+ private transient Subject subject;
private transient Object securityContext;
private transient boolean embedded;
@Override
- @ManagementProperty(description="Application assosiated with Session",
readOnly=true)
public String getApplicationName() {
return this.applicationName;
}
@@ -69,7 +64,6 @@
}
@Override
- @ManagementProperty(description="When session created", readOnly=true)
public long getCreatedTime() {
return this.createdTime;
}
@@ -79,7 +73,6 @@
}
@Override
- @ManagementProperty(description="Host name from where the session created",
readOnly=true)
public String getClientHostName() {
return this.clientHostName;
}
@@ -89,7 +82,6 @@
}
@Override
- @ManagementProperty(description="IP address from where session is created",
readOnly=true)
public String getIPAddress() {
return this.ipAddress;
}
@@ -99,7 +91,6 @@
}
@Override
- @ManagementProperty(description="Last ping time", readOnly=true)
public long getLastPingTime() {
return this.lastPingTime;
}
@@ -109,7 +100,6 @@
}
@Override
- @ManagementProperty(description="Session ID", readOnly=true)
public String getSessionId() {
return this.sessionId;
}
@@ -119,7 +109,6 @@
}
@Override
- @ManagementProperty(description="User name assosiated with session",
readOnly=true)
public String getUserName() {
return this.userName;
}
@@ -129,7 +118,6 @@
}
@Override
- @ManagementProperty(description="VDB name assosiated with session",
readOnly=true)
public String getVDBName() {
return this.vdbName;
}
@@ -139,7 +127,6 @@
}
@Override
- @ManagementProperty(description="VDB version name assosiated with session",
readOnly=true)
public int getVDBVersion() {
return this.vdbVersion;
}
@@ -149,7 +136,6 @@
}
@Override
- @ManagementProperty(description="Security Domain that session logged into",
readOnly=true)
public String getSecurityDomain() {
return this.securityDomain;
}
@@ -190,14 +176,10 @@
this.sessionToken = sessionToken;
}
- public LoginContext getLoginContext() {
- return loginContext;
+ public void setSubject(Subject subject) {
+ this.subject = subject;
}
- public void setLoginContext(LoginContext loginContext) {
- this.loginContext = loginContext;
- }
-
public Object getSecurityContext() {
return securityContext;
}
@@ -207,7 +189,7 @@
}
public Subject getSubject() {
- return this.loginContext.getSubject();
+ return this.subject;
}
public void setEmbedded(boolean embedded) {
Deleted:
branches/as7/client/src/main/java/org/teiid/adminapi/impl/SessionMetadataMapper.java
===================================================================
---
branches/as7/client/src/main/java/org/teiid/adminapi/impl/SessionMetadataMapper.java 2011-07-01
20:26:47 UTC (rev 3300)
+++
branches/as7/client/src/main/java/org/teiid/adminapi/impl/SessionMetadataMapper.java 2011-07-04
19:09:19 UTC (rev 3301)
@@ -1,80 +0,0 @@
-/*
- * 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.adminapi.impl;
-
-import org.jboss.dmr.ModelNode;
-import org.jboss.dmr.ModelType;
-
-
-public class SessionMetadataMapper {
- private static final String SECURITY_DOMAIN = "securityDomain"; //$NON-NLS-1$
- private static final String VDB_VERSION = "VDBVersion"; //$NON-NLS-1$
- private static final String VDB_NAME = "VDBName"; //$NON-NLS-1$
- private static final String USER_NAME = "userName"; //$NON-NLS-1$
- private static final String SESSION_ID = "sessionId"; //$NON-NLS-1$
- private static final String LAST_PING_TIME = "lastPingTime"; //$NON-NLS-1$
- private static final String IP_ADDRESS = "IPAddress"; //$NON-NLS-1$
- private static final String CLIENT_HOST_NAME = "clientHostName";
//$NON-NLS-1$
- private static final String CREATED_TIME = "createdTime"; //$NON-NLS-1$
- private static final String APPLICATION_NAME = "applicationName";
//$NON-NLS-1$
-
-
- public static ModelNode wrap(SessionMetadata object) {
- if (object == null) {
- return null;
- }
- ModelNode session = new ModelNode();
- session.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
-
- session.get(APPLICATION_NAME).set(object.getApplicationName());
- session.get(CREATED_TIME).set(object.getCreatedTime());
- session.get(CLIENT_HOST_NAME).set(object.getClientHostName());
- session.get(IP_ADDRESS).set(object.getIPAddress());
- session.get(LAST_PING_TIME).set(object.getLastPingTime());
- session.get(SESSION_ID).set(object.getSessionId());
- session.get(USER_NAME).set(object.getUserName());
- session.get(VDB_NAME).set(object.getVDBName());
- session.get(VDB_VERSION).set(object.getVDBVersion());
- session.get(SECURITY_DOMAIN).set(object.getSecurityDomain());
-
- return session;
- }
-
- public static SessionMetadata unwrap(ModelNode node) {
- if (node == null)
- return null;
-
- SessionMetadata session = new SessionMetadata();
- session.setApplicationName(node.get(APPLICATION_NAME).asString());
- session.setCreatedTime(node.get(CREATED_TIME).asLong());
- session.setClientHostName(node.get(CLIENT_HOST_NAME).asString());
- session.setIPAddress(node.get(IP_ADDRESS).asString());
- session.setLastPingTime(node.get(LAST_PING_TIME).asLong());
- session.setSessionId(node.get(SESSION_ID).asString());
- session.setUserName(node.get(USER_NAME).asString());
- session.setVDBName(node.get(VDB_NAME).asString());
- session.setVDBVersion(node.get(VDB_VERSION).asInt());
- session.setSecurityDomain(node.get(SECURITY_DOMAIN).asString());
- return session;
- }
-
-}
Modified:
branches/as7/client/src/main/java/org/teiid/adminapi/impl/SourceMappingMetadata.java
===================================================================
---
branches/as7/client/src/main/java/org/teiid/adminapi/impl/SourceMappingMetadata.java 2011-07-01
20:26:47 UTC (rev 3300)
+++
branches/as7/client/src/main/java/org/teiid/adminapi/impl/SourceMappingMetadata.java 2011-07-04
19:09:19 UTC (rev 3301)
@@ -29,14 +29,8 @@
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlType;
-import org.jboss.managed.api.annotation.ManagementObject;
-import org.jboss.managed.api.annotation.ManagementObjectID;
-import org.jboss.managed.api.annotation.ManagementProperties;
-import org.jboss.managed.api.annotation.ManagementProperty;
-
@XmlAccessorType(XmlAccessType.NONE)
@XmlType(name = "")
-(a)ManagementObject(properties=ManagementProperties.EXPLICIT)
public class SourceMappingMetadata implements Serializable {
private static final long serialVersionUID = -4417878417697685794L;
@@ -57,8 +51,6 @@
this.jndiName = connJndiName;
}
- @ManagementProperty (description="Source Name")
- @ManagementObjectID(type="source")
public String getName() {
return name;
}
@@ -67,7 +59,6 @@
this.name = name;
}
- @ManagementProperty (description="JNDI Name of the resource to assosiate with
Source name")
public String getConnectionJndiName() {
// this default could be controlled if needed.
if (this.jndiName == null) {
@@ -80,7 +71,6 @@
this.jndiName = jndiName;
}
- @ManagementProperty (description="Translator Name")
public String getTranslatorName() {
return translatorName;
}
Modified:
branches/as7/client/src/main/java/org/teiid/adminapi/impl/TransactionMetadata.java
===================================================================
---
branches/as7/client/src/main/java/org/teiid/adminapi/impl/TransactionMetadata.java 2011-07-01
20:26:47 UTC (rev 3300)
+++
branches/as7/client/src/main/java/org/teiid/adminapi/impl/TransactionMetadata.java 2011-07-04
19:09:19 UTC (rev 3301)
@@ -24,12 +24,9 @@
import java.util.Date;
-import org.jboss.managed.api.annotation.ManagementProperty;
-import org.jboss.metatype.api.annotations.MetaMapping;
import org.teiid.adminapi.Transaction;
-(a)MetaMapping(TransactionMetadataMapper.class)
public class TransactionMetadata extends AdminObjectImpl implements Transaction {
private static final long serialVersionUID = -8588785315218789068L;
@@ -39,7 +36,6 @@
private long createdTime;
@Override
- @ManagementProperty(description="Session ID", readOnly=true)
public String getAssociatedSession() {
return associatedSession;
}
@@ -49,7 +45,6 @@
}
@Override
- @ManagementProperty(description="Scope", readOnly=true)
public String getScope() {
return scope;
}
@@ -59,7 +54,6 @@
}
@Override
- @ManagementProperty(description="ID", readOnly=true)
public String getId() {
return id;
}
@@ -69,7 +63,6 @@
}
@Override
- @ManagementProperty(description="Transaction created time", readOnly=true)
public long getCreatedTime() {
return createdTime;
}
Deleted:
branches/as7/client/src/main/java/org/teiid/adminapi/impl/TransactionMetadataMapper.java
===================================================================
---
branches/as7/client/src/main/java/org/teiid/adminapi/impl/TransactionMetadataMapper.java 2011-07-01
20:26:47 UTC (rev 3300)
+++
branches/as7/client/src/main/java/org/teiid/adminapi/impl/TransactionMetadataMapper.java 2011-07-04
19:09:19 UTC (rev 3301)
@@ -1,60 +0,0 @@
-/*
- * 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.adminapi.impl;
-
-import org.jboss.dmr.ModelNode;
-import org.jboss.dmr.ModelType;
-
-public class TransactionMetadataMapper {
- private static final String ID = "id"; //$NON-NLS-1$
- private static final String SCOPE = "scope"; //$NON-NLS-1$
- private static final String CREATED_TIME = "createdTime"; //$NON-NLS-1$
- private static final String ASSOCIATED_SESSION = "associatedSession";
//$NON-NLS-1$
-
- public static ModelNode wrap(TransactionMetadata object) {
- if (object == null)
- return null;
-
- ModelNode transaction = new ModelNode();
- transaction.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
-
- transaction.get(ASSOCIATED_SESSION).set(object.getAssociatedSession());
- transaction.get(CREATED_TIME).set(object.getCreatedTime());
- transaction.get(SCOPE).set(object.getScope());
- transaction.get(ID).set(object.getId());
-
- return transaction;
- }
-
- public static TransactionMetadata unwrap(ModelNode node) {
- if (node == null)
- return null;
-
- TransactionMetadata transaction = new TransactionMetadata();
- transaction.setAssociatedSession(node.get(ASSOCIATED_SESSION).asString());
- transaction.setCreatedTime(node.get(CREATED_TIME).asLong());
- transaction.setScope(node.get(SCOPE).asString());
- transaction.setId(node.get(ID).asString());
- return transaction;
- }
-}
Deleted:
branches/as7/client/src/main/java/org/teiid/adminapi/impl/TranslatorMetaData.java
===================================================================
---
branches/as7/client/src/main/java/org/teiid/adminapi/impl/TranslatorMetaData.java 2011-07-01
20:26:47 UTC (rev 3300)
+++
branches/as7/client/src/main/java/org/teiid/adminapi/impl/TranslatorMetaData.java 2011-07-04
19:09:19 UTC (rev 3301)
@@ -1,32 +0,0 @@
-/*
- * 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.adminapi.impl;
-
-import org.jboss.managed.api.annotation.ManagementComponent;
-import org.jboss.managed.api.annotation.ManagementObject;
-import org.jboss.managed.api.annotation.ManagementProperties;
-
-@ManagementObject(componentType=@ManagementComponent(type="teiid",subtype="translator"),
properties=ManagementProperties.EXPLICIT)
-public class TranslatorMetaData extends VDBTranslatorMetaData{
- private static final long serialVersionUID = 116875548438603151L;
- public static final String TRANSLATOR_PREFIX = "translator-"; //$NON-NLS-1$
-}
Deleted:
branches/as7/client/src/main/java/org/teiid/adminapi/impl/TranslatorPropertyFactory.java
===================================================================
---
branches/as7/client/src/main/java/org/teiid/adminapi/impl/TranslatorPropertyFactory.java 2011-07-01
20:26:47 UTC (rev 3300)
+++
branches/as7/client/src/main/java/org/teiid/adminapi/impl/TranslatorPropertyFactory.java 2011-07-04
19:09:19 UTC (rev 3301)
@@ -1,109 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This 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 software 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 software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.teiid.adminapi.impl;
-
-import java.io.ObjectStreamException;
-import java.io.Serializable;
-
-import org.jboss.beans.info.spi.BeanInfo;
-import org.jboss.beans.info.spi.PropertyInfo;
-import org.jboss.managed.api.Fields;
-import org.jboss.managed.api.ManagedObject;
-import org.jboss.managed.api.factory.ManagedObjectFactory;
-import org.jboss.managed.plugins.ManagedPropertyImpl;
-import org.jboss.managed.spi.factory.InstanceClassFactory;
-import org.jboss.metatype.api.types.MapCompositeMetaType;
-import org.jboss.metatype.api.types.MetaType;
-import org.jboss.metatype.api.types.SimpleMetaType;
-import org.jboss.metatype.api.values.MetaValue;
-
-
-public class TranslatorPropertyFactory extends ManagedPropertyImpl {
- private ManagedObjectFactory moFactory;
- private MapCompositeMetaType type;
-
- public TranslatorPropertyFactory(String s) {
- super(s);
- }
-
- public TranslatorPropertyFactory(Fields fields) {
- super(fields);
- type = new MapCompositeMetaType(SimpleMetaType.STRING);
- setField(Fields.META_TYPE, null);
- }
-
- public TranslatorPropertyFactory(ManagedObject managedObject, Fields fields) {
- super(managedObject, fields);
- type = new MapCompositeMetaType(SimpleMetaType.STRING);
- setField(Fields.META_TYPE, null);
- }
-
- public MetaType getMetaType() {
- return type;
- }
-
- public void setField(String fieldName, Serializable value) {
- if (Fields.META_TYPE.equals(fieldName))
- value = type;
- super.setField(fieldName, value);
- }
-
- /**
- * Write the value back to the attachment if there is a PropertyInfo in the
- * Fields.PROPERTY_INFO field.
- */
- @Override
- @SuppressWarnings("unchecked")
- public void setValue(MetaValue value) {
- super.setValue(value);
-
- PropertyInfo propertyInfo = getField(Fields.PROPERTY_INFO,PropertyInfo.class);
- if (propertyInfo != null) {
- Object attachment = getManagedObject().getAttachment();
- if (attachment != null) {
- MetaValue metaValue = value;
- InstanceClassFactory icf =
getMOFactory().getInstanceClassFactory(attachment.getClass());
- BeanInfo beanInfo = propertyInfo.getBeanInfo();
- icf.setValue(beanInfo, this, attachment, metaValue);
- }
- }
- }
-
- private ManagedObjectFactory getMOFactory() {
- if (moFactory == null)
- moFactory = ManagedObjectFactory.getInstance();
- return moFactory;
- }
-
- /**
- * Expose only plain ManangedPropertyImpl.
- *
- * @return simpler ManagedPropertyImpl
- * @throws java.io.ObjectStreamException
- * for any error
- */
- private Object writeReplace() throws ObjectStreamException {
- ManagedPropertyImpl managedProperty = new ManagedPropertyImpl(getManagedObject(),
getFields());
- managedProperty.setTargetManagedObject(getTargetManagedObject());
- return managedProperty;
- }
-}
Modified: branches/as7/client/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java 2011-07-01
20:26:47 UTC (rev 3300)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java 2011-07-04
19:09:19 UTC (rev 3301)
@@ -22,24 +22,10 @@
package org.teiid.adminapi.impl;
import java.net.URL;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.*;
-import org.jboss.managed.api.annotation.ManagementComponent;
-import org.jboss.managed.api.annotation.ManagementObject;
-import org.jboss.managed.api.annotation.ManagementObjectID;
-import org.jboss.managed.api.annotation.ManagementProperties;
-import org.jboss.managed.api.annotation.ManagementProperty;
import org.teiid.adminapi.DataPolicy;
import org.teiid.adminapi.Model;
import org.teiid.adminapi.Translator;
@@ -48,7 +34,6 @@
import org.teiid.core.util.StringUtil;
-@ManagementObject(componentType=@ManagementComponent(type="teiid",subtype="vdb"),
properties=ManagementProperties.EXPLICIT)
@XmlAccessorType(XmlAccessType.NONE)
@XmlType(name = "", propOrder = {
"description",
@@ -110,14 +95,11 @@
private ConnectionType connectionType = VDB.ConnectionType.BY_VERSION;
private boolean removed;
- @ManagementProperty(description="Name of the VDB")
@XmlAttribute(name = "name", required = true)
public String getName() {
return super.getName();
}
- @ManagementProperty(description="Full Name of the VDB")
- @ManagementObjectID(type="vdb")
public String getFullName() {
return getName() + VERSION_DELIM + getVersion();
}
@@ -136,7 +118,6 @@
}
@Override
- @ManagementProperty(description="Collections Allowed")
public ConnectionType getConnectionType() {
return this.connectionType;
}
@@ -145,8 +126,11 @@
this.connectionType = allowConnections;
}
+ public void setConnectionType(String allowConnections) {
+ this.connectionType = ConnectionType.valueOf(allowConnections);
+ }
+
@Override
- @ManagementProperty(description="VDB Status")
public Status getStatus() {
return this.status;
}
@@ -155,8 +139,12 @@
this.status = s;
}
+ public void setStatus(String s) {
+ this.status = Status.valueOf(s);
+ }
+
+
@Override
- @ManagementProperty(description="VDB version")
public int getVersion() {
return this.version;
}
@@ -166,7 +154,6 @@
}
@Override
- @ManagementProperty(description = "The VDB file url")
public String getUrl() {
return this.fileUrl;
}
@@ -194,7 +181,6 @@
}
@Override
- @ManagementProperty(description="Models in a VDB", managed=true)
public List<Model> getModels(){
return new ArrayList<Model>(this.models.getMap().values());
}
@@ -220,7 +206,6 @@
}
@Override
- @ManagementProperty(description="Translators in a VDB", managed=true)
public List<Translator> getOverrideTranslators() {
return new ArrayList<Translator>(this.translators.getMap().values());
}
@@ -231,8 +216,11 @@
}
}
+ public void addOverideTranslator(VDBTranslatorMetaData t) {
+ this.translators.getMap().put(t.getName(), t);
+ }
+
@Override
- @ManagementProperty(description = "Description")
public String getDescription() {
return this.description;
}
@@ -242,7 +230,6 @@
}
@Override
- @ManagementProperty(description = "VDB validity errors", readOnly=true)
public List<String> getValidityErrors(){
List<String> allErrors = new ArrayList<String>();
for (ModelMetaData model:this.models.getMap().values()) {
@@ -259,7 +246,6 @@
}
@Override
- @ManagementProperty(description = "Is VDB Valid", readOnly=true)
public boolean isValid() {
if (!getValidityErrors().isEmpty()) {
return false;
@@ -310,12 +296,10 @@
// This one manages the JAXB binding
@Override
@XmlElement(name = "property", type = PropertyMetadata.class)
- @ManagementProperty(description = "VDB Properties", managed=true)
public List<PropertyMetadata> getJAXBProperties(){
return super.getJAXBProperties();
}
- @ManagementProperty(description="Is this a Dynamic VDB")
public boolean isDynamic() {
return dynamic;
}
@@ -325,7 +309,6 @@
}
@Override
- @ManagementProperty(description="Data Policies in a VDB", managed=true)
public List<DataPolicy> getDataPolicies(){
return new ArrayList<DataPolicy>(this.dataPolicies.getMap().values());
}
Modified:
branches/as7/client/src/main/java/org/teiid/adminapi/impl/VDBTranslatorMetaData.java
===================================================================
---
branches/as7/client/src/main/java/org/teiid/adminapi/impl/VDBTranslatorMetaData.java 2011-07-01
20:26:47 UTC (rev 3300)
+++
branches/as7/client/src/main/java/org/teiid/adminapi/impl/VDBTranslatorMetaData.java 2011-07-04
19:09:19 UTC (rev 3301)
@@ -28,16 +28,10 @@
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
-import org.jboss.managed.api.annotation.ManagementObject;
-import org.jboss.managed.api.annotation.ManagementObjectID;
-import org.jboss.managed.api.annotation.ManagementProperties;
-import org.jboss.managed.api.annotation.ManagementProperty;
-import org.jboss.managed.api.annotation.ManagementPropertyFactory;
import org.teiid.adminapi.Translator;
@XmlAccessorType(XmlAccessType.NONE)
-(a)ManagementObject(properties=ManagementProperties.EXPLICIT)
public class VDBTranslatorMetaData extends AdminObjectImpl implements Translator {
private static final long serialVersionUID = -3454161477587996138L;
private String type;
@@ -46,8 +40,6 @@
private String moduleName;
@Override
- @ManagementProperty(description="Name of the Translator", mandatory = true)
- @ManagementObjectID(type="translator")
public String getName() {
return super.getName();
}
@@ -58,7 +50,6 @@
}
@Override
- @ManagementProperty(description="Base type of Translator", mandatory = true)
public String getType() {
return type;
}
@@ -70,8 +61,6 @@
@Override
@XmlElement(name = "property", type = PropertyMetadata.class)
- @ManagementProperty(name="property", description = "Translator
Properties", managed=true)
- @ManagementPropertyFactory(TranslatorPropertyFactory.class)
public List<PropertyMetadata> getJAXBProperties(){
return super.getJAXBProperties();
}
@@ -89,7 +78,6 @@
addProperty(EXECUTION_FACTORY_CLASS, clazz.getName());
}
- @ManagementProperty(description="Translator Description")
public String getDescription() {
return this.description;
}
Modified:
branches/as7/client/src/main/java/org/teiid/adminapi/impl/WorkerPoolStatisticsMetadata.java
===================================================================
---
branches/as7/client/src/main/java/org/teiid/adminapi/impl/WorkerPoolStatisticsMetadata.java 2011-07-01
20:26:47 UTC (rev 3300)
+++
branches/as7/client/src/main/java/org/teiid/adminapi/impl/WorkerPoolStatisticsMetadata.java 2011-07-04
19:09:19 UTC (rev 3301)
@@ -22,14 +22,11 @@
package org.teiid.adminapi.impl;
-import org.jboss.managed.api.annotation.ManagementProperty;
-import org.jboss.metatype.api.annotations.MetaMapping;
import org.teiid.adminapi.WorkerPoolStatistics;
/**
* This class is a holder for all the statistics gathered about a worker pool.
*/
-(a)MetaMapping(WorkerPoolStatisticsMetadataMapper.class)
public class WorkerPoolStatisticsMetadata extends AdminObjectImpl implements
WorkerPoolStatistics {
private static final long serialVersionUID = -4917902925523802295L;
@@ -44,49 +41,41 @@
private long totalCompleted;
@Override
- @ManagementProperty(description="Number of Active Threads", readOnly=true)
public int getActiveThreads() {
return activeThreads;
}
@Override
- @ManagementProperty(description="Highest active threads", readOnly=true)
public int getHighestActiveThreads() {
return highestActiveThreads;
}
@Override
- @ManagementProperty(description="Total Completed Tasks", readOnly=true)
public long getTotalCompleted() {
return totalCompleted;
}
@Override
- @ManagementProperty(description="Total submitted Tasks", readOnly=true)
public long getTotalSubmitted() {
return totalSubmitted;
}
@Override
- @ManagementProperty(description="Queue Name", readOnly=true)
public String getQueueName() {
return getName();
}
@Override
- @ManagementProperty(description="Currently Queued Tasks", readOnly=true)
public int getQueued() {
return queued;
}
@Override
- @ManagementProperty(description="Highest Queued Tasks", readOnly=true)
public int getHighestQueued() {
return highestQueued;
}
@Override
- @ManagementProperty(description="Max Threads", readOnly=true)
public int getMaxThreads() {
return maxThreads;
}
Deleted:
branches/as7/client/src/main/java/org/teiid/adminapi/impl/WorkerPoolStatisticsMetadataMapper.java
===================================================================
---
branches/as7/client/src/main/java/org/teiid/adminapi/impl/WorkerPoolStatisticsMetadataMapper.java 2011-07-01
20:26:47 UTC (rev 3300)
+++
branches/as7/client/src/main/java/org/teiid/adminapi/impl/WorkerPoolStatisticsMetadataMapper.java 2011-07-04
19:09:19 UTC (rev 3301)
@@ -1,72 +0,0 @@
-/*
- * 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.adminapi.impl;
-
-import org.jboss.dmr.ModelNode;
-import org.jboss.dmr.ModelType;
-
-public class WorkerPoolStatisticsMetadataMapper {
- private static final String MAX_THREADS = "maxThreads"; //$NON-NLS-1$
- private static final String HIGHEST_QUEUED = "highestQueued"; //$NON-NLS-1$
- private static final String QUEUED = "queued"; //$NON-NLS-1$
- private static final String QUEUE_NAME = "queueName"; //$NON-NLS-1$
- private static final String TOTAL_SUBMITTED = "totalSubmitted"; //$NON-NLS-1$
- private static final String TOTAL_COMPLETED = "totalCompleted"; //$NON-NLS-1$
- private static final String HIGHEST_ACTIVE_THREADS = "highestActiveThreads";
//$NON-NLS-1$
- private static final String ACTIVE_THREADS = "activeThreads"; //$NON-NLS-1$
-
-
- public static ModelNode wrap(WorkerPoolStatisticsMetadata object) {
- if (object == null)
- return null;
- ModelNode transaction = new ModelNode();
- transaction.get(ModelNodeConstants.TYPE).set(ModelType.OBJECT);
-
- transaction.get(ACTIVE_THREADS).set(object.getActiveThreads());
- transaction.get(HIGHEST_ACTIVE_THREADS).set(object.getHighestActiveThreads());
- transaction.get(TOTAL_COMPLETED).set(object.getTotalCompleted());
- transaction.get(TOTAL_SUBMITTED).set(object.getTotalSubmitted());
- transaction.get(QUEUE_NAME).set(object.getQueueName());
- transaction.get(QUEUED).set(object.getQueued());
- transaction.get(HIGHEST_QUEUED).set(object.getHighestQueued());
- transaction.get(MAX_THREADS).set(object.getMaxThreads());
-
- return transaction;
- }
-
- public static WorkerPoolStatisticsMetadata unwrapMetaValue(ModelNode node) {
- if (node == null)
- return null;
-
- WorkerPoolStatisticsMetadata stats = new WorkerPoolStatisticsMetadata();
- stats.setActiveThreads(node.get(ACTIVE_THREADS).asInt());
- stats.setHighestActiveThreads(node.get(HIGHEST_ACTIVE_THREADS).asInt());
- stats.setTotalCompleted(node.get(TOTAL_COMPLETED).asLong());
- stats.setTotalSubmitted(node.get(TOTAL_SUBMITTED).asLong());
- stats.setQueueName(node.get(QUEUE_NAME).asString());
- stats.setQueued(node.get(QUEUED).asInt());
- stats.setHighestQueued(node.get(HIGHEST_QUEUED).asInt());
- stats.setMaxThreads(node.get(MAX_THREADS).asInt());
- return stats;
- }
-}
Modified: branches/as7/client/src/main/java/org/teiid/net/TeiidURL.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/net/TeiidURL.java 2011-07-01 20:26:47 UTC
(rev 3300)
+++ branches/as7/client/src/main/java/org/teiid/net/TeiidURL.java 2011-07-04 19:09:19 UTC
(rev 3301)
@@ -78,8 +78,6 @@
// constant for password part of url
public static final String PASSWORD = "password"; //$NON-NLS-1$
- public static final String ADMIN = "admin"; //$NON-NLS-1$
-
public static final String PASSTHROUGH_AUTHENTICATION =
"PassthroughAuthentication"; //$NON-NLS-1$
}
Modified:
branches/as7/client/src/main/java/org/teiid/net/socket/SocketServerConnection.java
===================================================================
---
branches/as7/client/src/main/java/org/teiid/net/socket/SocketServerConnection.java 2011-07-01
20:26:47 UTC (rev 3300)
+++
branches/as7/client/src/main/java/org/teiid/net/socket/SocketServerConnection.java 2011-07-04
19:09:19 UTC (rev 3301)
@@ -90,7 +90,6 @@
//ILogon that is allowed to failover
this.logon = this.getService(ILogon.class);
this.failOver =
Boolean.valueOf(connProps.getProperty(TeiidURL.CONNECTION.AUTO_FAILOVER)).booleanValue();
- this.failOver |=
Boolean.valueOf(connProps.getProperty(TeiidURL.CONNECTION.ADMIN)).booleanValue();
selectServerInstance(false);
}
Added: branches/as7/client/src/main/resources/org/teiid/adminapi/i18n.properties
===================================================================
--- branches/as7/client/src/main/resources/org/teiid/adminapi/i18n.properties
(rev 0)
+++ branches/as7/client/src/main/resources/org/teiid/adminapi/i18n.properties 2011-07-04
19:09:19 UTC (rev 3301)
@@ -0,0 +1,65 @@
+description.describe=Description
+vdb-name.describe=The Virtual Database Name
+model-name.describe=Name of the model
+model-path.describe=Path to model file inside the archive
+translator-name.describe=Name of the Translator
+connection-type.describe=Allowable Connections: 1) NONE - disallow new connections 2) BY
VERSION - allow connections only if the version is specified or if this is the earliest
'BY VERSION' vdb and there are no vdbs marked as 'ANY' 3) ANY - allow
connections with or without a version specified. If multiple versions of same VDB are
deployed, connect to one specified with ANY, or if there are multiple VDBs with ANY then
connect to the latest version with ANY
+status.describe=The Virtual Database Status
+vdb-version.describe=The Virtual Database Version
+url.describe=The Virtual Database URL
+dynamic.describe=Dynamic Virtual Database
+property-name.describe=Name
+property-value.describe=Property value
+visible.describe=Visibility of the model
+model-type.describe=Type of the Model(PHYSICAL, VIRTUAL, FUNCTION, OTHER)
+source-name.describe=Source name for this model
+jndi-name.describe=Connection JNDI Name
+translator-name.describe=Name of the translator
+error-path.describe=Path to the error in the Virtual Database
+severity.describe=Severity
+message.describe=Error message
+base-type.describe=Translator Base Type
+module-name.describe=Translator's Module name
+allow-create-temp-tables.describe=Allows create of temporary table
+any-authenticated.describe=Indicates if the role is mapped to any authenticated user
+policy-name.describe=Resource Name, for which permission defined
+properties.describe=properties
+source-mappings.describe=Model to source mapping
+validity-errors.describe=Model validation errors
+models.describe=Models inside a virtual database
+override-translators.describe=Overridden translators for the Virtual Database
+data-policies.describe=Data access policies defined for the Virtual Database
+data-permissions.describe=Permissions defined for data access
+mapped-role-names.describe=Policy name to role name mapping
+
+execution-id.describe=Unique Identifier for Request
+session-id.describe=Session Identifier
+start-time.describe=Start time for the request
+command.describe=Executing Command
+source-request.describe=Is this Connector level request
+node-id.describe=Node Identifier
+transaction-id.describe=Get Transaction XID if transaction involved
+processing-state.describe=State of the Request
+thread-state.describe=Thread state
+
+application-name.describe=Application assosiated with Session
+created-time.describe=When session created
+client-host-address.describe=Host name from where the session created
+ip-address.describe=IP address from where session is created
+last-ping-time.describe=Last ping time
+user-name.describe=User name associated with session
+security-domain.describe=Security domain that session used for login
+
+
+txn-created-time.describe=Transaction created time
+txn-scope.describe=Transaction scope (Request, Local, Global)
+txn-id.describe=Transaction Identifier (XID)
+
+max-threads.describe=Max Threads
+highest-queued.describe=Highest Queued Tasks
+queued.describe=Currently Queued Tasks
+queue-name.describe=Queue Name
+total-submitted.describe=Total submitted Tasks
+total-completed.describe=Total Completed Tasks
+highest-active-threads.describe=Highest active threads
+active-threads.describe=Number of Active Threads
\ No newline at end of file
Property changes on:
branches/as7/client/src/main/resources/org/teiid/adminapi/i18n.properties
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestRequestMetadata.java
===================================================================
---
branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestRequestMetadata.java 2011-07-01
20:26:47 UTC (rev 3300)
+++
branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestRequestMetadata.java 2011-07-04
19:09:19 UTC (rev 3301)
@@ -22,24 +22,113 @@
package org.teiid.adminapi.impl;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
-import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.dmr.ModelNode;
import org.junit.Test;
import org.teiid.adminapi.Request.ProcessingState;
-
+import org.teiid.adminapi.Request.ThreadState;
+@SuppressWarnings("nls")
public class TestRequestMetadata {
@Test public void testMapping() {
- RequestMetadata request = new RequestMetadata();
- request.setState(ProcessingState.PROCESSING);
+ RequestMetadata request = buildRequest();
- RequestMetadataMapper rmm = new RequestMetadataMapper();
- MetaValue mv = rmm.createMetaValue(rmm.getMetaType(), request);
+ ModelNode node = MetadataMapper.RequestMetadataMapper.wrap(request);
- RequestMetadata request1 = rmm.unwrapMetaValue(mv);
+ RequestMetadata actual = MetadataMapper.RequestMetadataMapper.unwrap(node);
- assertEquals(request.getState(), request1.getState());
+ assertEquals(request, actual);
+ assertEquals(request.getState(), actual.getState());
}
+ private RequestMetadata buildRequest() {
+ RequestMetadata request = new RequestMetadata();
+ request.setState(ProcessingState.PROCESSING);
+ request.setCommand("select * from foo"); //$NON-NLS-1$
+ request.setExecutionId(1234);
+ request.setName("request-name"); //$NON-NLS-1$
+ request.setSessionId("session-id");//$NON-NLS-1$
+ request.setSourceRequest(false);
+ request.setStartTime(12345L);
+ request.setTransactionId("transaction-id");//$NON-NLS-1$
+ request.setThreadState(ThreadState.RUNNING);
+ //request.setNodeId(1);
+ return request;
+ }
+
+ public static final String desc = "{\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"OBJECT\"\n" +
+ " },\n" +
+ " \"attributes\" : {\n" +
+ " \"execution-id\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"LONG\"\n" +
+ " },\n" +
+ " \"description\" : \"Unique Identifier for
Request\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"session-id\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
+ " },\n" +
+ " \"description\" : \"Session
Identifier\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"start-time\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"LONG\"\n" +
+ " },\n" +
+ " \"description\" : \"Start time for the
request\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"command\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
+ " },\n" +
+ " \"description\" : \"Executing Command\",\n"
+
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"source-request\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"BOOLEAN\"\n" +
+ " },\n" +
+ " \"description\" : \"Is this Connector level
request\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"node-id\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"INT\"\n" +
+ " },\n" +
+ " \"description\" : \"Node Identifier\",\n" +
+ " \"required\" : false\n" +
+ " },\n" +
+ " \"transaction-id\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
+ " },\n" +
+ " \"description\" : \"Get Transaction XID if
transaction involved\",\n" +
+ " \"required\" : false\n" +
+ " },\n" +
+ " \"processing-state\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
+ " },\n" +
+ " \"description\" : \"State of the
Request\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"thread-state\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
+ " },\n" +
+ " \"description\" : \"Thread state\",\n" +
+ " \"required\" : true\n" +
+ " }\n" +
+ " }\n" +
+ "}";
+ @Test public void testDescribe() {
+ assertEquals(desc, MetadataMapper.RequestMetadataMapper.describe(new
ModelNode()).toJSONString(false));
+ }
+
}
Modified:
branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestSessionMetadata.java
===================================================================
---
branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestSessionMetadata.java 2011-07-01
20:26:47 UTC (rev 3300)
+++
branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestSessionMetadata.java 2011-07-04
19:09:19 UTC (rev 3301)
@@ -22,9 +22,9 @@
package org.teiid.adminapi.impl;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
-import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.dmr.ModelNode;
import org.junit.Test;
@SuppressWarnings("nls")
@@ -34,13 +34,104 @@
SessionMetadata session = new SessionMetadata();
session.setSessionId("test");
session.setApplicationName("foo");
- SessionMetadataMapper smm = new SessionMetadataMapper();
- MetaValue mv = smm.createMetaValue(smm.getMetaType(), session);
+ session.setClientHostName("localhost");
+ session.setCreatedTime(1234);
+ session.setIPAddress("127.0.0.1");
+ session.setVDBName("vdb-name");
+ session.setVDBVersion(2);
+ session.setSecurityContext("auth-domain");
+ session.setUserName("user");
+
+ ModelNode node = MetadataMapper.SessionMetadataMapper.wrap(session);
- SessionMetadata session1 = smm.unwrapMetaValue(mv);
+ SessionMetadata session1 = MetadataMapper.SessionMetadataMapper.unwrap(node);
assertEquals(session.getSessionId(), session1.getSessionId());
assertEquals(session.getApplicationName(), session1.getApplicationName());
+
}
-
+
+ private static final String describe = "{\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"OBJECT\"\n" +
+ " },\n" +
+ " \"attributes\" : {\n" +
+ " \"application-name\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
+ " },\n" +
+ " \"description\" : \"Application assosiated with
Session\",\n" +
+ " \"required\" : false\n" +
+ " },\n" +
+ " \"created-time\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"LONG\"\n" +
+ " },\n" +
+ " \"description\" : \"When session
created\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"client-host-address\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"LONG\"\n" +
+ " },\n" +
+ " \"description\" : \"Host name from where the session
created\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"ip-address\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
+ " },\n" +
+ " \"description\" : \"IP address from where session is
created\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"last-ping-time\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"LONG\"\n" +
+ " },\n" +
+ " \"description\" : \"Last ping time\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"session-id\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
+ " },\n" +
+ " \"description\" : \"Session
Identifier\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"user-name\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
+ " },\n" +
+ " \"description\" : \"User name associated with
session\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"vdb-name\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
+ " },\n" +
+ " \"description\" : \"The Virtual Database
Name\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"vdb-version\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"INT\"\n" +
+ " },\n" +
+ " \"description\" : \"The Virtual Database
Version\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"security-domain\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
+ " },\n" +
+ " \"description\" : \"Security domain that session used
for login\",\n" +
+ " \"required\" : false\n" +
+ " }\n" +
+ " }\n" +
+ "}";
+
+ @Test public void testDescribe() {
+ ModelNode n = MetadataMapper.SessionMetadataMapper.describe(new ModelNode());
+ //System.out.println(n.toJSONString(false));
+ assertEquals(describe, n.toJSONString(false));
+ }
}
Modified:
branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestTransactionMetadata.java
===================================================================
---
branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestTransactionMetadata.java 2011-07-01
20:26:47 UTC (rev 3300)
+++
branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestTransactionMetadata.java 2011-07-04
19:09:19 UTC (rev 3301)
@@ -22,9 +22,9 @@
package org.teiid.adminapi.impl;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
-import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.dmr.ModelNode;
import org.junit.Test;
@SuppressWarnings("nls")
@@ -33,13 +33,60 @@
@Test public void testMapping() {
TransactionMetadata tm = new TransactionMetadata();
tm.setAssociatedSession("x");
-
- TransactionMetadataMapper tmm = new TransactionMetadataMapper();
- MetaValue mv = tmm.createMetaValue(tmm.getMetaType(), tm);
+ tm.setCreatedTime(1234);
+ tm.setId("tnx-id");
+ tm.setScope("scope");
- TransactionMetadata tm1 = tmm.unwrapMetaValue(mv);
+ ModelNode node = MetadataMapper.TransactionMetadataMapper.wrap(tm);
+ TransactionMetadata tm1 = MetadataMapper.TransactionMetadataMapper.unwrap(node);
+
assertEquals(tm.getAssociatedSession(), tm1.getAssociatedSession());
+
+ assertEquals(tm.getCreatedTime(), tm1.getCreatedTime());
+ assertEquals(tm.getId(), tm1.getId());
+ assertEquals(tm.getScope(), tm1.getScope());
}
+ private static final String describe = "{\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"OBJECT\"\n" +
+ " },\n" +
+ " \"attributes\" : {\n" +
+ " \"session-id\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
+ " },\n" +
+ " \"description\" : \"Session
Identifier\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"txn-created-time\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"LONG\"\n" +
+ " },\n" +
+ " \"description\" : \"Transaction created
time\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"txn-scope\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"LONG\"\n" +
+ " },\n" +
+ " \"description\" : \"Transaction scope (Request,
Local, Global)\",\n" +
+ " \"required\" : true\n" +
+ " },\n" +
+ " \"txn-id\" : {\n" +
+ " \"type\" : {\n" +
+ " \"TYPE_MODEL_VALUE\" : \"STRING\"\n" +
+ " },\n" +
+ " \"description\" : \"Transaction Identifier
(XID)\",\n" +
+ " \"required\" : true\n" +
+ " }\n" +
+ " }\n" +
+ "}";
+ @Test
+ public void testDescribe() {
+ ModelNode n = MetadataMapper.TransactionMetadataMapper.describe(new ModelNode());
+ //System.out.println(n.toJSONString(false));
+ assertEquals(describe, n.toJSONString(false));
+ }
}
Modified: branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java
===================================================================
---
branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java 2011-07-01
20:26:47 UTC (rev 3300)
+++
branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java 2011-07-04
19:09:19 UTC (rev 3301)
@@ -21,14 +21,9 @@
*/
package org.teiid.adminapi.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
-import java.io.StringReader;
-import java.io.StringWriter;
+import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
@@ -42,12 +37,15 @@
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
+import org.jboss.dmr.ModelNode;
import org.junit.Test;
import org.teiid.adminapi.DataPolicy;
import org.teiid.adminapi.Model;
import org.teiid.adminapi.Translator;
import org.teiid.adminapi.impl.DataPolicyMetadata.PermissionMetaData;
+import org.teiid.core.util.ObjectConverterUtil;
import org.teiid.core.util.PropertiesUtils;
+import org.teiid.core.util.UnitTestUtil;
@SuppressWarnings("nls")
public class TestVDBMetaData {
@@ -55,61 +53,8 @@
@Test
public void testMarshellUnmarshell() throws Exception {
- VDBMetaData vdb = new VDBMetaData();
- vdb.setName("myVDB"); //$NON-NLS-1$
- vdb.setDescription("vdb description"); //$NON-NLS-1$
- vdb.setVersion(1);
- vdb.addProperty("vdb-property", "vdb-value"); //$NON-NLS-1$
//$NON-NLS-2$
+ VDBMetaData vdb = buildVDB();
- ModelMetaData modelOne = new ModelMetaData();
- modelOne.setName("model-one"); //$NON-NLS-1$
- modelOne.addSourceMapping("s1", "translator",
"java:mybinding"); //$NON-NLS-1$ //$NON-NLS-2$
- modelOne.setModelType(Model.Type.PHYSICAL); //$NON-NLS-1$
- modelOne.addProperty("model-prop", "model-value"); //$NON-NLS-1$
//$NON-NLS-2$
- modelOne.addProperty("model-prop", "model-value-override");
//$NON-NLS-1$ //$NON-NLS-2$
- modelOne.setVisible(false);
- modelOne.addError("ERROR", "There is an error in VDB");
//$NON-NLS-1$ //$NON-NLS-2$
- modelOne.setDescription("model description");
-
- vdb.addModel(modelOne);
-
- ModelMetaData modelTwo = new ModelMetaData();
- modelTwo.setName("model-two"); //$NON-NLS-1$
- modelTwo.addSourceMapping("s1", "translator",
"java:binding-one"); //$NON-NLS-1$ //$NON-NLS-2$
- modelTwo.addSourceMapping("s2", "translator",
"java:binding-two"); //$NON-NLS-1$ //$NON-NLS-2$
- modelTwo.setModelType(Model.Type.VIRTUAL); //$NON-NLS-1$
- modelTwo.addProperty("model-prop", "model-value"); //$NON-NLS-1$
//$NON-NLS-2$
-
- vdb.addModel(modelTwo);
-
- TranslatorMetaData t1 = new TranslatorMetaData();
- t1.setName("oracleOverride");
- t1.setType("oracle");
- t1.setDescription("hello world");
- t1.addProperty("my-property", "my-value");
- List<Translator> list = new ArrayList<Translator>();
- list.add(t1);
- vdb.setOverrideTranslators(list);
-
- DataPolicyMetadata roleOne = new DataPolicyMetadata();
- roleOne.setName("roleOne"); //$NON-NLS-1$
- roleOne.setDescription("roleOne described"); //$NON-NLS-1$
- roleOne.setAllowCreateTemporaryTables(true);
- PermissionMetaData perm1 = new PermissionMetaData();
- perm1.setResourceName("myTable.T1"); //$NON-NLS-1$
- perm1.setAllowRead(true);
- roleOne.addPermission(perm1);
-
- PermissionMetaData perm2 = new PermissionMetaData();
- perm2.setResourceName("myTable.T2"); //$NON-NLS-1$
- perm2.setAllowRead(false);
- perm2.setAllowDelete(true);
- roleOne.addPermission(perm2);
-
- roleOne.setMappedRoleNames(Arrays.asList("ROLE1", "ROLE2"));
//$NON-NLS-1$ //$NON-NLS-2$
-
- vdb.addDataPolicy(roleOne);
-
SchemaFactory schemaFactory =
SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema schema =
schemaFactory.newSchema(VDBMetaData.class.getResource("/vdb-deployer.xsd"));
//$NON-NLS-1$
JAXBContext jc = JAXBContext.newInstance(new Class<?>[] {VDBMetaData.class});
@@ -127,6 +72,12 @@
un.setSchema(schema);
vdb = (VDBMetaData)un.unmarshal(new StringReader(sw.toString()));
+ validateVDB(vdb);
+ }
+
+ private void validateVDB(VDBMetaData vdb) {
+ ModelMetaData modelOne;
+ ModelMetaData modelTwo;
assertEquals("myVDB", vdb.getName()); //$NON-NLS-1$
assertEquals("vdb description", vdb.getDescription()); //$NON-NLS-1$
assertEquals(1, vdb.getVersion());
@@ -187,6 +138,65 @@
}
}
}
+
+ private VDBMetaData buildVDB() {
+ VDBMetaData vdb = new VDBMetaData();
+ vdb.setName("myVDB"); //$NON-NLS-1$
+ vdb.setDescription("vdb description"); //$NON-NLS-1$
+ vdb.setVersion(1);
+ vdb.addProperty("vdb-property", "vdb-value"); //$NON-NLS-1$
//$NON-NLS-2$
+ vdb.addProperty("vdb-property2", "vdb-value2"); //$NON-NLS-1$
//$NON-NLS-2$
+
+ ModelMetaData modelOne = new ModelMetaData();
+ modelOne.setName("model-one"); //$NON-NLS-1$
+ modelOne.addSourceMapping("s1", "translator",
"java:mybinding"); //$NON-NLS-1$ //$NON-NLS-2$
+ modelOne.setModelType(Model.Type.PHYSICAL); //$NON-NLS-1$
+ modelOne.addProperty("model-prop", "model-value"); //$NON-NLS-1$
//$NON-NLS-2$
+ modelOne.addProperty("model-prop", "model-value-override");
//$NON-NLS-1$ //$NON-NLS-2$
+ modelOne.setVisible(false);
+ modelOne.addError("ERROR", "There is an error in VDB");
//$NON-NLS-1$ //$NON-NLS-2$
+ modelOne.setDescription("model description");
+
+ vdb.addModel(modelOne);
+
+ ModelMetaData modelTwo = new ModelMetaData();
+ modelTwo.setName("model-two"); //$NON-NLS-1$
+ modelTwo.addSourceMapping("s1", "translator",
"java:binding-one"); //$NON-NLS-1$ //$NON-NLS-2$
+ modelTwo.addSourceMapping("s2", "translator",
"java:binding-two"); //$NON-NLS-1$ //$NON-NLS-2$
+ modelTwo.setModelType(Model.Type.VIRTUAL); //$NON-NLS-1$
+ modelTwo.addProperty("model-prop", "model-value"); //$NON-NLS-1$
//$NON-NLS-2$
+
+ vdb.addModel(modelTwo);
+
+ VDBTranslatorMetaData t1 = new VDBTranslatorMetaData();
+ t1.setName("oracleOverride");
+ t1.setType("oracle");
+ t1.setDescription("hello world");
+ t1.addProperty("my-property", "my-value");
+ List<Translator> list = new ArrayList<Translator>();
+ list.add(t1);
+ vdb.setOverrideTranslators(list);
+
+ DataPolicyMetadata roleOne = new DataPolicyMetadata();
+ roleOne.setName("roleOne"); //$NON-NLS-1$
+ roleOne.setDescription("roleOne described"); //$NON-NLS-1$
+ roleOne.setAllowCreateTemporaryTables(true);
+ PermissionMetaData perm1 = new PermissionMetaData();
+ perm1.setResourceName("myTable.T1"); //$NON-NLS-1$
+ perm1.setAllowRead(true);
+ roleOne.addPermission(perm1);
+
+ PermissionMetaData perm2 = new PermissionMetaData();
+ perm2.setResourceName("myTable.T2"); //$NON-NLS-1$
+ perm2.setAllowRead(false);
+ perm2.setAllowDelete(true);
+ roleOne.addPermission(perm2);
+
+ roleOne.setMappedRoleNames(Arrays.asList("ROLE1", "ROLE2"));
//$NON-NLS-1$ //$NON-NLS-2$
+
+ vdb.addDataPolicy(roleOne);
+ return vdb;
+ }
@Test
public void testAdminMOCreation() {
@@ -203,4 +213,20 @@
vdb.setUrl(new URL("file:///x/foo.2.vdb"));
assertEquals(2, vdb.getVersion());
}
+
+ @Test public void testVDBMetaDataMapper() {
+ VDBMetaData vdb = buildVDB();
+
+ ModelNode node = MetadataMapper.wrap(vdb);
+
+ vdb = MetadataMapper.unwrap(node);
+ validateVDB(vdb);
+ }
+
+ @Test
+ public void testVDBMetaDataDescribe() throws Exception {
+ ModelNode node = MetadataMapper.describe(new ModelNode());
+ String actual = node.toJSONString(false);
+ assertEquals(ObjectConverterUtil.convertFileToString(new
File(UnitTestUtil.getTestDataPath() + "/vdb-describe.txt")), actual);
+ }
}
Added: branches/as7/client/src/test/resources/vdb-describe.txt
===================================================================
--- branches/as7/client/src/test/resources/vdb-describe.txt (rev
0)
+++ branches/as7/client/src/test/resources/vdb-describe.txt 2011-07-04 19:09:19 UTC (rev
3301)
@@ -0,0 +1,344 @@
+{
+ "type" : {
+ "TYPE_MODEL_VALUE" : "OBJECT"
+ },
+ "attributes" : {
+ "vdb-name" : {
+ "type" : {
+ "TYPE_MODEL_VALUE" : "STRING"
+ },
+ "description" : "The Virtual Database Name",
+ "required" : true
+ },
+ "connection-type" : {
+ "type" : {
+ "TYPE_MODEL_VALUE" : "STRING"
+ },
+ "description" : "Allowable Connections: 1) NONE - disallow new
connections 2) BY VERSION - allow connections only if the version is specified or if this
is the earliest 'BY VERSION' vdb and there are no vdbs marked as 'ANY' 3)
ANY - allow connections with or without a version specified. If multiple versions of same
VDB are deployed, connect to one specified with ANY, or if there are multiple VDBs with
ANY then connect to the latest version with ANY ",
+ "required" : false
+ },
+ "status" : {
+ "type" : {
+ "TYPE_MODEL_VALUE" : "STRING"
+ },
+ "description" : "The Virtual Database Status",
+ "required" : true
+ },
+ "version" : {
+ "type" : {
+ "TYPE_MODEL_VALUE" : "INT"
+ },
+ "description" : "The Virtual Database Version",
+ "required" : true
+ },
+ "url" : {
+ "type" : {
+ "TYPE_MODEL_VALUE" : "STRING"
+ },
+ "description" : "The Virtual Database URL",
+ "required" : false
+ },
+ "description" : {
+ "type" : {
+ "TYPE_MODEL_VALUE" : "STRING"
+ },
+ "description" : "Description",
+ "required" : false
+ },
+ "dynamic" : {
+ "type" : {
+ "TYPE_MODEL_VALUE" : "BOOLEAN"
+ },
+ "description" : "Dynamic Virtual Database",
+ "required" : false
+ }
+ },
+ "allowed" : [
+ "ACTIVE",
+ "INACTIVE"
+ ],
+ "children" : {
+ "properties" : {
+ "description" : "properties",
+ "type" : {
+ "TYPE_MODEL_VALUE" : "OBJECT"
+ },
+ "attributes" : {
+ "property-name" : {
+ "type" : {
+ "TYPE_MODEL_VALUE" : "STRING"
+ },
+ "description" : "Name",
+ "required" : true
+ },
+ "property-value" : {
+ "type" : {
+ "TYPE_MODEL_VALUE" : "STRING"
+ },
+ "description" : "Property value",
+ "required" : true
+ }
+ }
+ },
+ "models" : {
+ "type" : {
+ "TYPE_MODEL_VALUE" : "OBJECT"
+ },
+ "attributes" : {
+ "model-name" : {
+ "type" : {
+ "TYPE_MODEL_VALUE" : "STRING"
+ },
+ "description" : "Name of the model",
+ "required" : true
+ },
+ "description" : {
+ "type" : {
+ "TYPE_MODEL_VALUE" : "STRING"
+ },
+ "description" : "Description",
+ "required" : false
+ },
+ "visible" : {
+ "type" : {
+ "TYPE_MODEL_VALUE" : "BOOLEAN"
+ },
+ "description" : "Visibility of the model",
+ "required" : false
+ },
+ "model-type" : {
+ "type" : {
+ "TYPE_MODEL_VALUE" : "STRING"
+ },
+ "description" : "Type of the Model(PHYSICAL, VIRTUAL,
FUNCTION, OTHER)",
+ "required" : true
+ },
+ "model-path" : {
+ "type" : {
+ "TYPE_MODEL_VALUE" : "STRING"
+ },
+ "description" : "Path to model file inside the
archive",
+ "required" : false
+ }
+ },
+ "allowed" : [
+ "PHYSICAL",
+ "VIRTUAL",
+ "FUNCTION",
+ "OTHER"
+ ],
+ "children" : {
+ "properties" : {
+ "description" : "properties",
+ "type" : {
+ "TYPE_MODEL_VALUE" : "OBJECT"
+ },
+ "attributes" : {
+ "property-name" : {
+ "type" : {
+ "TYPE_MODEL_VALUE" : "STRING"
+ },
+ "description" : "Name",
+ "required" : true
+ },
+ "property-value" : {
+ "type" : {
+ "TYPE_MODEL_VALUE" : "STRING"
+ },
+ "description" : "Property value",
+ "required" : true
+ }
+ }
+ },
+ "source-mappings" : {
+ "description" : "Model to source mapping",
+ "type" : {
+ "TYPE_MODEL_VALUE" : "OBJECT"
+ },
+ "attributes" : {
+ "source-name" : {
+ "type" : {
+ "TYPE_MODEL_VALUE" : "STRING"
+ },
+ "description" : "Source name for this
model",
+ "required" : true
+ },
+ "jndi-name" : {
+ "type" : {
+ "TYPE_MODEL_VALUE" : "STRING"
+ },
+ "description" : "Connection JNDI Name",
+ "required" : true
+ },
+ "translator-name" : {
+ "type" : {
+ "TYPE_MODEL_VALUE" : "STRING"
+ },
+ "description" : "Name of the
translator",
+ "required" : true
+ }
+ }
+ },
+ "validity-errors" : {
+ "description" : "Model validation errors",
+ "type" : {
+ "TYPE_MODEL_VALUE" : "OBJECT"
+ },
+ "attributes" : {
+ "error-path" : {
+ "type" : {
+ "TYPE_MODEL_VALUE" : "STRING"
+ },
+ "description" : "Path to the error in the
Virtual Database",
+ "required" : false
+ },
+ "severity" : {
+ "type" : {
+ "TYPE_MODEL_VALUE" : "STRING"
+ },
+ "description" : "Severity",
+ "required" : true
+ },
+ "message" : {
+ "type" : {
+ "TYPE_MODEL_VALUE" : "STRING"
+ },
+ "description" : "Error message",
+ "required" : true
+ }
+ }
+ }
+ },
+ "description" : "Models inside a virtual database",
+ "min-occurs" : 1
+ },
+ "override-translators" : {
+ "description" : "Overridden translators for the Virtual
Database",
+ "type" : {
+ "TYPE_MODEL_VALUE" : "OBJECT"
+ },
+ "attributes" : {
+ "translator-name" : {
+ "type" : {
+ "TYPE_MODEL_VALUE" : "STRING"
+ },
+ "description" : "Name of the translator",
+ "required" : true
+ },
+ "base-type" : {
+ "type" : {
+ "TYPE_MODEL_VALUE" : "STRING"
+ },
+ "description" : "Translator Base Type",
+ "required" : true
+ },
+ "description" : {
+ "type" : {
+ "TYPE_MODEL_VALUE" : "STRING"
+ },
+ "description" : "Description",
+ "required" : false
+ },
+ "module-name" : {
+ "type" : {
+ "TYPE_MODEL_VALUE" : "STRING"
+ },
+ "description" : "Translator's Module name",
+ "required" : false
+ }
+ },
+ "children" : {"properties" : {
+ "description" : "properties",
+ "type" : {
+ "TYPE_MODEL_VALUE" : "OBJECT"
+ },
+ "attributes" : {
+ "property-name" : {
+ "type" : {
+ "TYPE_MODEL_VALUE" : "STRING"
+ },
+ "description" : "Name",
+ "required" : true
+ },
+ "property-value" : {
+ "type" : {
+ "TYPE_MODEL_VALUE" : "STRING"
+ },
+ "description" : "Property value",
+ "required" : true
+ }
+ }
+ }}
+ },
+ "data-policies" : {
+ "description" : "Data access policies defined for the Virtual
Database",
+ "type" : {
+ "TYPE_MODEL_VALUE" : "OBJECT"
+ },
+ "attributes" : {
+ "policy-name" : {
+ "type" : {
+ "TYPE_MODEL_VALUE" : "STRING"
+ },
+ "description" : "Resource Name, for which permission
defined",
+ "required" : true
+ },
+ "description" : {
+ "type" : {
+ "TYPE_MODEL_VALUE" : "STRING"
+ },
+ "description" : "Description",
+ "required" : false
+ },
+ "allow-create-temp-tables" : {
+ "type" : {
+ "TYPE_MODEL_VALUE" : "BOOLEAN"
+ },
+ "description" : "Allows create of temporary
table",
+ "required" : false
+ },
+ "any-authenticated" : {
+ "type" : {
+ "TYPE_MODEL_VALUE" : "BOOLEAN"
+ },
+ "description" : "Indicates if the role is mapped to
any authenticated user",
+ "required" : false
+ }
+ },
+ "children" : {
+ "data-permissions" : {
+ "type" : {
+ "TYPE_MODEL_VALUE" : "OBJECT"
+ },
+ "attributes" : {
+ "property-name" : {
+ "type" : {
+ "TYPE_MODEL_VALUE" : "STRING"
+ },
+ "description" : "Name",
+ "required" : true
+ },
+ "property-value" : {
+ "type" : {
+ "TYPE_MODEL_VALUE" : "STRING"
+ },
+ "description" : "Property value",
+ "required" : true
+ }
+ },
+ "description" : "Permissions defined for data
access",
+ "min-occurs" : 1
+ },
+ "mapped-role-names" : {
+ "type" : {
+ "TYPE_MODEL_VALUE" : "LIST"
+ },
+ "description" : "Policy name to role name
mapping",
+ "value-type" : {
+ "TYPE_MODEL_VALUE" : "STRING"
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Property changes on: branches/as7/client/src/test/resources/vdb-describe.txt
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
branches/as7/engine/src/main/java/org/teiid/dqp/internal/datamgr/TranslatorRepository.java
===================================================================
---
branches/as7/engine/src/main/java/org/teiid/dqp/internal/datamgr/TranslatorRepository.java 2011-07-01
20:26:47 UTC (rev 3300)
+++
branches/as7/engine/src/main/java/org/teiid/dqp/internal/datamgr/TranslatorRepository.java 2011-07-04
19:09:19 UTC (rev 3301)
@@ -23,6 +23,8 @@
package org.teiid.dqp.internal.datamgr;
import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -48,4 +50,7 @@
return this.translatorRepo.remove(name);
}
+ public List<VDBTranslatorMetaData> getTranslators(){
+ return new ArrayList<VDBTranslatorMetaData>(translatorRepo.values());
+ }
}
\ No newline at end of file
Modified:
branches/as7/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java
===================================================================
---
branches/as7/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java 2011-07-01
20:26:47 UTC (rev 3300)
+++
branches/as7/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java 2011-07-04
19:09:19 UTC (rev 3301)
@@ -105,8 +105,8 @@
}
public Subject getSubject() {
- if (session.getLoginContext() != null) {
- return session.getLoginContext().getSubject();
+ if (session.getSubject() != null) {
+ return session.getSubject();
}
return null;
}
Modified: branches/as7/jboss-integration/pom.xml
===================================================================
--- branches/as7/jboss-integration/pom.xml 2011-07-01 20:26:47 UTC (rev 3300)
+++ branches/as7/jboss-integration/pom.xml 2011-07-04 19:09:19 UTC (rev 3301)
@@ -94,7 +94,11 @@
<artifactId>jboss-as-connector</artifactId>
<scope>provided</scope>
</dependency>
-
+ <dependency>
+ <groupId>org.jboss.as</groupId>
+ <artifactId>jboss-as-security</artifactId>
+ <scope>provided</scope>
+ </dependency>
<!--
<dependency>
<groupId>org.jboss</groupId>
Modified:
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/OperationsConstants.java
===================================================================
---
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/OperationsConstants.java 2011-07-01
20:26:47 UTC (rev 3300)
+++
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/OperationsConstants.java 2011-07-04
19:09:19 UTC (rev 3301)
@@ -35,5 +35,6 @@
public static final String TARGET_VDBVERSION =
"target-vdb-version";//$NON-NLS-1$
public static final String SQL_QUERY = "sql-query";//$NON-NLS-1$
public static final String TIMEOUT_IN_MILLI =
"timeout-in-milli";//$NON-NLS-1$
+ public static final String TRANSLATOR_NAME = "translator-name"; //$NON-NLS-1$
}
Modified:
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineAdd.java
===================================================================
---
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineAdd.java 2011-07-01
20:26:47 UTC (rev 3300)
+++
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineAdd.java 2011-07-04
19:09:19 UTC (rev 3301)
@@ -31,11 +31,13 @@
import org.jboss.as.controller.*;
import org.jboss.as.controller.operations.common.Util;
+import org.jboss.as.security.plugins.SecurityDomainContext;
import org.jboss.as.server.BootOperationContext;
import org.jboss.as.server.BootOperationHandler;
import org.jboss.as.server.deployment.Phase;
import org.jboss.as.server.services.net.SocketBinding;
import org.jboss.dmr.ModelNode;
+import org.jboss.msc.inject.ConcurrentMapInjector;
import org.jboss.msc.service.*;
import org.teiid.cache.CacheConfiguration;
import org.teiid.cache.CacheFactory;
@@ -43,9 +45,10 @@
import org.teiid.deployers.*;
import org.teiid.dqp.internal.datamgr.TranslatorRepository;
import org.teiid.jboss.deployers.RuntimeEngineDeployer;
+import org.teiid.logging.LogConstants;
+import org.teiid.logging.LogManager;
import org.teiid.query.function.SystemFunctionManager;
import org.teiid.services.BufferServiceImpl;
-import org.teiid.services.SessionServiceImpl;
import org.teiid.transport.ClientServiceRegistry;
import org.teiid.transport.SSLConfiguration;
import org.teiid.transport.SocketConfiguration;
@@ -79,9 +82,6 @@
TranslatorRepositoryService translatorService = new
TranslatorRepositoryService(translatorRepo);
target.addService(TeiidServiceNames.TRANSLATOR_REPO,
translatorService);
- final SessionServiceImpl sessionService =
buildSessionService(queryEngineNode);
- sessionService.setVDBRepository(vdbRepo);
-
final BufferServiceImpl bufferManager =
buildBufferManager(queryEngineNode.get(Configuration.BUFFER_SERVICE));
CacheFactory cacheFactory =
getCacheFactory(queryEngineNode.get(Configuration.CACHE_FACORY));
@@ -100,16 +100,16 @@
RuntimeEngineDeployer engine = buildQueryEngine(queryEngineNode);
engine.setJdbcSocketConfiguration(jdbc);
engine.setOdbcSocketConfiguration(odbc);
- engine.setSessionService(sessionService);
engine.setBufferService(bufferManager);
engine.setVDBRepository(vdbRepo);
engine.setCacheFactory(cacheFactory);
engine.setResultsetCacheConfig(resultsetCache);
engine.setPreparedPlanCacheConfig(preparePlanCache);
engine.setSecurityHelper(new JBossSecurityHelper());
+ engine.setTranslatorRepository(translatorRepo);
- ServiceBuilder<ClientServiceRegistry> serviceBuilder =
target.addService(RuntimeEngineDeployer.SERVICE_NAME, engine);
+ ServiceBuilder<ClientServiceRegistry> serviceBuilder =
target.addService(TeiidServiceNames.ENGINE, engine);
serviceBuilder.addDependency(ServiceName.JBOSS.append("connector",
"workmanager"), WorkManager.class, engine.workManagerInjector); //$NON-NLS-1$
//$NON-NLS-2$
serviceBuilder.addDependency(ServiceName.JBOSS.append("txn",
"XATerminator"), XATerminator.class, engine.xaTerminatorInjector); //$NON-NLS-1$
//$NON-NLS-2$
@@ -117,18 +117,27 @@
serviceBuilder.addDependency(ServiceName.JBOSS.append("thread",
"executor", asyncExecutor), Executor.class, engine.threadPoolInjector);
//$NON-NLS-1$ //$NON-NLS-2$
serviceBuilder.addDependency(ServiceName.JBOSS.append("binding",
jdbc.getSocketBinding()), SocketBinding.class, engine.jdbcSocketBindingInjector);
//$NON-NLS-1$
serviceBuilder.addDependency(ServiceName.JBOSS.append("binding",
odbc.getSocketBinding()), SocketBinding.class, engine.odbcSocketBindingInjector);
//$NON-NLS-1$
+
+ // add security domains
+ String domainNameOrder =
queryEngineNode.get(Configuration.JDBC_SECURITY_DOMAIN).asString();
+ if (domainNameOrder != null &&
domainNameOrder.trim().length()>0) {
+ LogManager.logInfo(LogConstants.CTX_SECURITY, "Security
Enabled: true"); //$NON-NLS-1$
+ String[] domainNames = domainNameOrder.split(",");
//$NON-NLS-1$
+ for (String domainName : domainNames) {
+
serviceBuilder.addDependency(ServiceName.JBOSS.append("security",
"security-domain", domainName), SecurityDomainContext.class, new
ConcurrentMapInjector<String,SecurityDomainContext>(engine.securityDomains,
domainName)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
serviceBuilder.addListener(new
AbstractServiceListener<Object>() {
@Override
public void serviceStarting(ServiceController<?>
serviceController) {
vdbRepo.start();
- sessionService.start();
bufferManager.start();
}
@Override
public void serviceStopped(ServiceController<?>
serviceController) {
bufferManager.stop();
- sessionService.stop();
}
@Override
@@ -213,25 +222,18 @@
}
if (node.get(Configuration.DETECTING_CHANGE_EVENTS) != null) {
engine.setDetectingChangeEvents(node.get(Configuration.DETECTING_CHANGE_EVENTS).asBoolean());
- }
+ }
+ if (node.get(Configuration.SESSION_EXPIRATION_TIME_LIMIT) != null) {
+
engine.setSessionExpirationTimeLimit(node.get(Configuration.SESSION_EXPIRATION_TIME_LIMIT).asInt());
+ }
+ if (node.get(Configuration.MAX_SESSIONS_ALLOWED) != null) {
+ engine.setSessionMaxLimit(node.get(Configuration.MAX_SESSIONS_ALLOWED).asInt());
+ }
+
return engine;
}
- private SessionServiceImpl buildSessionService(ModelNode node) {
- SessionServiceImpl sessionService = new SessionServiceImpl();
- if (node.get(Configuration.JDBC_SECURITY_DOMAIN) != null) {
-
sessionService.setSecurityDomains(node.get(Configuration.JDBC_SECURITY_DOMAIN).asString());
- }
- if (node.get(Configuration.SESSION_EXPIRATION_TIME_LIMIT) != null) {
-
sessionService.setSessionExpirationTimeLimit(node.get(Configuration.SESSION_EXPIRATION_TIME_LIMIT).asInt());
- }
- if (node.get(Configuration.MAX_SESSIONS_ALLOWED) != null) {
-
sessionService.setSessionMaxLimit(node.get(Configuration.MAX_SESSIONS_ALLOWED).asInt());
- }
- return sessionService;
- }
-
private VDBRepository buildVDBRepository(ModelNode node) {
SystemFunctionManager systemFunctionManager = new SystemFunctionManager();
if (node.get(Configuration.ALLOW_ENV_FUNCTION) != null) {
Deleted:
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineModelHandler.java
===================================================================
---
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineModelHandler.java 2011-07-01
20:26:47 UTC (rev 3300)
+++
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineModelHandler.java 2011-07-04
19:09:19 UTC (rev 3301)
@@ -1,480 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This 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 software 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 software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.teiid.jboss;
-
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.*;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Locale;
-import java.util.ResourceBundle;
-
-import org.jboss.as.controller.*;
-import org.jboss.as.controller.descriptions.DescriptionProvider;
-import org.jboss.dmr.ModelNode;
-import org.jboss.dmr.ModelType;
-import org.jboss.msc.service.ServiceController;
-import org.teiid.adminapi.AdminException;
-import org.teiid.adminapi.impl.*;
-import org.teiid.jboss.deployers.RuntimeEngineDeployer;
-
-abstract class QueryEngineModelHandler implements OperationHandler, DescriptionProvider
{
- private static final String DESCRIBE = ".describe"; //$NON-NLS-1$
-
- private String operationName;
-
- protected QueryEngineModelHandler(String operationName){
- this.operationName = operationName;
- }
-
- @Override
- public OperationResult execute(final OperationContext context, final ModelNode
operation, final ResultHandler resultHandler) throws OperationFailedException {
-
- final RuntimeOperationContext runtimeContext = context.getRuntimeContext();
- if (runtimeContext != null) {
- runtimeContext.setRuntimeTask(new RuntimeTask() {
-
- @Override
- public void execute(RuntimeTaskContext context) throws
OperationFailedException {
- ServiceController<?> sc =
context.getServiceRegistry().getRequiredService(RuntimeEngineDeployer.SERVICE_NAME);
- RuntimeEngineDeployer engine =
RuntimeEngineDeployer.class.cast(sc.getValue());
-
- resultHandler.handleResultFragment(ResultHandler.EMPTY_LOCATION,
executeOperation(engine, operation));
- }});
- }
-
- resultHandler.handleResultComplete();
- return new BasicOperationResult();
- }
-
- @Override
- public ModelNode getModelDescription(final Locale locale) {
- final ResourceBundle bundle = IntegrationPlugin.getResourceBundle(locale);
- final ModelNode operation = new ModelNode();
- operation.get(OPERATION_NAME).set(this.operationName);
-
operation.get(DESCRIPTION).set(bundle.getString(getBundleOperationName()+DESCRIBE));
- describeParameters(operation, bundle);
- return operation;
- }
-
- protected String getBundleOperationName() {
- return RuntimeEngineDeployer.class.getSimpleName()+"."+this.operationName;
//$NON-NLS-1$
- }
-
- protected String getParameterDescription(ResourceBundle bundle, String parmName) {
- return
bundle.getString(RuntimeEngineDeployer.class.getSimpleName()+"."+this.operationName+"."+parmName+DESCRIBE);
//$NON-NLS-1$ //$NON-NLS-2$
- }
-
- abstract protected ModelNode executeOperation(RuntimeEngineDeployer engine, ModelNode
operation) throws OperationFailedException;
-
- protected void describeParameters(@SuppressWarnings("unused") ModelNode
operationNode, @SuppressWarnings("unused")ResourceBundle bundle) {
- }
-}
-
-class GetRuntimeVersion extends QueryEngineModelHandler{
- protected GetRuntimeVersion(String operationName) {
- super(operationName);
- }
- @Override
- protected ModelNode executeOperation(RuntimeEngineDeployer engine, ModelNode operation)
throws OperationFailedException{
- ModelNode node = new ModelNode();
- node.set(engine.getRuntimeVersion());
- return node;
- }
-}
-
-class GetActiveSessionsCount extends QueryEngineModelHandler{
- protected GetActiveSessionsCount(String operationName) {
- super(operationName);
- }
- @Override
- protected ModelNode executeOperation(RuntimeEngineDeployer engine, ModelNode operation)
throws OperationFailedException{
- ModelNode node = new ModelNode();
- try {
- node.set(String.valueOf(engine.getActiveSessionsCount()));
- } catch (AdminException e) {
- // TODO: handle exception in model node terms
- }
- return node;
- }
-}
-
-class GetActiveSessions extends QueryEngineModelHandler{
- protected GetActiveSessions(String operationName) {
- super(operationName);
- }
- @Override
- protected ModelNode executeOperation(RuntimeEngineDeployer engine, ModelNode operation)
throws OperationFailedException{
- ModelNode node = new ModelNode();
- node.get(TYPE).set(ModelType.LIST);
-
- try {
- Collection<SessionMetadata> sessions = engine.getActiveSessions();
- for (SessionMetadata session:sessions) {
- node.add(SessionMetadataMapper.wrap(session));
- }
- } catch (AdminException e) {
- // TODO: handle exception in model node terms
- }
- return node;
- }
-}
-
-class GetRequestsPerSession extends QueryEngineModelHandler{
- protected GetRequestsPerSession(String operationName) {
- super(operationName);
- }
- @Override
- protected ModelNode executeOperation(RuntimeEngineDeployer engine, ModelNode operation)
throws OperationFailedException{
- ModelNode node = new ModelNode();
- node.get(TYPE).set(ModelType.LIST);
-
- List<RequestMetadata> requests =
engine.getRequestsForSession(operation.get(OperationsConstants.SESSION).asString());
- for (RequestMetadata request:requests) {
- node.add(RequestMetadataMapper.wrap(request));
- }
- return node;
- }
-
- protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SESSION,
TYPE).set(ModelType.STRING);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SESSION,
REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SESSION,
DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.SESSION));
-
- //TODO: define response??
- }
-}
-
-class GetRequestsPerVDB extends QueryEngineModelHandler{
- protected GetRequestsPerVDB(String operationName) {
- super(operationName);
- }
- @Override
- protected ModelNode executeOperation(RuntimeEngineDeployer engine, ModelNode operation)
throws OperationFailedException{
- ModelNode node = new ModelNode();
- node.get(TYPE).set(ModelType.LIST);
-
- try {
- String vdbName = operation.get(OperationsConstants.VDB_NAME).asString();
- int vdbVersion = operation.get(OperationsConstants.VDB_VERSION).asInt();
- List<RequestMetadata> requests =
engine.getRequestsUsingVDB(vdbName,vdbVersion);
- for (RequestMetadata request:requests) {
- node.add(RequestMetadataMapper.wrap(request));
- }
- } catch (AdminException e) {
- // TODO: handle exception in model node terms
- }
- return node;
- }
-
- protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_NAME,
TYPE).set(ModelType.STRING);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_NAME,
REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_NAME,
DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.VDB_NAME));
-
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION,
TYPE).set(ModelType.INT);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION,
REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION,
DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.VDB_VERSION));
-
- //TODO: define response??
- }
-}
-
-class GetLongRunningQueries extends QueryEngineModelHandler{
- protected GetLongRunningQueries(String operationName) {
- super(operationName);
- }
- @Override
- protected ModelNode executeOperation(RuntimeEngineDeployer engine, ModelNode operation)
throws OperationFailedException{
- ModelNode node = new ModelNode();
- node.get(TYPE).set(ModelType.LIST);
-
- List<RequestMetadata> requests = engine.getLongRunningRequests();
- for (RequestMetadata request:requests) {
- node.add(RequestMetadataMapper.wrap(request));
- }
- return node;
- }
-}
-
-class TerminateSession extends QueryEngineModelHandler{
- protected TerminateSession(String operationName) {
- super(operationName);
- }
- @Override
- protected ModelNode executeOperation(RuntimeEngineDeployer engine, ModelNode operation)
throws OperationFailedException{
- ModelNode node = new ModelNode();
- engine.terminateSession(operation.get(OperationsConstants.SESSION).asString());
- return node;
- }
-
- protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SESSION,
TYPE).set(ModelType.STRING);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SESSION,
REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SESSION,
DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.SESSION));
- }
-}
-
-class CancelQuery extends QueryEngineModelHandler{
- protected CancelQuery(String operationName) {
- super(operationName);
- }
- @Override
- protected ModelNode executeOperation(RuntimeEngineDeployer engine, ModelNode operation)
throws OperationFailedException{
- ModelNode node = new ModelNode();
- try {
- engine.cancelRequest(operation.get(OperationsConstants.SESSION).asString(),
operation.get(OperationsConstants.EXECUTION_ID).asLong());
- } catch (AdminException e) {
- // TODO: handle exception in model node terms
- }
- return node;
- }
-
- protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SESSION,
TYPE).set(ModelType.STRING);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SESSION,
REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SESSION,
DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.SESSION));
-
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.EXECUTION_ID,
TYPE).set(ModelType.LONG);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.EXECUTION_ID,
REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.EXECUTION_ID,
DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.EXECUTION_ID));
- }
-}
-
-class CacheTypes extends QueryEngineModelHandler{
- protected CacheTypes(String operationName) {
- super(operationName);
- }
- @Override
- protected ModelNode executeOperation(RuntimeEngineDeployer engine, ModelNode operation)
throws OperationFailedException {
- ModelNode node = new ModelNode();
- node.get(TYPE).set(ModelType.LIST);
- Collection<String> types = engine.getCacheTypes();
- for (String type:types) {
- node.add(type);
- }
- return node;
- }
-}
-
-class ClearCache extends QueryEngineModelHandler{
-
- protected ClearCache(String operationName) {
- super(operationName);
- }
- @Override
- protected ModelNode executeOperation(RuntimeEngineDeployer engine, ModelNode operation)
throws OperationFailedException {
- ModelNode node = new ModelNode();
- String cacheType = operation.get(OperationsConstants.CACHE_TYPE).asString();
-
- if (operation.get(OperationsConstants.VDB_NAME) != null &&
operation.get(OperationsConstants.VDB_VERSION) != null) {
- String vdbName = operation.get(OperationsConstants.VDB_NAME).asString();
- int vdbVersion = operation.get(OperationsConstants.VDB_VERSION).asInt();
- engine.clearCache(cacheType, vdbName, vdbVersion);
- }
- else {
- engine.clearCache(cacheType);
- }
- return node;
- }
-
- protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.CACHE_TYPE,
TYPE).set(ModelType.STRING);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.CACHE_TYPE,
REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.CACHE_TYPE,
DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.CACHE_TYPE));
-
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_NAME,
TYPE).set(ModelType.STRING);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_NAME,
REQUIRED).set(false);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_NAME,
DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.VDB_NAME));
-
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION,
TYPE).set(ModelType.INT);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION,
REQUIRED).set(false);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION,
DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.VDB_VERSION));
-
- }
-}
-
-class CacheStatistics extends QueryEngineModelHandler{
-
- protected CacheStatistics(String operationName) {
- super(operationName);
- }
- @Override
- protected ModelNode executeOperation(RuntimeEngineDeployer engine, ModelNode operation)
throws OperationFailedException {
- String cacheType = operation.get(OperationsConstants.CACHE_TYPE).asString();
- CacheStatisticsMetadata stats = engine.getCacheStatistics(cacheType);
- return CacheStatisticsMetadataMapper.wrap(stats);
- }
-
- protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.CACHE_TYPE,
TYPE).set(ModelType.STRING);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.CACHE_TYPE,
REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.CACHE_TYPE,
DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.CACHE_TYPE));
- }
-}
-
-class WorkerPoolStatistics extends QueryEngineModelHandler{
-
- protected WorkerPoolStatistics(String operationName) {
- super(operationName);
- }
- @Override
- protected ModelNode executeOperation(RuntimeEngineDeployer engine, ModelNode operation)
throws OperationFailedException {
- WorkerPoolStatisticsMetadata stats = engine.getWorkerPoolStatistics();
- return WorkerPoolStatisticsMetadataMapper.wrap(stats);
- }
-}
-
-class ActiveTransactions extends QueryEngineModelHandler{
-
- protected ActiveTransactions(String operationName) {
- super(operationName);
- }
- @Override
- protected ModelNode executeOperation(RuntimeEngineDeployer engine, ModelNode operation)
throws OperationFailedException {
- Collection<TransactionMetadata> txns = engine.getTransactions();
-
- ModelNode node = new ModelNode();
- node.get(TYPE).set(ModelType.LIST);
-
- for (TransactionMetadata txn:txns) {
- node.add(TransactionMetadataMapper.wrap(txn));
- }
-
- return node;
- }
-}
-
-class TerminateTransaction extends QueryEngineModelHandler{
-
- protected TerminateTransaction(String operationName) {
- super(operationName);
- }
- @Override
- protected ModelNode executeOperation(RuntimeEngineDeployer engine, ModelNode operation)
throws OperationFailedException {
- String xid = operation.get(OperationsConstants.XID).asString();
- try {
- engine.terminateTransaction(xid);
- } catch (AdminException e) {
- // TODO: Handle exception
- }
- return new ModelNode();
- }
-
- protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.XID,
TYPE).set(ModelType.STRING);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.XID, REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.XID,
DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.XID));
- }
-}
-
-class MergeVDBs extends QueryEngineModelHandler{
-
- protected MergeVDBs(String operationName) {
- super(operationName);
- }
- @Override
- protected ModelNode executeOperation(RuntimeEngineDeployer engine, ModelNode operation)
throws OperationFailedException {
- String sourceVDBName = operation.get(OperationsConstants.SOURCE_VDBNAME).asString();
- int sourceVDBversion = operation.get(OperationsConstants.SOURCE_VDBVERSION).asInt();
- String targetVDBName = operation.get(OperationsConstants.TARGET_VDBNAME).asString();
- int targetVDBversion = operation.get(OperationsConstants.TARGET_VDBVERSION).asInt();
- try {
- engine.mergeVDBs(sourceVDBName, sourceVDBversion, targetVDBName, targetVDBversion);
- } catch (AdminException e) {
- throw new OperationFailedException(new ModelNode().set(e.getMessage()));
- }
- return new ModelNode();
- }
-
- protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SOURCE_VDBNAME,
TYPE).set(ModelType.STRING);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SOURCE_VDBNAME,
REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SOURCE_VDBNAME,
DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.XID));
-
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SOURCE_VDBVERSION,
TYPE).set(ModelType.STRING);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SOURCE_VDBVERSION,
REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SOURCE_VDBVERSION,
DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.XID));
-
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TARGET_VDBNAME,
TYPE).set(ModelType.STRING);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TARGET_VDBNAME,
REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TARGET_VDBNAME,
DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.XID));
-
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TARGET_VDBVERSION,
TYPE).set(ModelType.STRING);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TARGET_VDBVERSION,
REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TARGET_VDBVERSION,
DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.XID));
- }
-}
-
-class ExecuteQuery extends QueryEngineModelHandler{
-
- protected ExecuteQuery(String operationName) {
- super(operationName);
- }
- @Override
- protected ModelNode executeOperation(RuntimeEngineDeployer engine, ModelNode operation)
throws OperationFailedException {
- String vdbName = operation.get(OperationsConstants.VDB_NAME).asString();
- int vdbVersion = operation.get(OperationsConstants.VDB_VERSION).asInt();
- String sql = operation.get(OperationsConstants.SQL_QUERY).asString();
- int timeout = operation.get(OperationsConstants.TIMEOUT_IN_MILLI).asInt();
- ModelNode node = new ModelNode();
- try {
- node.get(TYPE).set(ModelType.LIST);
-
- List<List> results = engine.executeQuery(vdbName, vdbVersion, sql, timeout);
- List colNames = results.get(0);
- for (int rowNum = 1; rowNum < results.size(); rowNum++) {
-
- List row = results.get(rowNum);
- ModelNode rowNode = new ModelNode();
- rowNode.get(TYPE).set(ModelType.OBJECT);
-
- for (int colNum = 0; colNum < colNames.size(); colNum++) {
- //TODO: support in native types instead of string here.
- rowNode.get(ATTRIBUTES,
colNames.get(colNum).toString()).set(row.get(colNum).toString());
- }
- node.add(rowNode);
- }
- } catch (AdminException e) {
- throw new OperationFailedException(new ModelNode().set(e.getMessage()));
- }
- return node;
- }
-
- protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_NAME,
TYPE).set(ModelType.STRING);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_NAME,
REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_NAME,
DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.XID));
-
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION,
TYPE).set(ModelType.STRING);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION,
REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION,
DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.XID));
-
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SQL_QUERY,
TYPE).set(ModelType.STRING);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SQL_QUERY,
REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SQL_QUERY,
DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.XID));
-
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TIMEOUT_IN_MILLI,
TYPE).set(ModelType.STRING);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TIMEOUT_IN_MILLI,
REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TIMEOUT_IN_MILLI,
DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.XID));
- }
-}
\ No newline at end of file
Modified:
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineOperationHandler.java
===================================================================
---
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineOperationHandler.java 2011-07-01
20:26:47 UTC (rev 3300)
+++
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineOperationHandler.java 2011-07-04
19:09:19 UTC (rev 3301)
@@ -55,7 +55,7 @@
@Override
public void execute(RuntimeTaskContext context) throws
OperationFailedException {
- ServiceController<?> sc =
context.getServiceRegistry().getRequiredService(RuntimeEngineDeployer.SERVICE_NAME);
+ ServiceController<?> sc =
context.getServiceRegistry().getRequiredService(TeiidServiceNames.ENGINE);
RuntimeEngineDeployer engine =
RuntimeEngineDeployer.class.cast(sc.getValue());
resultHandler.handleResultFragment(ResultHandler.EMPTY_LOCATION,
executeOperation(engine, operation));
@@ -80,6 +80,10 @@
return RuntimeEngineDeployer.class.getSimpleName()+"."+this.operationName;
//$NON-NLS-1$
}
+ protected String getReplyName() {
+ return getBundleOperationName()+".reply"+DESCRIBE; //$NON-NLS-1$
+ }
+
protected String getParameterDescription(ResourceBundle bundle, String parmName) {
return
bundle.getString(RuntimeEngineDeployer.class.getSimpleName()+"."+this.operationName+"."+parmName+DESCRIBE);
//$NON-NLS-1$ //$NON-NLS-2$
}
@@ -130,7 +134,7 @@
try {
Collection<SessionMetadata> sessions = engine.getActiveSessions();
for (SessionMetadata session:sessions) {
- node.add(SessionMetadataMapper.wrap(session));
+ node.add(MetadataMapper.SessionMetadataMapper.wrap(session));
}
} catch (AdminException e) {
// TODO: handle exception in model node terms
@@ -150,7 +154,7 @@
List<RequestMetadata> requests =
engine.getRequestsForSession(operation.get(OperationsConstants.SESSION).asString());
for (RequestMetadata request:requests) {
- node.add(RequestMetadataMapper.wrap(request));
+ node.add(MetadataMapper.RequestMetadataMapper.wrap(request));
}
return node;
}
@@ -178,7 +182,7 @@
int vdbVersion = operation.get(OperationsConstants.VDB_VERSION).asInt();
List<RequestMetadata> requests =
engine.getRequestsUsingVDB(vdbName,vdbVersion);
for (RequestMetadata request:requests) {
- node.add(RequestMetadataMapper.wrap(request));
+ node.add(MetadataMapper.RequestMetadataMapper.wrap(request));
}
} catch (AdminException e) {
// TODO: handle exception in model node terms
@@ -210,7 +214,7 @@
List<RequestMetadata> requests = engine.getLongRunningRequests();
for (RequestMetadata request:requests) {
- node.add(RequestMetadataMapper.wrap(request));
+ node.add(MetadataMapper.RequestMetadataMapper.wrap(request));
}
return node;
}
@@ -322,7 +326,7 @@
protected ModelNode executeOperation(RuntimeEngineDeployer engine, ModelNode operation)
throws OperationFailedException {
String cacheType = operation.get(OperationsConstants.CACHE_TYPE).asString();
CacheStatisticsMetadata stats = engine.getCacheStatistics(cacheType);
- return CacheStatisticsMetadataMapper.wrap(stats);
+ return MetadataMapper.CacheStatisticsMetadataMapper.wrap(stats);
}
protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
@@ -340,7 +344,7 @@
@Override
protected ModelNode executeOperation(RuntimeEngineDeployer engine, ModelNode operation)
throws OperationFailedException {
WorkerPoolStatisticsMetadata stats = engine.getWorkerPoolStatistics();
- return WorkerPoolStatisticsMetadataMapper.wrap(stats);
+ return MetadataMapper.WorkerPoolStatisticsMetadataMapper.wrap(stats);
}
}
@@ -357,7 +361,7 @@
node.get(TYPE).set(ModelType.LIST);
for (TransactionMetadata txn:txns) {
- node.add(TransactionMetadataMapper.wrap(txn));
+ node.add(MetadataMapper.TransactionMetadataMapper.wrap(txn));
}
return node;
@@ -409,19 +413,19 @@
protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SOURCE_VDBNAME,
TYPE).set(ModelType.STRING);
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SOURCE_VDBNAME,
REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SOURCE_VDBNAME,
DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.XID));
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SOURCE_VDBNAME,
DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.SOURCE_VDBNAME));
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SOURCE_VDBVERSION,
TYPE).set(ModelType.STRING);
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SOURCE_VDBVERSION,
REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SOURCE_VDBVERSION,
DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.XID));
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SOURCE_VDBVERSION,
DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.SOURCE_VDBVERSION));
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TARGET_VDBNAME,
TYPE).set(ModelType.STRING);
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TARGET_VDBNAME,
REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TARGET_VDBNAME,
DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.XID));
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TARGET_VDBNAME,
DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.TARGET_VDBNAME));
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TARGET_VDBVERSION,
TYPE).set(ModelType.STRING);
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TARGET_VDBVERSION,
REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TARGET_VDBVERSION,
DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.XID));
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TARGET_VDBVERSION,
DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.TARGET_VDBVERSION));
}
}
@@ -463,18 +467,110 @@
protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_NAME,
TYPE).set(ModelType.STRING);
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_NAME,
REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_NAME,
DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.XID));
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_NAME,
DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.VDB_NAME));
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION,
TYPE).set(ModelType.STRING);
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION,
REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION,
DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.XID));
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION,
DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.VDB_VERSION));
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SQL_QUERY,
TYPE).set(ModelType.STRING);
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SQL_QUERY,
REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SQL_QUERY,
DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.XID));
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.SQL_QUERY,
DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.SQL_QUERY));
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TIMEOUT_IN_MILLI,
TYPE).set(ModelType.STRING);
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TIMEOUT_IN_MILLI,
REQUIRED).set(true);
- operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TIMEOUT_IN_MILLI,
DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.XID));
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TIMEOUT_IN_MILLI,
DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.TIMEOUT_IN_MILLI));
}
+}
+
+class GetVDB extends QueryEngineOperationHandler{
+
+ protected GetVDB(String operationName) {
+ super(operationName);
+ }
+ @Override
+ protected ModelNode executeOperation(RuntimeEngineDeployer engine, ModelNode operation)
throws OperationFailedException {
+ String vdbName = operation.get(OperationsConstants.VDB_NAME).asString();
+ int vdbVersion = operation.get(OperationsConstants.VDB_VERSION).asInt();
+
+ VDBMetaData vdb = engine.getVDB(vdbName, vdbVersion);
+ return MetadataMapper.wrap(vdb);
+ }
+
+ protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_NAME,
TYPE).set(ModelType.STRING);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_NAME,
REQUIRED).set(true);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_NAME,
DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.VDB_NAME));
+
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION,
TYPE).set(ModelType.STRING);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION,
REQUIRED).set(true);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION,
DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.VDB_VERSION));
+ }
+}
+
+class GetVDBs extends QueryEngineOperationHandler{
+
+ protected GetVDBs(String operationName) {
+ super(operationName);
+ }
+ @Override
+ protected ModelNode executeOperation(RuntimeEngineDeployer engine, ModelNode operation)
throws OperationFailedException {
+ List<VDBMetaData> vdbs = engine.getVDBs();
+ ModelNode node = new ModelNode();
+ node.get(TYPE).set(ModelType.LIST);
+
+ for (VDBMetaData vdb:vdbs) {
+ node.add(MetadataMapper.wrap(vdb));
+ }
+ return node;
+ }
+
+}
+
+class GetTranslators extends QueryEngineOperationHandler{
+
+ protected GetTranslators(String operationName) {
+ super(operationName);
+ }
+ @Override
+ protected ModelNode executeOperation(RuntimeEngineDeployer engine, ModelNode operation)
throws OperationFailedException {
+ List<VDBTranslatorMetaData> translators = engine.getTranslators();
+ ModelNode node = new ModelNode();
+ node.get(TYPE).set(ModelType.OBJECT);
+
+ for (VDBTranslatorMetaData t:translators) {
+ node.add(MetadataMapper.VDBTranslatorMetaDataMapper.wrap(t));
+ }
+ return node;
+ }
+
+ protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+ operationNode.get(REPLY_PROPERTIES, TYPE).set(ModelType.LIST);
+ operationNode.get(REPLY_PROPERTIES, VALUE_TYPE).set(ModelType.OBJECT);
+ operationNode.get(REPLY_PROPERTIES,
DESCRIPTION).set(bundle.getString(getReplyName()));
+ }
+}
+
+class GetTranslator extends QueryEngineOperationHandler{
+
+ protected GetTranslator(String operationName) {
+ super(operationName);
+ }
+
+ @Override
+ protected ModelNode executeOperation(RuntimeEngineDeployer engine, ModelNode operation)
throws OperationFailedException {
+ String translatorName = operation.get(OperationsConstants.TRANSLATOR_NAME).asString();
+
+ VDBTranslatorMetaData translator = engine.getTranslator(translatorName);
+ return MetadataMapper.VDBTranslatorMetaDataMapper.wrap(translator);
+ }
+
+ protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TRANSLATOR_NAME,
TYPE).set(ModelType.STRING);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TRANSLATOR_NAME,
REQUIRED).set(true);
+ operationNode.get(REQUEST_PROPERTIES, OperationsConstants.TRANSLATOR_NAME,
DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.TRANSLATOR_NAME));
+
+ operationNode.get(REPLY_PROPERTIES, TYPE).set(ModelType.OBJECT);
+ operationNode.get(REPLY_PROPERTIES,
DESCRIPTION).set(bundle.getString(getReplyName()));
+ }
}
\ No newline at end of file
Modified:
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidExtension.java
===================================================================
---
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidExtension.java 2011-07-01
20:26:47 UTC (rev 3300)
+++
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidExtension.java 2011-07-04
19:09:19 UTC (rev 3301)
@@ -57,6 +57,8 @@
private static final String TERMINATE_TRANSACTION = "terminate-transaction";
private static final String MERGE_VDBS = "merge-vdbs";
private static final String EXECUTE_QUERY = "execute-query";
+ private static final String GETVDBS = "getVDBs";
+ private static final String GETVDB = "getVDB";
public static final String SUBSYSTEM_NAME = "teiid"; //$NON-NLS-1$
private static TeiidSubsystemParser parser = new TeiidSubsystemParser();
@@ -159,7 +161,13 @@
subsystem.registerOperationHandler(MERGE_VDBS, op, op);
op = new ExecuteQuery(EXECUTE_QUERY);
- subsystem.registerOperationHandler(EXECUTE_QUERY, op, op);
+ subsystem.registerOperationHandler(EXECUTE_QUERY, op, op);
+
+ op = new GetVDBs(GETVDBS);
+ subsystem.registerOperationHandler(GETVDBS, op, op);
+
+ op = new GetVDB(GETVDB);
+ subsystem.registerOperationHandler(GETVDB, op, op);
}
@Override
Deleted:
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidSubsystemDescription.java
===================================================================
---
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidSubsystemDescription.java 2011-07-01
20:26:47 UTC (rev 3300)
+++
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidSubsystemDescription.java 2011-07-04
19:09:19 UTC (rev 3301)
@@ -1,209 +0,0 @@
-/*
- * 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.jboss;
-
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.*;
-
-import java.util.Locale;
-import java.util.ResourceBundle;
-
-import org.jboss.as.controller.descriptions.DescriptionProvider;
-import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
-import org.jboss.dmr.ModelNode;
-import org.jboss.dmr.ModelType;
-
-public class TeiidSubsystemDescription implements DescriptionProvider {
- private static final String DESC = ".describe"; //$NON-NLS-1$
-
- @Override
- public ModelNode getModelDescription(Locale locale) {
- final ResourceBundle bundle = IntegrationPlugin.getResourceBundle(locale);
-
- ModelNode node = new ModelNode();
- node.get(ModelDescriptionConstants.DESCRIPTION).set("teiid subsystem");
//$NON-NLS-1$
- node.get(ModelDescriptionConstants.HEAD_COMMENT_ALLOWED).set(true);
- node.get(ModelDescriptionConstants.TAIL_COMMENT_ALLOWED).set(true);
- node.get(ModelDescriptionConstants.NAMESPACE).set(Namespace.CURRENT.getUri());
-
- getQueryEngineDescription(node.get(CHILDREN, Configuration.QUERY_ENGINE),
ATTRIBUTES, bundle);
- return node;
- }
-
- static void addAttribute(ModelNode node, String name, String type, String description,
ModelType dataType, boolean required, String defaultValue) {
- node.get(type, name, TYPE).set(dataType);
- node.get(type, name, DESCRIPTION).set(description);
- node.get(type, name, REQUIRED).set(required);
- node.get(type, name, MAX_OCCURS).set(1);
- if (defaultValue != null) {
- if (ModelType.INT.equals(dataType)) {
- node.get(type, name, DEFAULT).set(Integer.parseInt(defaultValue));
- }
- else if (ModelType.BOOLEAN.equals(dataType)) {
- node.get(type, name, DEFAULT).set(Boolean.parseBoolean(defaultValue));
- }
- else {
- node.get(type, name, DEFAULT).set(defaultValue);
- }
- }
- //TODO: add "allowed" values
- }
-
- static void getQueryEngineDescription(ModelNode node, String type, ResourceBundle
bundle) {
- addAttribute(node, Configuration.JNDI_NAME, type,
bundle.getString(Configuration.JNDI_NAME+DESC), ModelType.STRING, true,
"teiid/engine-deployer"); //$NON-NLS-1$
- addAttribute(node, Configuration.MAX_THREADS, type,
bundle.getString(Configuration.MAX_THREADS+DESC),
ModelType.INT, false, "64");
//$NON-NLS-1$
- addAttribute(node, Configuration.MAX_ACTIVE_PLANS, type,
bundle.getString(Configuration.MAX_ACTIVE_PLANS+DESC),
ModelType.INT, false,
"20"); //$NON-NLS-1$
- addAttribute(node, Configuration.USER_REQUEST_SOURCE_CONCURRENCY, type,
bundle.getString(Configuration.USER_REQUEST_SOURCE_CONCURRENCY+DESC),
ModelType.INT,
false, "0"); //$NON-NLS-1$
- addAttribute(node, Configuration.TIME_SLICE_IN_MILLI, type,
bundle.getString(Configuration.TIME_SLICE_IN_MILLI+DESC),
ModelType.INT, false,
"2000"); //$NON-NLS-1$
- addAttribute(node, Configuration.MAX_ROWS_FETCH_SIZE, type,
bundle.getString(Configuration.MAX_ROWS_FETCH_SIZE+DESC),
ModelType.INT, false,
"20480"); //$NON-NLS-1$
- addAttribute(node, Configuration.LOB_CHUNK_SIZE_IN_KB, type,
bundle.getString(Configuration.LOB_CHUNK_SIZE_IN_KB+DESC),
ModelType.INT, false,
"100"); //$NON-NLS-1$
- addAttribute(node, Configuration.USE_DATA_ROLES, type,
bundle.getString(Configuration.USE_DATA_ROLES+DESC), ModelType.BOOLEAN, false,
"true"); //$NON-NLS-1$
- addAttribute(node, Configuration.ALLOW_CREATE_TEMPORY_TABLES_BY_DEFAULT, type,
bundle.getString(Configuration.ALLOW_CREATE_TEMPORY_TABLES_BY_DEFAULT+DESC),
ModelType.BOOLEAN, false, "true"); //$NON-NLS-1$
- addAttribute(node, Configuration.ALLOW_FUNCTION_CALLS_BY_DEFAULT, type,
bundle.getString(Configuration.ALLOW_FUNCTION_CALLS_BY_DEFAULT+DESC), ModelType.BOOLEAN,
false, "true"); //$NON-NLS-1$
- addAttribute(node, Configuration.QUERY_THRESHOLD_IN_SECS, type,
bundle.getString(Configuration.QUERY_THRESHOLD_IN_SECS+DESC),
ModelType.INT, false,
"600"); //$NON-NLS-1$
- addAttribute(node, Configuration.MAX_SOURCE_ROWS, type,
bundle.getString(Configuration.MAX_SOURCE_ROWS+DESC),
ModelType.INT, false,
"-1"); //$NON-NLS-1$
- addAttribute(node, Configuration.EXCEPTION_ON_MAX_SOURCE_ROWS, type,
bundle.getString(Configuration.EXCEPTION_ON_MAX_SOURCE_ROWS+DESC), ModelType.BOOLEAN,
false, "true"); //$NON-NLS-1$
- addAttribute(node, Configuration.MAX_ODBC_LOB_SIZE_ALLOWED, type,
bundle.getString(Configuration.MAX_ODBC_LOB_SIZE_ALLOWED+DESC),
ModelType.INT, false,
"5242880"); //$NON-NLS-1$
- addAttribute(node, Configuration.EVENT_DISTRIBUTOR_NAME, type,
bundle.getString(Configuration.EVENT_DISTRIBUTOR_NAME+DESC), ModelType.STRING, false,
"teiid/event-distributor"); //$NON-NLS-1$
- addAttribute(node, Configuration.DETECTING_CHANGE_EVENTS, type,
bundle.getString(Configuration.DETECTING_CHANGE_EVENTS+DESC), ModelType.BOOLEAN, false,
"true"); //$NON-NLS-1$
-
- //session stuff
- addAttribute(node, Configuration.JDBC_SECURITY_DOMAIN, type,
bundle.getString(Configuration.JDBC_SECURITY_DOMAIN+DESC), ModelType.STRING, false,
null);
- addAttribute(node, Configuration.MAX_SESSIONS_ALLOWED, type,
bundle.getString(Configuration.MAX_SESSIONS_ALLOWED+DESC),
ModelType.INT, false,
"5000"); //$NON-NLS-1$
- addAttribute(node, Configuration.SESSION_EXPIRATION_TIME_LIMIT, type,
bundle.getString(Configuration.SESSION_EXPIRATION_TIME_LIMIT+DESC),
ModelType.INT, false,
"0"); //$NON-NLS-1$
-
- addAttribute(node, Configuration.ALLOW_ENV_FUNCTION, type,
bundle.getString(Configuration.ALLOW_ENV_FUNCTION+DESC), ModelType.BOOLEAN, false,
"false"); //$NON-NLS-1$
-
- //Buffer Manager stuff
- ModelNode bufferNode = node.get(CHILDREN, Configuration.BUFFER_SERVICE);
- bufferNode.get(TYPE).set(ModelType.OBJECT);
- bufferNode.get(DESCRIPTION).set(bundle.getString(Configuration.BUFFER_SERVICE+DESC));
- bufferNode.get(REQUIRED).set(false);
- bufferNode.get(MAX_OCCURS).set(1);
- bufferNode.get(MIN_OCCURS).set(1);
- getBufferDescription(bufferNode, type, bundle);
-
- // result-set-cache
- ModelNode rsCacheNode = node.get(CHILDREN, Configuration.RESULTSET_CACHE);
- rsCacheNode.get(TYPE).set(ModelType.OBJECT);
- rsCacheNode.get(DESCRIPTION).set(bundle.getString(Configuration.RESULTSET_CACHE+DESC));
- rsCacheNode.get(REQUIRED).set(false);
- rsCacheNode.get(MAX_OCCURS).set(1);
- rsCacheNode.get(MIN_OCCURS).set(1);
- getResultsetCacheDescription(rsCacheNode, type, bundle);
-
- // preparedplan-set-cache
- ModelNode preparedPlanCacheNode = node.get(CHILDREN,
Configuration.PREPAREDPLAN_CACHE);
- preparedPlanCacheNode.get(TYPE).set(ModelType.OBJECT);
- preparedPlanCacheNode.get(DESCRIPTION).set(bundle.getString(Configuration.PREPAREDPLAN_CACHE+DESC));
- preparedPlanCacheNode.get(REQUIRED).set(false);
- preparedPlanCacheNode.get(MAX_OCCURS).set(1);
- preparedPlanCacheNode.get(MIN_OCCURS).set(1);
- getResultsetCacheDescription(preparedPlanCacheNode, type, bundle);
-
- //distributed-cache
- ModelNode distributedCacheNode = node.get(CHILDREN, Configuration.CACHE_FACORY);
- distributedCacheNode.get(TYPE).set(ModelType.OBJECT);
- distributedCacheNode.get(DESCRIPTION).set(bundle.getString(Configuration.CACHE_FACORY+DESC));
- distributedCacheNode.get(REQUIRED).set(false);
- distributedCacheNode.get(MAX_OCCURS).set(1);
- distributedCacheNode.get(MIN_OCCURS).set(1);
- getDistributedCacheDescription(preparedPlanCacheNode, type, bundle);
-
- //jdbc
- ModelNode jdbcSocketNode = node.get(CHILDREN, Configuration.JDBC);
- jdbcSocketNode.get(TYPE).set(ModelType.OBJECT);
- jdbcSocketNode.get(DESCRIPTION).set(bundle.getString(Configuration.JDBC+DESC));
- jdbcSocketNode.get(REQUIRED).set(false);
- jdbcSocketNode.get(MAX_OCCURS).set(1);
- jdbcSocketNode.get(MIN_OCCURS).set(1);
- getSocketConfig(jdbcSocketNode, type, bundle);
-
- //odbc
- ModelNode odbcSocketNode = node.get(CHILDREN, Configuration.ODBC);
- odbcSocketNode.get(TYPE).set(ModelType.OBJECT);
- odbcSocketNode.get(DESCRIPTION).set(bundle.getString(Configuration.ODBC+DESC));
- odbcSocketNode.get(REQUIRED).set(false);
- odbcSocketNode.get(MAX_OCCURS).set(1);
- odbcSocketNode.get(MIN_OCCURS).set(1);
- getSocketConfig(odbcSocketNode, type, bundle);
- }
-
- private static void getDistributedCacheDescription(ModelNode node, String type,
ResourceBundle bundle) {
- addAttribute(node, Configuration.ENABLED, type,
bundle.getString(Configuration.ENABLED+DESC), ModelType.BOOLEAN, false, "true");
//$NON-NLS-1$
- addAttribute(node, Configuration.CACHE_SERVICE_JNDI_NAME, type,
bundle.getString(Configuration.CACHE_SERVICE_JNDI_NAME+DESC), ModelType.STRING, false,
"java:TeiidCacheManager"); //$NON-NLS-1$
- addAttribute(node, Configuration.RESULTSET_CACHE_NAME, type,
bundle.getString(Configuration.RESULTSET_CACHE_NAME+DESC), ModelType.STRING, false,
"teiid-resultset-cache"); //$NON-NLS-1$
- }
-
- private static void getBufferDescription(ModelNode node, String type, ResourceBundle
bundle) {
- addAttribute(node, Configuration.USE_DISK, type,
bundle.getString(Configuration.USE_DISK+DESC), ModelType.BOOLEAN, false,
"true"); //$NON-NLS-1$
- addAttribute(node, Configuration.DISK_DIRECTORY, type,
bundle.getString(Configuration.DISK_DIRECTORY+DESC), ModelType.STRING, true, null);
- addAttribute(node, Configuration.PROCESSOR_BATCH_SIZE, type,
bundle.getString(Configuration.PROCESSOR_BATCH_SIZE+DESC),
ModelType.INT, false,
"512"); //$NON-NLS-1$
- addAttribute(node, Configuration.CONNECTOR_BATCH_SIZE, type,
bundle.getString(Configuration.CONNECTOR_BATCH_SIZE+DESC),
ModelType.INT, false,
"1024"); //$NON-NLS-1$
- addAttribute(node, Configuration.MAX_RESERVE_BATCH_COLUMNS, type,
bundle.getString(Configuration.MAX_RESERVE_BATCH_COLUMNS+DESC),
ModelType.INT, false,
"-1"); //$NON-NLS-1$
- addAttribute(node, Configuration.MAX_PROCESSING_BATCH_COLUMNS, type,
bundle.getString(Configuration.MAX_PROCESSING_BATCH_COLUMNS+DESC),
ModelType.INT, false,
"-1"); //$NON-NLS-1$
- addAttribute(node, Configuration.MAX_FILE_SIZE, type,
bundle.getString(Configuration.MAX_FILE_SIZE+DESC),
ModelType.INT, false,
"2048"); //$NON-NLS-1$
- addAttribute(node, Configuration.MAX_BUFFER_SPACE, type,
bundle.getString(Configuration.MAX_BUFFER_SPACE+DESC),
ModelType.INT, false,
"51200"); //$NON-NLS-1$
- addAttribute(node, Configuration.MAX_OPEN_FILES, type,
bundle.getString(Configuration.MAX_OPEN_FILES+DESC),
ModelType.INT, false,
"64"); //$NON-NLS-1$
- }
-
- static void getResultsetCacheDescription(ModelNode node, String type, ResourceBundle
bundle) {
- addAttribute(node, Configuration.ENABLED, type,
bundle.getString(Configuration.ENABLED+DESC), ModelType.BOOLEAN, false, "true");
//$NON-NLS-1$
- addAttribute(node, Configuration.MAX_ENTRIES, type,
bundle.getString(Configuration.MAX_ENTRIES+DESC),
ModelType.INT, false, "1024");
//$NON-NLS-1$
- addAttribute(node, Configuration.MAX_AGE_IN_SECS, type,
bundle.getString(Configuration.MAX_AGE_IN_SECS+DESC),
ModelType.INT, false,
"7200");//$NON-NLS-1$
- addAttribute(node, Configuration.MAX_STALENESS, type,
bundle.getString(Configuration.MAX_STALENESS+DESC),
ModelType.INT, false,
"60");//$NON-NLS-1$
- addAttribute(node, Configuration.CACHE_TYPE, type,
bundle.getString(Configuration.CACHE_TYPE+DESC), ModelType.STRING, false,
"EXPIRATION"); //$NON-NLS-1$
- addAttribute(node, Configuration.CACHE_LOCATION, type,
bundle.getString(Configuration.CACHE_LOCATION+DESC), ModelType.STRING, false,
"resultset"); //$NON-NLS-1$
- }
-
- static void getPreparedPalnCacheDescription(ModelNode node, String type, ResourceBundle
bundle) {
- addAttribute(node, Configuration.ENABLED, type,
bundle.getString(Configuration.ENABLED+DESC), ModelType.BOOLEAN, false, "true");
//$NON-NLS-1$
- addAttribute(node, Configuration.MAX_ENTRIES, type,
bundle.getString(Configuration.MAX_ENTRIES+DESC),
ModelType.INT, false, "512");
//$NON-NLS-1$
- addAttribute(node, Configuration.MAX_AGE_IN_SECS, type,
bundle.getString(Configuration.MAX_AGE_IN_SECS+DESC),
ModelType.INT, false,
"28800");//$NON-NLS-1$
- addAttribute(node, Configuration.MAX_STALENESS, type,
bundle.getString(Configuration.MAX_STALENESS+DESC),
ModelType.INT, false,
"0");//$NON-NLS-1$
- addAttribute(node, Configuration.CACHE_TYPE, type,
bundle.getString(Configuration.CACHE_TYPE+DESC), ModelType.STRING, false,
"LRU"); //$NON-NLS-1$
- addAttribute(node, Configuration.CACHE_LOCATION, type,
bundle.getString(Configuration.CACHE_LOCATION+DESC), ModelType.STRING, false,
"preparedplan"); //$NON-NLS-1$
- }
-
- static void getSocketConfig(ModelNode node, String type, ResourceBundle bundle) {
- addAttribute(node, Configuration.SOCKET_ENABLED, type,
bundle.getString(Configuration.SOCKET_ENABLED+DESC), ModelType.BOOLEAN, false,
"true"); //$NON-NLS-1$
- addAttribute(node, Configuration.MAX_SOCKET_THREAD_SIZE, type,
bundle.getString(Configuration.MAX_SOCKET_THREAD_SIZE+DESC),
ModelType.INT, false,
"0"); //$NON-NLS-1$
- addAttribute(node, Configuration.IN_BUFFER_SIZE, type,
bundle.getString(Configuration.IN_BUFFER_SIZE+DESC),
ModelType.INT, false, "0");
//$NON-NLS-1$
- addAttribute(node, Configuration.OUT_BUFFER_SIZE, type,
bundle.getString(Configuration.OUT_BUFFER_SIZE+DESC),
ModelType.INT, false,
"0"); //$NON-NLS-1$
- addAttribute(node, Configuration.SOCKET_BINDING, type,
bundle.getString(Configuration.SOCKET_BINDING+DESC),
ModelType.INT, true, null);
-
- ModelNode sslNode = node.get(CHILDREN, Configuration.SSL);
- sslNode.get(TYPE).set(ModelType.OBJECT);
- sslNode.get(DESCRIPTION).set(bundle.getString(Configuration.SSL+DESC));
- sslNode.get(REQUIRED).set(false);
- sslNode.get(MAX_OCCURS).set(1);
- sslNode.get(MIN_OCCURS).set(0);
- addAttribute(node, Configuration.SSL_MODE, type,
bundle.getString(Configuration.SSL_MODE+DESC), ModelType.STRING, false,
"login"); //$NON-NLS-1$
- addAttribute(node, Configuration.KEY_STORE_FILE, type,
bundle.getString(Configuration.KEY_STORE_FILE+DESC), ModelType.STRING, false, null);
- addAttribute(node, Configuration.KEY_STORE_PASSWD, type,
bundle.getString(Configuration.KEY_STORE_PASSWD+DESC), ModelType.STRING, false, null);
- addAttribute(node, Configuration.KEY_STORE_TYPE, type,
bundle.getString(Configuration.KEY_STORE_TYPE+DESC), ModelType.STRING, false,
"JKS"); //$NON-NLS-1$
- addAttribute(node, Configuration.SSL_PROTOCOL, type,
bundle.getString(Configuration.SSL_PROTOCOL+DESC), ModelType.BOOLEAN, false,
"SSLv3"); //$NON-NLS-1$
- addAttribute(node, Configuration.KEY_MANAGEMENT_ALG, type,
bundle.getString(Configuration.KEY_MANAGEMENT_ALG+DESC), ModelType.STRING, false,
"false"); //$NON-NLS-1$
- addAttribute(node, Configuration.TRUST_FILE, type,
bundle.getString(Configuration.TRUST_FILE+DESC), ModelType.STRING, false, null);
- addAttribute(node, Configuration.TRUST_PASSWD, type,
bundle.getString(Configuration.TRUST_PASSWD+DESC), ModelType.STRING, false, null);
- addAttribute(node, Configuration.AUTH_MODE, type,
bundle.getString(Configuration.AUTH_MODE+DESC), ModelType.STRING, false,
"anonymous"); //$NON-NLS-1$
- }
-}
Modified:
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
===================================================================
---
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2011-07-01
20:26:47 UTC (rev 3300)
+++
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2011-07-04
19:09:19 UTC (rev 3301)
@@ -30,10 +30,7 @@
import java.sql.SQLException;
import java.sql.SQLXML;
import java.util.*;
-import java.util.concurrent.Callable;
-import java.util.concurrent.Executor;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
+import java.util.concurrent.*;
import javax.naming.InitialContext;
import javax.naming.NamingException;
@@ -42,12 +39,13 @@
import javax.security.auth.login.LoginException;
import javax.transaction.TransactionManager;
+import org.jboss.as.security.plugins.SecurityDomainContext;
import org.jboss.as.server.services.net.SocketBinding;
import org.jboss.msc.service.Service;
-import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.StartContext;
import org.jboss.msc.service.StopContext;
import org.jboss.msc.value.InjectedValue;
+import org.jboss.netty.util.internal.ConcurrentHashMap;
import org.jboss.util.naming.Util;
import org.teiid.adminapi.AdminComponentException;
import org.teiid.adminapi.AdminException;
@@ -70,6 +68,7 @@
import org.teiid.core.util.LRUCache;
import org.teiid.deployers.VDBLifeCycleListener;
import org.teiid.deployers.VDBRepository;
+import org.teiid.dqp.internal.datamgr.TranslatorRepository;
import org.teiid.dqp.internal.process.*;
import org.teiid.dqp.service.BufferService;
import org.teiid.dqp.service.SessionService;
@@ -91,14 +90,14 @@
import org.teiid.query.processor.DdlPlan;
import org.teiid.query.tempdata.TempTableStore;
import org.teiid.security.SecurityHelper;
+import org.teiid.services.SessionServiceImpl;
import org.teiid.transport.*;
import org.teiid.vdb.runtime.VDBKey;
public class RuntimeEngineDeployer extends DQPConfiguration implements DQPManagement,
Serializable , ClientServiceRegistry, EventDistributor, EventDistributorFactory,
Service<ClientServiceRegistry> {
private static final long serialVersionUID = -4676205340262775388L;
- public static final ServiceName SERVICE_NAME =
ServiceName.JBOSS.append("teiid", "runtime"); //$NON-NLS-1$
//$NON-NLS-2$
-
+
private transient SocketConfiguration jdbcSocketConfiguration;
private transient SocketConfiguration odbcSocketConfiguration;
private transient SocketListener jdbcSocket;
@@ -106,16 +105,19 @@
private transient TransactionServerImpl transactionServerImpl = new
TransactionServerImpl();
private transient DQPCore dqpCore = new DQPCore();
- private transient SessionService sessionService;
+ private transient SessionServiceImpl sessionService;
private transient ILogon logon;
private transient ClientServiceRegistryImpl csr = new ClientServiceRegistryImpl();
private transient VDBRepository vdbRepository;
+ private transient TranslatorRepository translatorRepository;
private transient String jndiName;
private String eventDistributorName;
private transient EventDistributor eventDistributor;
-
+ private long sessionMaxLimit = SessionService.DEFAULT_MAX_SESSIONS;
+ private long sessionExpirationTimeLimit = SessionService.DEFAULT_SESSION_EXPIRATION;
+
// TODO: remove public?
public final InjectedValue<WorkManager> workManagerInjector = new
InjectedValue<WorkManager>();
public final InjectedValue<XATerminator> xaTerminatorInjector = new
InjectedValue<XATerminator>();
@@ -123,7 +125,10 @@
public final InjectedValue<Executor> threadPoolInjector = new
InjectedValue<Executor>();
public final InjectedValue<SocketBinding> jdbcSocketBindingInjector = new
InjectedValue<SocketBinding>();
public final InjectedValue<SocketBinding> odbcSocketBindingInjector = new
InjectedValue<SocketBinding>();
+ public final ConcurrentMap<String, SecurityDomainContext> securityDomains = new
ConcurrentHashMap<String, SecurityDomainContext>();
+ private LinkedList<String> securityDomainNames = new LinkedList<String>();
+
public RuntimeEngineDeployer() {
// TODO: this does not belong here
LogManager.setLogListener(new Log4jListener());
@@ -146,6 +151,14 @@
setXATerminator(xaTerminatorInjector.getValue());
setTransactionManager(txnManagerInjector.getValue());
+ this.sessionService = new SessionServiceImpl(this.securityDomainNames,
this.securityDomains);
+ this.sessionService.setSessionExpirationTimeLimit(this.sessionExpirationTimeLimit);
+ this.sessionService.setSessionMaxLimit(this.sessionMaxLimit);
+ this.sessionService.setDqp(this.dqpCore);
+ this.sessionService.setVDBRepository(this.vdbRepository);
+ this.sessionService.start();
+
+
this.jdbcSocketConfiguration.setHostAddress(this.jdbcSocketBindingInjector.getValue().getAddress());
this.jdbcSocketConfiguration.setPortNumber(this.jdbcSocketBindingInjector.getValue().getPort());
this.odbcSocketConfiguration.setHostAddress(this.odbcSocketBindingInjector.getValue().getAddress());
@@ -284,6 +297,9 @@
this.odbcSocket.stop();
this.odbcSocket = null;
}
+
+ this.sessionService.stop();
+
LogManager.logInfo(LogConstants.CTX_RUNTIME,
IntegrationPlugin.Util.getString("engine_stopped", new
Date(System.currentTimeMillis()).toString())); //$NON-NLS-1$
}
@@ -332,12 +348,7 @@
public void setWorkManager(WorkManager mgr) {
this.transactionServerImpl.setWorkManager(mgr);
}
-
- public void setSessionService(SessionService service) {
- this.sessionService = service;
- service.setDqp(this.dqpCore);
- }
-
+
public void setBufferService(BufferService service) {
this.dqpCore.setBufferService(service);
}
@@ -474,7 +485,7 @@
SessionMetadata session = null;
try {
- session = this.sessionService.createSession(user, null, "JOPR", properties,
false, false); //$NON-NLS-1$
+ session = this.sessionService.createSession(user, null, "JOPR", properties,
false); //$NON-NLS-1$
} catch (SessionServiceException e1) {
throw new AdminProcessingException(e1);
} catch (LoginException e1) {
@@ -745,4 +756,35 @@
return ApplicationInfo.getInstance().getBuildNumber();
}
+ public void setSessionMaxLimit(long limit) {
+ this.sessionMaxLimit = limit;
+ }
+
+ public void setSessionExpirationTimeLimit(long limit) {
+ this.sessionExpirationTimeLimit = limit;
+ }
+
+ public void addSecurityDomain(String domain) {
+ this.securityDomainNames.add(domain);
+ }
+
+ public List<VDBMetaData> getVDBs(){
+ return this.vdbRepository.getVDBs();
+ }
+
+ public VDBMetaData getVDB(String vdbName, int version){
+ return this.vdbRepository.getVDB(vdbName, version);
+ }
+
+ public List<VDBTranslatorMetaData> getTranslators(){
+ return this.translatorRepository.getTranslators();
+ }
+
+ public VDBTranslatorMetaData getTranslator(String translatorName) {
+ return
(VDBTranslatorMetaData)this.translatorRepository.getTranslatorMetaData(translatorName);
+ }
+
+ public void setTranslatorRepository(TranslatorRepository translatorRepo) {
+ this.translatorRepository = translatorRepo;
+ }
}
Modified: branches/as7/pom.xml
===================================================================
--- branches/as7/pom.xml 2011-07-01 20:26:47 UTC (rev 3300)
+++ branches/as7/pom.xml 2011-07-04 19:09:19 UTC (rev 3301)
@@ -420,7 +420,13 @@
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-connector</artifactId>
<version>${jbossas-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.as</groupId>
+ <artifactId>jboss-as-security</artifactId>
+ <version>${jbossas-version}</version>
</dependency>
+
<!--
<dependency>
<groupId>jgroups</groupId>
Modified: branches/as7/runtime/pom.xml
===================================================================
--- branches/as7/runtime/pom.xml 2011-07-01 20:26:47 UTC (rev 3300)
+++ branches/as7/runtime/pom.xml 2011-07-04 19:09:19 UTC (rev 3301)
@@ -80,6 +80,11 @@
<artifactId>jboss-vfs</artifactId>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.jboss.as</groupId>
+ <artifactId>jboss-as-security</artifactId>
+ <scope>provided</scope>
+ </dependency>
<!--
<dependency>
<groupId>org.jboss.cache</groupId>
Modified: branches/as7/runtime/src/main/java/org/teiid/deployers/TranslatorUtil.java
===================================================================
--- branches/as7/runtime/src/main/java/org/teiid/deployers/TranslatorUtil.java 2011-07-01
20:26:47 UTC (rev 3300)
+++ branches/as7/runtime/src/main/java/org/teiid/deployers/TranslatorUtil.java 2011-07-04
19:09:19 UTC (rev 3301)
@@ -31,7 +31,6 @@
import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
import org.teiid.adminapi.Translator;
-import org.teiid.adminapi.impl.TranslatorMetaData;
import org.teiid.adminapi.impl.VDBTranslatorMetaData;
import org.teiid.core.TeiidException;
import org.teiid.core.TeiidRuntimeException;
@@ -92,7 +91,7 @@
public static ExecutionFactory buildExecutionFactory(Translator data) throws
DeploymentUnitProcessingException {
ExecutionFactory executionFactory;
try {
- String executionClass =
data.getPropertyValue(TranslatorMetaData.EXECUTION_FACTORY_CLASS);
+ String executionClass =
data.getPropertyValue(VDBTranslatorMetaData.EXECUTION_FACTORY_CLASS);
Object o = ReflectionHelper.create(executionClass, null,
Thread.currentThread().getContextClassLoader());
if(!(o instanceof ExecutionFactory)) {
throw new
DeploymentUnitProcessingException(RuntimePlugin.Util.getString("invalid_class",
executionClass));//$NON-NLS-1$
Modified: branches/as7/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java
===================================================================
---
branches/as7/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java 2011-07-01
20:26:47 UTC (rev 3300)
+++
branches/as7/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java 2011-07-04
19:09:19 UTC (rev 3301)
@@ -25,9 +25,10 @@
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
-import javax.security.auth.login.LoginContext;
+import javax.security.auth.Subject;
import javax.security.auth.login.LoginException;
+import org.jboss.as.security.plugins.SecurityDomainContext;
import org.teiid.adminapi.VDB;
import org.teiid.adminapi.VDB.ConnectionType;
import org.teiid.adminapi.impl.SessionMetadata;
@@ -52,8 +53,6 @@
* This class serves as the primary implementation of the Session Service.
*/
public class SessionServiceImpl implements SessionService {
- public static final String SECURITY_DOMAINS = "securitydomains";
//$NON-NLS-1$
-
/*
* Configuration state
*/
@@ -70,8 +69,13 @@
private Map<String, SessionMetadata> sessionCache = new
ConcurrentHashMap<String, SessionMetadata>();
private Timer sessionMonitor = new Timer("SessionMonitor", true);
//$NON-NLS-1$
- private LinkedList<String> securityDomains = new LinkedList<String>();
+ private Map<String, SecurityDomainContext> securityDomainMap;
+ private LinkedList<String> securityDomainNames;
+ public SessionServiceImpl(LinkedList<String> domainNames, Map<String,
SecurityDomainContext> domains) {
+ this.securityDomainNames = domainNames;
+ this.securityDomainMap = domains;
+ }
//
-----------------------------------------------------------------------------------
// S E R V I C E - R E L A T E D M E T H O D S
@@ -111,16 +115,6 @@
LogManager.logWarning(LogConstants.CTX_SECURITY,e,"Exception
terminitating session"); //$NON-NLS-1$
}
}
-
- // try to log out of the context.
- try {
- LoginContext context = info.getLoginContext();
- if (context != null) {
- context.logout();
- }
- } catch (LoginException e) {
- LogManager.logWarning(LogConstants.CTX_SECURITY,e,"Exception terminitating
session"); //$NON-NLS-1$
- }
}
@Override
@@ -129,10 +123,10 @@
ArgCheck.isNotNull(applicationName);
ArgCheck.isNotNull(properties);
- LoginContext loginContext = null;
String securityDomain = "none"; //$NON-NLS-1$
Object securityContext = null;
- List<String> domains = this.securityDomains;
+ Subject subject = null;
+ List<String> domains = this.securityDomainNames;
// Validate VDB and version if logging on to server product...
VDBMetaData vdb = null;
@@ -150,11 +144,11 @@
// Authenticate user...
// if not authenticated, this method throws exception
boolean onlyAllowPassthrough =
Boolean.valueOf(properties.getProperty(TeiidURL.CONNECTION.PASSTHROUGH_AUTHENTICATION,
"false")); //$NON-NLS-1$
- TeiidLoginContext membership = authenticate(userName, credentials,
applicationName, domains, this.securityHelper, onlyAllowPassthrough);
- loginContext = membership.getLoginContext();
+ TeiidLoginContext membership = authenticate(userName, credentials,
applicationName, domains, this.securityDomainMap, this.securityHelper,
onlyAllowPassthrough);
userName = membership.getUserName();
securityDomain = membership.getSecurityDomain();
securityContext = membership.getSecurityContext();
+ subject = membership.getSubject();
}
long creationTime = System.currentTimeMillis();
@@ -175,7 +169,7 @@
}
// these are local no need for monitoring.
- newSession.setLoginContext(loginContext);
+ newSession.setSubject(subject);
newSession.setSecurityContext(securityContext);
newSession.setVdb(vdb);
LogManager.logDetail(LogConstants.CTX_SECURITY, new Object[] {"Logon
successful for \"", userName, "\" - created SessionID \"",
newSession.getSessionToken().getSessionID(), "\"" }); //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$
@@ -223,10 +217,10 @@
return vdb;
}
- protected TeiidLoginContext authenticate(String userName, Credentials credentials,
String applicationName, List<String> domains, SecurityHelper helper, boolean
onlyallowPassthrough)
+ protected TeiidLoginContext authenticate(String userName, Credentials credentials,
String applicationName, List<String> domains, Map<String,
SecurityDomainContext> securityDomainMap, SecurityHelper helper, boolean
onlyallowPassthrough)
throws LoginException {
TeiidLoginContext membership = new TeiidLoginContext(helper);
- membership.authenticateUser(userName, credentials, applicationName, domains,
onlyallowPassthrough);
+ membership.authenticateUser(userName, credentials, applicationName, domains,
securityDomainMap, onlyallowPassthrough);
return membership;
}
@@ -315,17 +309,6 @@
this.sessionExpirationTimeLimit = limit;
}
- public void setSecurityDomains(String domainNameOrder) {
- if (domainNameOrder != null && domainNameOrder.trim().length()>0) {
- LogManager.logInfo(LogConstants.CTX_SECURITY, "Security Enabled:
true"); //$NON-NLS-1$
-
- String[] domainNames = domainNameOrder.split(","); //$NON-NLS-1$
- for (String domainName : domainNames) {
- this.securityDomains.addLast(domainName);
- }
- }
- }
-
public void start() {
this.sessionMonitor.schedule(new TimerTask() {
@Override
Modified: branches/as7/runtime/src/main/java/org/teiid/services/TeiidLoginContext.java
===================================================================
---
branches/as7/runtime/src/main/java/org/teiid/services/TeiidLoginContext.java 2011-07-01
20:26:47 UTC (rev 3300)
+++
branches/as7/runtime/src/main/java/org/teiid/services/TeiidLoginContext.java 2011-07-04
19:09:19 UTC (rev 3301)
@@ -22,24 +22,16 @@
package org.teiid.services;
-import java.io.IOException;
import java.security.Principal;
import java.security.acl.Group;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
import javax.security.auth.Subject;
-import javax.security.auth.callback.Callback;
-import javax.security.auth.callback.CallbackHandler;
-import javax.security.auth.callback.NameCallback;
-import javax.security.auth.callback.PasswordCallback;
-import javax.security.auth.callback.UnsupportedCallbackException;
-import javax.security.auth.login.LoginContext;
import javax.security.auth.login.LoginException;
+import org.jboss.as.security.plugins.SecurityDomainContext;
+import org.jboss.security.AuthenticationManager;
+import org.jboss.security.SimplePrincipal;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.runtime.RuntimePlugin;
@@ -54,10 +46,10 @@
*/
public class TeiidLoginContext {
public static final String AT = "@"; //$NON-NLS-1$
- private LoginContext loginContext;
+ private Subject subject;
private String userName;
private String securitydomain;
- private Object credentials;
+ private Object securityContext;
private SecurityHelper securityHelper;
public TeiidLoginContext(SecurityHelper helper) {
@@ -65,7 +57,7 @@
}
public void authenticateUser(String username, final Credentials credential,
- String applicationName, List<String> domains, boolean onlyallowPassthrough)
+ String applicationName, List<String> domains, Map<String,
SecurityDomainContext> securityDomainMap, boolean onlyallowPassthrough)
throws LoginException {
LogManager.logDetail(LogConstants.CTX_SECURITY, new Object[]
{"authenticateUser", username, applicationName}); //$NON-NLS-1$
@@ -78,7 +70,8 @@
if (existing != null) {
this.userName = getUserName(existing)+AT+domain;
this.securitydomain = domain;
- this.loginContext = createLoginContext(domain, existing);
+ this.subject = existing;
+ this.securityContext = this.securityHelper.getSecurityContext(domain);
return;
}
}
@@ -89,40 +82,23 @@
// If username specifies a domain (user@domain) only that domain is authenticated
against.
// If username specifies no domain, then all domains are tried in order.
for (String domain:getDomainsForUser(domains, username)) {
-
- try {
- CallbackHandler handler = new CallbackHandler() {
- @Override
- public void handle(Callback[] callbacks) throws IOException,
UnsupportedCallbackException {
- for (int i = 0; i < callbacks.length; i++) {
- if (callbacks[i] instanceof NameCallback) {
- NameCallback nc = (NameCallback)callbacks[i];
- nc.setName(baseUsername);
- } else if (callbacks[i] instanceof PasswordCallback) {
- PasswordCallback pc = (PasswordCallback)callbacks[i];
- char[] password = null;
- if (credential != null) {
- password = credential.getCredentialsAsCharArray();
- }
- pc.setPassword(password);
- credentials = password;
- } else {
- throw new UnsupportedCallbackException(callbacks[i], "Unrecognized
Callback"); //$NON-NLS-1$
- }
- }
- }
- };
-
- // this is the configured login for teiid
- this.loginContext = createLoginContext(domain,handler);
- this.loginContext.login();
- this.userName = baseUsername+AT+domain;
- this.securitydomain = domain;
- LogManager.logDetail(LogConstants.CTX_SECURITY, new Object[] {"Logon successful
for \"", username, "\""}); //$NON-NLS-1$ //$NON-NLS-2$
- return;
- } catch (LoginException e) {
- LogManager.logDetail(LogConstants.CTX_SECURITY,e, e.getMessage());
- }
+ // this is the configured login for teiid
+ SecurityDomainContext securityDomainContext = securityDomainMap.get(domain);
+ if (securityDomainContext != null) {
+ AuthenticationManager authManager =
securityDomainContext.getAuthenticationManager();
+ if (authManager != null) {
+ Principal userPrincipal = new SimplePrincipal(username);
+ Subject subject = new Subject();
+ boolean isValid = authManager.isValid(userPrincipal, credential,
subject);
+ if (isValid) {
+ this.userName = baseUsername+AT+domain;
+ this.securitydomain = domain;
+ this.securityContext =
this.securityHelper.createSecurityContext(this.securitydomain, userPrincipal, credential,
subject);
+ LogManager.logDetail(LogConstants.CTX_SECURITY, new Object[] {"Logon
successful for \"", username, "\""}); //$NON-NLS-1$
//$NON-NLS-2$
+ return;
+ }
+ }
+ }
}
throw new
LoginException(RuntimePlugin.Util.getString("SessionServiceImpl.The_username_0_and/or_password_are_incorrect",
username )); //$NON-NLS-1$
}
@@ -137,19 +113,7 @@
}
return null;
}
-
- protected LoginContext createLoginContext(String domain, CallbackHandler handler) throws
LoginException {
- return new LoginContext(domain, handler);
- }
-
- protected LoginContext createLoginContext(String domain, Subject subject) throws
LoginException {
- return new LoginContext(domain, subject);
- }
- public LoginContext getLoginContext() {
- return this.loginContext;
- }
-
public String getUserName() {
return this.userName;
}
@@ -158,23 +122,12 @@
return this.securitydomain;
}
+ public Subject getSubject() {
+ return this.subject;
+ }
+
public Object getSecurityContext() {
- Object sc = null;
- if (this.loginContext != null) {
- sc = this.securityHelper.getSecurityContext(this.securitydomain);
- if ( sc == null){
- Subject subject = this.loginContext.getSubject();
- Principal principal = null;
- for(Principal p:subject.getPrincipals()) {
- if (this.userName.startsWith(p.getName())) {
- principal = p;
- break;
- }
- }
- return this.securityHelper.createSecurityContext(this.securitydomain,
principal, credentials, subject);
- }
- }
- return sc;
+ return this.securityContext;
}
static String getBaseUsername(String username) {
Modified: branches/as7/runtime/src/main/java/org/teiid/transport/LogonImpl.java
===================================================================
--- branches/as7/runtime/src/main/java/org/teiid/transport/LogonImpl.java 2011-07-01
20:26:47 UTC (rev 3300)
+++ branches/as7/runtime/src/main/java/org/teiid/transport/LogonImpl.java 2011-07-04
19:09:19 UTC (rev 3301)
@@ -71,9 +71,8 @@
credential = new Credentials(password.toCharArray());
}
- boolean adminConnection =
Boolean.parseBoolean(connProps.getProperty(TeiidURL.CONNECTION.ADMIN));
try {
- SessionMetadata sessionInfo = service.createSession(user,credential, applicationName,
connProps, adminConnection, true);
+ SessionMetadata sessionInfo = service.createSession(user,credential, applicationName,
connProps, true);
updateDQPContext(sessionInfo);
if (DQPWorkContext.getWorkContext().getClientAddress() == null) {
sessionInfo.setEmbedded(true);
Deleted:
branches/as7/runtime/src/test/java/org/teiid/deployers/TestManagedPropertyUtil.java
===================================================================
---
branches/as7/runtime/src/test/java/org/teiid/deployers/TestManagedPropertyUtil.java 2011-07-01
20:26:47 UTC (rev 3300)
+++
branches/as7/runtime/src/test/java/org/teiid/deployers/TestManagedPropertyUtil.java 2011-07-04
19:09:19 UTC (rev 3301)
@@ -1,85 +0,0 @@
-/*
- * 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.deployers;
-
-import static org.junit.Assert.*;
-
-import java.util.Map;
-
-import org.jboss.managed.api.ManagedProperty;
-import org.jboss.metatype.api.values.MetaValueFactory;
-import org.junit.Test;
-import org.teiid.deployers.TestManagedPropertyUtil.FakeExecutionFactory.PropEnum;
-import org.teiid.templates.TranslatorTemplateInfoFactory;
-import org.teiid.translator.TranslatorProperty;
-
-@SuppressWarnings("nls")
-public class TestManagedPropertyUtil {
-
- public static class FakeExecutionFactory {
-
- public enum PropEnum {
- A, B, C
- }
-
- private PropEnum val = PropEnum.A;
-
- @TranslatorProperty(display="Read Only")
- public int readonly() {
- return 1;
- }
-
- @TranslatorProperty(display="Setter Property")
- public void x(@SuppressWarnings("unused") String y) {
-
- }
-
- @TranslatorProperty(display="Enum Property")
- public PropEnum getEnum() {
- return val;
- }
-
- public void setEnum(PropEnum value) {
- this.val = value;
- }
-
- }
-
- @Test public void testAnnotationProcessing() throws Exception {
- FakeExecutionFactory ef = new FakeExecutionFactory();
-
- Map<String, ManagedProperty> properties =
TranslatorTemplateInfoFactory.getProperties(ef.getClass());
- ManagedProperty mp = properties.get("readonly");
- assertTrue(mp.isReadOnly());
- assertEquals(Integer.valueOf(1),
MetaValueFactory.getInstance().unwrap(mp.getDefaultValue()));
-
- mp = properties.get("x");
- assertFalse(mp.isReadOnly());
- assertNull(mp.getDefaultValue());
-
- mp = properties.get("Enum");
- assertFalse(mp.isReadOnly());
- assertEquals(PropEnum.A.name(),
MetaValueFactory.getInstance().unwrap(mp.getDefaultValue()));
- }
-
-}
Deleted:
branches/as7/runtime/src/test/java/org/teiid/deployers/TestTranslatorMetadata.java
===================================================================
---
branches/as7/runtime/src/test/java/org/teiid/deployers/TestTranslatorMetadata.java 2011-07-01
20:26:47 UTC (rev 3300)
+++
branches/as7/runtime/src/test/java/org/teiid/deployers/TestTranslatorMetadata.java 2011-07-04
19:09:19 UTC (rev 3301)
@@ -1,74 +0,0 @@
-/*
- * 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.deployers;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.StringReader;
-import java.io.StringWriter;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.Marshaller;
-import javax.xml.bind.Unmarshaller;
-
-import org.junit.Test;
-import org.teiid.adminapi.Translator;
-import org.teiid.adminapi.impl.TranslatorMetaData;
-import org.teiid.translator.ExecutionFactory;
-
-
-@SuppressWarnings("nls")
-public class TestTranslatorMetadata {
-
- @Test
- public void testFormat() throws Exception {
-
- TranslatorMetaDataGroup group = new TranslatorMetaDataGroup();
- TranslatorMetaData tm = new TranslatorMetaData();
- group.translators.add(tm);
-
- tm.setExecutionFactoryClass(ExecutionFactory.class);
- tm.setName("Oracle");
- tm.setDescription("desc");
- tm.addProperty("ExtensionTranslationClassName",
"org.teiid.translator.jdbc.oracle.OracleSQLTranslator");
-
- JAXBContext jc = JAXBContext.newInstance(new Class<?>[]
{TranslatorMetaDataGroup.class});
- Marshaller marshell = jc.createMarshaller();
- marshell.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,new Boolean(true));
-
- StringWriter sw = new StringWriter();
- marshell.marshal(group, sw);
-
- System.out.println(sw.toString());
-
- Unmarshaller un = jc.createUnmarshaller();
- group = (TranslatorMetaDataGroup)un.unmarshal(new StringReader(sw.toString()));
-
- tm = group.getTranslators().get(0);
-
- assertEquals("Oracle", tm.getName());
- assertEquals("desc", tm.getDescription());
- assertEquals(ExecutionFactory.class.getName(),
tm.getPropertyValue(Translator.EXECUTION_FACTORY_CLASS));
- assertEquals("org.teiid.translator.jdbc.oracle.OracleSQLTranslator",
tm.getPropertyValue("ExtensionTranslationClassName"));
-
- }
-}