Author: rareddy
Date: 2012-06-18 10:37:59 -0400 (Mon, 18 Jun 2012)
New Revision: 4183
Added:
trunk/runtime/src/main/java/org/teiid/deployers/RuntimeVDB.java
Removed:
trunk/admin/src/main/java/org/teiid/adminapi/impl/ListOverMap.java
trunk/admin/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java
Modified:
trunk/admin/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java
trunk/admin/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java
trunk/admin/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java
trunk/admin/src/main/java/org/teiid/adminapi/impl/PermissionMap.java
trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java
trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataMapper.java
trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBTranslatorMetaData.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/IntegrationPlugin.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidOperationHandler.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java
trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties
trunk/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java
trunk/runtime/src/main/java/org/teiid/runtime/RuntimePlugin.java
trunk/runtime/src/main/resources/org/teiid/runtime/i18n.properties
Log:
TEIID-2057: fixing the VDB modify operations to be synchronous, removing the duplicated
code in TeiidOperationHandler and VDBService. Now all the VDB runtime operations should be
handled through RuntimeVDB. Removed ListOverMap objects in the AdminObject(s) that was
previously used in support of JAXB.
Modified: trunk/admin/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java
===================================================================
--- trunk/admin/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java 2012-06-15
17:53:09 UTC (rev 4182)
+++ trunk/admin/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java 2012-06-18
14:37:59 UTC (rev 4183)
@@ -24,11 +24,9 @@
import java.io.Serializable;
import java.util.Collections;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import java.util.Properties;
-
import org.teiid.adminapi.AdminObject;
public abstract class AdminObjectImpl implements AdminObject, Serializable {
@@ -40,15 +38,7 @@
private String serverName;
private String hostName;
- private ListOverMap<PropertyMetadata> properties = new
ListOverMap<PropertyMetadata>(new KeyBuilder<PropertyMetadata>() {
- private static final long serialVersionUID = 3687928367250819142L;
-
- @Override
- public String getKey(PropertyMetadata entry) {
- return entry.getName();
- }
- });
-
+ private Properties properties = new Properties();
private transient Map<String, Object> attachments =
Collections.synchronizedMap(new HashMap<String, Object>());
@Override
@@ -87,8 +77,8 @@
@Override
public Properties getProperties() {
Properties props = new Properties();
- for (PropertyMetadata p:this.properties.getMap().values()) {
- props.setProperty(p.getName(), p.getValue());
+ for (String key:this.properties.stringPropertyNames()) {
+ props.setProperty(key, this.properties.getProperty(key));
}
return props;
}
@@ -102,110 +92,93 @@
}
}
- 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);
- if (prop == null) {
- return null;
- }
- return prop.getValue();
+ return this.properties.getProperty(name);
}
public void addProperty(String key, String value) {
- this.properties.getMap().put(key, new PropertyMetadata(key, value));
+ this.properties.setProperty(key, value);
}
- /**
- * Add attachment
- *
- * @param <T> the expected type
- * @param attachment the attachment
- * @param type the type
- * @return any previous attachment
- * @throws IllegalArgumentException for a null name, attachment or type
- * @throws UnsupportedOperationException when not supported by the implementation
- */
- public <T> T addAttchment(Class<T> type, T attachment) {
- if (type == null)
+ /**
+ * Add attachment
+ *
+ * @param <T> the expected type
+ * @param attachment the attachment
+ * @param type the type
+ * @return any previous attachment
+ * @throws IllegalArgumentException for a null name, attachment or type
+ * @throws UnsupportedOperationException when not supported by the implementation
+ */
+ public <T> T addAttchment(Class<T> type, T attachment) {
+ if (type == null)
+ throw new IllegalArgumentException("Null type"); //$NON-NLS-1$
+ Object result = this.attachments.put(type.getName(), attachment);
+ if (result == null)
+ return null;
+ return type.cast(result);
+
+ }
+
+ public Object addAttchment(String key, Object attachment) {
+ if (key == null)
throw new IllegalArgumentException("Null type"); //$NON-NLS-1$
- Object result = this.attachments.put(type.getName(), attachment);
+ Object result = this.attachments.put(key, attachment);
if (result == null)
return null;
- return type.cast(result);
-
- }
-
- public Object addAttchment(String key, Object attachment) {
- if (key == null)
- throw new IllegalArgumentException("Null type"); //$NON-NLS-1$
- Object result = this.attachments.put(key, attachment);
- if (result == null)
- return null;
- return result;
- }
-
- /**
- * Remove attachment
- *
- * @param <T> the expected type
- * @return the attachment or null if not present
- * @param type the type
- * @throws IllegalArgumentException for a null name or type
- */
- public <T> T removeAttachment(Class<T> type) {
- if (type == null)
- throw new IllegalArgumentException("Null type"); //$NON-NLS-1$
- Object result = this.attachments.remove(type.getName());
- if (result == null)
- return null;
- return type.cast(result);
- }
-
- public Object removeAttachment(String key) {
- if (key == null)
- throw new IllegalArgumentException("Null type"); //$NON-NLS-1$
- Object result = this.attachments.remove(key);
- if (result == null)
- return null;
- return result;
- }
- /**
- * Get attachment
- *
- * @param <T> the expected type
- * @param type the type
- * @return the attachment or null if not present
- * @throws IllegalArgumentException for a null name or type
- */
- public <T> T getAttachment(Class<T> type) {
- if (type == null)
+ return result;
+ }
+
+ /**
+ * Remove attachment
+ *
+ * @param <T> the expected type
+ * @return the attachment or null if not present
+ * @param type the type
+ * @throws IllegalArgumentException for a null name or type
+ */
+ public <T> T removeAttachment(Class<T> type) {
+ if (type == null)
+ throw new IllegalArgumentException("Null type"); //$NON-NLS-1$
+ Object result = this.attachments.remove(type.getName());
+ if (result == null)
+ return null;
+ return type.cast(result);
+ }
+
+ public Object removeAttachment(String key) {
+ if (key == null)
+ throw new IllegalArgumentException("Null type"); //$NON-NLS-1$
+ Object result = this.attachments.remove(key);
+ if (result == null)
+ return null;
+ return result;
+ }
+ /**
+ * Get attachment
+ *
+ * @param <T> the expected type
+ * @param type the type
+ * @return the attachment or null if not present
+ * @throws IllegalArgumentException for a null name or type
+ */
+ public <T> T getAttachment(Class<T> type) {
+ if (type == null)
+ throw new IllegalArgumentException("Null type"); //$NON-NLS-1$
+ Object result = this.attachments.get(type.getName());
+ if (result == null)
+ return null;
+ return type.cast(result);
+ }
+
+ public Object getAttachment(String key) {
+ if (key == null)
throw new IllegalArgumentException("Null type"); //$NON-NLS-1$
- Object result = this.attachments.get(type.getName());
+ Object result = this.attachments.get(key);
if (result == null)
return null;
- return type.cast(result);
- }
-
- public Object getAttachment(String key) {
- if (key == null)
- throw new IllegalArgumentException("Null type"); //$NON-NLS-1$
- Object result = this.attachments.get(key);
- if (result == null)
- return null;
- return result;
- }
+ return result;
+ }
}
Modified: trunk/admin/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java
===================================================================
--- trunk/admin/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java 2012-06-15
17:53:09 UTC (rev 4182)
+++ trunk/admin/src/main/java/org/teiid/adminapi/impl/DataPolicyMetadata.java 2012-06-18
14:37:59 UTC (rev 4183)
@@ -37,13 +37,7 @@
protected boolean anyAuthenticated;
protected Boolean allowCreateTemporaryTables;
- protected PermissionMap permissions = new PermissionMap(new
KeyBuilder<PermissionMetaData>() {
- private static final long serialVersionUID = -6992984146431492449L;
- @Override
- public String getKey(PermissionMetaData entry) {
- return entry.getResourceName().toLowerCase();
- }
- });
+ protected PermissionMap permissions = new PermissionMap();
protected List<String> mappedRoleNames = new ArrayList<String>();
@@ -67,19 +61,19 @@
@Override
public List<DataPermission> getPermissions() {
- return new ArrayList<DataPermission>(this.permissions.getMap().values());
+ return new ArrayList<DataPermission>(this.permissions.values());
}
public void setPermissions(List<DataPermission> permissions) {
- this.permissions.getMap().clear();
+ this.permissions.clear();
for (DataPermission permission:permissions) {
- this.permissions.add((PermissionMetaData)permission);
+ this.permissions.put(permission.getResourceName().toLowerCase(),
(PermissionMetaData)permission);
}
}
public void addPermission(PermissionMetaData... permissions) {
for (PermissionMetaData permission:permissions) {
- this.permissions.add(permission);
+ this.permissions.put(permission.getResourceName().toLowerCase(), permission);
}
}
@@ -104,7 +98,7 @@
public boolean allows(String resourceName, DataPolicy.PermissionType type) {
resourceName = resourceName.toLowerCase();
while (resourceName.length() > 0) {
- PermissionMetaData p = this.permissions.getMap().get(resourceName);
+ PermissionMetaData p = this.permissions.get(resourceName);
if (p != null) {
Boolean allowed = p.allows(type);
if (allowed != null) {
Deleted: trunk/admin/src/main/java/org/teiid/adminapi/impl/ListOverMap.java
===================================================================
--- trunk/admin/src/main/java/org/teiid/adminapi/impl/ListOverMap.java 2012-06-15 17:53:09
UTC (rev 4182)
+++ trunk/admin/src/main/java/org/teiid/adminapi/impl/ListOverMap.java 2012-06-18 14:37:59
UTC (rev 4183)
@@ -1,89 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright (C) 2008 Red Hat, Inc.
- * Licensed to Red Hat, Inc. under one or more contributor
- * license agreements. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * 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.io.Serializable;
-import java.util.AbstractList;
-import java.util.LinkedHashMap;
-import java.util.Set;
-
-class ListOverMap<E> extends AbstractList<E> implements Serializable {
-
- private static final long serialVersionUID = 5171741731121210240L;
-
- protected LinkedHashMap<String, E> map = new LinkedHashMap<String, E>();
- protected KeyBuilder<E> builder;
-
- public ListOverMap(KeyBuilder<E> builder) {
- this.builder = builder;
- }
-
- public LinkedHashMap<String, E> getMap() {
- return map;
- }
-
- @Override
- public void add(int index, E element) {
- this.map.put(builder.getKey(element), element);
- }
-
- @Override
- public E remove(int index) {
- String key = getKey(index);
- if (key == null) {
- throw new IndexOutOfBoundsException("Index: "+index+", Size:
"+size()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- return this.map.remove(key);
- }
-
- @Override
- public E get(int index) {
- String key = getKey(index);
- if (key == null) {
- throw new IndexOutOfBoundsException("Index: "+index+", Size:
"+size()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- return this.map.get(key);
- }
-
- private String getKey(int index) {
- Set<String> keys = this.map.keySet();
- int i = 0;
- for (String key:keys) {
- if (i == index) {
- return key;
- }
- i++;
- }
- return null;
- }
-
- @Override
- public int size() {
- return this.map.size();
- }
-}
-
-interface KeyBuilder<E> extends Serializable {
- String getKey(E entry);
-}
-
Modified: trunk/admin/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java
===================================================================
--- trunk/admin/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java 2012-06-15
17:53:09 UTC (rev 4182)
+++ trunk/admin/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java 2012-06-18
14:37:59 UTC (rev 4183)
@@ -25,6 +25,7 @@
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
@@ -38,15 +39,7 @@
private static final String SUPPORTS_MULTI_SOURCE_BINDINGS_KEY =
"supports-multi-source-bindings"; //$NON-NLS-1$
private static final long serialVersionUID = 3714234763056162230L;
- protected ListOverMap<SourceMappingMetadata> sources = new
ListOverMap<SourceMappingMetadata>(new KeyBuilder<SourceMappingMetadata>() {
- private static final long serialVersionUID = 2273673984691112369L;
-
- @Override
- public String getKey(SourceMappingMetadata entry) {
- return entry.getName();
- }
- });
-
+ protected LinkedHashMap<String, SourceMappingMetadata> sources = new
LinkedHashMap<String, SourceMappingMetadata>();
protected String modelType = Type.PHYSICAL.name();
protected String description;
protected String path;
@@ -107,11 +100,6 @@
return Boolean.parseBoolean(supports);
}
- @Override
- public List<PropertyMetadata> getJAXBProperties(){
- return super.getJAXBProperties();
- }
-
public void setSupportsMultiSourceBindings(boolean supports) {
addProperty(SUPPORTS_MULTI_SOURCE_BINDINGS_KEY, Boolean.toString(supports));
}
@@ -137,15 +125,15 @@
}
public List<SourceMappingMetadata> getSourceMappings(){
- return new ArrayList<SourceMappingMetadata>(this.sources.getMap().values());
+ return new ArrayList<SourceMappingMetadata>(this.sources.values());
}
public SourceMappingMetadata getSourceMapping(String sourceName){
- return this.sources.getMap().get(sourceName);
+ return this.sources.get(sourceName);
}
public void setSourceMappings(List<SourceMappingMetadata> sources){
- this.sources.getMap().clear();
+ this.sources.clear();
for (SourceMappingMetadata source: sources) {
addSourceMapping(source.getName(), source.getTranslatorName(),
source.getConnectionJndiName());
}
@@ -153,12 +141,12 @@
@Override
public List<String> getSourceNames() {
- return new ArrayList<String>(this.sources.getMap().keySet());
+ return new ArrayList<String>(this.sources.keySet());
}
@Override
public String getSourceConnectionJndiName(String sourceName) {
- SourceMappingMetadata s = this.sources.getMap().get(sourceName);
+ SourceMappingMetadata s = this.sources.get(sourceName);
if (s == null) {
return null;
}
@@ -167,7 +155,7 @@
@Override
public String getSourceTranslatorName(String sourceName) {
- SourceMappingMetadata s = this.sources.getMap().get(sourceName);
+ SourceMappingMetadata s = this.sources.get(sourceName);
if (s == null) {
return null;
}
@@ -175,7 +163,7 @@
}
public SourceMappingMetadata addSourceMapping(String name, String translatorName, String
connJndiName) {
- return this.sources.getMap().put(name, new SourceMappingMetadata(name, translatorName,
connJndiName));
+ return this.sources.put(name, new SourceMappingMetadata(name, translatorName,
connJndiName));
}
public void addSourceMapping(SourceMappingMetadata source) {
Modified: trunk/admin/src/main/java/org/teiid/adminapi/impl/PermissionMap.java
===================================================================
--- trunk/admin/src/main/java/org/teiid/adminapi/impl/PermissionMap.java 2012-06-15
17:53:09 UTC (rev 4182)
+++ trunk/admin/src/main/java/org/teiid/adminapi/impl/PermissionMap.java 2012-06-18
14:37:59 UTC (rev 4183)
@@ -22,19 +22,17 @@
*/
package org.teiid.adminapi.impl;
+import java.util.LinkedHashMap;
+
import org.teiid.adminapi.impl.DataPolicyMetadata.PermissionMetaData;
-public class PermissionMap extends ListOverMap<PermissionMetaData> {
+public class PermissionMap extends LinkedHashMap<String, PermissionMetaData> {
private static final long serialVersionUID = -1170556665834875267L;
- public PermissionMap(KeyBuilder<PermissionMetaData> builder) {
- super(builder);
- }
-
@Override
- public void add(int index, PermissionMetaData element) {
- PermissionMetaData previous = this.map.get(builder.getKey(element));
+ public PermissionMetaData put(String key, PermissionMetaData element) {
+ PermissionMetaData previous = get(element.getResourceName().toLowerCase());
if (previous != null) {
if (element.allowCreate != null) {
previous.setAllowCreate(element.allowCreate);
@@ -48,10 +46,8 @@
if (element.allowDelete != null) {
previous.setAllowDelete(element.allowDelete);
}
+ return previous;
}
- else {
- super.add(index, element);
- }
+ return super.put(element.getResourceName().toLowerCase(), element);
}
-
}
Deleted: trunk/admin/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java
===================================================================
--- trunk/admin/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java 2012-06-15
17:53:09 UTC (rev 4182)
+++ trunk/admin/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java 2012-06-18
14:37:59 UTC (rev 4183)
@@ -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.adminapi.impl;
-
-import java.io.Serializable;
-
-/**
- * <pre>
- * <complexType name="property">
- * <complexContent>
- * <restriction
base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <attribute name="name" use="required"
type="{http://www.w3.org/2001/XMLSchema}string" />
- * <attribute name="value" use="required"
type="{http://www.w3.org/2001/XMLSchema}string" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </pre>
- *
- *
- */
-public class PropertyMetadata implements Serializable{
- private static final long serialVersionUID = -5040224539939758816L;
-
- protected String name;
- protected String value;
-
- public PropertyMetadata() {
- }
-
- public PropertyMetadata(String key, String value) {
- this.name = key;
- this.value = value;
- }
-
- public String getName() {
- return name;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- public String toString() {
- return this.name+"="+this.value; //$NON-NLS-1$
- }
-}
\ No newline at end of file
Modified: trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java
===================================================================
--- trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java 2012-06-15 17:53:09
UTC (rev 4182)
+++ trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java 2012-06-18 14:37:59
UTC (rev 4183)
@@ -25,6 +25,7 @@
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -42,43 +43,12 @@
private static final long serialVersionUID = -4723595252013356436L;
- /**
- * This simulating a list over a map. JAXB requires a list and performance recommends
- * map and we would like to keep one variable to represent both.
- */
- protected ListOverMap<ModelMetaData> models = new
ListOverMap<ModelMetaData>(new KeyBuilder<ModelMetaData>() {
- private static final long serialVersionUID = 846247100420118961L;
-
- @Override
- public String getKey(ModelMetaData entry) {
- return entry.getName();
- }
- });
-
- protected ListOverMap<VDBTranslatorMetaData> translators = new
ListOverMap<VDBTranslatorMetaData>(new KeyBuilder<VDBTranslatorMetaData>() {
- private static final long serialVersionUID = 3890502172003653563L;
-
- @Override
- public String getKey(VDBTranslatorMetaData entry) {
- return entry.getName();
- }
- });
-
- protected ListOverMap<DataPolicyMetadata> dataPolicies = new
ListOverMap<DataPolicyMetadata>(new KeyBuilder<DataPolicyMetadata>() {
- private static final long serialVersionUID = 4954591545242715254L;
-
- @Override
- public String getKey(DataPolicyMetadata entry) {
- return entry.getName();
- }
- });
-
+ private LinkedHashMap<String, ModelMetaData> models = new LinkedHashMap<String,
ModelMetaData>();
+ private LinkedHashMap<String, VDBTranslatorMetaData> translators = new
LinkedHashMap<String, VDBTranslatorMetaData>();
+ private LinkedHashMap<String, DataPolicyMetadata> dataPolicies = new
LinkedHashMap<String, DataPolicyMetadata>();
private List<VDBImportMetadata> imports = new
ArrayList<VDBImportMetadata>(2);
-
private int version = 1;
-
- protected String description;
-
+ private String description;
private boolean dynamic = false;
private volatile VDB.Status status = VDB.Status.ACTIVE;
private ConnectionType connectionType = VDB.ConnectionType.BY_VERSION;
@@ -134,44 +104,44 @@
@Override
public List<Model> getModels(){
- return new ArrayList<Model>(this.models.getMap().values());
+ return new ArrayList<Model>(this.models.values());
}
public Map<String, ModelMetaData> getModelMetaDatas() {
- return this.models.getMap();
+ return this.models;
}
/**
* @param models
*/
public void setModels(Collection<ModelMetaData> models) {
- this.models.getMap().clear();
+ this.models.clear();
for (ModelMetaData obj : models) {
addModel(obj);
}
}
public ModelMetaData addModel(ModelMetaData m) {
- return this.models.getMap().put(m.getName(), m);
+ return this.models.put(m.getName(), m);
}
@Override
public List<Translator> getOverrideTranslators() {
- return new ArrayList<Translator>(this.translators.getMap().values());
+ return new ArrayList<Translator>(this.translators.values());
}
public void setOverrideTranslators(List<Translator> translators) {
for (Translator t: translators) {
- this.translators.getMap().put(t.getName(), (VDBTranslatorMetaData)t);
+ this.translators.put(t.getName(), (VDBTranslatorMetaData)t);
}
}
public void addOverideTranslator(VDBTranslatorMetaData t) {
- this.translators.getMap().put(t.getName(), t);
+ this.translators.put(t.getName(), t);
}
public boolean isOverideTranslator(String name) {
- return this.translators.getMap().containsKey(name);
+ return this.translators.containsKey(name);
}
@Override
@@ -186,7 +156,7 @@
@Override
public List<String> getValidityErrors(){
List<String> allErrors = new ArrayList<String>();
- for (ModelMetaData model:this.models.getMap().values()) {
+ for (ModelMetaData model:this.models.values()) {
List<ValidationError> errors = model.getErrors();
if (errors != null && !errors.isEmpty()) {
for (ValidationError m:errors) {
@@ -202,7 +172,7 @@
@Override
public List<String> getRuntimeErrors(){
List<String> allErrors = new ArrayList<String>();
- for (ModelMetaData model:this.models.getMap().values()) {
+ for (ModelMetaData model:this.models.values()) {
List<ValidationError> errors = model.getRuntimeErrors();
if (errors != null && !errors.isEmpty()) {
for (ValidationError m:errors) {
@@ -226,7 +196,7 @@
if (getModels().isEmpty()) {
return false;
}
- for(ModelMetaData m: this.models.getMap().values()) {
+ for(ModelMetaData m: this.models.values()) {
if (m.isSource()) {
List<String> resourceNames = m.getSourceNames();
if (resourceNames.isEmpty()) {
@@ -238,7 +208,7 @@
}
public String toString() {
- return getName()+VERSION_DELIM+getVersion()+ models.getMap().values();
+ return getName()+VERSION_DELIM+getVersion()+ models.values();
}
public boolean isVisible(String modelName) {
@@ -247,12 +217,12 @@
}
public ModelMetaData getModel(String modelName) {
- return this.models.getMap().get(modelName);
+ return this.models.get(modelName);
}
public Set<String> getMultiSourceModelNames(){
Set<String> list = new HashSet<String>();
- for(ModelMetaData m: models.getMap().values()) {
+ for(ModelMetaData m: models.values()) {
if (m.isSupportsMultiSourceBindings()) {
list.add(m.getName());
}
@@ -270,7 +240,7 @@
@Override
public List<DataPolicy> getDataPolicies(){
- return new ArrayList<DataPolicy>(this.dataPolicies.getMap().values());
+ return new ArrayList<DataPolicy>(this.dataPolicies.values());
}
/**
@@ -279,22 +249,22 @@
* @param policies
*/
public void setDataPolicies(List<DataPolicy> policies){
- this.dataPolicies.getMap().clear();
+ this.dataPolicies.clear();
for (DataPolicy policy:policies) {
- this.dataPolicies.getMap().put(policy.getName(), (DataPolicyMetadata)policy);
+ this.dataPolicies.put(policy.getName(), (DataPolicyMetadata)policy);
}
}
public DataPolicyMetadata addDataPolicy(DataPolicyMetadata policy){
- return this.dataPolicies.getMap().put(policy.getName(), policy);
+ return this.dataPolicies.put(policy.getName(), policy);
}
public DataPolicyMetadata getDataPolicy(String policyName) {
- return this.dataPolicies.getMap().get(policyName);
+ return this.dataPolicies.get(policyName);
}
public VDBTranslatorMetaData getTranslator(String name) {
- return this.translators.getMap().get(name);
+ return this.translators.get(name);
}
public boolean isPreview() {
Modified: trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataMapper.java
===================================================================
--- trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataMapper.java 2012-06-15
17:53:09 UTC (rev 4182)
+++ trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataMapper.java 2012-06-18
14:37:59 UTC (rev 4183)
@@ -23,6 +23,7 @@
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;
@@ -68,11 +69,11 @@
node.get(DYNAMIC).set(vdb.isDynamic());
//PROPERTIES
- List<PropertyMetadata> properties = vdb.getJAXBProperties();
+ Properties properties = vdb.getProperties();
if (properties!= null && !properties.isEmpty()) {
- ModelNode propsNode = node.get(PROPERTIES);
- for (PropertyMetadata prop:properties) {
- propsNode.add(PropertyMetaDataMapper.INSTANCE.wrap(prop, new ModelNode()));
+ ModelNode propsNode = node.get(PROPERTIES);
+ for (String key:properties.stringPropertyNames()) {
+ propsNode.add(PropertyMetaDataMapper.INSTANCE.wrap(key, properties.getProperty(key),
new ModelNode()));
}
}
@@ -144,9 +145,9 @@
if (node.get(PROPERTIES).isDefined()) {
List<ModelNode> propNodes = node.get(PROPERTIES).asList();
for (ModelNode propNode:propNodes) {
- PropertyMetadata prop = PropertyMetaDataMapper.INSTANCE.unwrap(propNode);
+ String[] prop = PropertyMetaDataMapper.INSTANCE.unwrap(propNode);
if (prop != null) {
- vdb.addProperty(prop.getName(), prop.getValue());
+ vdb.addProperty(prop[0], prop[1]);
}
}
}
@@ -282,11 +283,11 @@
node.get(MODELPATH).set(model.getPath());
}
- List<PropertyMetadata> properties = model.getJAXBProperties();
+ Properties properties = model.getProperties();
if (properties!= null && !properties.isEmpty()) {
ModelNode propsNode = node.get(PROPERTIES);
- for (PropertyMetadata prop:properties) {
- propsNode.add(PropertyMetaDataMapper.INSTANCE.wrap(prop, new ModelNode()));
+ for (String key:properties.stringPropertyNames()) {
+ propsNode.add(PropertyMetaDataMapper.INSTANCE.wrap(key, properties.getProperty(key),
new ModelNode()));
}
}
@@ -339,9 +340,9 @@
if (node.get(PROPERTIES).isDefined()) {
List<ModelNode> propNodes = node.get(PROPERTIES).asList();
for (ModelNode propNode:propNodes) {
- PropertyMetadata prop = PropertyMetaDataMapper.INSTANCE.unwrap(propNode);
+ String[] prop = PropertyMetaDataMapper.INSTANCE.unwrap(propNode);
if (prop != null) {
- model.addProperty(prop.getName(), prop.getValue());
+ model.addProperty(prop[0], prop[1]);
}
}
}
@@ -582,11 +583,11 @@
node.get(MODULE_NAME).set(translator.getModuleName());
}
- List<PropertyMetadata> properties = translator.getJAXBProperties();
+ Properties properties = translator.getProperties();
if (properties!= null && !properties.isEmpty()) {
ModelNode propsNode = node.get(PROPERTIES);
- for (PropertyMetadata prop:properties) {
- propsNode.add(PropertyMetaDataMapper.INSTANCE.wrap(prop, new ModelNode()));
+ for (String key:properties.stringPropertyNames()) {
+ propsNode.add(PropertyMetaDataMapper.INSTANCE.wrap(key, properties.getProperty(key),
new ModelNode()));
}
}
wrapDomain(translator, node);
@@ -614,9 +615,9 @@
if (node.get(PROPERTIES).isDefined()) {
List<ModelNode> propNodes = node.get(PROPERTIES).asList();
for (ModelNode propNode:propNodes) {
- PropertyMetadata prop = PropertyMetaDataMapper.INSTANCE.unwrap(propNode);
+ String[] prop = PropertyMetaDataMapper.INSTANCE.unwrap(propNode);
if (prop != null) {
- translator.addProperty(prop.getName(), prop.getValue());
+ translator.addProperty(prop[0], prop[1]);
}
}
}
@@ -638,38 +639,35 @@
}
}
+
/**
* Property Metadata mapper
*/
- public static class PropertyMetaDataMapper implements
MetadataMapper<PropertyMetadata>{
+ 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 PropertyMetaDataMapper INSTANCE = new PropertyMetaDataMapper();
- public ModelNode wrap(PropertyMetadata property, ModelNode node) {
- if (property == null) {
- return null;
- }
-
- node.get(PROPERTY_NAME).set(property.getName());
- node.get(PROPERTY_VALUE).set(property.getValue());
-
+ public ModelNode wrap(String key, String value, ModelNode node) {
+ node.get(PROPERTY_NAME).set(key);
+ node.get(PROPERTY_VALUE).set(value);
return node;
}
- public PropertyMetadata unwrap(ModelNode node) {
+ public String[] unwrap(ModelNode node) {
if(node == null) {
return null;
}
- PropertyMetadata property = new PropertyMetadata();
+ String key = null;
+ String value = null;
if (node.has(PROPERTY_NAME)) {
- property.setName(node.get(PROPERTY_NAME).asString());
+ key = node.get(PROPERTY_NAME).asString();
}
if(node.has(PROPERTY_VALUE)) {
- property.setValue(node.get(PROPERTY_VALUE).asString());
+ value = node.get(PROPERTY_VALUE).asString();
}
- return property;
+ return new String[] {key, value};
}
public ModelNode describe(ModelNode node) {
@@ -688,12 +686,6 @@
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$
- private static final String ALLOW_CREATE = "allow-create"; //$NON-NLS-1$
- private static final String ALLOW_READ = "allow-read"; //$NON-NLS-1$
- private static final String ALLOW_UPDATE = "allow-update"; //$NON-NLS-1$
- private static final String ALLOW_DELETE = "allow-delete"; //$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$
private static final String POLICY_DESCRIPTION = "policy-description";
//$NON-NLS-1$
public static DataPolicyMetadataMapper INSTANCE = new DataPolicyMetadataMapper();
Modified: trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBTranslatorMetaData.java
===================================================================
---
trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBTranslatorMetaData.java 2012-06-15
17:53:09 UTC (rev 4182)
+++
trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBTranslatorMetaData.java 2012-06-18
14:37:59 UTC (rev 4183)
@@ -21,8 +21,6 @@
*/
package org.teiid.adminapi.impl;
-import java.util.List;
-
import org.teiid.adminapi.Translator;
@@ -51,11 +49,6 @@
this.type = type;
}
- @Override
- public List<PropertyMetadata> getJAXBProperties(){
- return super.getJAXBProperties();
- }
-
public String toString() {
return getName();
}
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/IntegrationPlugin.java
===================================================================
---
trunk/jboss-integration/src/main/java/org/teiid/jboss/IntegrationPlugin.java 2012-06-15
17:53:09 UTC (rev 4182)
+++
trunk/jboss-integration/src/main/java/org/teiid/jboss/IntegrationPlugin.java 2012-06-18
14:37:59 UTC (rev 4183)
@@ -81,13 +81,10 @@
TEIID50047,
TEIID50048,
TEIID50049,
- TEIID50051,
TEIID50054,
TEIID50055,
TEIID50056,
TEIID50057,
- TEIID50062,
- TEIID50063,
TEIID50064,
TEIID50065,
TEIID50066,
@@ -101,7 +98,6 @@
TEIID50076,
TEIID50077,
TEIID50078,
-
TEIID50086,
TEIID50087,
TEIID50088
Modified:
trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidOperationHandler.java
===================================================================
---
trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidOperationHandler.java 2012-06-15
17:53:09 UTC (rev 4182)
+++
trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidOperationHandler.java 2012-06-18
14:37:59 UTC (rev 4183)
@@ -21,9 +21,16 @@
*/
package org.teiid.jboss;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.*;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ALLOWED;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.DEFAULT;
+import static
org.jboss.as.controller.descriptions.ModelDescriptionConstants.DESCRIPTION;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.READ_ONLY;
+import static
org.jboss.as.controller.descriptions.ModelDescriptionConstants.REPLY_PROPERTIES;
+import static
org.jboss.as.controller.descriptions.ModelDescriptionConstants.REQUEST_PROPERTIES;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.REQUIRED;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.TYPE;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.VALUE_TYPE;
-import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.Blob;
@@ -39,8 +46,6 @@
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
-import javax.xml.stream.XMLStreamException;
-
import org.jboss.as.connector.metadata.xmldescriptors.ConnectorXmlDescriptor;
import org.jboss.as.controller.AbstractWriteAttributeHandler;
import org.jboss.as.controller.OperationContext;
@@ -58,15 +63,24 @@
import org.teiid.adminapi.Admin;
import org.teiid.adminapi.AdminException;
import org.teiid.adminapi.AdminProcessingException;
-import org.teiid.adminapi.impl.*;
+import org.teiid.adminapi.VDB.ConnectionType;
+import org.teiid.adminapi.impl.CacheStatisticsMetadata;
+import org.teiid.adminapi.impl.RequestMetadata;
+import org.teiid.adminapi.impl.SessionMetadata;
+import org.teiid.adminapi.impl.TransactionMetadata;
+import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.adminapi.impl.VDBMetadataMapper;
import org.teiid.adminapi.impl.VDBMetadataMapper.TransactionMetadataMapper;
import org.teiid.adminapi.impl.VDBMetadataMapper.VDBTranslatorMetaDataMapper;
+import org.teiid.adminapi.impl.VDBTranslatorMetaData;
+import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
import org.teiid.client.RequestMessage;
import org.teiid.client.ResultsMessage;
import org.teiid.client.plan.PlanNode;
import org.teiid.client.util.ResultsFuture;
import org.teiid.core.TeiidComponentException;
import org.teiid.deployers.ExtendedPropertyMetadata;
+import org.teiid.deployers.RuntimeVDB;
import org.teiid.deployers.VDBRepository;
import org.teiid.deployers.VDBStatusChecker;
import org.teiid.dqp.internal.datamgr.TranslatorRepository;
@@ -934,15 +948,14 @@
}
}
-abstract class VDBOperations extends BaseOperationHandler<VDBMetaData>{
- private ObjectSerializer serializer;
+abstract class VDBOperations extends BaseOperationHandler<RuntimeVDB>{
public VDBOperations(String operationName) {
super(operationName);
}
@Override
- public VDBMetaData getService(OperationContext context, PathAddress pathAddress,
ModelNode operation) throws OperationFailedException {
+ public RuntimeVDB getService(OperationContext context, PathAddress pathAddress,
ModelNode operation) throws OperationFailedException {
if (!operation.hasDefined(OperationsConstants.VDB_NAME)) {
throw new OperationFailedException(new
ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.VDB_NAME+MISSING)));
}
@@ -954,11 +967,8 @@
String vdbName = operation.get(OperationsConstants.VDB_NAME).asString();
int vdbVersion = operation.get(OperationsConstants.VDB_VERSION).asInt();
- ServiceController<?> osSvc =
context.getServiceRegistry(false).getRequiredService(TeiidServiceNames.OBJECT_SERIALIZER);
- this.serializer = ObjectSerializer.class.cast(osSvc.getValue());
-
ServiceController<?> sc =
context.getServiceRegistry(false).getRequiredService(TeiidServiceNames.vdbServiceName(vdbName,
vdbVersion));
- return VDBMetaData.class.cast(sc.getValue());
+ return RuntimeVDB.class.cast(sc.getValue());
}
protected void describeParameters(ModelNode operationNode, ResourceBundle bundle) {
@@ -970,16 +980,6 @@
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION,
REQUIRED).set(true);
operationNode.get(REQUEST_PROPERTIES, OperationsConstants.VDB_VERSION,
DESCRIPTION).set(getParameterDescription(bundle, OperationsConstants.VDB_VERSION));
}
-
- protected void save(VDBMetaData vdb) throws AdminProcessingException{
- try {
- VDBMetadataParser.marshell(vdb, this.serializer.getVdbXmlOutputStream(vdb));
- } catch (IOException e) {
- throw new AdminProcessingException(IntegrationPlugin.Event.TEIID50048, e);
- } catch (XMLStreamException e) {
- throw new AdminProcessingException(IntegrationPlugin.Event.TEIID50049, e);
- }
- }
}
class AddDataRole extends VDBOperations {
@@ -989,7 +989,7 @@
}
@Override
- protected void executeOperation(OperationContext context, VDBMetaData vdb, ModelNode
operation) throws OperationFailedException {
+ protected void executeOperation(OperationContext context, RuntimeVDB vdb, ModelNode
operation) throws OperationFailedException {
if (!operation.hasDefined(OperationsConstants.DATA_ROLE)) {
throw new OperationFailedException(new
ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.DATA_ROLE+MISSING)));
}
@@ -1002,10 +1002,7 @@
String mappedRole = operation.get(OperationsConstants.MAPPED_ROLE).asString();
try {
- DataPolicyMetadata policy = VDBService.getPolicy(vdb, policyName);
-
- policy.addMappedRoleName(mappedRole);
- save(vdb);
+ vdb.addDataRole(policyName, mappedRole);
} catch (AdminProcessingException e) {
throw new OperationFailedException(new ModelNode().set(e.getMessage()));
}
@@ -1033,7 +1030,7 @@
}
@Override
- protected void executeOperation(OperationContext context, VDBMetaData vdb, ModelNode
operation) throws OperationFailedException {
+ protected void executeOperation(OperationContext context, RuntimeVDB vdb, ModelNode
operation) throws OperationFailedException {
if (!operation.hasDefined(OperationsConstants.DATA_ROLE)) {
throw new OperationFailedException(new
ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.DATA_ROLE+MISSING)));
}
@@ -1046,10 +1043,7 @@
String mappedRole = operation.get(OperationsConstants.MAPPED_ROLE).asString();
try {
- DataPolicyMetadata policy = VDBService.getPolicy(vdb, policyName);
-
- policy.removeMappedRoleName(mappedRole);
- save(vdb);
+ vdb.remoteDataRole(policyName, mappedRole);
} catch (AdminProcessingException e) {
throw new OperationFailedException(new ModelNode().set(e.getMessage()));
}
@@ -1077,18 +1071,14 @@
}
@Override
- protected void executeOperation(OperationContext context, VDBMetaData vdb, ModelNode
operation) throws OperationFailedException {
+ protected void executeOperation(OperationContext context, RuntimeVDB vdb, ModelNode
operation) throws OperationFailedException {
if (!operation.hasDefined(OperationsConstants.DATA_ROLE)) {
throw new OperationFailedException(new
ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.DATA_ROLE+MISSING)));
}
String policyName = operation.get(OperationsConstants.DATA_ROLE).asString();
-
try {
- DataPolicyMetadata policy = VDBService.getPolicy(vdb, policyName);
-
- policy.setAnyAuthenticated(true);
- save(vdb);
+ vdb.addAnyAuthenticated(policyName);
} catch (AdminProcessingException e) {
throw new OperationFailedException(new ModelNode().set(e.getMessage()));
}
@@ -1113,18 +1103,14 @@
}
@Override
- protected void executeOperation(OperationContext context, VDBMetaData vdb, ModelNode
operation) throws OperationFailedException {
+ protected void executeOperation(OperationContext context, RuntimeVDB vdb, ModelNode
operation) throws OperationFailedException {
if (!operation.hasDefined(OperationsConstants.DATA_ROLE)) {
throw new OperationFailedException(new
ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.DATA_ROLE+MISSING)));
}
String policyName = operation.get(OperationsConstants.DATA_ROLE).asString();
-
try {
- DataPolicyMetadata policy = VDBService.getPolicy(vdb, policyName);
-
- policy.setAnyAuthenticated(false);
- save(vdb);
+ vdb.removeAnyAuthenticated(policyName);
} catch (AdminProcessingException e) {
throw new OperationFailedException(new ModelNode().set(e.getMessage()));
}
@@ -1148,15 +1134,14 @@
}
@Override
- protected void executeOperation(OperationContext context, VDBMetaData vdb, ModelNode
operation) throws OperationFailedException {
+ protected void executeOperation(OperationContext context, RuntimeVDB vdb, ModelNode
operation) throws OperationFailedException {
if (!operation.hasDefined(OperationsConstants.CONNECTION_TYPE)) {
throw new OperationFailedException(new
ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.CONNECTION_TYPE+MISSING)));
}
String connectionType = operation.get(OperationsConstants.CONNECTION_TYPE).asString();
try {
- vdb.setConnectionType(connectionType);
- save(vdb);
+ vdb.changeConnectionType(ConnectionType.valueOf(connectionType));
} catch (AdminProcessingException e) {
throw new OperationFailedException(new ModelNode().set(e.getMessage()));
}
@@ -1180,7 +1165,7 @@
}
@Override
- protected void executeOperation(OperationContext context, VDBMetaData vdb, ModelNode
operation) throws OperationFailedException {
+ protected void executeOperation(OperationContext context, RuntimeVDB vdb, ModelNode
operation) throws OperationFailedException {
if (!operation.hasDefined(OperationsConstants.MODEL_NAME)) {
throw new OperationFailedException(new
ModelNode().set(IntegrationPlugin.Util.getString(OperationsConstants.MODEL_NAME+MISSING)));
}
@@ -1204,23 +1189,7 @@
String dsName = operation.get(OperationsConstants.DS_NAME).asString();
try {
- ModelMetaData model = vdb.getModel(modelName);
-
- if (model == null) {
- throw new AdminProcessingException(IntegrationPlugin.Event.TEIID50054,
IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50054, modelName, vdb.getName(),
vdb.getVersion()));
- }
-
- SourceMappingMetadata source = model.getSourceMapping(sourceName);
- if(source == null) {
- throw new AdminProcessingException(IntegrationPlugin.Event.TEIID50055,
IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50055, sourceName, modelName,
vdb.getName(), vdb.getVersion()));
- }
- source.setTranslatorName(translatorName);
- source.setConnectionJndiName(dsName);
- save(vdb);
- ServiceController<?> sc =
context.getServiceRegistry(false).getRequiredService(TeiidServiceNames.VDB_STATUS_CHECKER);
- VDBStatusChecker vsc = VDBStatusChecker.class.cast(sc.getValue());
- // enforce the changes in the engine.
- vsc.dataSourceReplaced(vdb.getName(), vdb.getVersion(), modelName, sourceName,
translatorName, dsName);
+ vdb.assignDatasource(modelName, sourceName, translatorName, dsName);
} catch (AdminProcessingException e) {
throw new OperationFailedException(new ModelNode().set(e.getMessage()));
}
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java 2012-06-15
17:53:09 UTC (rev 4182)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java 2012-06-18
14:37:59 UTC (rev 4183)
@@ -55,6 +55,7 @@
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.adminapi.impl.VDBTranslatorMetaData;
import org.teiid.common.buffer.BufferManager;
+import org.teiid.deployers.RuntimeVDB;
import org.teiid.deployers.UDFMetaData;
import org.teiid.deployers.VDBRepository;
import org.teiid.deployers.VDBStatusChecker;
@@ -160,7 +161,7 @@
// build a VDB service
VDBService vdb = new VDBService(deployment, visibilityMap);
- final ServiceBuilder<VDBMetaData> vdbService =
context.getServiceTarget().addService(TeiidServiceNames.vdbServiceName(deployment.getName(),
deployment.getVersion()), vdb);
+ final ServiceBuilder<RuntimeVDB> vdbService =
context.getServiceTarget().addService(TeiidServiceNames.vdbServiceName(deployment.getName(),
deployment.getVersion()), vdb);
// add dependencies to data-sources
dataSourceDependencies(deployment, new DependentServices() {
@@ -195,6 +196,8 @@
vdbService.addDependency(TeiidServiceNames.executorServiceName(this.asyncThreadPoolName),
Executor.class, vdb.executorInjector);
vdbService.addDependency(TeiidServiceNames.OBJECT_SERIALIZER, ObjectSerializer.class,
vdb.serializerInjector);
vdbService.addDependency(TeiidServiceNames.BUFFER_MGR, BufferManager.class,
vdb.bufferManagerInjector);
+ vdbService.addDependency(TeiidServiceNames.VDB_STATUS_CHECKER, VDBStatusChecker.class,
vdb.vdbStatusCheckInjector);
+
vdbService.addDependency(DependencyType.OPTIONAL, TeiidServiceNames.OBJECT_REPLICATOR,
ObjectReplicator.class, vdb.objectReplicatorInjector);
vdbService.setInitialMode(Mode.PASSIVE).install();
}
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java 2012-06-15
17:53:09 UTC (rev 4182)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java 2012-06-18
14:37:59 UTC (rev 4183)
@@ -49,8 +49,6 @@
import org.teiid.adminapi.Model;
import org.teiid.adminapi.Translator;
import org.teiid.adminapi.VDB;
-import org.teiid.adminapi.VDB.ConnectionType;
-import org.teiid.adminapi.impl.DataPolicyMetadata;
import org.teiid.adminapi.impl.ModelMetaData;
import org.teiid.adminapi.impl.SourceMappingMetadata;
import org.teiid.adminapi.impl.VDBMetaData;
@@ -59,15 +57,17 @@
import org.teiid.common.buffer.BufferManager;
import org.teiid.core.TeiidException;
import org.teiid.deployers.CompositeVDB;
+import org.teiid.deployers.RuntimeVDB;
import org.teiid.deployers.TranslatorUtil;
import org.teiid.deployers.UDFMetaData;
import org.teiid.deployers.VDBLifeCycleListener;
import org.teiid.deployers.VDBRepository;
+import org.teiid.deployers.VDBStatusChecker;
import org.teiid.deployers.VirtualDatabaseException;
import org.teiid.dqp.internal.datamgr.ConnectorManager;
import org.teiid.dqp.internal.datamgr.ConnectorManagerRepository;
-import org.teiid.dqp.internal.datamgr.TranslatorRepository;
import
org.teiid.dqp.internal.datamgr.ConnectorManagerRepository.ConnectorManagerException;
+import org.teiid.dqp.internal.datamgr.TranslatorRepository;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.metadata.Datatype;
@@ -84,14 +84,17 @@
import org.teiid.translator.ExecutionFactory;
import org.teiid.translator.TranslatorException;
-class VDBService implements Service<VDBMetaData> {
+class VDBService implements Service<RuntimeVDB> {
private VDBMetaData vdb;
+ private RuntimeVDB runtimeVDB;
protected final InjectedValue<VDBRepository> vdbRepositoryInjector = new
InjectedValue<VDBRepository>();
protected final InjectedValue<TranslatorRepository> translatorRepositoryInjector =
new InjectedValue<TranslatorRepository>();
protected final InjectedValue<Executor> executorInjector = new
InjectedValue<Executor>();
protected final InjectedValue<ObjectSerializer> serializerInjector = new
InjectedValue<ObjectSerializer>();
protected final InjectedValue<BufferManager> bufferManagerInjector = new
InjectedValue<BufferManager>();
protected final InjectedValue<ObjectReplicator> objectReplicatorInjector = new
InjectedValue<ObjectReplicator>();
+ protected final InjectedValue<VDBStatusChecker> vdbStatusCheckInjector = new
InjectedValue<VDBStatusChecker>();
+
private VDBLifeCycleListener vdbListener;
private LinkedHashMap<String, Resource> visibilityMap;
@@ -101,7 +104,7 @@
}
@Override
- public void start(StartContext context) throws StartException {
+ public void start(final StartContext context) throws StartException {
ConnectorManagerRepository cmr = new ConnectorManagerRepository();
TranslatorRepository repo = new TranslatorRepository();
@@ -189,8 +192,32 @@
LogManager.logTrace(LogConstants.CTX_RUNTIME, "Model ", model.getName(),
"in VDB ", vdb.getName(), " skipped being loaded because of its type
", model.getModelType()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
}
+
+ this.runtimeVDB = buildRuntimeVDB(this.vdb);
}
+ private RuntimeVDB buildRuntimeVDB(VDBMetaData vdbMetadata) {
+ RuntimeVDB.VDBModificationListener modificationListener = new
RuntimeVDB.VDBModificationListener() {
+ @Override
+ public void dataRoleChanged(String policyName) throws AdminProcessingException {
+ save();
+ }
+ @Override
+ public void connectionTypeChanged() throws AdminProcessingException {
+ save();
+ }
+ @Override
+ public void dataSourceChanged(String modelName, String sourceName,String
translatorName, String dsName) throws AdminProcessingException {
+ save();
+ }
+ };
+ return new RuntimeVDB(vdbMetadata, modificationListener) {
+ protected VDBStatusChecker getVDBStatusChecker() {
+ return VDBService.this.vdbStatusCheckInjector.getValue();
+ }
+ };
+ }
+
private ServiceBuilder<Void> addVDBFinishedService(StartContext context) {
ServiceContainer serviceContainer = context.getController().getServiceContainer();
final ServiceController<?> controller =
serviceContainer.getService(TeiidServiceNames.vdbFinishedServiceName(vdb.getName(),
vdb.getVersion()));
@@ -237,8 +264,8 @@
}
@Override
- public VDBMetaData getValue() throws IllegalStateException,IllegalArgumentException {
- return this.vdb;
+ public RuntimeVDB getValue() throws IllegalStateException,IllegalArgumentException {
+ return this.runtimeVDB;
}
private void createConnectorManagers(ConnectorManagerRepository cmr, final
TranslatorRepository repo, final VDBMetaData deployment) throws StartException {
@@ -440,74 +467,14 @@
return bufferManagerInjector.getValue();
}
- public void addDataRole(String policyName, String mappedRole) throws
AdminProcessingException{
- DataPolicyMetadata policy = getPolicy(vdb, policyName);
-
- policy.addMappedRoleName(mappedRole);
- save();
- }
-
- public void remoteDataRole(String policyName, String mappedRole) throws
AdminProcessingException{
- DataPolicyMetadata policy = getPolicy(vdb, policyName);
-
- policy.removeMappedRoleName(mappedRole);
- save();
- }
-
- public void addAnyAuthenticated(String policyName) throws AdminProcessingException{
- DataPolicyMetadata policy = getPolicy(vdb, policyName);
-
- policy.setAnyAuthenticated(true);
- save();
- }
-
- public void removeAnyAuthenticated(String policyName) throws AdminProcessingException{
- DataPolicyMetadata policy = getPolicy(vdb, policyName);
-
- policy.setAnyAuthenticated(false);
- save();
- }
-
- public void changeConnectionType(ConnectionType type) throws AdminProcessingException {
- this.vdb.setConnectionType(type);
- save();
- }
-
- public void assignDatasource(String modelName, String sourceName, String translatorName,
String dsName) throws AdminProcessingException{
- ModelMetaData model = this.vdb.getModel(modelName);
-
- if (model == null) {
- throw new AdminProcessingException(IntegrationPlugin.Event.TEIID50062,
IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50062, modelName,
this.vdb.getName(), this.vdb.getVersion()));
- }
-
- SourceMappingMetadata source = model.getSourceMapping(sourceName);
- if(source == null) {
- throw new AdminProcessingException(IntegrationPlugin.Event.TEIID50063,
IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50063, sourceName, modelName,
this.vdb.getName(), this.vdb.getVersion()));
- }
- source.setTranslatorName(translatorName);
- source.setConnectionJndiName(dsName);
- save();
- }
-
- private void save() throws AdminProcessingException{
+ private void save() throws AdminProcessingException {
try {
ObjectSerializer os = getSerializer();
VDBMetadataParser.marshell(this.vdb, os.getVdbXmlOutputStream(this.vdb));
} catch (IOException e) {
- throw new AdminProcessingException(IntegrationPlugin.Event.TEIID50064, e);
+ throw new AdminProcessingException(IntegrationPlugin.Event.TEIID50064, e);
} catch (XMLStreamException e) {
- throw new AdminProcessingException(IntegrationPlugin.Event.TEIID50065, e);
+ throw new AdminProcessingException(IntegrationPlugin.Event.TEIID50065, e);
}
}
-
- static DataPolicyMetadata getPolicy(VDBMetaData vdb, String policyName)
- throws AdminProcessingException {
- DataPolicyMetadata policy = vdb.getDataPolicy(policyName);
-
- if (policy == null) {
- throw new AdminProcessingException(IntegrationPlugin.Event.TEIID50051,
IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50051, policyName, vdb.getName(),
vdb.getVersion()));
- }
- return policy;
- }
-
}
Modified: trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties
===================================================================
--- trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties 2012-06-15
17:53:09 UTC (rev 4182)
+++ trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties 2012-06-18
14:37:59 UTC (rev 4183)
@@ -28,14 +28,9 @@
TEIID50038=Teiid Embedded transport enabled. Bound to: {0}
TEIID50041=Teiid Embedded transport disabled. Local Connections will fail. UnBound : {0}
TEIID50002=Teiid Engine stopped {0}
-TEIID50062=Model name "{0}" not found in the VDB with name "{1}"
version "{2}"
-TEIID50062=Source name "{0}" not found for model {1} in the VDB with name
"{2}" version "{3}"
-TEIID50063=Source with name {0} not found in the Model {1} in VDB {2}.{3}
-TEIID50062=Model with name {0} not found in the VDB {1}.{2}
event_distributor_bound=org.teiid.events.EventDistributorFactory is bound to {0} for
manual control of Teiid events.
TEIID50019=Re-deploying VDB {0}
TEIID50066=Cache system has been shutdown
-TEIID50051=Policy {0} not found in VDB {1}.{2}
TEIID50054=Model {0} not found in VDB {1}.{2}
TEIID50055=Source name {0} not found in Model {1} in VDB {1}.{2}
Modified: trunk/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java 2012-06-15 17:53:09
UTC (rev 4182)
+++ trunk/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java 2012-06-18 14:37:59
UTC (rev 4183)
@@ -114,7 +114,7 @@
newMergedVDB.setDataPolicies(this.vdb.getDataPolicies());
newMergedVDB.setDescription(this.vdb.getDescription());
newMergedVDB.setStatus(this.vdb.getStatus());
- newMergedVDB.setJAXBProperties(this.vdb.getJAXBProperties());
+ newMergedVDB.setProperties(this.vdb.getProperties());
newMergedVDB.setConnectionType(this.vdb.getConnectionType());
ConnectorManagerRepository mergedRepo = new ConnectorManagerRepository();
mergedRepo.getConnectorManagers().putAll(this.cmr.getConnectorManagers());
Added: trunk/runtime/src/main/java/org/teiid/deployers/RuntimeVDB.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/RuntimeVDB.java
(rev 0)
+++ trunk/runtime/src/main/java/org/teiid/deployers/RuntimeVDB.java 2012-06-18 14:37:59
UTC (rev 4183)
@@ -0,0 +1,159 @@
+/*
+ * 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 java.util.List;
+
+import org.teiid.adminapi.AdminProcessingException;
+import org.teiid.adminapi.VDB.ConnectionType;
+import org.teiid.adminapi.impl.DataPolicyMetadata;
+import org.teiid.adminapi.impl.ModelMetaData;
+import org.teiid.adminapi.impl.SourceMappingMetadata;
+import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.runtime.RuntimePlugin;
+
+public abstract class RuntimeVDB {
+ private VDBMetaData vdb;
+ private VDBModificationListener listener;
+
+ public interface VDBModificationListener {
+ void dataRoleChanged(String policyName) throws AdminProcessingException;
+ void connectionTypeChanged() throws AdminProcessingException;
+ void dataSourceChanged(String modelName, String sourceName, String translatorName,
String dsName) throws AdminProcessingException;
+ }
+
+ public RuntimeVDB(VDBMetaData vdb, VDBModificationListener listener) {
+ this.vdb = vdb;
+ this.listener = listener;
+ }
+
+ public void addDataRole(String policyName, String mappedRole) throws
AdminProcessingException {
+ synchronized (this.vdb) {
+ DataPolicyMetadata policy = getPolicy(policyName);
+ List<String> previous = policy.getMappedRoleNames();
+ policy.addMappedRoleName(mappedRole);
+ try {
+ this.listener.dataRoleChanged(policyName);
+ } catch(AdminProcessingException e) {
+ policy.setMappedRoleNames(previous);
+ throw e;
+ }
+ }
+ }
+
+ public void remoteDataRole(String policyName, String mappedRole) throws
AdminProcessingException{
+ synchronized (this.vdb) {
+ DataPolicyMetadata policy = getPolicy(policyName);
+ List<String> previous = policy.getMappedRoleNames();
+ policy.removeMappedRoleName(mappedRole);
+ try {
+ this.listener.dataRoleChanged(policyName);
+ } catch(AdminProcessingException e) {
+ policy.setMappedRoleNames(previous);
+ throw e;
+ }
+ }
+ }
+
+ public void addAnyAuthenticated(String policyName) throws AdminProcessingException{
+ synchronized (this.vdb) {
+ DataPolicyMetadata policy = getPolicy(policyName);
+ boolean previous = policy.isAnyAuthenticated();
+ policy.setAnyAuthenticated(true);
+ try {
+ this.listener.dataRoleChanged(policyName);
+ } catch(AdminProcessingException e) {
+ policy.setAnyAuthenticated(previous);
+ throw e;
+ }
+ }
+ }
+
+ public void removeAnyAuthenticated(String policyName) throws AdminProcessingException{
+ synchronized (this.vdb) {
+ DataPolicyMetadata policy = getPolicy(policyName);
+ boolean previous = policy.isAnyAuthenticated();
+ policy.setAnyAuthenticated(false);
+ try {
+ this.listener.dataRoleChanged(policyName);
+ } catch(AdminProcessingException e) {
+ policy.setAnyAuthenticated(previous);
+ throw e;
+ }
+ }
+ }
+
+ public void changeConnectionType(ConnectionType type) throws AdminProcessingException {
+ synchronized (this.vdb) {
+ ConnectionType previous = this.vdb.getConnectionType();
+ this.vdb.setConnectionType(type);
+ try {
+ this.listener.connectionTypeChanged();
+ } catch(AdminProcessingException e) {
+ this.vdb.setConnectionType(previous);
+ throw e;
+ }
+ }
+ }
+
+ public void assignDatasource(String modelName, String sourceName, String translatorName,
String dsName) throws AdminProcessingException{
+ synchronized (this.vdb) {
+ ModelMetaData model = this.vdb.getModel(modelName);
+
+ if (model == null) {
+ throw new AdminProcessingException(RuntimePlugin.Event.TEIID40090,
RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40090, modelName, this.vdb.getName(),
this.vdb.getVersion()));
+ }
+
+ SourceMappingMetadata source = model.getSourceMapping(sourceName);
+ if(source == null) {
+ throw new AdminProcessingException(RuntimePlugin.Event.TEIID40091,
RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40091, sourceName, modelName,
this.vdb.getName(), this.vdb.getVersion()));
+ }
+
+ String previousTranslatorName = source.getTranslatorName();
+ String previousDsName = source.getConnectionJndiName();
+
+ source.setTranslatorName(translatorName);
+ source.setConnectionJndiName(dsName);
+
+ try {
+ this.listener.dataSourceChanged(modelName, sourceName, translatorName, dsName);
+ getVDBStatusChecker().dataSourceReplaced(vdb.getName(), vdb.getVersion(), modelName,
sourceName, translatorName, dsName);
+ } catch(AdminProcessingException e) {
+ source.setTranslatorName(previousTranslatorName);
+ source.setConnectionJndiName(previousDsName);
+ throw e;
+ }
+ }
+ }
+
+ private DataPolicyMetadata getPolicy(String policyName)
+ throws AdminProcessingException {
+ DataPolicyMetadata policy = vdb.getDataPolicy(policyName);
+
+ if (policy == null) {
+ throw new AdminProcessingException(RuntimePlugin.Event.TEIID40092,
RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40092, policyName, vdb.getName(),
vdb.getVersion()));
+ }
+ return policy;
+ }
+
+ protected abstract VDBStatusChecker getVDBStatusChecker();
+}
Property changes on: trunk/runtime/src/main/java/org/teiid/deployers/RuntimeVDB.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/runtime/src/main/java/org/teiid/runtime/RuntimePlugin.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/runtime/RuntimePlugin.java 2012-06-15 17:53:09
UTC (rev 4182)
+++ trunk/runtime/src/main/java/org/teiid/runtime/RuntimePlugin.java 2012-06-18 14:37:59
UTC (rev 4183)
@@ -102,5 +102,8 @@
TEIID40087, //pass-through failed
TEIID40088, //event distributor replication failed
TEIID40089, //txn disabled
+ TEIID40090,
+ TEIID40091,
+ TEIID40092
}
}
Modified: trunk/runtime/src/main/resources/org/teiid/runtime/i18n.properties
===================================================================
--- trunk/runtime/src/main/resources/org/teiid/runtime/i18n.properties 2012-06-15 17:53:09
UTC (rev 4182)
+++ trunk/runtime/src/main/resources/org/teiid/runtime/i18n.properties 2012-06-18 14:37:59
UTC (rev 4183)
@@ -91,4 +91,7 @@
TEIID40087=Passthrough authentication failed. No authentication information found.
TEIID40088=Could not replicate object {0}
-TEIID40089=No transaction manager set, transaction support is not enabled.
\ No newline at end of file
+TEIID40089=No transaction manager set, transaction support is not enabled.
+TEIID40090=Model name "{0}" not found in the VDB with name "{1}"
version "{2}"
+TEIID40091=Source name "{0}" not found for model {1} in the VDB with name
"{2}" version "{3}"
+TEIID40092=Policy {0} not found in VDB {1}.{2}