Author: rareddy
Date: 2010-08-03 14:00:54 -0400 (Tue, 03 Aug 2010)
New Revision: 2405
Modified:
trunk/runtime/src/main/java/org/teiid/deployers/BaseMultipleVFSParsingDeployer.java
trunk/runtime/src/main/java/org/teiid/deployers/UDFMetaData.java
trunk/runtime/src/main/java/org/teiid/deployers/VDBParserDeployer.java
trunk/runtime/src/main/java/org/teiid/deployers/VDBStructure.java
Log:
TEIID-1182: Modifying the VDBDeployer to scan all the directories for XMI files that may
be UDF function libraries. Based on the "path" information provided in the
"vdb.xml" that xmi file is loaded into teiid query engine.
Modified:
trunk/runtime/src/main/java/org/teiid/deployers/BaseMultipleVFSParsingDeployer.java
===================================================================
---
trunk/runtime/src/main/java/org/teiid/deployers/BaseMultipleVFSParsingDeployer.java 2010-08-03
17:30:45 UTC (rev 2404)
+++
trunk/runtime/src/main/java/org/teiid/deployers/BaseMultipleVFSParsingDeployer.java 2010-08-03
18:00:54 UTC (rev 2405)
@@ -69,7 +69,15 @@
metadata.put(clazz, instances);
}
Object instance = parse(unit, clazz, file, root);
- instances.add(instance);
+ boolean found = false;
+ for (Object obj:instances) {
+ if (obj == instance) {
+ found = true;
+ }
+ }
+ if (!found) {
+ instances.add(instance);
+ }
}
return mergeMetaData(unit, root, metadata, missingFiles);
}
Modified: trunk/runtime/src/main/java/org/teiid/deployers/UDFMetaData.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/UDFMetaData.java 2010-08-03 17:30:45
UTC (rev 2404)
+++ trunk/runtime/src/main/java/org/teiid/deployers/UDFMetaData.java 2010-08-03 18:00:54
UTC (rev 2405)
@@ -47,7 +47,13 @@
void buildFunctionModelFile(String name) throws IOException, JAXBException {
- VirtualFile file = this.files.get(name);
+ for (String f:files.keySet()) {
+ if (f.endsWith(name)) {
+ name = f;
+ break;
+ }
+ }
+ VirtualFile file =this.files.get(name);
if (file != null) {
this.methods.addAll(FunctionMetadataReader.loadFunctionMethods(file.openStream()));
}
Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBParserDeployer.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBParserDeployer.java 2010-08-03
17:30:45 UTC (rev 2404)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBParserDeployer.java 2010-08-03
18:00:54 UTC (rev 2405)
@@ -90,10 +90,12 @@
root = unit.getAttachment(UDFMetaData.class);
if (root == null) {
root = new UDFMetaData();
+ unit.addAttachment(UDFMetaData.class, UDFMetaData.class.cast(root));
}
}
UDFMetaData udf = UDFMetaData.class.cast(root);
udf.addModelFile(file);
+
return expectedType.cast(udf);
}
else if (expectedType.equals(IndexMetadataFactory.class)) {
@@ -126,6 +128,7 @@
protected VDBMetaData mergeMetaData(VFSDeploymentUnit unit, Map<Class<?>,
List<Object>> metadata) throws Exception {
VDBMetaData vdb = getInstance(metadata, VDBMetaData.class);
UDFMetaData udf = getInstance(metadata, UDFMetaData.class);
+ IndexMetadataFactory imf = getInstance(metadata, IndexMetadataFactory.class);
if (vdb == null) {
LogManager.logError(LogConstants.CTX_RUNTIME,
RuntimePlugin.Util.getString("invlaid_vdb_file",unit.getRoot().getName()));
//$NON-NLS-1$
@@ -135,22 +138,18 @@
vdb.setUrl(unit.getRoot().toURL().toExternalForm());
// build the metadata store
- List<Object> indexFiles = metadata.get(IndexMetadataFactory.class);
- if (indexFiles != null && !indexFiles.isEmpty()) {
- IndexMetadataFactory imf = (IndexMetadataFactory)indexFiles.get(0);
- if (imf != null) {
- imf.addEntriesPlusVisibilities(unit.getRoot(), vdb);
- unit.addAttachment(IndexMetadataFactory.class, imf);
-
- // add the cached store.
- File cacheFile = this.serializer.getAttachmentPath(unit,
vdb.getName()+"_"+vdb.getVersion()); //$NON-NLS-1$
- MetadataStoreGroup stores = this.serializer.loadSafe(cacheFile,
MetadataStoreGroup.class);
- if (stores == null) {
- stores = new MetadataStoreGroup();
- stores.addStore(imf.getMetadataStore(vdbRepository.getSystemStore().getDatatypes()));
- }
- unit.addAttachment(MetadataStoreGroup.class, stores);
+ if (imf != null) {
+ imf.addEntriesPlusVisibilities(unit.getRoot(), vdb);
+ unit.addAttachment(IndexMetadataFactory.class, imf);
+
+ // add the cached store.
+ File cacheFile = this.serializer.getAttachmentPath(unit,
vdb.getName()+"_"+vdb.getVersion()); //$NON-NLS-1$
+ MetadataStoreGroup stores = this.serializer.loadSafe(cacheFile,
MetadataStoreGroup.class);
+ if (stores == null) {
+ stores = new MetadataStoreGroup();
+ stores.addStore(imf.getMetadataStore(vdbRepository.getSystemStore().getDatatypes()));
}
+ unit.addAttachment(MetadataStoreGroup.class, stores);
}
if (udf != null) {
Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBStructure.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBStructure.java 2010-08-03 17:30:45
UTC (rev 2404)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBStructure.java 2010-08-03 18:00:54
UTC (rev 2405)
@@ -22,6 +22,8 @@
package org.teiid.deployers;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
import org.jboss.deployers.spi.DeploymentException;
import org.jboss.deployers.vfs.plugins.structure.AbstractVFSStructureDeployer;
@@ -36,7 +38,7 @@
public VDBStructure(){
setRelativeOrder(1000);
- JarUtils.addJarSuffix(".vdb");
+ JarUtils.addJarSuffix(".vdb"); //$NON-NLS-1$
}
@Override
@@ -44,9 +46,9 @@
VirtualFile file = structureContext.getFile();
try {
if (isLeaf(file) == false) {
- if (file.getName().endsWith(".vdb")) {
+ if (file.getName().endsWith(".vdb")) { //$NON-NLS-1$
- VirtualFile metainf = file.getChild("META-INF");
+ VirtualFile metainf = file.getChild("META-INF"); //$NON-NLS-1$
if (metainf == null) {
return false;
}
@@ -54,12 +56,22 @@
if (metainf.getChild(VdbConstants.DEPLOYMENT_FILE) == null) {
return false;
}
- createContext(structureContext, new String[] {"/", "META-INF",
"runtime-inf"});
+
+ List<String> scanDirs = new ArrayList<String>();
+ scanDirs.add("/"); //$NON-NLS-1$
+
+ List<VirtualFile> children = file.getChildren();
+ for (VirtualFile child:children) {
+ if (!child.isLeaf()) {
+ scanDirs.add(child.getName());
+ }
+ }
+ createContext(structureContext, scanDirs.toArray(new String[scanDirs.size()]));
return true;
}
}
} catch (IOException e) {
- throw DeploymentException.rethrowAsDeploymentException("Error determining
structure: " + file.getName(), e);
+ throw DeploymentException.rethrowAsDeploymentException("Error determining
structure: " + file.getName(), e); //$NON-NLS-1$
}
return false;
}