[teiid-commits] teiid SVN: r1962 - in trunk: client/src/main/java/org/teiid/adminapi and 11 other directories.
teiid-commits at lists.jboss.org
teiid-commits at lists.jboss.org
Mon Mar 15 13:15:44 EDT 2010
Author: rareddy
Date: 2010-03-15 13:15:42 -0400 (Mon, 15 Mar 2010)
New Revision: 1962
Added:
trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/VDBMetaDataInstanceClassFactory.java
Removed:
trunk/client/src/main/java/org/teiid/adminapi/impl/ModelMetadataMapper.java
Modified:
trunk/build/kit-jboss-container/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml
trunk/client/src/main/java/org/teiid/adminapi/Admin.java
trunk/client/src/main/java/org/teiid/adminapi/TeiidAdmin.java
trunk/client/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java
trunk/client/src/main/java/org/teiid/adminapi/impl/ConnectorBindingMetaData.java
trunk/client/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java
trunk/client/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java
trunk/client/src/main/java/org/teiid/adminapi/impl/SourceMappingMetadata.java
trunk/client/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java
trunk/engine/src/main/java/com/metamatrix/common/util/LogConstants.java
trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/VDBMetadataComponentMapper.java
trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties
trunk/jboss-integration/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java
trunk/jboss-integration/src/test/resources/TransactionsRevisited.vdb
trunk/runtime/src/main/java/org/teiid/deployers/DynamicVDBDeployer.java
trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java
trunk/runtime/src/main/java/org/teiid/deployers/VDBParserDeployer.java
trunk/runtime/src/main/java/org/teiid/logging/Log4JUtil.java
trunk/runtime/src/main/resources/org/teiid/runtime/i18n.properties
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java
Log:
TEIID-910, TEIID-833: Adding the provision to update the VDBMetadata artifact through ProfileService. Using this JON and Admin API can issue "assignConnectorBinding" calls on the VDB.
Modified: trunk/build/kit-jboss-container/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml
===================================================================
--- trunk/build/kit-jboss-container/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml 2010-03-12 21:47:08 UTC (rev 1961)
+++ trunk/build/kit-jboss-container/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml 2010-03-15 17:15:42 UTC (rev 1962)
@@ -10,9 +10,15 @@
<bean name="VDBParserDeployer" class="org.teiid.deployers.VDBParserDeployer">
<property name="objectSerializer"><inject bean="ObjectSerializer"/></property>
+ <property name="managedObjectFactory"><inject bean="ManagedObjectFactory"/></property>
</bean>
-
+ <bean name="VDBMetaDataInstanceClassFactory" class="org.teiid.jboss.deployers.VDBMetaDataInstanceClassFactory">
+ <constructor>
+ <parameter><inject bean="ManagedObjectFactory"/></parameter>
+ </constructor>
+ </bean>
+
<bean name="DynamicVDBDeployer" class="org.teiid.deployers.DynamicVDBDeployer">
</bean>
Modified: trunk/client/src/main/java/org/teiid/adminapi/Admin.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/Admin.java 2010-03-12 21:47:08 UTC (rev 1961)
+++ trunk/client/src/main/java/org/teiid/adminapi/Admin.java 2010-03-15 17:15:42 UTC (rev 1962)
@@ -35,27 +35,19 @@
/**
* Assign a {@link ConnectorBinding} to a {@link VDB}'s Model
*
- * @param connectorBindingName
- * Name of the ConnectorBinding
- * @param vdbName
- * Name of the VDB
- * @param vdbVersion
- * Version of the VDB
- * @param modelName
- * Name of the Model to map Connector Binding
- * @throws AdminException
- * if there's a system error or if there's a user input error.
+ * @param vdbName Name of the VDB
+ * @param vdbVersion Version of the VDB
+ * @param modelName Name of the Model to map Connector Binding
+ * @param sourceName sourceName for the model
+ * @param jndiName JNDI names to which the source name needs to map to
+ * @throws AdminException if there's a system error or if there's a user input error.
*/
void assignBindingToModel(String vdbName,
int vdbVersion,
String modelName,
- String connectorBindingName) throws AdminException;
+ String sourceName,
+ String jndiName) throws AdminException;
- void assignBindingsToModel(String vdbName,
- int vdbVersion,
- String modelName,
- String[] connectorBindingName) throws AdminException;
-
/**
* Set/update the property for the Connector Binding identified by the given deployed name.
* @param deployedName
@@ -338,20 +330,6 @@
void terminateTransaction(String transactionId) throws AdminException;
/**
- * Stop the Teiid. If millisToWait is >0, then close to incoming queries, wait the time period
- * for work to stop, then stop the MM Query. Otherwise, stop immediately, aborting all running queries.
- * @param millisToWait Milliseconds to wait (if >0) or <=0 for no wait before stopping
- * @throws AdminException
- */
- void shutdown(int millisToWait) throws AdminException;
-
- /**
- * Restart System
- * @throws AdminException if there's a system error.
- */
- void restart() throws AdminException;
-
- /**
* Adds JDBC XA Data Source in the container.
* @param dsName - name of the source
* @param properties - properties
Modified: trunk/client/src/main/java/org/teiid/adminapi/TeiidAdmin.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/TeiidAdmin.java 2010-03-12 21:47:08 UTC (rev 1961)
+++ trunk/client/src/main/java/org/teiid/adminapi/TeiidAdmin.java 2010-03-15 17:15:42 UTC (rev 1962)
@@ -29,13 +29,6 @@
public abstract class TeiidAdmin implements Admin, Serializable {
@Override
- public void assignBindingToModel(String vdbName, int vdbVersion, String modelName, String connectorBindingName)
- throws AdminException {
- throw new AdminProcessingException("feature coming soon..");
- }
-
-
- @Override
public Collection<ProcessObject> getProcesses(String processIdentifier) throws AdminException {
ArrayList<ProcessObject> list = new ArrayList<ProcessObject>();
//list.add(manager.getProcess());
@@ -43,16 +36,6 @@
}
@Override
- public void restart() throws AdminException {
- throw new AdminProcessingException("feature coming soon..");
- }
-
- @Override
- public void shutdown(int millisToWait) throws AdminException {
- throw new AdminProcessingException("feature coming soon..");
- }
-
- @Override
public void setRuntimeProperty(String propertyName, String propertyValue) throws AdminException {
throw new AdminProcessingException("feature coming soon..");
}
Modified: trunk/client/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java 2010-03-12 21:47:08 UTC (rev 1961)
+++ trunk/client/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java 2010-03-15 17:15:42 UTC (rev 1962)
@@ -69,15 +69,26 @@
public void setProperties(Properties props) {
this.properties.clear();
- for (String key:props.stringPropertyNames()) {
- addProperty(key, props.getProperty(key));
+ if (props != null) {
+ for (String key:props.stringPropertyNames()) {
+ addProperty(key, props.getProperty(key));
+ }
}
}
- protected List<PropertyMetadata> getJAXBProperties(){
+ public List<PropertyMetadata> getJAXBProperties(){
return properties;
}
+ public void setJAXBProperties(List<PropertyMetadata> props){
+ this.properties.clear();
+ if (props != null) {
+ for (PropertyMetadata prop:props) {
+ addProperty(prop.getName(), prop.getValue());
+ }
+ }
+ }
+
@Override
public String getPropertyValue(String name) {
PropertyMetadata prop = this.properties.getMap().get(name);
@@ -103,7 +114,7 @@
*/
public <T> T addAttchment(Class<T> type, T attachment) {
if (type == null)
- throw new IllegalArgumentException("Null type");
+ throw new IllegalArgumentException("Null type"); //$NON-NLS-1$
Object result = this.attachments.put(type.getName(), attachment);
if (result == null)
return null;
@@ -113,7 +124,7 @@
public Object addAttchment(String key, Object attachment) {
if (key == null)
- throw new IllegalArgumentException("Null type");
+ throw new IllegalArgumentException("Null type"); //$NON-NLS-1$
Object result = this.attachments.put(key, attachment);
if (result == null)
return null;
@@ -130,7 +141,7 @@
*/
public <T> T removeAttachment(Class<T> type) {
if (type == null)
- throw new IllegalArgumentException("Null type");
+ throw new IllegalArgumentException("Null type"); //$NON-NLS-1$
Object result = this.attachments.remove(type.getName());
if (result == null)
return null;
@@ -139,7 +150,7 @@
public Object removeAttachment(String key) {
if (key == null)
- throw new IllegalArgumentException("Null type");
+ throw new IllegalArgumentException("Null type"); //$NON-NLS-1$
Object result = this.attachments.remove(key);
if (result == null)
return null;
@@ -155,7 +166,7 @@
*/
public <T> T getAttachment(Class<T> type) {
if (type == null)
- throw new IllegalArgumentException("Null type");
+ throw new IllegalArgumentException("Null type"); //$NON-NLS-1$
Object result = this.attachments.get(type.getName());
if (result == null)
return null;
@@ -164,7 +175,7 @@
public Object getAttachment(String key) {
if (key == null)
- throw new IllegalArgumentException("Null type");
+ throw new IllegalArgumentException("Null type"); //$NON-NLS-1$
Object result = this.attachments.get(key);
if (result == null)
return null;
Modified: trunk/client/src/main/java/org/teiid/adminapi/impl/ConnectorBindingMetaData.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/impl/ConnectorBindingMetaData.java 2010-03-12 21:47:08 UTC (rev 1961)
+++ trunk/client/src/main/java/org/teiid/adminapi/impl/ConnectorBindingMetaData.java 2010-03-15 17:15:42 UTC (rev 1962)
@@ -42,13 +42,13 @@
@Override
@ManagementProperty(description="RAR file name", readOnly=true)
public String getRARFileName() {
- return getPropertyValue("rar-name");
+ return getPropertyValue("rar-name"); //$NON-NLS-1$
}
@Override
@ManagementProperty(description="JNDI name", readOnly=true)
public String getJNDIName() {
- return getPropertyValue("jndi-name");
+ return getPropertyValue("jndi-name"); //$NON-NLS-1$
}
public void setComponentType(Object type) {
Modified: trunk/client/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java 2010-03-12 21:47:08 UTC (rev 1961)
+++ trunk/client/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java 2010-03-15 17:15:42 UTC (rev 1962)
@@ -75,7 +75,7 @@
@XmlElement(name = "validation-error")
protected List<ValidationError> errors;
- @ManagementProperty(description="Model Name", readOnly=true)
+ @ManagementProperty(description="Model Name")
@ManagementObjectID(type="model")
@XmlAttribute(name = "name", required = true)
public String getName() {
@@ -88,24 +88,24 @@
}
@Override
- @ManagementProperty(description = "Is Model Source model", readOnly=true)
+ @ManagementProperty(description = "Is Model Source model")
public boolean isSource() {
return ModelType.parseString(modelType.toUpperCase()) == ModelType.PHYSICAL;
}
@Override
- @ManagementProperty(description = "Is Model Visible", readOnly=true)
+ @ManagementProperty(description = "Is Model Visible")
public boolean isVisible() {
return this.visible;
}
@Override
- @ManagementProperty(description = "Model Type", readOnly=true)
+ @ManagementProperty(description = "Model Type")
public Type getModelType() {
return Type.valueOf(modelType);
}
- @ManagementProperty(description = "Path to model file inside the archive", readOnly=true)
+ @ManagementProperty(description = "Path to model file inside the archive")
public String getPath() {
return path;
}
@@ -115,21 +115,21 @@
}
@Override
- @ManagementProperty(description = "Does Model supports multi-source bindings", readOnly=true)
+ @ManagementProperty(description = "Does Model supports multi-source bindings")
public boolean isSupportsMultiSourceBindings() {
String supports = getPropertyValue(SUPPORTS_MULTI_SOURCE_BINDINGS_KEY);
return Boolean.parseBoolean(supports);
}
@Override
- @ManagementProperty(description = "Properties", readOnly=true)
public Properties getProperties() {
return new Properties(super.getProperties());
}
@Override
@XmlElement(name = "property", type = PropertyMetadata.class)
- protected List<PropertyMetadata> getJAXBProperties(){
+ @ManagementProperty(description = "Model Properties", managed=true)
+ public List<PropertyMetadata> getJAXBProperties(){
return super.getJAXBProperties();
}
@@ -154,6 +154,12 @@
return new ArrayList<SourceMappingMetadata>(this.sources.getMap().values());
}
+ public void setSourceMappings(List<SourceMappingMetadata> sources){
+ for (SourceMappingMetadata source: sources) {
+ addSourceMapping(source.getName(), source.getJndiName());
+ }
+ }
+
@Override
public List<String> getSourceNames() {
return new ArrayList<String>(this.sources.getMap().keySet());
@@ -206,7 +212,7 @@
this.value = msg;
}
- @ManagementProperty (description="Error Message", readOnly = true)
+ @ManagementProperty (description="Error Message")
@ManagementObjectID(type="error")
public String getValue() {
return value;
@@ -216,7 +222,7 @@
this.value = value;
}
- @ManagementProperty (description="Severity", readOnly = true)
+ @ManagementProperty (description="Severity")
public String getSeverity() {
return severity;
}
Deleted: trunk/client/src/main/java/org/teiid/adminapi/impl/ModelMetadataMapper.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/impl/ModelMetadataMapper.java 2010-03-12 21:47:08 UTC (rev 1961)
+++ trunk/client/src/main/java/org/teiid/adminapi/impl/ModelMetadataMapper.java 2010-03-15 17:15:42 UTC (rev 1962)
@@ -1,110 +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 java.lang.reflect.Type;
-import java.util.Properties;
-
-import org.jboss.metatype.api.types.CompositeMetaType;
-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.CompositeValue;
-import org.jboss.metatype.api.values.CompositeValueSupport;
-import org.jboss.metatype.api.values.MapCompositeValueSupport;
-import org.jboss.metatype.api.values.MetaValue;
-import org.jboss.metatype.api.values.MetaValueFactory;
-import org.jboss.metatype.api.values.PropertiesMetaValue;
-import org.jboss.metatype.api.values.SimpleValueSupport;
-import org.jboss.metatype.plugins.types.MutableCompositeMetaType;
-import org.jboss.metatype.spi.values.MetaMapper;
-
-public class ModelMetadataMapper extends MetaMapper<ModelMetaData> {
- private static final MutableCompositeMetaType metaType;
- private static final MetaValueFactory metaValueFactory = MetaValueFactory.getInstance();
-
- static {
- metaType = new MutableCompositeMetaType(ModelMetaData.class.getName(), "The Model meta data");
- metaType.addItem("name", "name", SimpleMetaType.STRING);
- metaType.addItem("visible", "visible", SimpleMetaType.BOOLEAN_PRIMITIVE);
- metaType.addItem("modelType", "modelType", SimpleMetaType.STRING);
-
-
-
- //metaType.addItem("properties", "properties", new MapCompositeMetaType());
- metaType.freeze();
- }
-
- @Override
- public Type mapToType() {
- return ModelMetaData.class;
- }
-
- @Override
- public MetaType getMetaType() {
- return metaType;
- }
-
- @Override
- public MetaValue createMetaValue(MetaType metaType, ModelMetaData object) {
- if (object == null)
- return null;
- if (metaType instanceof CompositeMetaType) {
- CompositeMetaType composite = (CompositeMetaType) metaType;
- CompositeValueSupport request = new CompositeValueSupport(composite);
-
- request.set("modelType", SimpleValueSupport.wrap(object.getModelType().name()));
- request.set("visible", SimpleValueSupport.wrap(object.isVisible()));
- request.set("name",SimpleValueSupport.wrap(object.getName()));
- request.set("properties", new PropertiesMetaValue(object.getProperties()));
-
- return request;
- }
- throw new IllegalArgumentException("Cannot convert request " + object);
- }
-
- @Override
- public ModelMetaData unwrapMetaValue(MetaValue metaValue) {
- if (metaValue == null)
- return null;
-
- if (metaValue instanceof CompositeValue) {
- CompositeValue compositeValue = (CompositeValue) metaValue;
-
- ModelMetaData model = new ModelMetaData();
- String type = (String) metaValueFactory.unwrap(compositeValue.get("modelType"));
- if (type != null) {
- model.setModelType(type);
- }
- else {
- model.setModelType("PHYSICAL");
- }
-
- model.setVisible((Boolean) metaValueFactory.unwrap(compositeValue.get("visible")));
- model.setName((String) metaValueFactory.unwrap(compositeValue.get("name")));
- model.setProperties((Properties) metaValueFactory.unwrap(compositeValue.get("properties")));
- return model;
- }
- throw new IllegalStateException("Unable to unwrap request " + metaValue);
- }
-
-}
Modified: trunk/client/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java 2010-03-12 21:47:08 UTC (rev 1961)
+++ trunk/client/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java 2010-03-15 17:15:42 UTC (rev 1962)
@@ -29,6 +29,11 @@
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;
+
/**
* <pre>
* <complexType name="property">
@@ -45,6 +50,7 @@
*/
@XmlAccessorType(XmlAccessType.NONE)
@XmlType(name = "property")
+ at ManagementObject(properties=ManagementProperties.EXPLICIT)
public class PropertyMetadata implements Serializable{
private static final long serialVersionUID = -5040224539939758816L;
@@ -61,10 +67,13 @@
this.value = value;
}
+ @ManagementProperty(description="property key")
+ @ManagementObjectID(type="property")
public String getName() {
return name;
}
+ @ManagementProperty(description="property value")
public String getValue() {
return value;
}
@@ -78,6 +87,6 @@
}
public String toString() {
- return this.name+"="+this.value;
+ return this.name+"="+this.value; //$NON-NLS-1$
}
}
\ No newline at end of file
Modified: trunk/client/src/main/java/org/teiid/adminapi/impl/SourceMappingMetadata.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/impl/SourceMappingMetadata.java 2010-03-12 21:47:08 UTC (rev 1961)
+++ trunk/client/src/main/java/org/teiid/adminapi/impl/SourceMappingMetadata.java 2010-03-15 17:15:42 UTC (rev 1962)
@@ -55,7 +55,7 @@
this.jndiName = jndiName;
}
- @ManagementProperty (description="Source Name", readOnly = true)
+ @ManagementProperty (description="Source Name")
@ManagementObjectID(type="sourceMapping")
public String getName() {
return name;
@@ -69,7 +69,7 @@
public String getJndiName() {
// this default could be controlled if needed.
if (this.jndiName == null) {
- return "java:"+name;
+ return "java:"+name; //$NON-NLS-1$
}
return jndiName;
}
@@ -79,6 +79,6 @@
}
public String toString() {
- return getName()+":"+getJndiName();
+ return getName()+":"+getJndiName(); //$NON-NLS-1$
}
}
\ No newline at end of file
Modified: trunk/client/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java 2010-03-12 21:47:08 UTC (rev 1961)
+++ trunk/client/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java 2010-03-15 17:15:42 UTC (rev 1962)
@@ -37,14 +37,14 @@
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.ManagementOperation;
+import org.jboss.managed.api.annotation.ManagementProperties;
import org.jboss.managed.api.annotation.ManagementProperty;
import org.teiid.adminapi.Model;
import org.teiid.adminapi.VDB;
import org.teiid.adminapi.impl.ModelMetaData.ValidationError;
- at ManagementObject(componentType=@ManagementComponent(type="teiid",subtype="vdb"))
+ at ManagementObject(componentType=@ManagementComponent(type="teiid",subtype="vdb"), properties=ManagementProperties.EXPLICIT)
@XmlAccessorType(XmlAccessType.NONE)
@XmlType(name = "", propOrder = {
"description",
@@ -91,7 +91,7 @@
// auto add sytem model.
}
- @ManagementProperty(description="Name of the VDB", readOnly=true)
+ @ManagementProperty(description="Name of the VDB")
@ManagementObjectID(type="vdb")
@XmlAttribute(name = "name", required = true)
public String getName() {
@@ -104,7 +104,7 @@
}
@Override
- @ManagementProperty(description="VDB Status")
+ @ManagementProperty(description="VDB Status", readOnly=true)
public Status getStatus() {
String status = getPropertyValue(STATUS_KEY);
if (status != null) {
@@ -128,7 +128,7 @@
}
@Override
- @ManagementProperty(description = "The VDB file url", readOnly=true)
+ @ManagementProperty(description = "The VDB file url")
public String getUrl() {
return this.fileUrl;
}
@@ -143,12 +143,24 @@
return new ArrayList<Model>(this.models.getMap().values());
}
+ /**
+ * This method required to make the JNDI assignment on the model work; if not present Management framework
+ * treating "models" as ReadOnly property.
+ * @param models
+ */
+ public void setModels(List<Model> models) {
+ for (Model obj : models) {
+ ModelMetaData model = (ModelMetaData) obj;
+ addModel(model);
+ }
+ }
+
public void addModel(ModelMetaData m) {
this.models.getMap().put(m.getName(), m);
}
-
+
@Override
- @ManagementProperty(description = "Description", readOnly=true)
+ @ManagementProperty(description = "Description")
public String getDescription() {
return this.description;
}
@@ -204,7 +216,6 @@
return getName()+"."+getVersion()+ models.getMap().values(); //$NON-NLS-1$
}
- @ManagementOperation(description = "Get the model with given name")
public ModelMetaData getModel(String modelName) {
return this.models.getMap().get(modelName);
}
@@ -228,9 +239,7 @@
this.securityRoleMappings.getMap().put(data.getRefName(), data);
}
- // this one manages the Management API
@Override
- @ManagementProperty(description = "Properties", readOnly=true)
public Properties getProperties() {
return super.getProperties();
}
@@ -238,7 +247,8 @@
// This one manages the JAXB binding
@Override
@XmlElement(name = "property", type = PropertyMetadata.class)
- protected List<PropertyMetadata> getJAXBProperties(){
+ @ManagementProperty(description = "VDB Properties", managed=true)
+ public List<PropertyMetadata> getJAXBProperties(){
return super.getJAXBProperties();
}
Modified: trunk/engine/src/main/java/com/metamatrix/common/util/LogConstants.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/util/LogConstants.java 2010-03-12 21:47:08 UTC (rev 1961)
+++ trunk/engine/src/main/java/com/metamatrix/common/util/LogConstants.java 2010-03-15 17:15:42 UTC (rev 1962)
@@ -25,7 +25,10 @@
import org.teiid.connector.basic.DefaultConnectorLogger;
public interface LogConstants {
- // add the new contexts to the Log4JUtil.java class, for configuration purpose
+ /*
+ * important:
+ * Must need to add the new contexts to the Log4JUtil.java class, for configuration purpose
+ */
public static final String CTX_SESSION = "SESSION"; //$NON-NLS-1$
public static final String CTX_MEMBERSHIP = "MEMBERSHIP"; //$NON-NLS-1$
public static final String CTX_AUTHORIZATION = "AUTHORIZATION"; //$NON-NLS-1$
Modified: trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java 2010-03-12 21:47:08 UTC (rev 1961)
+++ trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java 2010-03-15 17:15:42 UTC (rev 1962)
@@ -47,7 +47,10 @@
import org.jboss.managed.api.ManagedComponent;
import org.jboss.managed.api.ManagedObject;
import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.plugins.DefaultFieldsImpl;
+import org.jboss.managed.plugins.WritethroughManagedPropertyImpl;
import org.jboss.metatype.api.types.MapCompositeMetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
import org.jboss.metatype.api.values.CollectionValueSupport;
import org.jboss.metatype.api.values.MapCompositeValueSupport;
import org.jboss.metatype.api.values.MetaValue;
@@ -446,7 +449,11 @@
}
vdb.setVersion(ManagedUtil.getSimpleValue(mc, "version", Integer.class));//$NON-NLS-1$
vdb.setUrl(mc.getDeployment().getName());
- vdb.setProperties(ManagedUtil.getPropertiesValue(mc, "properties"));//$NON-NLS-1$
+ ManagedProperty prop = mc.getProperty("JAXBProperties"); //$NON-NLS-1$
+ List<ManagedObject> properties = (List<ManagedObject>)MetaValueFactory.getInstance().unwrap(prop.getValue());
+ for (ManagedObject managedProperty:properties) {
+ vdb.addProperty(ManagedUtil.getSimpleValue(managedProperty, "name", String.class), ManagedUtil.getSimpleValue(managedProperty, "value", String.class)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
// models
ManagedProperty mp = mc.getProperty("models");//$NON-NLS-1$
@@ -461,15 +468,19 @@
return vdb;
}
- private ModelMetaData buildModel(ManagedObject mc) {
+ private ModelMetaData buildModel(ManagedObject managedModel) {
ModelMetaData model = new ModelMetaData();
- model.setName(ManagedUtil.getSimpleValue(mc, "name", String.class));//$NON-NLS-1$
- model.setVisible(ManagedUtil.getSimpleValue(mc, "visible", Boolean.class));//$NON-NLS-1$
- model.setModelType(ManagedUtil.getSimpleValue(mc, "modelType", String.class));//$NON-NLS-1$
- model.setProperties(ManagedUtil.getPropertiesValue(mc, "properties"));//$NON-NLS-1$
+ model.setName(ManagedUtil.getSimpleValue(managedModel, "name", String.class));//$NON-NLS-1$
+ model.setVisible(ManagedUtil.getSimpleValue(managedModel, "visible", Boolean.class));//$NON-NLS-1$
+ model.setModelType(ManagedUtil.getSimpleValue(managedModel, "modelType", String.class));//$NON-NLS-1$
+
+ ManagedProperty prop = managedModel.getProperty("JAXBProperties"); //$NON-NLS-1$
+ List<ManagedObject> properties = (List<ManagedObject>)MetaValueFactory.getInstance().unwrap(prop.getValue());
+ for (ManagedObject managedProperty:properties) {
+ model.addProperty(ManagedUtil.getSimpleValue(managedProperty, "name", String.class), ManagedUtil.getSimpleValue(managedProperty, "value", String.class)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
-
- ManagedProperty sourceMappings = mc.getProperty("sourceMappings");//$NON-NLS-1$
+ ManagedProperty sourceMappings = managedModel.getProperty("sourceMappings");//$NON-NLS-1$
if (sourceMappings != null){
List<ManagedObject> mappings = (List<ManagedObject>)MetaValueFactory.getInstance().unwrap(sourceMappings.getValue());
for (ManagedObject mo:mappings) {
@@ -479,7 +490,7 @@
}
}
- ManagedProperty validationErrors = mc.getProperty("errors");//$NON-NLS-1$
+ ManagedProperty validationErrors = managedModel.getProperty("errors");//$NON-NLS-1$
if (validationErrors != null) {
List<ManagedObject> errors = (List<ManagedObject>)MetaValueFactory.getInstance().unwrap(validationErrors.getValue());
if (errors != null) {
@@ -872,44 +883,52 @@
@Override
- public void assignBindingsToModel(String vdbName, int vdbVersion, String modelName, String[] connectorBindingNames) throws AdminException {
+ public void assignBindingToModel(String vdbName, int vdbVersion, String modelName, String sourceName, String jndiName) throws AdminException {
-// ManagedComponent mc = getVDBManagedComponent(vdbName, vdbVersion);
-// if (mc == null) {
-// throw new AdminProcessingException("VDB with name = "+vdbName + " version = "+ vdbVersion + " not found in configuration");
-// }
-// VDBMetaData vdb = buildVDB(mc);
-// ModelMetaData model = vdb.getModel(modelName);
-// if (model == null) {
-// throw new AdminProcessingException("Model name = "+modelName+" not found in the VDB with name = "+vdbName + " version = "+ vdbVersion);
-// }
-//
-// String referenceName = model.getConnectorReference();
-// ArrayList<MetaValue> newBindings = new ArrayList<MetaValue>();
-// for (String name:connectorBindingNames) {
-// newBindings.add(new SimpleValueSupport(SimpleMetaType.STRING, name));
-// }
-//
-// ManagedProperty mappings = mc.getProperty("connectorMappings");
-// MetaValue[] elements = ((CollectionValueSupport)mappings.getValue()).getElements();
-// ArrayList<MetaValue> modifiedElements = new ArrayList<MetaValue>();
-// for (MetaValue mv:elements) {
-// MetaValue value = ((CompositeValueSupport)mv).get("refName");
-// if (value != null && ManagedUtil.stringValue(value).equals(referenceName)) {
-// CollectionValueSupport bindings = (CollectionValueSupport)((CompositeValueSupport)mv).get("resourceNames");
-// bindings.setElements(newBindings.toArray(new MetaValue[newBindings.size()]));
-// }
-// else {
-// modifiedElements.add(mv);
-// }
-// }
-//
-// try {
-// getView().updateComponent(mc);
-// } catch (Exception e) {
-// throw new AdminComponentException(e.getMessage(), e);
-// }
- throw new AdminProcessingException("feature coming soon..");//$NON-NLS-1$
+ ManagedComponent mc = getVDBManagedComponent(vdbName, vdbVersion);
+ if (mc == null) {
+ throw new AdminProcessingException(IntegrationPlugin.Util.getString("vdb_not_found", vdbName, vdbVersion)); //$NON-NLS-1$
+ }
+
+ ManagedProperty mp = mc.getProperty("models");//$NON-NLS-1$
+ List<ManagedObject> models = (List<ManagedObject>)MetaValueFactory.getInstance().unwrap(mp.getValue());
+ ManagedObject managedModel = null;
+ if (models != null && !models.isEmpty()) {
+ for(ManagedObject mo:models) {
+ String name = ManagedUtil.getSimpleValue(mo, "name", String.class); //$NON-NLS-1$
+ if (modelName.equals(name)) {
+ managedModel = mo;
+ }
+ }
+ }
+
+ if (managedModel == null) {
+ throw new AdminProcessingException(IntegrationPlugin.Util.getString("model_not_found", modelName, vdbName, vdbVersion)); //$NON-NLS-1$
+ }
+
+ ManagedProperty sourceMappings = managedModel.getProperty("sourceMappings");//$NON-NLS-1$
+ if (sourceMappings != null){
+ List<ManagedObject> mappings = (List<ManagedObject>)MetaValueFactory.getInstance().unwrap(sourceMappings.getValue());
+ for (ManagedObject mo:mappings) {
+ String sName = ManagedUtil.getSimpleValue(mo, "name", String.class);//$NON-NLS-1$
+ if (sName.equals(sourceName)) {
+ ManagedProperty jndiProperty = mo.getProperty("jndiName"); //$NON-NLS-1$
+ if (jndiProperty == null) {
+ jndiProperty = new WritethroughManagedPropertyImpl(mo, new DefaultFieldsImpl("jndiName")); //$NON-NLS-1$
+ }
+ jndiProperty.setValue(ManagedUtil.wrap(SimpleMetaType.STRING, jndiName));
+ }
+ }
+ } else {
+ //TODO: this can be in the default situation when no source mappings are specified
+ throw new AdminProcessingException(IntegrationPlugin.Util.getString("sourcename_not_found", sourceName, vdbName, vdbVersion, modelName)); //$NON-NLS-1$
+ }
+
+ try {
+ getView().updateComponent(mc);
+ } catch (Exception e) {
+ throw new AdminComponentException(e.getMessage(), e);
+ }
}
}
Added: trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/VDBMetaDataInstanceClassFactory.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/VDBMetaDataInstanceClassFactory.java (rev 0)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/VDBMetaDataInstanceClassFactory.java 2010-03-15 17:15:42 UTC (rev 1962)
@@ -0,0 +1,82 @@
+/*
+ * 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.deployers;
+
+import java.util.List;
+
+import org.jboss.beans.info.spi.BeanInfo;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.api.factory.ManagedObjectFactory;
+import org.jboss.managed.plugins.factory.AbstractInstanceClassFactory;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.MetaValueFactory;
+import org.teiid.adminapi.impl.ModelMetaData;
+import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.adminapi.jboss.ManagedUtil;
+
+public class VDBMetaDataInstanceClassFactory extends AbstractInstanceClassFactory<VDBMetaData> {
+
+ public VDBMetaDataInstanceClassFactory() {
+ }
+
+ public VDBMetaDataInstanceClassFactory(ManagedObjectFactory mof) {
+ super(mof);
+ }
+
+ @Override
+ public Class<VDBMetaData> getType() {
+ return VDBMetaData.class;
+ }
+
+ @Override
+ public void setValue(BeanInfo beanInfo, ManagedProperty property, VDBMetaData vdb, MetaValue value) {
+
+ if (property.getName().equals("models")) { //$NON-NLS-1$
+ List<ManagedObject> models = (List<ManagedObject>)MetaValueFactory.getInstance().unwrap(property.getValue());
+ for(ManagedObject managedModel:models) {
+ String modelName = ManagedUtil.getSimpleValue(managedModel, "name", String.class); //$NON-NLS-1$
+ ModelMetaData model = vdb.getModel(modelName);
+
+ ManagedProperty sourceMappings = managedModel.getProperty("sourceMappings");//$NON-NLS-1$
+ if (sourceMappings != null){
+ List<ManagedObject> mappings = (List<ManagedObject>)MetaValueFactory.getInstance().unwrap(sourceMappings.getValue());
+ for (ManagedObject mo:mappings) {
+ String name = ManagedUtil.getSimpleValue(mo, "name", String.class);//$NON-NLS-1$
+ String jndiName = ManagedUtil.getSimpleValue(mo, "jndiName", String.class);//$NON-NLS-1$
+ model.addSourceMapping(name, jndiName);
+ }
+ }
+ }
+ }
+ else if (property.getName().equals("JAXBProperties")) { //$NON-NLS-1$
+ List<ManagedObject> properties = (List<ManagedObject>)MetaValueFactory.getInstance().unwrap(property.getValue());
+ for (ManagedObject managedProperty:properties) {
+ vdb.addProperty(ManagedUtil.getSimpleValue(managedProperty, "name", String.class), ManagedUtil.getSimpleValue(managedProperty, "value", String.class)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ else {
+ super.setValue(beanInfo, property, vdb, value);
+ }
+ }
+
+}
Property changes on: trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/VDBMetaDataInstanceClassFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/VDBMetadataComponentMapper.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/VDBMetadataComponentMapper.java 2010-03-12 21:47:08 UTC (rev 1961)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/VDBMetadataComponentMapper.java 2010-03-15 17:15:42 UTC (rev 1962)
@@ -40,7 +40,7 @@
protected ManagedObject getComponent(Object attachment, PersistedComponent component, boolean create) {
VDBMetaData metadata = (VDBMetaData)attachment;
String vdbName = metadata.getName()+"_"+metadata.getVersion(); //$NON-NLS-1$
- if (vdbName.equals(component.getOriginalName())) {
+ if (vdbName.equals(component.getName())) {
return getMOF().initManagedObject(metadata, VDBMetaData.class, vdbName, vdbName);
}
throw new IllegalStateException("could not find deployment " + component.getOriginalName());//$NON-NLS-1$
Modified: trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties
===================================================================
--- trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties 2010-03-12 21:47:08 UTC (rev 1961)
+++ trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties 2010-03-15 17:15:42 UTC (rev 1962)
@@ -32,4 +32,7 @@
bad_vdb_extension=The extension of the file name must be either ".vdb" for designer vdb or "xxx-vdb.xml" for dynamic VDBs
bad_connector_type_name="Teiid connector type names must start with \"connector-\""
connector_type_exists=Connector type with name:"{0}" already exists!
-connector_type_not_found=Connector Type template "{0}" not found in the configuration.
\ No newline at end of file
+connector_type_not_found=Connector Type template "{0}" not found in the configuration.
+vdb_not_found=VDB with name "{0}" version "{1}" not found in configuration
+model_not_found=Model name "{0}" not found in the VDB with name "{1}" version "{2}"
+sourcename_not_found=No source name {0} found in the model: {1}.{2}.{3}
\ No newline at end of file
Modified: trunk/jboss-integration/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java
===================================================================
--- trunk/jboss-integration/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java 2010-03-12 21:47:08 UTC (rev 1961)
+++ trunk/jboss-integration/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java 2010-03-15 17:15:42 UTC (rev 1962)
@@ -28,7 +28,6 @@
import com.metamatrix.core.util.ObjectConverterUtil;
import com.metamatrix.core.util.UnitTestUtil;
- at Ignore
public class TestConnectorBindings extends BaseConnection {
ServerDatasourceConnection ds;
Admin admin;
@@ -302,14 +301,12 @@
}
@Test public void testAssignConnectorBinding() throws Exception {
+
+ admin.assignBindingToModel("TransactionsRevisited", 1, "pm1", "mysql", "jndi:FOO");
+ }
+
+ @Test public void testVDB() throws Exception {
- VDB vdb = admin.getVDB("TransactionsRevisited", 1);
- if (vdb == null) {
- admin.deleteVDB("TransactionsRevisited", 1);
- File f = UnitTestUtil.getTestDataFile("TransactionsRevisited.vdb");
- admin.deployVDB(f.getName(), f.toURI().toURL());
- }
-
- admin.assignBindingsToModel("TransactionsRevisited", 1, "pm1", new String[] {"java:foo", "java:bar"});
+ admin.getVDB("TransactionsRevisited", 1);
}
}
Modified: trunk/jboss-integration/src/test/resources/TransactionsRevisited.vdb
===================================================================
(Binary files differ)
Modified: trunk/runtime/src/main/java/org/teiid/deployers/DynamicVDBDeployer.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/DynamicVDBDeployer.java 2010-03-12 21:47:08 UTC (rev 1961)
+++ trunk/runtime/src/main/java/org/teiid/deployers/DynamicVDBDeployer.java 2010-03-15 17:15:42 UTC (rev 1962)
@@ -26,13 +26,19 @@
import org.jboss.deployers.vfs.spi.deployer.AbstractVFSParsingDeployer;
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
import org.jboss.virtual.VirtualFile;
+import org.teiid.adminapi.Model;
+import org.teiid.adminapi.impl.ModelMetaData;
import org.teiid.adminapi.impl.VDBMetaData;
+import com.metamatrix.common.log.LogManager;
+import com.metamatrix.common.util.LogConstants;
+import com.metamatrix.core.CoreConstants;
+
public class DynamicVDBDeployer extends AbstractVFSParsingDeployer<VDBMetaData> {
public DynamicVDBDeployer() {
super(VDBMetaData.class);
- setSuffix("-vdb.xml");
+ setSuffix("-vdb.xml"); //$NON-NLS-1$
}
@Override
@@ -42,8 +48,18 @@
vdb.setUrl(unit.getRoot().toURL().toExternalForm());
vdb.setDynamic(true);
- log.debug("VDB "+unit.getRoot().getName()+" has been parsed.");
+ // Add system model to the deployed VDB
+ ModelMetaData system = new ModelMetaData();
+ system.setName(CoreConstants.SYSTEM_MODEL);
+ system.setVisible(true);
+ system.setModelType(Model.Type.PHYSICAL.name());
+ system.addSourceMapping(CoreConstants.SYSTEM_MODEL, CoreConstants.SYSTEM_MODEL);
+ system.setSupportsMultiSourceBindings(false);
+ vdb.addModel(system);
+
+ LogManager.logDetail(LogConstants.CTX_RUNTIME,"VDB "+unit.getRoot().getName()+" has been parsed."); //$NON-NLS-1$ //$NON-NLS-2$
+
// The loading of metadata from data sources will be done during the real deploy
// as the resources are guaranteed to be available by that time.
Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java 2010-03-12 21:47:08 UTC (rev 1961)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java 2010-03-15 17:15:42 UTC (rev 1962)
@@ -35,11 +35,11 @@
import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
-import org.jboss.logging.Logger;
import org.jboss.virtual.VirtualFile;
import org.teiid.adminapi.Model;
import org.teiid.adminapi.VDB;
import org.teiid.adminapi.impl.ModelMetaData;
+import org.teiid.adminapi.impl.SourceMappingMetadata;
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.metadata.runtime.MetadataStore;
@@ -51,13 +51,14 @@
import org.teiid.metadata.index.IndexMetadataFactory;
import org.teiid.runtime.RuntimePlugin;
+import com.metamatrix.common.log.LogManager;
+import com.metamatrix.common.util.LogConstants;
import com.metamatrix.core.CoreConstants;
import com.metamatrix.core.util.FileUtils;
import com.metamatrix.query.function.metadata.FunctionMethod;
import com.metamatrix.query.metadata.QueryMetadataInterface;
public class VDBDeployer extends AbstractSimpleRealDeployer<VDBMetaData> {
- protected Logger log = Logger.getLogger(getClass());
private VDBRepository vdbRepository;
private ConnectorManagerRepository connectorManagerRepository;
private DQPContextCache contextCache;
@@ -73,7 +74,7 @@
public void deploy(DeploymentUnit unit, VDBMetaData deployment) throws DeploymentException {
if (this.vdbRepository.getVDB(deployment.getName(), deployment.getVersion()) != null) {
this.vdbRepository.removeVDB(deployment.getName(), deployment.getVersion());
- log.info(RuntimePlugin.Util.getString("redeploying_vdb", deployment)); //$NON-NLS-1$
+ LogManager.logInfo(LogConstants.CTX_RUNTIME, RuntimePlugin.Util.getString("redeploying_vdb", deployment)); //$NON-NLS-1$
}
List<String> errors = deployment.getValidityErrors();
@@ -81,15 +82,6 @@
throw new DeploymentException(RuntimePlugin.Util.getString("validity_errors_in_vdb", deployment)); //$NON-NLS-1$
}
- // Add system model to the deployed VDB
- ModelMetaData system = new ModelMetaData();
- system.setName(CoreConstants.SYSTEM_MODEL);
- system.setVisible(true);
- system.setModelType(Model.Type.PHYSICAL.name());
- system.addSourceMapping("system", "system"); //$NON-NLS-1$ //$NON-NLS-2$
- system.setSupportsMultiSourceBindings(false);
- deployment.addModel(system);
-
// get the metadata store of the VDB (this is build in parse stage)
CompositeMetadataStore store = unit.getAttachment(CompositeMetadataStore.class);
@@ -106,6 +98,10 @@
unit.addAttachment(CompositeMetadataStore.class, store);
}
+ if (store == null) {
+ LogManager.logError(LogConstants.CTX_RUNTIME, RuntimePlugin.Util.getString("failed_matadata_load", deployment.getName(), deployment.getVersion())); //$NON-NLS-1$
+ }
+
// check if this is a VDB with index files, if there are then build the TransformationMetadata
TransformationMetadata metadata = null;
IndexMetadataFactory indexFactory = unit.getAttachment(IndexMetadataFactory.class);
@@ -133,7 +129,7 @@
try {
saveMetadataStore((VFSDeploymentUnit)unit, deployment, metadata.getMetadataStore());
} catch (IOException e1) {
- log.warn(RuntimePlugin.Util.getString("vdb_save_failed", deployment.getName()+"."+deployment.getVersion()), e1); //$NON-NLS-1$ //$NON-NLS-2$
+ LogManager.logWarning(LogConstants.CTX_RUNTIME, e1, RuntimePlugin.Util.getString("vdb_save_failed", deployment.getName()+"."+deployment.getVersion())); //$NON-NLS-1$ //$NON-NLS-2$
}
boolean valid = validateSources(deployment);
@@ -142,26 +138,26 @@
if (valid) {
deployment.setStatus(VDB.Status.ACTIVE);
}
- log.info(RuntimePlugin.Util.getString("vdb_deployed",deployment)); //$NON-NLS-1$
+ LogManager.logInfo(LogConstants.CTX_RUNTIME, RuntimePlugin.Util.getString("vdb_deployed",deployment)); //$NON-NLS-1$
}
private boolean validateSources(VDBMetaData deployment) {
boolean valid = true;
for(Model m:deployment.getModels()) {
ModelMetaData model = (ModelMetaData)m;
- for (String sourceName:model.getSourceNames()) {
- if (sourceName.equals(CoreConstants.SYSTEM_MODEL)) {
+ List<SourceMappingMetadata> mappings = model.getSourceMappings();
+ for (SourceMappingMetadata mapping:mappings) {
+ if (mapping.getName().equals(CoreConstants.SYSTEM_MODEL)) {
continue;
}
- String jndiName = model.getSourceJndiName(sourceName);
try {
InitialContext ic = new InitialContext();
- ic.lookup(jndiName);
+ ic.lookup(mapping.getJndiName());
} catch (NamingException e) {
valid = false;
- String msg = RuntimePlugin.Util.getString("jndi_not_found", jndiName,sourceName); //$NON-NLS-1$
+ String msg = RuntimePlugin.Util.getString("jndi_not_found", mapping.getJndiName(),mapping.getName()); //$NON-NLS-1$
model.addError(ModelMetaData.ValidationError.Severity.ERROR.name(), msg);
- log.info(msg);
+ LogManager.logInfo(LogConstants.CTX_RUNTIME, msg);
}
}
}
@@ -210,10 +206,10 @@
try {
deleteMetadataStore((VFSDeploymentUnit)unit, deployment);
} catch (IOException e) {
- log.warn(RuntimePlugin.Util.getString("vdb_delete_failed", e.getMessage())); //$NON-NLS-1$
+ LogManager.logWarning(LogConstants.CTX_RUNTIME, RuntimePlugin.Util.getString("vdb_delete_failed", e.getMessage())); //$NON-NLS-1$
}
- log.info(RuntimePlugin.Util.getString("vdb_undeployed", deployment)); //$NON-NLS-1$
+ LogManager.logInfo(LogConstants.CTX_RUNTIME, RuntimePlugin.Util.getString("vdb_undeployed", deployment)); //$NON-NLS-1$
}
public void setContextCache(DQPContextCache cache) {
@@ -258,9 +254,9 @@
return this.serializer.loadAttachment(cacheFile, MetadataStore.class);
}
} catch (IOException e) {
- log.warn(RuntimePlugin.Util.getString("invalid_metadata_file", cacheFile.getAbsolutePath())); //$NON-NLS-1$
+ LogManager.logWarning(LogConstants.CTX_RUNTIME, RuntimePlugin.Util.getString("invalid_metadata_file", cacheFile.getAbsolutePath())); //$NON-NLS-1$
} catch (ClassNotFoundException e) {
- log.warn(RuntimePlugin.Util.getString("invalid_metadata_file", cacheFile.getAbsolutePath())); //$NON-NLS-1$
+ LogManager.logWarning(LogConstants.CTX_RUNTIME, RuntimePlugin.Util.getString("invalid_metadata_file", cacheFile.getAbsolutePath())); //$NON-NLS-1$
}
}
Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBParserDeployer.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBParserDeployer.java 2010-03-12 21:47:08 UTC (rev 1961)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBParserDeployer.java 2010-03-15 17:15:42 UTC (rev 1962)
@@ -26,6 +26,7 @@
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import javax.xml.XMLConstants;
import javax.xml.bind.JAXBContext;
@@ -34,8 +35,12 @@
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.managed.ManagedObjectCreator;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
-import org.jboss.logging.Logger;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.factory.ManagedObjectFactory;
import org.jboss.virtual.VirtualFile;
import org.teiid.adminapi.Model;
import org.teiid.adminapi.impl.ModelMetaData;
@@ -46,6 +51,8 @@
import org.teiid.runtime.RuntimePlugin;
import org.xml.sax.SAXException;
+import com.metamatrix.common.log.LogManager;
+import com.metamatrix.common.util.LogConstants;
import com.metamatrix.core.CoreConstants;
import com.metamatrix.core.util.StringUtil;
import com.metamatrix.core.vdb.VdbConstants;
@@ -53,8 +60,7 @@
/**
* This file loads the "vdb.xml" file inside a ".vdb" file, along with all the metadata in the .INDEX files
*/
-public class VDBParserDeployer extends BaseMultipleVFSParsingDeployer<VDBMetaData> {
- protected Logger log = Logger.getLogger(getClass());
+public class VDBParserDeployer extends BaseMultipleVFSParsingDeployer<VDBMetaData> implements ManagedObjectCreator {
private ObjectSerializer serializer;
public VDBParserDeployer() {
@@ -122,7 +128,7 @@
UDFMetaData udf = getInstance(metadata, UDFMetaData.class);
if (vdb == null) {
- log.error(RuntimePlugin.Util.getString("invlaid_vdb_file",unit.getRoot().getName())); //$NON-NLS-1$
+ LogManager.logError(LogConstants.CTX_RUNTIME, RuntimePlugin.Util.getString("invlaid_vdb_file",unit.getRoot().getName())); //$NON-NLS-1$
return null;
}
@@ -163,7 +169,7 @@
if (model.getModelType().equals(Model.Type.FUNCTION)) {
String path = ((ModelMetaData)model).getPath();
if (path == null) {
- path = model.getName()+VdbConstants.MODEL_EXT;
+ throw new DeploymentException(RuntimePlugin.Util.getString("invalid_udf_file", model.getName())); //$NON-NLS-1$
}
udf.buildFunctionModelFile(path);
}
@@ -173,7 +179,16 @@
unit.addAttachment(UDFMetaData.class, udf);
}
- log.debug("VDB "+unit.getRoot().getName()+" has been parsed."); //$NON-NLS-1$ //$NON-NLS-2$
+ // Add system model to the deployed VDB
+ ModelMetaData system = new ModelMetaData();
+ system.setName(CoreConstants.SYSTEM_MODEL);
+ system.setVisible(true);
+ system.setModelType(Model.Type.PHYSICAL.name());
+ system.addSourceMapping(CoreConstants.SYSTEM_MODEL, CoreConstants.SYSTEM_MODEL);
+ system.setSupportsMultiSourceBindings(false);
+ vdb.addModel(system);
+
+ LogManager.logTrace(LogConstants.CTX_RUNTIME, "VDB "+unit.getRoot().getName()+" has been parsed."); //$NON-NLS-1$ //$NON-NLS-2$
return vdb;
}
@@ -215,4 +230,31 @@
public void setObjectSerializer(ObjectSerializer serializer) {
this.serializer = serializer;
}
+
+ private ManagedObjectFactory mof;
+
+ @Override
+ public void build(DeploymentUnit unit, Set<String> attachmentNames, Map<String, ManagedObject> managedObjects)
+ throws DeploymentException {
+
+ ManagedObject vdbMO = managedObjects.get(VDBMetaData.class.getName());
+ if (vdbMO != null) {
+ VDBMetaData vdb = (VDBMetaData) vdbMO.getAttachment();
+ for (Model m : vdb.getModels()) {
+ if (m.getName().equals(CoreConstants.SYSTEM_MODEL)) {
+ continue;
+ }
+ ManagedObject mo = this.mof.initManagedObject(m, ModelMetaData.class, m.getName(),m.getName());
+ if (mo == null) {
+ throw new DeploymentException("could not create managed object");
+ }
+ managedObjects.put(mo.getName(), mo);
+ }
+ }
+ }
+
+ public void setManagedObjectFactory(ManagedObjectFactory mof) {
+ this.mof = mof;
+ }
+
}
Modified: trunk/runtime/src/main/java/org/teiid/logging/Log4JUtil.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/logging/Log4JUtil.java 2010-03-12 21:47:08 UTC (rev 1961)
+++ trunk/runtime/src/main/java/org/teiid/logging/Log4JUtil.java 2010-03-15 17:15:42 UTC (rev 1962)
@@ -110,7 +110,13 @@
contexts.add(ROOT_CONTEXT+com.metamatrix.common.util.LogConstants.CTX_TRANSPORT);
contexts.add(ROOT_CONTEXT+com.metamatrix.common.util.LogConstants.CTX_ADMIN_API);
contexts.add(ROOT_CONTEXT+com.metamatrix.common.util.LogConstants.CTX_QUERY_PLANNER);
+ contexts.add(ROOT_CONTEXT+com.metamatrix.common.util.LogConstants.CTX_RUNTIME);
+ contexts.add(ROOT_CONTEXT+com.metamatrix.common.util.LogConstants.CTX_FUNCTION_TREE);
+ contexts.add(ROOT_CONTEXT+com.metamatrix.common.util.LogConstants.CTX_QUERY_RESOLVER);
+ contexts.add(ROOT_CONTEXT+com.metamatrix.common.util.LogConstants.CTX_XML_PLANNER);
+ contexts.add(ROOT_CONTEXT+com.metamatrix.common.util.LogConstants.CTX_XML_PLAN);
+
contexts.add("com.arjuna"); //$NON-NLS-1$
contexts.add("org.jboss"); //$NON-NLS-1$
contexts.add("org.teiid"); //$NON-NLS-1$
Modified: trunk/runtime/src/main/resources/org/teiid/runtime/i18n.properties
===================================================================
--- trunk/runtime/src/main/resources/org/teiid/runtime/i18n.properties 2010-03-12 21:47:08 UTC (rev 1961)
+++ trunk/runtime/src/main/resources/org/teiid/runtime/i18n.properties 2010-03-15 17:15:42 UTC (rev 1962)
@@ -291,4 +291,6 @@
udf_model_not_found=User Defined Function (UDF) model "{0}" not found in the VDB
duplicate_vdb=VDB with given name and version already exists! {0}.{1}
system_vdb_not_found=System.vdb not found in classpath
-failed_to_deployed=Failed to deploy {0}
\ No newline at end of file
+failed_to_deployed=Failed to deploy {0}
+invalid_udf_file=No "path" information found to load the FUNCTION model {0}; FUNCTION model must have path information.
+failed_matadata_load=Failed to load metadata for VDB {0}.{1}
\ No newline at end of file
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java 2010-03-12 21:47:08 UTC (rev 1961)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java 2010-03-15 17:15:42 UTC (rev 1962)
@@ -206,7 +206,7 @@
api.addConnectorBinding(ds.getName(),ds.getConnectorType(), ds.getProperties());
- api.assignBindingToModel(vdb.getName(), vdb.getVersion(), m.getName(), ds.getName());
+ api.assignBindingToModel(vdb.getName(), vdb.getVersion(), m.getName(), ds.getName(), ds.getProperty("jndi-name"));
api.startConnectorBinding(api.getConnectorBinding(ds.getName()));
} else {
More information about the teiid-commits
mailing list