You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@metamodel.apache.org by ka...@apache.org on 2016/07/11 05:23:12 UTC

[01/16] metamodel git commit: METAMODEL-241: Fixed

Repository: metamodel
Updated Branches:
  refs/heads/feature/5.x/swagger-docs 3ac879eac -> 35c9861eb


METAMODEL-241: Fixed

This fix is implemented by further diving deep into the depths of
OpenJDK. I'm not really fond of going down that route, but it seems to
be the way to go if we really want to keep deserialization support.

Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/cfe3e120
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/cfe3e120
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/cfe3e120

Branch: refs/heads/feature/5.x/swagger-docs
Commit: cfe3e1207ea3a753bde45c1b8108bb05cee8703b
Parents: 2e39b50
Author: kaspersorensen <i....@gmail.com>
Authored: Sun May 15 21:47:27 2016 -0700
Committer: kaspersorensen <i....@gmail.com>
Committed: Sun May 15 21:47:27 2016 -0700

----------------------------------------------------------------------
 CHANGES.md                                      |  1 +
 .../LegacyDeserializationObjectInputStream.java | 26 ++++++++++++++++++++
 2 files changed, 27 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/cfe3e120/CHANGES.md
----------------------------------------------------------------------
diff --git a/CHANGES.md b/CHANGES.md
index 66d1917..d4d0110 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -8,6 +8,7 @@
  * [METAMODEL-159] - DataContextFactory misses methods to create HBase and POJO data contexts.
  * [METAMODEL-252] - Fixed a bug that caused JDBC updates to unnecessarily refresh schema objects.
  * [METAMODEL-1082] - Improved performance of batch ElasticSearch operations by using bulk API.
+ * [METAMODEL-241] - Fixed deserialization of legacy enum types on OpenJDK after rev. 7c1d34773aa6.
 
 ### Apache MetaModel 4.5.2
 

http://git-wip-us.apache.org/repos/asf/metamodel/blob/cfe3e120/core/src/main/java/org/apache/metamodel/util/LegacyDeserializationObjectInputStream.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/util/LegacyDeserializationObjectInputStream.java b/core/src/main/java/org/apache/metamodel/util/LegacyDeserializationObjectInputStream.java
index c4d4570..95fad92 100644
--- a/core/src/main/java/org/apache/metamodel/util/LegacyDeserializationObjectInputStream.java
+++ b/core/src/main/java/org/apache/metamodel/util/LegacyDeserializationObjectInputStream.java
@@ -22,6 +22,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.ObjectInputStream;
 import java.io.ObjectStreamClass;
+import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import java.util.Comparator;
 
@@ -252,6 +253,31 @@ public class LegacyDeserializationObjectInputStream extends ObjectInputStream {
      */
     private boolean isEnumExpected(ObjectStreamClass objectStreamClass) {
         try {
+            final Field initializedField = ObjectStreamClass.class.getDeclaredField("initialized");
+            initializedField.setAccessible(true);
+            final Boolean initialized = (Boolean) initializedField.get(objectStreamClass);
+            if (!initialized) {
+                /*
+                 * Snippet from the JDK source:
+                 * 
+                 * void initNonProxy(ObjectStreamClass model,
+                 * Class<?> cl,
+                 * ClassNotFoundException resolveEx,
+                 * ObjectStreamClass superDesc)
+                 **/
+                final Method initMethod = ObjectStreamClass.class.getDeclaredMethod("initNonProxy", ObjectStreamClass.class,
+                        Class.class, ClassNotFoundException.class, ObjectStreamClass.class);
+                initMethod.setAccessible(true);
+                initMethod.invoke(objectStreamClass, objectStreamClass, null, null, null);
+            }
+        } catch (NoSuchFieldError e) {
+            logger.debug("Failed to access boolean field 'initialized' in {}", objectStreamClass.getName(), e);
+        } catch (Exception e) {
+            logger.debug("Failed to access invoke ObjectStreamClass.initialize() to prepare {}", objectStreamClass
+                    .getName(), e);
+        }
+        
+        try {
             final Method isEnumMethod = ObjectStreamClass.class.getDeclaredMethod("isEnum");
             isEnumMethod.setAccessible(true);
             final Boolean result = (Boolean) isEnumMethod.invoke(objectStreamClass);


[05/16] metamodel git commit: METAMODEL-1088: Fixed #106

Posted by ka...@apache.org.
METAMODEL-1088: Fixed #106


Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/dbc9b54e
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/dbc9b54e
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/dbc9b54e

Branch: refs/heads/feature/5.x/swagger-docs
Commit: dbc9b54e5546646ff7023ad5f8cccceaece54816
Parents: 35928e3
Author: Alberto Rodriguez <ar...@stratio.com>
Authored: Mon May 30 09:37:15 2016 +0200
Committer: Alberto Rodriguez <ar...@stratio.com>
Committed: Mon May 30 09:37:15 2016 +0200

----------------------------------------------------------------------
 CHANGES.md                                      |  5 ++
 .../mongodb/mongo2/MongoDbDataContext.java      | 45 +++++++++++++++---
 .../mongodb/mongo2/MongoDbDataSet.java          |  8 ++++
 .../mongodb/mongo2/MongoDbDataContextTest.java  | 35 ++++++++++++++
 .../mongodb/mongo3/MongoDbDataContext.java      | 48 +++++++++++++++++---
 .../mongodb/mongo3/MongoDbDataSet.java          |  8 ++++
 .../mongodb/mongo3/MongoDbDataContextTest.java  | 34 ++++++++++++++
 7 files changed, 170 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/dbc9b54e/CHANGES.md
----------------------------------------------------------------------
diff --git a/CHANGES.md b/CHANGES.md
index 33f3a04..52f1323 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,3 +1,8 @@
+### Apache MetaModel 4.5.4 (work in progress)
+
+ * [METAMODEL-1088] - Add support for aliases in MongoDB
+
+
 ### Apache MetaModel 4.5.3
 
  * [METAMODEL-235] - Fixed a bug related to handling of null or missing values in ElasticSearch using REST client.

http://git-wip-us.apache.org/repos/asf/metamodel/blob/dbc9b54e/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataContext.java
----------------------------------------------------------------------
diff --git a/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataContext.java b/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataContext.java
index cfeb836..535c8f8 100644
--- a/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataContext.java
+++ b/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataContext.java
@@ -287,7 +287,9 @@ public class MongoDbDataContext extends QueryPostprocessDataContext implements U
                 // "SELECT [columns] FROM [table] WHERE [conditions]"
                 // query.
                 for (SelectItem selectItem : selectItems) {
-                    if (selectItem.getFunction() != null || selectItem.getColumn() == null) {
+                    if (selectItem.getAggregateFunction() != null
+                            || selectItem.getScalarFunction() != null
+                                    || selectItem.getColumn() == null) {
                         allSelectItemsAreColumns = false;
                         break;
                     }
@@ -325,10 +327,29 @@ public class MongoDbDataContext extends QueryPostprocessDataContext implements U
 
                     int firstRow = (query.getFirstRow() == null ? 1 : query.getFirstRow());
                     int maxRows = (query.getMaxRows() == null ? -1 : query.getMaxRows());
+                    boolean thereIsAtLeastOneAlias = false;
 
-                    final DataSet dataSet = materializeMainSchemaTableInternal(table, columns, whereItems, firstRow,
-                            maxRows, false);
-                    return dataSet;
+                    for (SelectItem selectItem : selectItems) {
+                        if (selectItem.getAlias() != null) {
+                            thereIsAtLeastOneAlias = true;
+                            break;
+                        }
+                    }
+
+                    if (thereIsAtLeastOneAlias) {
+                        final SelectItem[] selectItemsAsArray = selectItems.toArray(new SelectItem[selectItems.size()]);
+                        final DataSet dataSet = materializeMainSchemaTableInternal(
+                                table,
+                                selectItemsAsArray,
+                                whereItems,
+                                firstRow,
+                                maxRows, false);
+                        return dataSet;
+                    } else {
+                        final DataSet dataSet = materializeMainSchemaTableInternal(table, columns, whereItems, firstRow,
+                                maxRows, false);
+                        return dataSet;
+                    }
                 }
             }
         }
@@ -339,6 +360,19 @@ public class MongoDbDataContext extends QueryPostprocessDataContext implements U
 
     private DataSet materializeMainSchemaTableInternal(Table table, Column[] columns, List<FilterItem> whereItems,
             int firstRow, int maxRows, boolean queryPostProcessed) {
+        DBCursor cursor = getCursor(table, whereItems, firstRow, maxRows);
+
+        return new MongoDbDataSet(cursor, columns, queryPostProcessed);
+    }
+
+    private DataSet materializeMainSchemaTableInternal(Table table, SelectItem[] selectItems,
+            List<FilterItem> whereItems, int firstRow, int maxRows, boolean queryPostProcessed) {
+        DBCursor cursor = getCursor(table, whereItems, firstRow, maxRows);
+
+        return new MongoDbDataSet(cursor, selectItems, queryPostProcessed);
+    }
+
+    private DBCursor getCursor(Table table, List<FilterItem> whereItems, int firstRow, int maxRows) {
         final DBCollection collection = _mongoDb.getCollection(table.getName());
 
         final DBObject query = createMongoDbQuery(table, whereItems);
@@ -353,8 +387,7 @@ public class MongoDbDataContext extends QueryPostprocessDataContext implements U
             final int skip = firstRow - 1;
             cursor = cursor.skip(skip);
         }
-
-        return new MongoDbDataSet(cursor, columns, queryPostProcessed);
+        return cursor;
     }
 
     protected BasicDBObject createMongoDbQuery(Table table, List<FilterItem> whereItems) {

http://git-wip-us.apache.org/repos/asf/metamodel/blob/dbc9b54e/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataSet.java
----------------------------------------------------------------------
diff --git a/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataSet.java b/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataSet.java
index 8c2a107..ea7cd9e 100644
--- a/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataSet.java
+++ b/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataSet.java
@@ -21,6 +21,7 @@ package org.apache.metamodel.mongodb.mongo2;
 import org.apache.metamodel.data.AbstractDataSet;
 import org.apache.metamodel.data.Row;
 import org.apache.metamodel.mongodb.common.MongoDBUtils;
+import org.apache.metamodel.query.SelectItem;
 import org.apache.metamodel.schema.Column;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -45,6 +46,13 @@ final class MongoDbDataSet extends AbstractDataSet {
         _closed = false;
     }
 
+    public MongoDbDataSet(DBCursor cursor, SelectItem[] selectItems, boolean queryPostProcessed) {
+        super(selectItems);
+        _cursor = cursor;
+        _queryPostProcessed = queryPostProcessed;
+        _closed = false;
+    }
+
     public boolean isQueryPostProcessed() {
         return _queryPostProcessed;
     }

http://git-wip-us.apache.org/repos/asf/metamodel/blob/dbc9b54e/mongodb/mongo2/src/test/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataContextTest.java
----------------------------------------------------------------------
diff --git a/mongodb/mongo2/src/test/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataContextTest.java b/mongodb/mongo2/src/test/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataContextTest.java
index a03585a..da99955 100644
--- a/mongodb/mongo2/src/test/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataContextTest.java
+++ b/mongodb/mongo2/src/test/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataContextTest.java
@@ -632,4 +632,39 @@ public class MongoDbDataContextTest extends MongoDbTestCase {
             ds4.close();
         }
     }
+
+    public void testSelectWithAlias() throws Exception {
+        if (!isConfigured()) {
+            System.err.println(getInvalidConfigurationMessage());
+            return;
+        }
+
+        DBCollection col = db.createCollection(getCollectionName(), new BasicDBObject());
+
+        // delete if already exists
+        {
+            col.drop();
+            col = db.createCollection(getCollectionName(), new BasicDBObject());
+        }
+
+        final BasicDBObject dbRow = new BasicDBObject();
+        dbRow.append("name", new BasicDBObject().append("first", "John").append("last", "Doe"));
+        dbRow.append("gender", "MALE");
+        col.insert(dbRow);
+
+        final MongoDbDataContext dc = new MongoDbDataContext(db, new SimpleTableDef(getCollectionName(), new String[] {
+                "name.first", "name.last", "gender", "addresses", "addresses[0].city", "addresses[0].country",
+                "addresses[5].foobar" }));
+
+        final DataSet ds1 = dc.executeQuery("select gender AS my_gender, name.first AS my_name from my_collection where gender LIKE '%MALE%'");
+        final SelectItem[] selectItems = ds1.getSelectItems();
+        SelectItem firstSelectItem = selectItems[0];
+        SelectItem secondSelectItem = selectItems[1];
+        try {
+            assertNotNull(firstSelectItem.getAlias());
+            assertNotNull(secondSelectItem.getAlias());
+        } finally {
+            ds1.close();
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/metamodel/blob/dbc9b54e/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataContext.java
----------------------------------------------------------------------
diff --git a/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataContext.java b/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataContext.java
index fbc9047..3108964 100644
--- a/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataContext.java
+++ b/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataContext.java
@@ -275,7 +275,9 @@ public class MongoDbDataContext extends QueryPostprocessDataContext implements U
                 // "SELECT [columns] FROM [table] WHERE [conditions]"
                 // query.
                 for (SelectItem selectItem : selectItems) {
-                    if (selectItem.getFunction() != null || selectItem.getColumn() == null) {
+                    if (selectItem.getAggregateFunction() != null
+                            || selectItem.getScalarFunction() != null
+                                    || selectItem.getColumn() == null) {
                         allSelectItemsAreColumns = false;
                         break;
                     }
@@ -314,9 +316,29 @@ public class MongoDbDataContext extends QueryPostprocessDataContext implements U
                     int firstRow = (query.getFirstRow() == null ? 1 : query.getFirstRow());
                     int maxRows = (query.getMaxRows() == null ? -1 : query.getMaxRows());
 
-                    final DataSet dataSet = materializeMainSchemaTableInternal(table, columns, whereItems, firstRow,
-                            maxRows, false);
-                    return dataSet;
+                    boolean thereIsAtLeastOneAlias = false;
+
+                    for (SelectItem selectItem : selectItems) {
+                        if (selectItem.getAlias() != null) {
+                            thereIsAtLeastOneAlias = true;
+                            break;
+                        }
+                    }
+
+                    if (thereIsAtLeastOneAlias) {
+                        final SelectItem[] selectItemsAsArray = selectItems.toArray(new SelectItem[selectItems.size()]);
+                        final DataSet dataSet = materializeMainSchemaTableInternal(
+                                table,
+                                selectItemsAsArray,
+                                whereItems,
+                                firstRow,
+                                maxRows, false);
+                        return dataSet;
+                    } else {
+                        final DataSet dataSet = materializeMainSchemaTableInternal(table, columns, whereItems, firstRow,
+                                maxRows, false);
+                        return dataSet;
+                    }
                 }
             }
         }
@@ -327,6 +349,20 @@ public class MongoDbDataContext extends QueryPostprocessDataContext implements U
 
     private DataSet materializeMainSchemaTableInternal(Table table, Column[] columns, List<FilterItem> whereItems,
             int firstRow, int maxRows, boolean queryPostProcessed) {
+        MongoCursor<Document> cursor = getDocumentMongoCursor(table, whereItems, firstRow, maxRows);
+
+        return new MongoDbDataSet(cursor, columns, queryPostProcessed);
+    }
+
+    private DataSet materializeMainSchemaTableInternal(Table table, SelectItem[] selectItems, List<FilterItem> whereItems,
+            int firstRow, int maxRows, boolean queryPostProcessed) {
+        MongoCursor<Document> cursor = getDocumentMongoCursor(table, whereItems, firstRow, maxRows);
+
+        return new MongoDbDataSet(cursor, selectItems, queryPostProcessed);
+    }
+
+    private MongoCursor<Document> getDocumentMongoCursor(Table table, List<FilterItem> whereItems, int firstRow,
+            int maxRows) {
         final MongoCollection<Document> collection = _mongoDb.getCollection(table.getName());
 
         final Document query = createMongoDbQuery(table, whereItems);
@@ -342,9 +378,7 @@ public class MongoDbDataContext extends QueryPostprocessDataContext implements U
             iterable = iterable.skip(skip);
         }
 
-        MongoCursor<Document> cursor = iterable.iterator();
-
-        return new MongoDbDataSet(cursor, columns, queryPostProcessed);
+        return iterable.iterator();
     }
 
     protected Document createMongoDbQuery(Table table, List<FilterItem> whereItems) {

http://git-wip-us.apache.org/repos/asf/metamodel/blob/dbc9b54e/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataSet.java
----------------------------------------------------------------------
diff --git a/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataSet.java b/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataSet.java
index 7a480d1..19e543f 100644
--- a/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataSet.java
+++ b/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataSet.java
@@ -21,6 +21,7 @@ package org.apache.metamodel.mongodb.mongo3;
 import org.apache.metamodel.data.AbstractDataSet;
 import org.apache.metamodel.data.Row;
 import org.apache.metamodel.mongodb.common.MongoDBUtils;
+import org.apache.metamodel.query.SelectItem;
 import org.apache.metamodel.schema.Column;
 import org.bson.Document;
 import org.slf4j.Logger;
@@ -45,6 +46,13 @@ final class MongoDbDataSet extends AbstractDataSet {
         _closed = false;
     }
 
+    public MongoDbDataSet(MongoCursor<Document> cursor, SelectItem[] selectItems, boolean queryPostProcessed) {
+        super(selectItems);
+        _cursor = cursor;
+        _queryPostProcessed = queryPostProcessed;
+        _closed = false;
+    }
+
     public boolean isQueryPostProcessed() {
         return _queryPostProcessed;
     }

http://git-wip-us.apache.org/repos/asf/metamodel/blob/dbc9b54e/mongodb/mongo3/src/test/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataContextTest.java
----------------------------------------------------------------------
diff --git a/mongodb/mongo3/src/test/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataContextTest.java b/mongodb/mongo3/src/test/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataContextTest.java
index d16e47c..197fae9 100644
--- a/mongodb/mongo3/src/test/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataContextTest.java
+++ b/mongodb/mongo3/src/test/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataContextTest.java
@@ -24,6 +24,8 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBCollection;
 import com.mongodb.WriteConcern;
 
 import org.apache.metamodel.DataContext;
@@ -610,4 +612,36 @@ public class MongoDbDataContextTest extends MongoDbTestCase {
             ds4.close();
         }
     }
+
+    public void testSelectWithAlias() throws Exception {
+        if (!isConfigured()) {
+            System.err.println(getInvalidConfigurationMessage());
+            return;
+        }
+
+        mongoDb.createCollection(getCollectionName());
+        MongoCollection<Document> col = mongoDb.getCollection(getCollectionName());
+
+        final Document dbRow = new Document();
+        dbRow.append("name", new Document().append("first", "John").append("last", "Doe"));
+        dbRow.append("gender", "MALE");
+        col.insertOne(dbRow);
+
+        final MongoDbDataContext dc = new MongoDbDataContext(mongoDb,
+                new SimpleTableDef(getCollectionName(), new String[] {
+                        "name.first", "name.last", "gender", "addresses", "addresses[0].city", "addresses[0].country",
+                        "addresses[5].foobar" }));
+
+        final DataSet ds1 = dc.executeQuery("select gender as my_gender, name.first as my_name from my_collection where gender LIKE '%MALE%'");
+        final SelectItem[] selectItems = ds1.getSelectItems();
+        SelectItem firstSelectItem = selectItems[0];
+        SelectItem secondSelectItem = selectItems[1];
+        try {
+            assertNotNull(firstSelectItem.getAlias());
+            assertNotNull(secondSelectItem.getAlias());
+
+        } finally {
+            ds1.close();
+        }
+    }
 }


[04/16] metamodel git commit: [maven-release-plugin] prepare for next development iteration

Posted by ka...@apache.org.
[maven-release-plugin] prepare for next development iteration


Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/35928e35
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/35928e35
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/35928e35

Branch: refs/heads/feature/5.x/swagger-docs
Commit: 35928e3524ac012897a10b819dd2dfd6ed8e0bdb
Parents: 1a1dc0d
Author: kaspersorensen <i....@gmail.com>
Authored: Mon May 16 11:14:15 2016 -0700
Committer: kaspersorensen <i....@gmail.com>
Committed: Mon May 16 11:14:15 2016 -0700

----------------------------------------------------------------------
 cassandra/pom.xml            | 2 +-
 core/pom.xml                 | 2 +-
 couchdb/pom.xml              | 2 +-
 csv/pom.xml                  | 2 +-
 elasticsearch/common/pom.xml | 2 +-
 elasticsearch/native/pom.xml | 2 +-
 elasticsearch/pom.xml        | 2 +-
 elasticsearch/rest/pom.xml   | 2 +-
 excel/pom.xml                | 2 +-
 fixedwidth/pom.xml           | 2 +-
 full/pom.xml                 | 2 +-
 hadoop/pom.xml               | 2 +-
 hbase/pom.xml                | 2 +-
 jdbc/pom.xml                 | 2 +-
 json/pom.xml                 | 2 +-
 mongodb/common/pom.xml       | 2 +-
 mongodb/mongo2/pom.xml       | 2 +-
 mongodb/mongo3/pom.xml       | 2 +-
 mongodb/pom.xml              | 2 +-
 neo4j/pom.xml                | 2 +-
 openoffice/pom.xml           | 2 +-
 pojo/pom.xml                 | 2 +-
 pom.xml                      | 4 ++--
 salesforce/pom.xml           | 2 +-
 spring/pom.xml               | 2 +-
 sugarcrm/pom.xml             | 2 +-
 xml/pom.xml                  | 2 +-
 27 files changed, 28 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/35928e35/cassandra/pom.xml
----------------------------------------------------------------------
diff --git a/cassandra/pom.xml b/cassandra/pom.xml
index 9fa6e15..8bb99a5 100644
--- a/cassandra/pom.xml
+++ b/cassandra/pom.xml
@@ -13,7 +13,7 @@
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3</version>
+		<version>4.5.4-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-cassandra</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/35928e35/core/pom.xml
----------------------------------------------------------------------
diff --git a/core/pom.xml b/core/pom.xml
index b38f9ef..4f34660 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3</version>
+		<version>4.5.4-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-core</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/35928e35/couchdb/pom.xml
----------------------------------------------------------------------
diff --git a/couchdb/pom.xml b/couchdb/pom.xml
index 50bb56f..3563e1d 100644
--- a/couchdb/pom.xml
+++ b/couchdb/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3</version>
+		<version>4.5.4-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-couchdb</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/35928e35/csv/pom.xml
----------------------------------------------------------------------
diff --git a/csv/pom.xml b/csv/pom.xml
index 23f4b6a..f2c7c43 100644
--- a/csv/pom.xml
+++ b/csv/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3</version>
+		<version>4.5.4-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-csv</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/35928e35/elasticsearch/common/pom.xml
----------------------------------------------------------------------
diff --git a/elasticsearch/common/pom.xml b/elasticsearch/common/pom.xml
index f922dde..a11ff50 100644
--- a/elasticsearch/common/pom.xml
+++ b/elasticsearch/common/pom.xml
@@ -13,7 +13,7 @@
 	<parent>
 		<artifactId>MetaModel-elasticsearch</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3</version>
+		<version>4.5.4-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 

http://git-wip-us.apache.org/repos/asf/metamodel/blob/35928e35/elasticsearch/native/pom.xml
----------------------------------------------------------------------
diff --git a/elasticsearch/native/pom.xml b/elasticsearch/native/pom.xml
index c9d4604..dc3ed9c 100644
--- a/elasticsearch/native/pom.xml
+++ b/elasticsearch/native/pom.xml
@@ -13,7 +13,7 @@
 	<parent>
 		<artifactId>MetaModel-elasticsearch</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3</version>
+		<version>4.5.4-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 

http://git-wip-us.apache.org/repos/asf/metamodel/blob/35928e35/elasticsearch/pom.xml
----------------------------------------------------------------------
diff --git a/elasticsearch/pom.xml b/elasticsearch/pom.xml
index db3366d..31b05a9 100644
--- a/elasticsearch/pom.xml
+++ b/elasticsearch/pom.xml
@@ -13,7 +13,7 @@
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3</version>
+		<version>4.5.4-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-elasticsearch</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/35928e35/elasticsearch/rest/pom.xml
----------------------------------------------------------------------
diff --git a/elasticsearch/rest/pom.xml b/elasticsearch/rest/pom.xml
index 20a2849..0af3ec5 100644
--- a/elasticsearch/rest/pom.xml
+++ b/elasticsearch/rest/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel-elasticsearch</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3</version>
+		<version>4.5.4-SNAPSHOT</version>
 	</parent>
 
 	<modelVersion>4.0.0</modelVersion>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/35928e35/excel/pom.xml
----------------------------------------------------------------------
diff --git a/excel/pom.xml b/excel/pom.xml
index 1e0d396..4d10b16 100644
--- a/excel/pom.xml
+++ b/excel/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3</version>
+		<version>4.5.4-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-excel</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/35928e35/fixedwidth/pom.xml
----------------------------------------------------------------------
diff --git a/fixedwidth/pom.xml b/fixedwidth/pom.xml
index ba6f1b0..7461e86 100644
--- a/fixedwidth/pom.xml
+++ b/fixedwidth/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3</version>
+		<version>4.5.4-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-fixedwidth</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/35928e35/full/pom.xml
----------------------------------------------------------------------
diff --git a/full/pom.xml b/full/pom.xml
index 1fd9162..df1572e 100644
--- a/full/pom.xml
+++ b/full/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3</version>
+		<version>4.5.4-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-full</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/35928e35/hadoop/pom.xml
----------------------------------------------------------------------
diff --git a/hadoop/pom.xml b/hadoop/pom.xml
index c488daa..618bf47 100644
--- a/hadoop/pom.xml
+++ b/hadoop/pom.xml
@@ -13,7 +13,7 @@
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3</version>
+		<version>4.5.4-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-hadoop</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/35928e35/hbase/pom.xml
----------------------------------------------------------------------
diff --git a/hbase/pom.xml b/hbase/pom.xml
index b7c190b..fa74f1b 100644
--- a/hbase/pom.xml
+++ b/hbase/pom.xml
@@ -13,7 +13,7 @@
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3</version>
+		<version>4.5.4-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-hbase</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/35928e35/jdbc/pom.xml
----------------------------------------------------------------------
diff --git a/jdbc/pom.xml b/jdbc/pom.xml
index 94707f7..7f7579f 100644
--- a/jdbc/pom.xml
+++ b/jdbc/pom.xml
@@ -13,7 +13,7 @@
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3</version>
+		<version>4.5.4-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-jdbc</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/35928e35/json/pom.xml
----------------------------------------------------------------------
diff --git a/json/pom.xml b/json/pom.xml
index aec9e02..44bd2a0 100644
--- a/json/pom.xml
+++ b/json/pom.xml
@@ -13,7 +13,7 @@
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3</version>
+		<version>4.5.4-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-json</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/35928e35/mongodb/common/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/common/pom.xml b/mongodb/common/pom.xml
index 234b2d7..19fbb1a 100644
--- a/mongodb/common/pom.xml
+++ b/mongodb/common/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel-mongodb</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3</version>
+		<version>4.5.4-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-mongodb-common</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/35928e35/mongodb/mongo2/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/mongo2/pom.xml b/mongodb/mongo2/pom.xml
index 1a169ea..4bab569 100644
--- a/mongodb/mongo2/pom.xml
+++ b/mongodb/mongo2/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel-mongodb</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3</version>
+		<version>4.5.4-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-mongodb-mongo2</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/35928e35/mongodb/mongo3/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/mongo3/pom.xml b/mongodb/mongo3/pom.xml
index 059770f..da46b43 100644
--- a/mongodb/mongo3/pom.xml
+++ b/mongodb/mongo3/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel-mongodb</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3</version>
+		<version>4.5.4-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-mongodb-mongo3</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/35928e35/mongodb/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/pom.xml b/mongodb/pom.xml
index fbad461..59a61a5 100644
--- a/mongodb/pom.xml
+++ b/mongodb/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3</version>
+		<version>4.5.4-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-mongodb</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/35928e35/neo4j/pom.xml
----------------------------------------------------------------------
diff --git a/neo4j/pom.xml b/neo4j/pom.xml
index 91a5a1f..15852d1 100644
--- a/neo4j/pom.xml
+++ b/neo4j/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3</version>
+		<version>4.5.4-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-neo4j</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/35928e35/openoffice/pom.xml
----------------------------------------------------------------------
diff --git a/openoffice/pom.xml b/openoffice/pom.xml
index 7d86149..e311520 100644
--- a/openoffice/pom.xml
+++ b/openoffice/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3</version>
+		<version>4.5.4-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-openoffice</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/35928e35/pojo/pom.xml
----------------------------------------------------------------------
diff --git a/pojo/pom.xml b/pojo/pom.xml
index 59697d5..d3fcc93 100644
--- a/pojo/pom.xml
+++ b/pojo/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3</version>
+		<version>4.5.4-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-pojo</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/35928e35/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 0a43f3d..dad89f2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -42,11 +42,11 @@ under the License.
 		<url>https://git-wip-us.apache.org/repos/asf?p=metamodel.git</url>
 		<connection>scm:git:http://git-wip-us.apache.org/repos/asf/metamodel.git</connection>
 		<developerConnection>scm:git:https://git-wip-us.apache.org/repos/asf/metamodel.git</developerConnection>
-		<tag>MetaModel-4.5.3</tag>
+		<tag>HEAD</tag>
 	</scm>
 	<groupId>org.apache.metamodel</groupId>
 	<artifactId>MetaModel</artifactId>
-	<version>4.5.3</version>
+	<version>4.5.4-SNAPSHOT</version>
 	<name>MetaModel</name>
 	<description>MetaModel is a library that encapsulates the differences and enhances 
 		the capabilities of different datastores. Rich querying abilities are

http://git-wip-us.apache.org/repos/asf/metamodel/blob/35928e35/salesforce/pom.xml
----------------------------------------------------------------------
diff --git a/salesforce/pom.xml b/salesforce/pom.xml
index 700d015..a43577b 100644
--- a/salesforce/pom.xml
+++ b/salesforce/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3</version>
+		<version>4.5.4-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-salesforce</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/35928e35/spring/pom.xml
----------------------------------------------------------------------
diff --git a/spring/pom.xml b/spring/pom.xml
index d9615e6..aef691d 100644
--- a/spring/pom.xml
+++ b/spring/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3</version>
+		<version>4.5.4-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-spring</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/35928e35/sugarcrm/pom.xml
----------------------------------------------------------------------
diff --git a/sugarcrm/pom.xml b/sugarcrm/pom.xml
index d9d508f..a13c33e 100644
--- a/sugarcrm/pom.xml
+++ b/sugarcrm/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3</version>
+		<version>4.5.4-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-sugarcrm</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/35928e35/xml/pom.xml
----------------------------------------------------------------------
diff --git a/xml/pom.xml b/xml/pom.xml
index ba5dc11..70a2223 100644
--- a/xml/pom.xml
+++ b/xml/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3</version>
+		<version>4.5.4-SNAPSHOT</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-xml</artifactId>


[10/16] metamodel git commit: Fixes #105

Posted by ka...@apache.org.
Fixes #105


Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/b4bfc5cf
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/b4bfc5cf
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/b4bfc5cf

Branch: refs/heads/feature/5.x/swagger-docs
Commit: b4bfc5cf418eb1441bd1c76fc4798230cc9af333
Parents: d79c0ce
Author: Kasper S�rensen <i....@gmail.com>
Authored: Sat Jun 25 10:39:14 2016 -0700
Committer: Kasper S�rensen <i....@gmail.com>
Committed: Sat Jun 25 10:39:14 2016 -0700

----------------------------------------------------------------------
 .../metamodel/fixedwidth/FixedWidthReader.java  | 20 ++++---
 .../fixedwidth/FixedWidthReaderTest.java        | 57 ++++++++++++++++++++
 .../apache/metamodel/DataContextFactory.java    | 15 ++++++
 3 files changed, 86 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/b4bfc5cf/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthReader.java
----------------------------------------------------------------------
diff --git a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthReader.java b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthReader.java
index d740cff..40dc145 100644
--- a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthReader.java
+++ b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthReader.java
@@ -30,7 +30,7 @@ import java.util.List;
 /**
  * Reader capable of separating values based on a fixed width setting.
  */
-final class FixedWidthReader implements Closeable {
+final public class FixedWidthReader implements Closeable {
 
 	private final BufferedReader _reader;
 	private final int _fixedValueWidth;
@@ -82,6 +82,7 @@ final class FixedWidthReader implements Closeable {
 		this.expectedLineLength = expectedLineLength;
 	}
 
+	
 	/***
 	 * Reads the next line in the file.
 	 * 
@@ -92,10 +93,20 @@ final class FixedWidthReader implements Closeable {
 	 *             if an exception occurs while reading the file.
 	 */
 	public String[] readLine() throws IllegalStateException {
+        String line;
+        try {
+            line = _reader.readLine();
+            return readLine(line);
+        } catch (IOException e) {
+            throw new IllegalStateException(e);
+        }
+	}
+	
+	public String[] readLine(String line) throws IOException {
+
 
-		try {
 			final List<String> values = new ArrayList<String>();
-			final String line = _reader.readLine();
+		
 			if (line == null) {
 				return null;
 			}
@@ -173,9 +184,6 @@ final class FixedWidthReader implements Closeable {
 			}
 
 			return result;
-		} catch (IOException e) {
-			throw new IllegalStateException(e);
-		}
 	}
 
 	@Override

http://git-wip-us.apache.org/repos/asf/metamodel/blob/b4bfc5cf/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthReaderTest.java
----------------------------------------------------------------------
diff --git a/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthReaderTest.java b/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthReaderTest.java
new file mode 100644
index 0000000..dd45900
--- /dev/null
+++ b/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthReaderTest.java
@@ -0,0 +1,57 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.metamodel.fixedwidth;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.Arrays;
+
+import org.junit.Test;
+
+public class FixedWidthReaderTest {
+
+    @Test
+    public void testBufferedReader() throws IOException {
+        final File file = new File("src/test/resources/example_simple1.txt");
+        final BufferedReader reader = new BufferedReader(new FileReader(file));
+        int[] widths = new int[] { 8, 9 };
+        try (final FixedWidthReader fixedWidthReader = new FixedWidthReader(reader, widths, false)) {
+            final String[] line1 = fixedWidthReader.readLine();
+            assertEquals("[greeting, greeter]", Arrays.asList(line1).toString());
+            final String[] line2 = fixedWidthReader.readLine();
+            assertEquals("[hello, world]", Arrays.asList(line2).toString());
+            final String[] line3 = fixedWidthReader.readLine();
+            assertEquals("[hi, there]", Arrays.asList(line3).toString());
+        }
+    }
+
+    @Test
+    public void testNoBufferReader() throws IOException {
+        int[] widths = new int[] { 8, 9 };
+        final String lineToBeRead = "greeting  greeter  ";
+        @SuppressWarnings("resource")
+        final FixedWidthReader fixedWidthReader = new FixedWidthReader(null, widths, false);
+        final String[] line = fixedWidthReader.readLine(lineToBeRead);
+        assertEquals("[greeting, greeter]", Arrays.asList(line).toString());
+    }
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/b4bfc5cf/full/src/main/java/org/apache/metamodel/DataContextFactory.java
----------------------------------------------------------------------
diff --git a/full/src/main/java/org/apache/metamodel/DataContextFactory.java b/full/src/main/java/org/apache/metamodel/DataContextFactory.java
index 0bf3618..b4bf3f6 100644
--- a/full/src/main/java/org/apache/metamodel/DataContextFactory.java
+++ b/full/src/main/java/org/apache/metamodel/DataContextFactory.java
@@ -50,6 +50,7 @@ import org.apache.metamodel.salesforce.SalesforceDataContext;
 import org.apache.metamodel.schema.TableType;
 import org.apache.metamodel.sugarcrm.SugarCrmDataContext;
 import org.apache.metamodel.util.FileHelper;
+import org.apache.metamodel.util.Resource;
 import org.apache.metamodel.util.SimpleTableDef;
 import org.apache.metamodel.xml.XmlDomDataContext;
 import org.ektorp.http.StdHttpClient.Builder;
@@ -291,6 +292,20 @@ public class DataContextFactory {
         FixedWidthDataContext dc = new FixedWidthDataContext(file, configuration);
         return dc;
     }
+    /**
+    * Creates a DataContext based on a fixed width file.
+    * 
+    * @param file
+    *            the file to read from.
+    * @param configuration
+    *            the fixed width configuration to use
+    * @return a DataContext object that matches the request
+    */
+   public static DataContext createFixedWidthDataContext(Resource resource, FixedWidthConfiguration configuration) {
+       final FixedWidthDataContext dc = new FixedWidthDataContext(resource, configuration);
+       return dc;
+   }
+
 
     /**
      * Creates a DataContext based on a fixed width file.


[06/16] metamodel git commit: METAMODEL-1086: Fixed

Posted by ka...@apache.org.
METAMODEL-1086: Fixed

Fixes #104

Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/f1fc2bf4
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/f1fc2bf4
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/f1fc2bf4

Branch: refs/heads/feature/5.x/swagger-docs
Commit: f1fc2bf4da40775ffa11416c665460d59b0180fb
Parents: dbc9b54
Author: Kasper S�rensen <i....@gmail.com>
Authored: Wed Jun 8 21:20:40 2016 -0700
Committer: Kasper S�rensen <i....@gmail.com>
Committed: Wed Jun 8 21:20:40 2016 -0700

----------------------------------------------------------------------
 CHANGES.md                                                     | 4 ++--
 csv/src/main/java/org/apache/metamodel/csv/CsvDataContext.java | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/f1fc2bf4/CHANGES.md
----------------------------------------------------------------------
diff --git a/CHANGES.md b/CHANGES.md
index 52f1323..92e13e4 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,7 +1,7 @@
 ### Apache MetaModel 4.5.4 (work in progress)
 
- * [METAMODEL-1088] - Add support for aliases in MongoDB
-
+ * [METAMODEL-1088] - Add support for aliases in MongoDB.
+ * [METAMODEL-1086] - Fixed encoding issue when CsvDataContext is instantiated with InputStream.
 
 ### Apache MetaModel 4.5.3
 

http://git-wip-us.apache.org/repos/asf/metamodel/blob/f1fc2bf4/csv/src/main/java/org/apache/metamodel/csv/CsvDataContext.java
----------------------------------------------------------------------
diff --git a/csv/src/main/java/org/apache/metamodel/csv/CsvDataContext.java b/csv/src/main/java/org/apache/metamodel/csv/CsvDataContext.java
index 3787453..ee456f0 100644
--- a/csv/src/main/java/org/apache/metamodel/csv/CsvDataContext.java
+++ b/csv/src/main/java/org/apache/metamodel/csv/CsvDataContext.java
@@ -244,7 +244,7 @@ public final class CsvDataContext extends QueryPostprocessDataContext implements
         file = fileCandidate;
 
         final BufferedWriter writer = FileHelper.getBufferedWriter(file, encoding);
-        final BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
+        final BufferedReader reader = FileHelper.getBufferedReader(inputStream, encoding);
 
         try {
             file.createNewFile();


[13/16] metamodel git commit: Merge branch '5.x' into feature/5.x/rest-api

Posted by ka...@apache.org.
Merge branch '5.x' into feature/5.x/rest-api

Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/ba9b4cc4
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/ba9b4cc4
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/ba9b4cc4

Branch: refs/heads/feature/5.x/swagger-docs
Commit: ba9b4cc4f4453ff0ceb020453b84cbab45ed05ad
Parents: 79af7dd 02397db
Author: Kasper S�rensen <i....@gmail.com>
Authored: Sun Jul 10 21:29:02 2016 -0700
Committer: Kasper S�rensen <i....@gmail.com>
Committed: Sun Jul 10 21:29:02 2016 -0700

----------------------------------------------------------------------
 CHANGES.md                                      |  11 +-
 cassandra/pom.xml                               |  12 +-
 .../metamodel/cassandra/CassandraUtils.java     |   2 +-
 .../apache/metamodel/ConnectionException.java   |  44 +++
 .../factory/ClasspathResourceFactory.java       |  36 +++
 .../metamodel/factory/DataContextFactory.java   |  30 ++
 .../factory/DataContextFactoryRegistry.java     |  41 +++
 .../factory/DataContextFactoryRegistryImpl.java |  84 +++++
 .../factory/DataContextProperties.java          |  92 ++++++
 .../factory/DataContextPropertiesImpl.java      | 304 +++++++++++++++++++
 .../metamodel/factory/FileResourceFactory.java  |  38 +++
 .../factory/InMemoryResourceFactory.java        |  36 +++
 .../metamodel/factory/ResourceFactory.java      |  28 ++
 .../factory/ResourceFactoryRegistry.java        |  34 +++
 .../factory/ResourceFactoryRegistryImpl.java    |  80 +++++
 .../metamodel/factory/ResourceProperties.java   |  46 +++
 .../factory/ResourcePropertiesImpl.java         |  74 +++++
 .../factory/SimpleResourceProperties.java       |  60 ++++
 ...supportedDataContextPropertiesException.java |  47 +++
 .../UnsupportedResourcePropertiesException.java |  43 +++
 .../metamodel/factory/UrlResourceFactory.java   |  48 +++
 .../LegacyDeserializationObjectInputStream.java |  26 ++
 .../apache/metamodel/util/ResourceUtils.java    |  45 +++
 ...org.apache.metamodel.factory.ResourceFactory |   4 +
 .../ResourceFactoryRegistryImplTest.java        |  72 +++++
 .../apache/metamodel/util/UrlResourceTest.java  |   8 +-
 .../apache/metamodel/csv/CsvDataContext.java    |   2 +-
 .../metamodel/csv/CsvDataContextFactory.java    |  73 +++++
 ....apache.metamodel.factory.DataContextFactory |   1 +
 .../csv/CsvDataContextFactoryTest.java          |  57 ++++
 fixedwidth/pom.xml                              |  46 +--
 .../metamodel/fixedwidth/FixedWidthReader.java  |  20 +-
 .../fixedwidth/FixedWidthReaderTest.java        |  57 ++++
 .../apache/metamodel/DataContextFactory.java    |  15 +
 .../metamodel/hadoop/HdfsResourceFactory.java   |  46 +++
 ...org.apache.metamodel.factory.ResourceFactory |   1 +
 jdbc/pom.xml                                    |   2 +-
 .../jdbc/JdbcCompiledQueryLeaseFactory.java     |   5 +-
 .../apache/metamodel/jdbc/JdbcDataContext.java  |  40 +--
 .../metamodel/jdbc/JdbcDataContextFactory.java  |  86 ++++++
 .../org/apache/metamodel/jdbc/JdbcDataSet.java  |   6 +-
 .../metamodel/jdbc/JdbcMetadataLoader.java      | 100 +++---
 .../metamodel/jdbc/JdbcUpdateCallback.java      |   2 +-
 ....apache.metamodel.factory.DataContextFactory |   1 +
 .../apache/metamodel/jdbc/H2databaseTest.java   |  11 +-
 .../jdbc/JdbcDataContextFactoryTest.java        |  45 +++
 .../jdbc/integrationtests/MysqlTest.java        |  61 +++-
 .../mongodb/mongo2/MongoDbDataContext.java      |  41 ++-
 .../mongodb/mongo2/MongoDbDataSet.java          |   8 +
 .../mongodb/mongo2/MongoDbDataContextTest.java  |  35 +++
 .../mongodb/mongo3/MongoDbDataContext.java      |  44 ++-
 .../mongodb/mongo3/MongoDbDataSet.java          |   8 +
 .../mongodb/mongo3/MongoDbDataContextTest.java  |  34 +++
 pom.xml                                         |   1 +
 54 files changed, 2036 insertions(+), 157 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/ba9b4cc4/pom.xml
----------------------------------------------------------------------


[07/16] metamodel git commit: METAMODEL-1094: Fixed

Posted by ka...@apache.org.
METAMODEL-1094: Fixed

Fixes #108

Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/2486a569
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/2486a569
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/2486a569

Branch: refs/heads/feature/5.x/swagger-docs
Commit: 2486a56998550b5a74d265efef7dbebec68a22a0
Parents: f1fc2bf
Author: Kasper S�rensen <i....@gmail.com>
Authored: Wed Jun 8 21:27:05 2016 -0700
Committer: Kasper S�rensen <i....@gmail.com>
Committed: Wed Jun 8 21:27:05 2016 -0700

----------------------------------------------------------------------
 CHANGES.md                                              |  1 +
 cassandra/pom.xml                                       | 12 ++++++++++--
 .../org/apache/metamodel/cassandra/CassandraUtils.java  |  2 +-
 3 files changed, 12 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/2486a569/CHANGES.md
----------------------------------------------------------------------
diff --git a/CHANGES.md b/CHANGES.md
index 92e13e4..c10eb35 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -2,6 +2,7 @@
 
  * [METAMODEL-1088] - Add support for aliases in MongoDB.
  * [METAMODEL-1086] - Fixed encoding issue when CsvDataContext is instantiated with InputStream.
+ * [METAMODEL-1094]�- Added support for Apache Cassandra version 3.x.
 
 ### Apache MetaModel 4.5.3
 

http://git-wip-us.apache.org/repos/asf/metamodel/blob/2486a569/cassandra/pom.xml
----------------------------------------------------------------------
diff --git a/cassandra/pom.xml b/cassandra/pom.xml
index 8bb99a5..7a84f6e 100644
--- a/cassandra/pom.xml
+++ b/cassandra/pom.xml
@@ -20,7 +20,8 @@
 	<name>MetaModel module for Apache Cassandra database</name>
 
 	<properties>
-		<cassandra.driver.latest.version>2.1.1</cassandra.driver.latest.version>
+		<cassandra.driver.latest.version>3.0.2</cassandra.driver.latest.version>
+		<cassandraunit.latest.version>2.2.2.1</cassandraunit.latest.version>
 	</properties>
 
 	<dependencies>
@@ -34,6 +35,13 @@
 			<groupId>com.datastax.cassandra</groupId>
 			<artifactId>cassandra-driver-core</artifactId>
 			<version>${cassandra.driver.latest.version}</version>
+			<!-- Excluded netty dependency -->
+			<exclusions>
+				<exclusion>
+					<groupId>io.netty</groupId>
+					<artifactId>netty-handler</artifactId>
+				</exclusion>
+			</exclusions>
 		</dependency>
 		<dependency>
 			<groupId>commons-io</groupId>
@@ -53,7 +61,7 @@
 		<dependency>
 			<groupId>org.cassandraunit</groupId>
 			<artifactId>cassandra-unit</artifactId>
-			<version>2.1.3.1</version>
+			<version>${cassandraunit.latest.version}</version>
 			<scope>test</scope>
 			<exclusions>
 				<exclusion>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/2486a569/cassandra/src/main/java/org/apache/metamodel/cassandra/CassandraUtils.java
----------------------------------------------------------------------
diff --git a/cassandra/src/main/java/org/apache/metamodel/cassandra/CassandraUtils.java b/cassandra/src/main/java/org/apache/metamodel/cassandra/CassandraUtils.java
index 0805dfe..b8f7327 100644
--- a/cassandra/src/main/java/org/apache/metamodel/cassandra/CassandraUtils.java
+++ b/cassandra/src/main/java/org/apache/metamodel/cassandra/CassandraUtils.java
@@ -84,7 +84,7 @@ public class CassandraUtils {
         case TEXT:
             return row.getString(columnName);
         case TIMESTAMP:
-            return row.getDate(columnName);
+            return row.getTimestamp(columnName);
         case UUID:
             return row.getUUID(columnName);
         case VARCHAR:


[12/16] metamodel git commit: Merge branch 'master' into 5.x

Posted by ka...@apache.org.
Merge branch 'master' into 5.x

Conflicts:
	CHANGES.md
	cassandra/pom.xml
	core/pom.xml
	couchdb/pom.xml
	csv/pom.xml
	elasticsearch/common/pom.xml
	elasticsearch/native/pom.xml
	elasticsearch/pom.xml
	elasticsearch/rest/pom.xml
	excel/pom.xml
	fixedwidth/pom.xml
	full/pom.xml
	hadoop/pom.xml
	hbase/pom.xml
	jdbc/pom.xml
	json/pom.xml
	mongodb/common/pom.xml
	mongodb/mongo2/pom.xml
	mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataContext.java
	mongodb/mongo3/pom.xml
	mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataContext.java
	mongodb/pom.xml
	neo4j/pom.xml
	openoffice/pom.xml
	pojo/pom.xml
	pom.xml
	salesforce/pom.xml
	spring/pom.xml
	sugarcrm/pom.xml
	xml/pom.xml


Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/02397db0
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/02397db0
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/02397db0

Branch: refs/heads/feature/5.x/swagger-docs
Commit: 02397db0a15ef50ae3135143b4f60be75921fbd9
Parents: dd0cff7 52c3daf
Author: Kasper S�rensen <i....@gmail.com>
Authored: Sun Jul 10 21:27:21 2016 -0700
Committer: Kasper S�rensen <i....@gmail.com>
Committed: Sun Jul 10 21:27:21 2016 -0700

----------------------------------------------------------------------
 CHANGES.md                                      |  11 +-
 cassandra/pom.xml                               |  12 +-
 .../metamodel/cassandra/CassandraUtils.java     |   2 +-
 .../apache/metamodel/ConnectionException.java   |  44 +++
 .../factory/ClasspathResourceFactory.java       |  36 +++
 .../metamodel/factory/DataContextFactory.java   |  30 ++
 .../factory/DataContextFactoryRegistry.java     |  41 +++
 .../factory/DataContextFactoryRegistryImpl.java |  84 +++++
 .../factory/DataContextProperties.java          |  92 ++++++
 .../factory/DataContextPropertiesImpl.java      | 304 +++++++++++++++++++
 .../metamodel/factory/FileResourceFactory.java  |  38 +++
 .../factory/InMemoryResourceFactory.java        |  36 +++
 .../metamodel/factory/ResourceFactory.java      |  28 ++
 .../factory/ResourceFactoryRegistry.java        |  34 +++
 .../factory/ResourceFactoryRegistryImpl.java    |  80 +++++
 .../metamodel/factory/ResourceProperties.java   |  46 +++
 .../factory/ResourcePropertiesImpl.java         |  74 +++++
 .../factory/SimpleResourceProperties.java       |  60 ++++
 ...supportedDataContextPropertiesException.java |  47 +++
 .../UnsupportedResourcePropertiesException.java |  43 +++
 .../metamodel/factory/UrlResourceFactory.java   |  48 +++
 .../LegacyDeserializationObjectInputStream.java |  26 ++
 .../apache/metamodel/util/ResourceUtils.java    |  45 +++
 ...org.apache.metamodel.factory.ResourceFactory |   4 +
 .../ResourceFactoryRegistryImplTest.java        |  72 +++++
 .../apache/metamodel/util/UrlResourceTest.java  |   8 +-
 .../apache/metamodel/csv/CsvDataContext.java    |   2 +-
 .../metamodel/csv/CsvDataContextFactory.java    |  73 +++++
 ....apache.metamodel.factory.DataContextFactory |   1 +
 .../csv/CsvDataContextFactoryTest.java          |  57 ++++
 fixedwidth/pom.xml                              |  46 +--
 .../metamodel/fixedwidth/FixedWidthReader.java  |  20 +-
 .../fixedwidth/FixedWidthReaderTest.java        |  57 ++++
 .../apache/metamodel/DataContextFactory.java    |  15 +
 .../metamodel/hadoop/HdfsResourceFactory.java   |  46 +++
 ...org.apache.metamodel.factory.ResourceFactory |   1 +
 jdbc/pom.xml                                    |   2 +-
 .../jdbc/JdbcCompiledQueryLeaseFactory.java     |   5 +-
 .../apache/metamodel/jdbc/JdbcDataContext.java  |  40 +--
 .../metamodel/jdbc/JdbcDataContextFactory.java  |  86 ++++++
 .../org/apache/metamodel/jdbc/JdbcDataSet.java  |   6 +-
 .../metamodel/jdbc/JdbcMetadataLoader.java      | 100 +++---
 .../metamodel/jdbc/JdbcUpdateCallback.java      |   2 +-
 ....apache.metamodel.factory.DataContextFactory |   1 +
 .../apache/metamodel/jdbc/H2databaseTest.java   |  11 +-
 .../jdbc/JdbcDataContextFactoryTest.java        |  45 +++
 .../jdbc/integrationtests/MysqlTest.java        |  61 +++-
 .../mongodb/mongo2/MongoDbDataContext.java      |  41 ++-
 .../mongodb/mongo2/MongoDbDataSet.java          |   8 +
 .../mongodb/mongo2/MongoDbDataContextTest.java  |  35 +++
 .../mongodb/mongo3/MongoDbDataContext.java      |  44 ++-
 .../mongodb/mongo3/MongoDbDataSet.java          |   8 +
 .../mongodb/mongo3/MongoDbDataContextTest.java  |  34 +++
 pom.xml                                         |   1 +
 54 files changed, 2036 insertions(+), 157 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/02397db0/CHANGES.md
----------------------------------------------------------------------
diff --cc CHANGES.md
index 8e47adf,3ff4ca0..bb64682
--- a/CHANGES.md
+++ b/CHANGES.md
@@@ -1,10 -1,12 +1,18 @@@
 +### Apache MetaModel 5.0
 +
 + * [METAMODEL-6] - Added update summary containing information about changes on returning UpdateableDataContext.executeUpdate(..)
 + * [METAMODEL-222] - Added support for Java 8 lambdas, removed support for Java 7.
 + * [METAMODEL-1087] - Removed deprecated APIs from MetaModel's codebase.
 +
- ### Apache MetaModel 4.5.3 (work in progress)
+ ### Apache MetaModel 4.5.4 (work in progress)
+ 
+  * [METAMODEL-1099] - Created a new DataContextFactory SPI and a extensible registry of implementations based on ServiceLoader.
+  * [METAMODEL-1088] - Add support for aliases in MongoDB.
+  * [METAMODEL-1086] - Fixed encoding issue when CsvDataContext is instantiated with InputStream.
+  * [METAMODEL-1094]�- Added support for Apache Cassandra version 3.x.
+  * [METAMODEL-1093] - Close compiled ResultSets.
+ 
+ ### Apache MetaModel 4.5.3
  
   * [METAMODEL-235] - Fixed a bug related to handling of null or missing values in ElasticSearch using REST client.
   * [METAMODEL-225] - Fixed support for nested objects and arrays in ElasticSearch using REST client.

http://git-wip-us.apache.org/repos/asf/metamodel/blob/02397db0/cassandra/pom.xml
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/metamodel/blob/02397db0/csv/src/main/java/org/apache/metamodel/csv/CsvDataContext.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/metamodel/blob/02397db0/fixedwidth/pom.xml
----------------------------------------------------------------------
diff --cc fixedwidth/pom.xml
index 7cae86b,7461e86..24e2451
--- a/fixedwidth/pom.xml
+++ b/fixedwidth/pom.xml
@@@ -1,52 -1,52 +1,52 @@@
 -<?xml version="1.0" encoding="UTF-8" ?>
 -<!--
 -Licensed to the Apache Software Foundation (ASF) under one
 -or more contributor license agreements.  See the NOTICE file
 -distributed with this work for additional information
 -regarding copyright ownership.  The ASF licenses this file
 -to you under the Apache License, Version 2.0 (the
 -"License"); you may not use this file except in compliance
 -with the License.  You may obtain a copy of the License at
 -
 -  http://www.apache.org/licenses/LICENSE-2.0
 -
 -Unless required by applicable law or agreed to in writing,
 -software distributed under the License is distributed on an
 -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 -KIND, either express or implied.  See the License for the
 -specific language governing permissions and limitations
 -under the License.
 --->
 -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 -	<parent>
 -		<artifactId>MetaModel</artifactId>
 -		<groupId>org.apache.metamodel</groupId>
 -		<version>4.5.4-SNAPSHOT</version>
 -	</parent>
 -	<modelVersion>4.0.0</modelVersion>
 -	<artifactId>MetaModel-fixedwidth</artifactId>
 -	<name>MetaModel module for fixed width value files</name>
 -	<dependencies>
 +<?xml version="1.0" encoding="UTF-8" ?>
 +<!--
 +Licensed to the Apache Software Foundation (ASF) under one
 +or more contributor license agreements.  See the NOTICE file
 +distributed with this work for additional information
 +regarding copyright ownership.  The ASF licenses this file
 +to you under the Apache License, Version 2.0 (the
 +"License"); you may not use this file except in compliance
 +with the License.  You may obtain a copy of the License at
 +
 +  http://www.apache.org/licenses/LICENSE-2.0
 +
 +Unless required by applicable law or agreed to in writing,
 +software distributed under the License is distributed on an
 +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 +KIND, either express or implied.  See the License for the
 +specific language governing permissions and limitations
 +under the License.
 +-->
 +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 +	<parent>
 +		<artifactId>MetaModel</artifactId>
 +		<groupId>org.apache.metamodel</groupId>
 +		<version>5.0-SNAPSHOT</version>
 +	</parent>
 +	<modelVersion>4.0.0</modelVersion>
 +	<artifactId>MetaModel-fixedwidth</artifactId>
 +	<name>MetaModel module for fixed width value files</name>
 +	<dependencies>
- 		<dependency>
- 			<groupId>org.apache.metamodel</groupId>
- 			<artifactId>MetaModel-core</artifactId>
- 			<version>${project.version}</version>
- 		</dependency>
- 	  <dependency>
-       <groupId>org.apache.metamodel</groupId>
-       <artifactId>MetaModel-csv</artifactId>
-       <version>${project.version}</version>
-       <optional>true</optional>
-     </dependency>
- 		<dependency>
- 			<groupId>org.slf4j</groupId>
- 			<artifactId>slf4j-nop</artifactId>
- 			<scope>test</scope>
- 		</dependency>
- 		<dependency>
- 			<groupId>junit</groupId>
- 			<artifactId>junit</artifactId>
- 			<scope>test</scope>
- 		</dependency>
- 	</dependencies>
- </project>
+ 		<dependency>
+ 			<groupId>org.apache.metamodel</groupId>
+ 			<artifactId>MetaModel-core</artifactId>
+ 			<version>${project.version}</version>
+ 		</dependency>
+ 		<dependency>
+ 			<groupId>org.apache.metamodel</groupId>
+ 			<artifactId>MetaModel-csv</artifactId>
+ 			<version>${project.version}</version>
+ 			<optional>true</optional>
+ 		</dependency>
+ 		<dependency>
+ 			<groupId>org.slf4j</groupId>
+ 			<artifactId>slf4j-nop</artifactId>
+ 			<scope>test</scope>
+ 		</dependency>
+ 		<dependency>
+ 			<groupId>junit</groupId>
+ 			<artifactId>junit</artifactId>
+ 			<scope>test</scope>
+ 		</dependency>
+ 	</dependencies>
+ </project>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/02397db0/jdbc/pom.xml
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/metamodel/blob/02397db0/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcDataContext.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/metamodel/blob/02397db0/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcUpdateCallback.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/metamodel/blob/02397db0/mongodb/mongo2/src/main/java/org/apache/metamodel/mongodb/mongo2/MongoDbDataContext.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/metamodel/blob/02397db0/mongodb/mongo3/src/main/java/org/apache/metamodel/mongodb/mongo3/MongoDbDataContext.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/metamodel/blob/02397db0/pom.xml
----------------------------------------------------------------------


[15/16] metamodel git commit: Merge branch 'feature/5.x/rest-api' into feature/5.x/swagger-docs

Posted by ka...@apache.org.
Merge branch 'feature/5.x/rest-api' into feature/5.x/swagger-docs

Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/2c1f8689
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/2c1f8689
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/2c1f8689

Branch: refs/heads/feature/5.x/swagger-docs
Commit: 2c1f86897f46868d7b5b8818baf614e0edf1498a
Parents: 3ac879e 11d9a9e
Author: Kasper S�rensen <i....@gmail.com>
Authored: Sun Jul 10 22:11:53 2016 -0700
Committer: Kasper S�rensen <i....@gmail.com>
Committed: Sun Jul 10 22:11:53 2016 -0700

----------------------------------------------------------------------
 CHANGES.md                                      |  11 +-
 cassandra/pom.xml                               |  12 +-
 .../metamodel/cassandra/CassandraUtils.java     |   2 +-
 .../apache/metamodel/ConnectionException.java   |  44 +++
 .../factory/ClasspathResourceFactory.java       |  36 +++
 .../metamodel/factory/DataContextFactory.java   |  30 ++
 .../factory/DataContextFactoryRegistry.java     |  41 +++
 .../factory/DataContextFactoryRegistryImpl.java |  84 +++++
 .../factory/DataContextProperties.java          |  92 ++++++
 .../factory/DataContextPropertiesImpl.java      | 307 +++++++++++++++++++
 .../metamodel/factory/FileResourceFactory.java  |  38 +++
 .../factory/InMemoryResourceFactory.java        |  36 +++
 .../metamodel/factory/ResourceFactory.java      |  28 ++
 .../factory/ResourceFactoryRegistry.java        |  34 ++
 .../factory/ResourceFactoryRegistryImpl.java    |  80 +++++
 .../metamodel/factory/ResourceProperties.java   |  46 +++
 .../factory/ResourcePropertiesImpl.java         |  74 +++++
 .../factory/SimpleResourceProperties.java       |  60 ++++
 ...supportedDataContextPropertiesException.java |  47 +++
 .../UnsupportedResourcePropertiesException.java |  43 +++
 .../metamodel/factory/UrlResourceFactory.java   |  48 +++
 .../LegacyDeserializationObjectInputStream.java |  26 ++
 .../apache/metamodel/util/ResourceUtils.java    |  45 +++
 ...org.apache.metamodel.factory.ResourceFactory |   4 +
 .../ResourceFactoryRegistryImplTest.java        |  72 +++++
 .../apache/metamodel/util/UrlResourceTest.java  |   8 +-
 .../apache/metamodel/csv/CsvDataContext.java    |   2 +-
 .../metamodel/csv/CsvDataContextFactory.java    |  73 +++++
 ....apache.metamodel.factory.DataContextFactory |   1 +
 .../csv/CsvDataContextFactoryTest.java          |  57 ++++
 fixedwidth/pom.xml                              |  46 +--
 .../metamodel/fixedwidth/FixedWidthReader.java  |  20 +-
 .../fixedwidth/FixedWidthReaderTest.java        |  57 ++++
 .../apache/metamodel/DataContextFactory.java    |  15 +
 .../metamodel/hadoop/HdfsResourceFactory.java   |  46 +++
 ...org.apache.metamodel.factory.ResourceFactory |   1 +
 jdbc/pom.xml                                    |   2 +-
 .../jdbc/JdbcCompiledQueryLeaseFactory.java     |   5 +-
 .../apache/metamodel/jdbc/JdbcDataContext.java  |  40 ++-
 .../metamodel/jdbc/JdbcDataContextFactory.java  |  86 ++++++
 .../org/apache/metamodel/jdbc/JdbcDataSet.java  |   6 +-
 .../metamodel/jdbc/JdbcMetadataLoader.java      | 100 ++----
 .../metamodel/jdbc/JdbcUpdateCallback.java      |   2 +-
 ....apache.metamodel.factory.DataContextFactory |   1 +
 .../apache/metamodel/jdbc/H2databaseTest.java   |  11 +-
 .../jdbc/JdbcDataContextFactoryTest.java        |  45 +++
 .../jdbc/integrationtests/MysqlTest.java        |  61 +++-
 .../mongodb/mongo2/MongoDbDataContext.java      |  41 ++-
 .../mongodb/mongo2/MongoDbDataSet.java          |   8 +
 .../mongodb/mongo2/MongoDbDataContextTest.java  |  35 +++
 .../mongodb/mongo3/MongoDbDataContext.java      |  44 ++-
 .../mongodb/mongo3/MongoDbDataSet.java          |   8 +
 .../mongodb/mongo3/MongoDbDataContextTest.java  |  34 ++
 .../apache/metamodel/pojo/PojoDataContext.java  |   4 +-
 .../metamodel/pojo/PojoDataContextFactory.java  |  71 +++++
 ....apache.metamodel.factory.DataContextFactory |   1 +
 pom.xml                                         |   1 +
 .../app/CachedDataSourceRegistryWrapper.java    | 109 +++++++
 .../service/app/DataContextSupplier.java        |  59 +---
 .../service/app/DataSourceDefinition.java       |   8 +-
 .../service/app/DataSourceRegistry.java         |   3 +-
 .../service/app/InMemoryDataSourceRegistry.java |   5 +-
 .../service/app/InMemoryTenantContext.java      |   2 +-
 .../controllers/DataSourceController.java       |  17 +-
 .../model/RestDataSourceDefinition.java         |  27 +-
 .../TenantInteractionScenarioTest.java          |   2 +-
 66 files changed, 2273 insertions(+), 231 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/2c1f8689/service-webapp/src/main/java/org/apache/metamodel/service/controllers/DataSourceController.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/metamodel/blob/2c1f8689/service-webapp/src/test/java/org/apache/metamodel/service/controllers/TenantInteractionScenarioTest.java
----------------------------------------------------------------------


[16/16] metamodel git commit: Updated swagger file with info about PUT datasource endpoint

Posted by ka...@apache.org.
Updated swagger file with info about PUT datasource endpoint

Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/35c9861e
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/35c9861e
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/35c9861e

Branch: refs/heads/feature/5.x/swagger-docs
Commit: 35c9861eb042f69435b6478ac53b0d0452b9e727
Parents: 2c1f868
Author: Kasper S�rensen <i....@gmail.com>
Authored: Sun Jul 10 22:23:01 2016 -0700
Committer: Kasper S�rensen <i....@gmail.com>
Committed: Sun Jul 10 22:23:01 2016 -0700

----------------------------------------------------------------------
 service-webapp/swagger.yaml | 11 +++++++++++
 1 file changed, 11 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/35c9861e/service-webapp/swagger.yaml
----------------------------------------------------------------------
diff --git a/service-webapp/swagger.yaml b/service-webapp/swagger.yaml
index c52cc2b..2db13b2 100644
--- a/service-webapp/swagger.yaml
+++ b/service-webapp/swagger.yaml
@@ -180,6 +180,17 @@ paths:
           description: Datasource not found
           schema:
             $ref: "#/definitions/error"
+    put:
+      parameters:
+        - name: inputData
+          in: body
+          description: The definition of the datasource using properties. The same properties as normally applied in MetaModel factories (e.g. 'type', 'resource', 'url', 'driver-class' ,'hostname', 'port', 'catalog', 'database', 'username', 'port', 'table-defs') are used here.
+          required: true
+          schema:
+            type: object
+      responses:
+        200:
+          description: Datasource created
   /{tenant}/{datasource}/q:
     parameters:
       - name: tenant


[02/16] metamodel git commit: Wrapped up the 4.5.3 section in CHANGES.md

Posted by ka...@apache.org.
Wrapped up the 4.5.3 section in CHANGES.md

Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/d16d4f1c
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/d16d4f1c
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/d16d4f1c

Branch: refs/heads/feature/5.x/swagger-docs
Commit: d16d4f1cf366da3c97c3394cf140a328b3205055
Parents: cfe3e12
Author: kaspersorensen <i....@gmail.com>
Authored: Mon May 16 11:09:40 2016 -0700
Committer: kaspersorensen <i....@gmail.com>
Committed: Mon May 16 11:09:40 2016 -0700

----------------------------------------------------------------------
 CHANGES.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/d16d4f1c/CHANGES.md
----------------------------------------------------------------------
diff --git a/CHANGES.md b/CHANGES.md
index d4d0110..33f3a04 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,4 +1,4 @@
-### Apache MetaModel 4.5.3 (work in progress)
+### Apache MetaModel 4.5.3
 
  * [METAMODEL-235] - Fixed a bug related to handling of null or missing values in ElasticSearch using REST client.
  * [METAMODEL-225] - Fixed support for nested objects and arrays in ElasticSearch using REST client.


[14/16] metamodel git commit: Made the new REST API use the METAMODEL-1099 based factories

Posted by ka...@apache.org.
Made the new REST API use the METAMODEL-1099 based factories

Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/11d9a9e8
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/11d9a9e8
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/11d9a9e8

Branch: refs/heads/feature/5.x/swagger-docs
Commit: 11d9a9e8ac10f0f1d5da08a091d3b03a4f0a3256
Parents: ba9b4cc
Author: Kasper S�rensen <i....@gmail.com>
Authored: Sun Jul 10 22:11:22 2016 -0700
Committer: Kasper S�rensen <i....@gmail.com>
Committed: Sun Jul 10 22:11:22 2016 -0700

----------------------------------------------------------------------
 .../factory/DataContextPropertiesImpl.java      |   3 +
 .../apache/metamodel/pojo/PojoDataContext.java  |   4 +-
 .../metamodel/pojo/PojoDataContextFactory.java  |  71 ++++++++++++
 ....apache.metamodel.factory.DataContextFactory |   1 +
 .../app/CachedDataSourceRegistryWrapper.java    | 109 +++++++++++++++++++
 .../service/app/DataContextSupplier.java        |  59 ++--------
 .../service/app/DataSourceDefinition.java       |   8 +-
 .../service/app/DataSourceRegistry.java         |   3 +-
 .../service/app/InMemoryDataSourceRegistry.java |   5 +-
 .../service/app/InMemoryTenantContext.java      |   2 +-
 .../controllers/DataSourceController.java       |  17 ++-
 .../model/RestDataSourceDefinition.java         |  27 +++--
 .../TenantInteractionScenarioTest.java          |   2 +-
 13 files changed, 237 insertions(+), 74 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/11d9a9e8/core/src/main/java/org/apache/metamodel/factory/DataContextPropertiesImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/factory/DataContextPropertiesImpl.java b/core/src/main/java/org/apache/metamodel/factory/DataContextPropertiesImpl.java
index e66a811..13ce9c1 100644
--- a/core/src/main/java/org/apache/metamodel/factory/DataContextPropertiesImpl.java
+++ b/core/src/main/java/org/apache/metamodel/factory/DataContextPropertiesImpl.java
@@ -288,6 +288,9 @@ public class DataContextPropertiesImpl implements DataContextProperties {
     @Override
     public SimpleTableDef[] getTableDefs() {
         final Object obj = get(PROPERTY_TABLE_DEFS);
+        if (obj == null) {
+            return null;
+        }
         if (obj instanceof SimpleTableDef[]) {
             return (SimpleTableDef[]) obj;
         }

http://git-wip-us.apache.org/repos/asf/metamodel/blob/11d9a9e8/pojo/src/main/java/org/apache/metamodel/pojo/PojoDataContext.java
----------------------------------------------------------------------
diff --git a/pojo/src/main/java/org/apache/metamodel/pojo/PojoDataContext.java b/pojo/src/main/java/org/apache/metamodel/pojo/PojoDataContext.java
index 9369e96..340228f 100644
--- a/pojo/src/main/java/org/apache/metamodel/pojo/PojoDataContext.java
+++ b/pojo/src/main/java/org/apache/metamodel/pojo/PojoDataContext.java
@@ -49,6 +49,8 @@ import org.apache.metamodel.util.SimpleTableDef;
 public class PojoDataContext extends QueryPostprocessDataContext implements UpdateableDataContext, Serializable {
 
     private static final long serialVersionUID = 1L;
+    
+    public static final String DEFAULT_SCHEMA_NAME = "Schema";
 
     private final Map<String, TableDataProvider<?>> _tables;
     private final String _schemaName;
@@ -68,7 +70,7 @@ public class PojoDataContext extends QueryPostprocessDataContext implements Upda
      * @param tables
      */
     public PojoDataContext(List<TableDataProvider<?>> tables) {
-        this("Schema", tables);
+        this(DEFAULT_SCHEMA_NAME, tables);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/metamodel/blob/11d9a9e8/pojo/src/main/java/org/apache/metamodel/pojo/PojoDataContextFactory.java
----------------------------------------------------------------------
diff --git a/pojo/src/main/java/org/apache/metamodel/pojo/PojoDataContextFactory.java b/pojo/src/main/java/org/apache/metamodel/pojo/PojoDataContextFactory.java
new file mode 100644
index 0000000..35842bf
--- /dev/null
+++ b/pojo/src/main/java/org/apache/metamodel/pojo/PojoDataContextFactory.java
@@ -0,0 +1,71 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.metamodel.pojo;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.metamodel.ConnectionException;
+import org.apache.metamodel.DataContext;
+import org.apache.metamodel.factory.DataContextFactory;
+import org.apache.metamodel.factory.DataContextProperties;
+import org.apache.metamodel.factory.ResourceFactoryRegistry;
+import org.apache.metamodel.factory.UnsupportedDataContextPropertiesException;
+import org.apache.metamodel.util.SimpleTableDef;
+
+public class PojoDataContextFactory implements DataContextFactory {
+
+    public static final String PROPERTY_TYPE = "pojo";
+
+    @Override
+    public boolean accepts(DataContextProperties properties, ResourceFactoryRegistry resourceFactoryRegistry) {
+        return PROPERTY_TYPE.equals(properties.getDataContextType());
+    }
+
+    @Override
+    public DataContext create(DataContextProperties properties, ResourceFactoryRegistry resourceFactoryRegistry)
+            throws UnsupportedDataContextPropertiesException, ConnectionException {
+
+        assert accepts(properties, resourceFactoryRegistry);
+
+        final String schemaName;
+        if (properties.getDatabaseName() != null) {
+            schemaName = properties.getDatabaseName();
+        } else {
+            schemaName = "Schema";
+        }
+
+        final List<TableDataProvider<?>> tableDataProviders;
+
+        final SimpleTableDef[] tableDefs = properties.getTableDefs();
+        if (tableDefs == null) {
+            tableDataProviders = new ArrayList<>();
+        } else {
+            tableDataProviders = new ArrayList<>(tableDefs.length);
+            for (int i = 0; i < tableDefs.length; i++) {
+                final TableDataProvider<?> tableDataProvider = new ArrayTableDataProvider(tableDefs[i],
+                        new ArrayList<Object[]>());
+                tableDataProviders.add(tableDataProvider);
+            }
+        }
+
+        return new PojoDataContext(schemaName, tableDataProviders);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/11d9a9e8/pojo/src/main/resources/META-INF/services/org.apache.metamodel.factory.DataContextFactory
----------------------------------------------------------------------
diff --git a/pojo/src/main/resources/META-INF/services/org.apache.metamodel.factory.DataContextFactory b/pojo/src/main/resources/META-INF/services/org.apache.metamodel.factory.DataContextFactory
new file mode 100644
index 0000000..76f808d
--- /dev/null
+++ b/pojo/src/main/resources/META-INF/services/org.apache.metamodel.factory.DataContextFactory
@@ -0,0 +1 @@
+org.apache.metamodel.pojo.PojoDataContextFactory
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/metamodel/blob/11d9a9e8/service-webapp/src/main/java/org/apache/metamodel/service/app/CachedDataSourceRegistryWrapper.java
----------------------------------------------------------------------
diff --git a/service-webapp/src/main/java/org/apache/metamodel/service/app/CachedDataSourceRegistryWrapper.java b/service-webapp/src/main/java/org/apache/metamodel/service/app/CachedDataSourceRegistryWrapper.java
new file mode 100644
index 0000000..fffe83d
--- /dev/null
+++ b/service-webapp/src/main/java/org/apache/metamodel/service/app/CachedDataSourceRegistryWrapper.java
@@ -0,0 +1,109 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.metamodel.service.app;
+
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.metamodel.DataContext;
+import org.apache.metamodel.MetaModelException;
+import org.apache.metamodel.factory.DataContextProperties;
+import org.apache.metamodel.service.app.exceptions.DataSourceAlreadyExistException;
+import org.apache.metamodel.service.app.exceptions.NoSuchDataSourceException;
+import org.apache.metamodel.util.FileHelper;
+
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
+import com.google.common.cache.RemovalListener;
+import com.google.common.cache.RemovalNotification;
+
+/**
+ * A wrapper that adds a cache around a {@link DataSourceRegistry} in order to
+ * prevent re-connecting all the time to the same data source.
+ */
+public class CachedDataSourceRegistryWrapper implements DataSourceRegistry {
+
+    /**
+     * The default timeout (in seconds) before the cache evicts and closes the
+     * created {@link DataContext}s.
+     */
+    public static final int DEFAULT_TIMEOUT_SECONDS = 60;
+
+    private final DataSourceRegistry delegate;
+    private final LoadingCache<String, DataContext> loadingCache;
+
+    public CachedDataSourceRegistryWrapper(DataSourceRegistry delegate) {
+        this(delegate, DEFAULT_TIMEOUT_SECONDS, TimeUnit.SECONDS);
+    }
+
+    public CachedDataSourceRegistryWrapper(DataSourceRegistry delegate, long cacheTimeout, TimeUnit cacheTimeoutUnit) {
+        this.delegate = delegate;
+        this.loadingCache = CacheBuilder.newBuilder().expireAfterAccess(cacheTimeout, cacheTimeoutUnit).removalListener(
+                createRemovalListener()).build(createCacheLoader());
+    }
+
+    private RemovalListener<String, DataContext> createRemovalListener() {
+        return new RemovalListener<String, DataContext>() {
+            @Override
+            public void onRemoval(RemovalNotification<String, DataContext> notification) {
+                final DataContext dataContext = notification.getValue();
+                // some DataContexts are closeable - attempt closing it here
+                FileHelper.safeClose(dataContext);
+            }
+        };
+    }
+
+    private CacheLoader<String, DataContext> createCacheLoader() {
+        return new CacheLoader<String, DataContext>() {
+            @Override
+            public DataContext load(String key) throws Exception {
+                return delegate.openDataContext(key);
+            }
+        };
+    }
+
+    @Override
+    public List<String> getDataSourceNames() {
+        return delegate.getDataSourceNames();
+    }
+
+    @Override
+    public String registerDataSource(String dataContextName, DataContextProperties dataContextProperties)
+            throws DataSourceAlreadyExistException {
+        loadingCache.invalidate(dataContextName);
+        return delegate.registerDataSource(dataContextName, dataContextProperties);
+    }
+
+    @Override
+    public DataContext openDataContext(String dataSourceName) throws NoSuchDataSourceException {
+        try {
+            return loadingCache.get(dataSourceName);
+        } catch (ExecutionException e) {
+            final Throwable cause = e.getCause();
+            if (cause instanceof RuntimeException) {
+                throw (RuntimeException) cause;
+            }
+            throw new MetaModelException("Unexpected error happened while getting DataContext '" + dataSourceName
+                    + "' from cache", e);
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/11d9a9e8/service-webapp/src/main/java/org/apache/metamodel/service/app/DataContextSupplier.java
----------------------------------------------------------------------
diff --git a/service-webapp/src/main/java/org/apache/metamodel/service/app/DataContextSupplier.java b/service-webapp/src/main/java/org/apache/metamodel/service/app/DataContextSupplier.java
index a0fb6ec..2f42c6f 100644
--- a/service-webapp/src/main/java/org/apache/metamodel/service/app/DataContextSupplier.java
+++ b/service-webapp/src/main/java/org/apache/metamodel/service/app/DataContextSupplier.java
@@ -18,68 +18,31 @@
  */
 package org.apache.metamodel.service.app;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
 import java.util.function.Supplier;
-import java.util.stream.Collectors;
 
 import org.apache.metamodel.DataContext;
-import org.apache.metamodel.pojo.ArrayTableDataProvider;
-import org.apache.metamodel.pojo.PojoDataContext;
-import org.apache.metamodel.pojo.TableDataProvider;
-import org.apache.metamodel.util.SimpleTableDef;
-import org.apache.metamodel.util.SimpleTableDefParser;
+import org.apache.metamodel.factory.DataContextFactoryRegistryImpl;
+import org.apache.metamodel.factory.DataContextProperties;
 
 public class DataContextSupplier implements Supplier<DataContext> {
 
     private final String dataSourceName;
-    private final DataSourceDefinition dataSourceDefinition;
-    private final DataContext eagerLoadedDataContext;
+    private final DataContextProperties dataContextProperties;
 
-    public DataContextSupplier(String dataSourceName, DataSourceDefinition dataSourceDefinition) {
+    public DataContextSupplier(String dataSourceName, DataContextProperties dataContextProperties) {
         this.dataSourceName = dataSourceName;
-        this.dataSourceDefinition = dataSourceDefinition;
-        this.eagerLoadedDataContext = createDataContext(true);
+        this.dataContextProperties = dataContextProperties;
     }
 
     @Override
     public DataContext get() {
-        if (eagerLoadedDataContext != null) {
-            return eagerLoadedDataContext;
-        }
-        return createDataContext(false);
+        final DataContext dataContext = DataContextFactoryRegistryImpl.getDefaultInstance().createDataContext(
+                dataContextProperties);
+        return dataContext;
     }
 
-    private DataContext createDataContext(boolean eager) {
-        final String type = dataSourceDefinition.getType();
-        switch (type.toLowerCase()) {
-        case "pojo":
-            final List<TableDataProvider<?>> tableDataProviders;
-
-            final Object tableDefinitions = dataSourceDefinition.getTableDefinitions();
-            if (tableDefinitions == null) {
-                tableDataProviders = new ArrayList<>(0);
-            } else if (tableDefinitions instanceof String) {
-                final SimpleTableDef[] tableDefs = SimpleTableDefParser.parseTableDefs((String) tableDefinitions);
-                tableDataProviders = Arrays.stream(tableDefs).map((tableDef) -> {
-                    return new ArrayTableDataProvider(tableDef, new ArrayList<Object[]>());
-                }).collect(Collectors.toList());
-            } else {
-                throw new UnsupportedOperationException("Unsupported table definition type: " + tableDefinitions);
-            }
-
-            final String schemaName = dataSourceDefinition.getSchemaName() == null ? dataSourceName
-                    : dataSourceDefinition.getSchemaName();
-
-            return new PojoDataContext(schemaName, tableDataProviders);
-        }
-
-        if (eager) {
-            return null;
-        } else {
-            throw new UnsupportedOperationException("Unsupported data source type: " + type);
-        }
+    @Override
+    public String toString() {
+        return "DataContextSupplier[" + dataSourceName + "]";
     }
-
 }

http://git-wip-us.apache.org/repos/asf/metamodel/blob/11d9a9e8/service-webapp/src/main/java/org/apache/metamodel/service/app/DataSourceDefinition.java
----------------------------------------------------------------------
diff --git a/service-webapp/src/main/java/org/apache/metamodel/service/app/DataSourceDefinition.java b/service-webapp/src/main/java/org/apache/metamodel/service/app/DataSourceDefinition.java
index 11140a7..2aaa8e5 100644
--- a/service-webapp/src/main/java/org/apache/metamodel/service/app/DataSourceDefinition.java
+++ b/service-webapp/src/main/java/org/apache/metamodel/service/app/DataSourceDefinition.java
@@ -18,13 +18,11 @@
  */
 package org.apache.metamodel.service.app;
 
+import java.util.Map;
+
 public interface DataSourceDefinition {
 
     public String getType();
     
-    public Object getTableDefinitions();
-    
-    public String getSchemaName();
-    
-    // TODO
+    public Map<String, Object> getProperties();
 }

http://git-wip-us.apache.org/repos/asf/metamodel/blob/11d9a9e8/service-webapp/src/main/java/org/apache/metamodel/service/app/DataSourceRegistry.java
----------------------------------------------------------------------
diff --git a/service-webapp/src/main/java/org/apache/metamodel/service/app/DataSourceRegistry.java b/service-webapp/src/main/java/org/apache/metamodel/service/app/DataSourceRegistry.java
index 3a9ba43..e0c8697 100644
--- a/service-webapp/src/main/java/org/apache/metamodel/service/app/DataSourceRegistry.java
+++ b/service-webapp/src/main/java/org/apache/metamodel/service/app/DataSourceRegistry.java
@@ -22,6 +22,7 @@ import java.util.List;
 
 import org.apache.metamodel.DataContext;
 import org.apache.metamodel.UpdateableDataContext;
+import org.apache.metamodel.factory.DataContextProperties;
 import org.apache.metamodel.service.app.exceptions.DataSourceAlreadyExistException;
 import org.apache.metamodel.service.app.exceptions.DataSourceNotUpdateableException;
 import org.apache.metamodel.service.app.exceptions.NoSuchDataSourceException;
@@ -33,7 +34,7 @@ public interface DataSourceRegistry {
 
     public List<String> getDataSourceNames();
 
-    public String registerDataSource(String dataContextName, DataSourceDefinition dataSourceDef) throws DataSourceAlreadyExistException;
+    public String registerDataSource(String dataContextName, DataContextProperties dataContextProperties) throws DataSourceAlreadyExistException;
 
     public DataContext openDataContext(String dataSourceName) throws NoSuchDataSourceException;
 

http://git-wip-us.apache.org/repos/asf/metamodel/blob/11d9a9e8/service-webapp/src/main/java/org/apache/metamodel/service/app/InMemoryDataSourceRegistry.java
----------------------------------------------------------------------
diff --git a/service-webapp/src/main/java/org/apache/metamodel/service/app/InMemoryDataSourceRegistry.java b/service-webapp/src/main/java/org/apache/metamodel/service/app/InMemoryDataSourceRegistry.java
index b99c6e7..386232a 100644
--- a/service-webapp/src/main/java/org/apache/metamodel/service/app/InMemoryDataSourceRegistry.java
+++ b/service-webapp/src/main/java/org/apache/metamodel/service/app/InMemoryDataSourceRegistry.java
@@ -25,6 +25,7 @@ import java.util.function.Supplier;
 import java.util.stream.Collectors;
 
 import org.apache.metamodel.DataContext;
+import org.apache.metamodel.factory.DataContextProperties;
 import org.apache.metamodel.service.app.exceptions.DataSourceAlreadyExistException;
 import org.apache.metamodel.service.app.exceptions.NoSuchDataSourceException;
 
@@ -37,13 +38,13 @@ public class InMemoryDataSourceRegistry implements DataSourceRegistry {
     }
 
     @Override
-    public String registerDataSource(final String name, final DataSourceDefinition dataSourceDef)
+    public String registerDataSource(final String name, final DataContextProperties dataContextProperties)
             throws DataSourceAlreadyExistException {
         if (dataSources.containsKey(name)) {
             throw new DataSourceAlreadyExistException(name);
         }
 
-        dataSources.put(name, new DataContextSupplier(name, dataSourceDef));
+        dataSources.put(name, new DataContextSupplier(name, dataContextProperties));
         return name;
     }
 

http://git-wip-us.apache.org/repos/asf/metamodel/blob/11d9a9e8/service-webapp/src/main/java/org/apache/metamodel/service/app/InMemoryTenantContext.java
----------------------------------------------------------------------
diff --git a/service-webapp/src/main/java/org/apache/metamodel/service/app/InMemoryTenantContext.java b/service-webapp/src/main/java/org/apache/metamodel/service/app/InMemoryTenantContext.java
index 04fb708..022ab28 100644
--- a/service-webapp/src/main/java/org/apache/metamodel/service/app/InMemoryTenantContext.java
+++ b/service-webapp/src/main/java/org/apache/metamodel/service/app/InMemoryTenantContext.java
@@ -25,7 +25,7 @@ public class InMemoryTenantContext implements TenantContext {
 
     public InMemoryTenantContext(String tenantIdentifier) {
         this.tenantIdentifier = tenantIdentifier;
-        this.dataContextRegistry = new InMemoryDataSourceRegistry();
+        this.dataContextRegistry = new CachedDataSourceRegistryWrapper(new InMemoryDataSourceRegistry());
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/metamodel/blob/11d9a9e8/service-webapp/src/main/java/org/apache/metamodel/service/controllers/DataSourceController.java
----------------------------------------------------------------------
diff --git a/service-webapp/src/main/java/org/apache/metamodel/service/controllers/DataSourceController.java b/service-webapp/src/main/java/org/apache/metamodel/service/controllers/DataSourceController.java
index 9c678ff..6ac0c43 100644
--- a/service-webapp/src/main/java/org/apache/metamodel/service/controllers/DataSourceController.java
+++ b/service-webapp/src/main/java/org/apache/metamodel/service/controllers/DataSourceController.java
@@ -19,6 +19,7 @@
 package org.apache.metamodel.service.controllers;
 
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
@@ -29,6 +30,8 @@ import javax.ws.rs.core.UriBuilder;
 
 import org.apache.metamodel.DataContext;
 import org.apache.metamodel.UpdateableDataContext;
+import org.apache.metamodel.factory.DataContextProperties;
+import org.apache.metamodel.factory.DataContextPropertiesImpl;
 import org.apache.metamodel.service.app.TenantContext;
 import org.apache.metamodel.service.app.TenantRegistry;
 import org.apache.metamodel.service.controllers.model.RestDataSourceDefinition;
@@ -58,8 +61,20 @@ public class DataSourceController {
     public Map<String, Object> put(@PathVariable("tenant") String tenantId,
             @PathVariable("datasource") String dataSourceId,
             @Valid @RequestBody RestDataSourceDefinition dataContextDefinition) {
+
+        final Map<String, Object> map = new HashMap<>();
+        map.putAll(dataContextDefinition.getProperties());
+        map.put(DataContextPropertiesImpl.PROPERTY_DATA_CONTEXT_TYPE, dataContextDefinition.getType());
+
+        if (!map.containsKey(DataContextPropertiesImpl.PROPERTY_DATABASE)) {
+            // add the data source ID as database name if it is not already set.
+            map.put(DataContextPropertiesImpl.PROPERTY_DATABASE, dataSourceId);
+        }
+
+        final DataContextProperties properties = new DataContextPropertiesImpl(map);
+
         final String dataContextIdentifier = tenantRegistry.getTenantContext(tenantId).getDataSourceRegistry()
-                .registerDataSource(dataSourceId, dataContextDefinition);
+                .registerDataSource(dataSourceId, properties);
 
         return get(tenantId, dataContextIdentifier);
     }

http://git-wip-us.apache.org/repos/asf/metamodel/blob/11d9a9e8/service-webapp/src/main/java/org/apache/metamodel/service/controllers/model/RestDataSourceDefinition.java
----------------------------------------------------------------------
diff --git a/service-webapp/src/main/java/org/apache/metamodel/service/controllers/model/RestDataSourceDefinition.java b/service-webapp/src/main/java/org/apache/metamodel/service/controllers/model/RestDataSourceDefinition.java
index 48c5926..b6fdb28 100644
--- a/service-webapp/src/main/java/org/apache/metamodel/service/controllers/model/RestDataSourceDefinition.java
+++ b/service-webapp/src/main/java/org/apache/metamodel/service/controllers/model/RestDataSourceDefinition.java
@@ -18,39 +18,38 @@
  */
 package org.apache.metamodel.service.controllers.model;
 
+import java.util.HashMap;
+import java.util.Map;
+
 import javax.validation.constraints.NotNull;
 
 import org.apache.metamodel.service.app.DataSourceDefinition;
 
-import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonAnyGetter;
+import com.fasterxml.jackson.annotation.JsonAnySetter;
 import com.fasterxml.jackson.annotation.JsonProperty;
 
 public class RestDataSourceDefinition implements DataSourceDefinition {
 
+    private final Map<String, Object> properties = new HashMap<>();
+
     @JsonProperty(value = "type", required = true)
     @NotNull
     private String type;
 
-    @JsonProperty(value = "table-definitions", required = false)
-    @JsonInclude(JsonInclude.Include.NON_NULL)
-    private Object tableDefinitions;
-
-    @JsonProperty(value = "schema-name", required = false)
-    @JsonInclude(JsonInclude.Include.NON_NULL)
-    private String schemaName;
-
     @Override
     public String getType() {
         return type;
     }
 
+    @JsonAnyGetter
     @Override
-    public Object getTableDefinitions() {
-        return tableDefinitions;
+    public Map<String, Object> getProperties() {
+        return properties;
     }
 
-    @Override
-    public String getSchemaName() {
-        return schemaName;
+    @JsonAnySetter
+    public void set(String name, Object value) {
+        properties.put(name, value);
     }
 }

http://git-wip-us.apache.org/repos/asf/metamodel/blob/11d9a9e8/service-webapp/src/test/java/org/apache/metamodel/service/controllers/TenantInteractionScenarioTest.java
----------------------------------------------------------------------
diff --git a/service-webapp/src/test/java/org/apache/metamodel/service/controllers/TenantInteractionScenarioTest.java b/service-webapp/src/test/java/org/apache/metamodel/service/controllers/TenantInteractionScenarioTest.java
index 793f88c..01bc7f5 100644
--- a/service-webapp/src/test/java/org/apache/metamodel/service/controllers/TenantInteractionScenarioTest.java
+++ b/service-webapp/src/test/java/org/apache/metamodel/service/controllers/TenantInteractionScenarioTest.java
@@ -72,7 +72,7 @@ public class TenantInteractionScenarioTest {
         // create datasource
         {
             final MvcResult result = mockMvc.perform(MockMvcRequestBuilders.put("/tenant1/mydata").content(
-                    "{'type':'pojo','table-definitions':'hello_world (greeting VARCHAR, who VARCHAR); foo (bar INTEGER, baz DATE);'}"
+                    "{'type':'pojo','table-defs':'hello_world (greeting VARCHAR, who VARCHAR); foo (bar INTEGER, baz DATE);'}"
                             .replace('\'', '"')).contentType(MediaType.APPLICATION_JSON)).andExpect(
                                     MockMvcResultMatchers.status().isOk()).andReturn();
 


[08/16] metamodel git commit: METAMODEL-1093: Close compiled ResultSets

Posted by ka...@apache.org.
METAMODEL-1093: Close compiled ResultSets

Fixes #107


Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/b648ff1c
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/b648ff1c
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/b648ff1c

Branch: refs/heads/feature/5.x/swagger-docs
Commit: b648ff1cf098faeb2c9875c787e17539ebf1dc64
Parents: 2486a56
Author: Dennis Du Kr�ger <de...@humaninference.com>
Authored: Mon Jun 13 13:07:11 2016 +0200
Committer: Dennis Du Kr�ger <de...@humaninference.com>
Committed: Mon Jun 13 13:09:03 2016 +0200

----------------------------------------------------------------------
 jdbc/pom.xml                                    |   2 +-
 .../jdbc/JdbcCompiledQueryLeaseFactory.java     |   5 +-
 .../apache/metamodel/jdbc/JdbcDataContext.java  |  40 ++++----
 .../org/apache/metamodel/jdbc/JdbcDataSet.java  |   6 +-
 .../metamodel/jdbc/JdbcMetadataLoader.java      | 100 +++++++------------
 .../metamodel/jdbc/JdbcUpdateCallback.java      |   2 +-
 .../jdbc/integrationtests/MysqlTest.java        |  61 ++++++++---
 7 files changed, 112 insertions(+), 104 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/b648ff1c/jdbc/pom.xml
----------------------------------------------------------------------
diff --git a/jdbc/pom.xml b/jdbc/pom.xml
index 7f7579f..fb332f7 100644
--- a/jdbc/pom.xml
+++ b/jdbc/pom.xml
@@ -80,7 +80,7 @@
 		<dependency>
 			<groupId>mysql</groupId>
 			<artifactId>mysql-connector-java</artifactId>
-			<version>5.1.18</version>
+			<version>5.1.39</version>
 			<scope>test</scope>
 		</dependency>
 		<dependency>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/b648ff1c/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcCompiledQueryLeaseFactory.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcCompiledQueryLeaseFactory.java b/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcCompiledQueryLeaseFactory.java
index d973d13..931c224 100644
--- a/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcCompiledQueryLeaseFactory.java
+++ b/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcCompiledQueryLeaseFactory.java
@@ -23,6 +23,7 @@ import java.sql.PreparedStatement;
 import java.sql.SQLException;
 
 import org.apache.commons.pool.PoolableObjectFactory;
+import org.apache.metamodel.util.FileHelper;
 
 /**
  * Factory for the object pool of {@link JdbcCompiledQueryLease}s.
@@ -52,9 +53,9 @@ final class JdbcCompiledQueryLeaseFactory implements PoolableObjectFactory<JdbcC
 
     @Override
     public void destroyObject(JdbcCompiledQueryLease lease) throws Exception {
-        final PreparedStatement statement = lease.getStatement();
+        FileHelper.safeClose(lease.getStatement());
         final Connection connection = lease.getConnection();
-        _dataContext.close(connection, null, statement);
+        _dataContext.close(connection);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/metamodel/blob/b648ff1c/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcDataContext.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcDataContext.java b/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcDataContext.java
index 84254f9..63e42e5 100644
--- a/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcDataContext.java
+++ b/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcDataContext.java
@@ -216,7 +216,7 @@ public class JdbcDataContext extends AbstractDataContext implements UpdateableDa
         } catch (SQLException e) {
             logger.debug("Unexpected exception during JdbcDataContext initialization", e);
         } finally {
-            closeIfNescesary(con);
+            closeIfNecessary(con);
         }
         _databaseProductName = databaseProductName;
         logger.debug("Database product name: {}", _databaseProductName);
@@ -296,7 +296,7 @@ public class JdbcDataContext extends AbstractDataContext implements UpdateableDa
         } catch (SQLException e) {
             throw JdbcUtils.wrapException(e, "retrieve schema and catalog metadata");
         } finally {
-            close(null, rs, null);
+            close(null);
         }
         return result;
     }
@@ -507,12 +507,12 @@ public class JdbcDataContext extends AbstractDataContext implements UpdateableDa
         } catch (SQLException e) {
             // only close in case of an error - the JdbcDataSet will close
             // otherwise
-            close(connection, null, statement);
+            close(connection);
             throw JdbcUtils.wrapException(e, "execute query");
         } catch (RuntimeException e) {
             // only close in case of an error - the JdbcDataSet will close
             // otherwise
-            close(connection, null, statement);
+            close(connection);
             throw e;
         }
 
@@ -533,18 +533,24 @@ public class JdbcDataContext extends AbstractDataContext implements UpdateableDa
     }
 
     /**
-     * Quietly closes any of the parameterized JDBC objects
-     * 
-     * @param connection
-     * 
-     * @param rs
-     * @param st
+     * Quietly closes the connection
+     *  @param connection The connection to close (if it makes sense, @see closeIfNecessary)
+
      */
+    public void close(Connection connection) {
+        closeIfNecessary(connection);
+    }
+
+    /**
+     * @deprecated Manually close {@link ResultSet} and {@link Statement} instead.
+     */
+    @Deprecated
     public void close(Connection connection, ResultSet rs, Statement st) {
-        closeIfNescesary(connection);
+        close(connection);
         FileHelper.safeClose(rs, st);
     }
 
+
     /**
      * Convenience method to get the available catalogNames using this
      * connection.
@@ -576,7 +582,7 @@ public class JdbcDataContext extends AbstractDataContext implements UpdateableDa
         } catch (SQLException e) {
             logger.error("Error retrieving catalog metadata", e);
         } finally {
-            close(connection, rs, null);
+            close(connection);
             logger.debug("Retrieved {} catalogs", catalogs.size());
         }
         return catalogs.toArray(new String[catalogs.size()]);
@@ -600,7 +606,7 @@ public class JdbcDataContext extends AbstractDataContext implements UpdateableDa
      * Gets an appropriate connection object to use - either a dedicated
      * connection or a new connection from the datasource object.
      * 
-     * Hint: Use the {@link #close(Connection, ResultSet, Statement)} method to
+     * Hint: Use the {@link #close(Connection)} method to
      * close the connection (and any ResultSet or Statements involved).
      */
     public Connection getConnection() {
@@ -614,7 +620,7 @@ public class JdbcDataContext extends AbstractDataContext implements UpdateableDa
         }
     }
 
-    private void closeIfNescesary(Connection con) {
+    private void closeIfNecessary(Connection con) {
         if (con != null) {
             if (_dataSource != null) {
                 // closing connections after individual usage is only nescesary
@@ -687,7 +693,7 @@ public class JdbcDataContext extends AbstractDataContext implements UpdateableDa
             } catch (SQLException e) {
                 throw JdbcUtils.wrapException(e, "determine default schema name");
             } finally {
-                closeIfNescesary(connection);
+                closeIfNecessary(connection);
             }
 
             // Fourth strategy: Find default schema name by vendor-specific
@@ -798,7 +804,7 @@ public class JdbcDataContext extends AbstractDataContext implements UpdateableDa
         } catch (SQLException e) {
             throw JdbcUtils.wrapException(e, "get schema names");
         } finally {
-            closeIfNescesary(connection);
+            closeIfNecessary(connection);
         }
     }
 
@@ -809,7 +815,7 @@ public class JdbcDataContext extends AbstractDataContext implements UpdateableDa
         try {
             _metadataLoader.loadTables(schema, connection);
         } finally {
-            close(connection, null, null);
+            close(connection);
         }
         return schema;
     }

http://git-wip-us.apache.org/repos/asf/metamodel/blob/b648ff1c/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcDataSet.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcDataSet.java b/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcDataSet.java
index a1b76f7..4142ab7 100644
--- a/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcDataSet.java
+++ b/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcDataSet.java
@@ -197,8 +197,12 @@ final class JdbcDataSet extends AbstractDataSet {
         if (_closed) {
             return;
         }
+
+        FileHelper.safeClose(_resultSet);
+
         if (_jdbcDataContext != null) {
-            _jdbcDataContext.close(_connection, _resultSet, _statement);
+            FileHelper.safeClose(_statement);
+            _jdbcDataContext.close(_connection);
         }
         if (_compiledQuery != null) {
             _compiledQuery.returnLease(_lease);

http://git-wip-us.apache.org/repos/asf/metamodel/blob/b648ff1c/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcMetadataLoader.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcMetadataLoader.java b/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcMetadataLoader.java
index 5d5697e..837fb18 100644
--- a/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcMetadataLoader.java
+++ b/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcMetadataLoader.java
@@ -22,7 +22,6 @@ import java.sql.Connection;
 import java.sql.DatabaseMetaData;
 import java.sql.ResultSet;
 import java.sql.SQLException;
-import java.util.Arrays;
 import java.util.Collections;
 import java.util.Set;
 import java.util.StringTokenizer;
@@ -75,7 +74,7 @@ final class JdbcMetadataLoader implements MetadataLoader {
         try {
             loadTables(schema, connection);
         } finally {
-            _dataContext.close(connection, null, null);
+            _dataContext.close(connection);
         }
     }
 
@@ -92,20 +91,27 @@ final class JdbcMetadataLoader implements MetadataLoader {
         }
     }
 
+    private String getJdbcSchemaName(Schema schema) {
+        if(_usesCatalogsAsSchemas) {
+            return null;
+        } else {
+            return schema.getName();
+        }
+    }
+
+    private String getCatalogName(Schema schema) {
+        if(_usesCatalogsAsSchemas) {
+            return schema.getName();
+        } else {
+            return _dataContext.getCatalogName();
+        }
+    }
+
     private void loadTables(JdbcSchema schema, DatabaseMetaData metaData, String[] types) {
-        String catalogName = _dataContext.getCatalogName();
+        try (ResultSet rs = metaData.getTables(getCatalogName(schema), getJdbcSchemaName(schema), null, types)) {
+            logger.debug("Querying for table types {}, in catalog: {}, schema: {}", types,
+                    _dataContext.getCatalogName(), schema.getName());
 
-        ResultSet rs = null;
-        try {
-            if (logger.isDebugEnabled()) {
-                logger.debug("Querying for table types " + Arrays.toString(types) + " in catalog: " + catalogName
-                        + ", schema: " + schema.getName());
-            }
-            if (_usesCatalogsAsSchemas) {
-                rs = metaData.getTables(schema.getName(), null, null, types);
-            } else {
-                rs = metaData.getTables(catalogName, schema.getName(), null, types);
-            }
             schema.clearTables();
             int tableNumber = -1;
             while (rs.next()) {
@@ -122,10 +128,6 @@ final class JdbcMetadataLoader implements MetadataLoader {
                             + ",tableName=" + tableName);
                 }
 
-                if (tableSchema == null) {
-                    tableSchema = tableCatalog;
-                }
-
                 JdbcTable table = new JdbcTable(tableName, tableType, schema, this);
                 table.setRemarks(tableRemarks);
                 table.setQuote(_identifierQuoteString);
@@ -142,8 +144,6 @@ final class JdbcMetadataLoader implements MetadataLoader {
 
         } catch (SQLException e) {
             throw JdbcUtils.wrapException(e, "retrieve table metadata for " + schema.getName());
-        } finally {
-            _dataContext.close(null, rs, null);
         }
     }
     
@@ -158,7 +158,7 @@ final class JdbcMetadataLoader implements MetadataLoader {
         try {
             loadIndexes(jdbcTable, connection);
         } finally {
-            _dataContext.close(connection, null, null);
+            _dataContext.close(connection);
         }
     }
 
@@ -194,7 +194,7 @@ final class JdbcMetadataLoader implements MetadataLoader {
         try {
             loadPrimaryKeys(jdbcTable, connection);
         } finally {
-            _dataContext.close(connection, null, null);
+            _dataContext.close(connection);
         }
     }
 
@@ -220,14 +220,7 @@ final class JdbcMetadataLoader implements MetadataLoader {
 
     private void loadPrimaryKeys(JdbcTable table, DatabaseMetaData metaData) throws MetaModelException {
         Schema schema = table.getSchema();
-        ResultSet rs = null;
-
-        try {
-            if (_usesCatalogsAsSchemas) {
-                rs = metaData.getPrimaryKeys(schema.getName(), null, table.getName());
-            } else {
-                rs = metaData.getPrimaryKeys(_dataContext.getCatalogName(), schema.getName(), table.getName());
-            }
+        try (ResultSet rs = metaData.getPrimaryKeys(getCatalogName(schema), getJdbcSchemaName(schema), table.getName());){
             while (rs.next()) {
                 String columnName = rs.getString(4);
                 if (columnName != null) {
@@ -241,23 +234,15 @@ final class JdbcMetadataLoader implements MetadataLoader {
             }
         } catch (SQLException e) {
             throw JdbcUtils.wrapException(e, "retrieve primary keys for " + table.getName());
-        } finally {
-            _dataContext.close(null, rs, null);
         }
     }
 
     private void loadIndexes(Table table, DatabaseMetaData metaData) throws MetaModelException {
         Schema schema = table.getSchema();
-        ResultSet rs = null;
+
         // Ticket #170: IndexInfo is nice-to-have, not need-to-have, so
         // we will do a nice failover on SQLExceptions
-        try {
-            if (_usesCatalogsAsSchemas) {
-                rs = metaData.getIndexInfo(schema.getName(), null, table.getName(), false, true);
-            } else {
-                rs = metaData.getIndexInfo(_dataContext.getCatalogName(), schema.getName(), table.getName(), false,
-                        true);
-            }
+        try (ResultSet rs = metaData.getIndexInfo(getCatalogName(schema), getJdbcSchemaName(schema), table.getName(), false, true)) {
             while (rs.next()) {
                 String columnName = rs.getString(9);
                 if (columnName != null) {
@@ -271,8 +256,6 @@ final class JdbcMetadataLoader implements MetadataLoader {
             }
         } catch (SQLException e) {
             throw JdbcUtils.wrapException(e, "retrieve index information for " + table.getName());
-        } finally {
-            _dataContext.close(null, rs, null);
         }
     }
     
@@ -287,7 +270,7 @@ final class JdbcMetadataLoader implements MetadataLoader {
         try {
             loadColumns(jdbcTable, connection);
         } finally {
-            _dataContext.close(connection, null, null);
+            _dataContext.close(connection);
         }
     }
 
@@ -325,17 +308,13 @@ final class JdbcMetadataLoader implements MetadataLoader {
     private void loadColumns(JdbcTable table, DatabaseMetaData metaData) {
         final boolean convertLobs = isLobConversionEnabled();
         final Schema schema = table.getSchema();
-        ResultSet rs = null;
-        try {
+
+        try (ResultSet rs = metaData.getColumns(getCatalogName(schema), getJdbcSchemaName(schema), table.getName(), null)) {
             if (logger.isDebugEnabled()) {
                 logger.debug("Querying for columns in table: " + table.getName());
             }
             int columnNumber = -1;
-            if (_usesCatalogsAsSchemas) {
-                rs = metaData.getColumns(schema.getName(), null, table.getName(), null);
-            } else {
-                rs = metaData.getColumns(_dataContext.getCatalogName(), schema.getName(), table.getName(), null);
-            }
+
             while (rs.next()) {
                 columnNumber++;
                 final String columnName = rs.getString(4);
@@ -386,14 +365,11 @@ final class JdbcMetadataLoader implements MetadataLoader {
                 logger.info("No column metadata records returned for table '{}' in schema '{}'", table.getName(),
                         schema.getName());
             } else {
-                logger.debug("Returned {} column metadata records for table '{}' in schema '{}'", new Object[] {
-                        columnsReturned, table.getName(), schema.getName() });
+                logger.debug("Returned {} column metadata records for table '{}' in schema '{}'", columnsReturned,
+                        table.getName(), schema.getName());
             }
-
         } catch (SQLException e) {
             throw JdbcUtils.wrapException(e, "retrieve table metadata for " + table.getName());
-        } finally {
-            _dataContext.close(null, rs, null);
         }
     }
     
@@ -407,7 +383,7 @@ final class JdbcMetadataLoader implements MetadataLoader {
         try {
             loadRelations(jdbcSchema, connection);
         } finally {
-            _dataContext.close(connection, null, null);
+            _dataContext.close(connection);
         }
     }
 
@@ -436,18 +412,10 @@ final class JdbcMetadataLoader implements MetadataLoader {
 
     private void loadRelations(Table table, DatabaseMetaData metaData) {
         Schema schema = table.getSchema();
-        ResultSet rs = null;
-        try {
-            if (_usesCatalogsAsSchemas) {
-                rs = metaData.getImportedKeys(schema.getName(), null, table.getName());
-            } else {
-                rs = metaData.getImportedKeys(_dataContext.getCatalogName(), schema.getName(), table.getName());
-            }
+        try (ResultSet rs = metaData.getImportedKeys(getCatalogName(schema), getJdbcSchemaName(schema), table.getName())) {
             loadRelations(rs, schema);
         } catch (SQLException e) {
             throw JdbcUtils.wrapException(e, "retrieve imported keys for " + table.getName());
-        } finally {
-            _dataContext.close(null, rs, null);
         }
     }
 
@@ -481,7 +449,7 @@ final class JdbcMetadataLoader implements MetadataLoader {
             if (pkColumn == null || fkColumn == null) {
                 logger.error(
                         "Could not find relation columns: pkTableName={},pkColumnName={},fkTableName={},fkColumnName={}",
-                        new Object[] { pkTableName, pkColumnName, fkTableName, fkColumnName });
+                        pkTableName, pkColumnName, fkTableName, fkColumnName);
                 logger.error("pkColumn={}", pkColumn);
                 logger.error("fkColumn={}", fkColumn);
             } else {

http://git-wip-us.apache.org/repos/asf/metamodel/blob/b648ff1c/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcUpdateCallback.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcUpdateCallback.java b/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcUpdateCallback.java
index 5e60826..a9db2fd 100644
--- a/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcUpdateCallback.java
+++ b/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcUpdateCallback.java
@@ -92,7 +92,7 @@ abstract class JdbcUpdateCallback extends AbstractUpdateCallback implements Upda
                         }
                     }
                 } finally {
-                    getDataContext().close(_connection, null, null);
+                    getDataContext().close(_connection);
                 }
             }
         }

http://git-wip-us.apache.org/repos/asf/metamodel/blob/b648ff1c/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/MysqlTest.java
----------------------------------------------------------------------
diff --git a/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/MysqlTest.java b/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/MysqlTest.java
index ba273e3..c5485ca 100644
--- a/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/MysqlTest.java
+++ b/jdbc/src/test/java/org/apache/metamodel/jdbc/integrationtests/MysqlTest.java
@@ -22,6 +22,7 @@ import java.sql.Connection;
 import java.sql.DatabaseMetaData;
 import java.sql.SQLException;
 import java.sql.Statement;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.concurrent.TimeUnit;
@@ -33,14 +34,17 @@ import org.apache.metamodel.UpdateCallback;
 import org.apache.metamodel.UpdateScript;
 import org.apache.metamodel.data.DataSet;
 import org.apache.metamodel.data.DataSetTableModel;
+import org.apache.metamodel.data.Row;
 import org.apache.metamodel.jdbc.JdbcDataContext;
 import org.apache.metamodel.jdbc.JdbcTestTemplates;
 import org.apache.metamodel.jdbc.QuerySplitter;
 import org.apache.metamodel.jdbc.dialects.MysqlQueryRewriter;
+import org.apache.metamodel.query.CompiledQuery;
 import org.apache.metamodel.query.FilterItem;
 import org.apache.metamodel.query.FromItem;
 import org.apache.metamodel.query.OperatorType;
 import org.apache.metamodel.query.Query;
+import org.apache.metamodel.query.QueryParameter;
 import org.apache.metamodel.schema.Column;
 import org.apache.metamodel.schema.ColumnType;
 import org.apache.metamodel.schema.Schema;
@@ -50,8 +54,8 @@ import org.apache.metamodel.schema.TableType;
 /**
  * Test case that tests mysql interaction. The test requires the "sakila" sample
  * database that can be found at dev.mysql.com.
- * 
- * @see http://dev.mysql.com/doc/sakila/en/sakila-installation.html
+ *
+ * @see <a href="http://dev.mysql.com/doc/sakila/en/sakila-installation.html">Sakila installation</a>
  */
 public class MysqlTest extends AbstractJdbIntegrationTest {
 
@@ -75,12 +79,12 @@ public class MysqlTest extends AbstractJdbIntegrationTest {
 
         JdbcTestTemplates.compositeKeyCreation(getDataContext(), "metamodel_test_composite_keys");
     }
-    
+
     public void testTimestampValueInsertSelect() throws Exception {
         if (!isConfigured()) {
             return;
         }
-        
+
         final Connection connection = getConnection();
         JdbcTestTemplates.timestampValueInsertSelect(connection, TimeUnit.MICROSECONDS, "TIMESTAMP(6)");
     }
@@ -180,11 +184,10 @@ public class MysqlTest extends AbstractJdbIntegrationTest {
         }
 
         DataContext dc = new JdbcDataContext(getConnection(), TableType.DEFAULT_TABLE_TYPES, "sakila");
-        Schema[] schemas = dc.getSchemas();
-        assertEquals("[Schema[name=mysql], Schema[name=performance_schema], Schema[name=portal], "
-                + "Schema[name=sakila], Schema[name=world]]", Arrays.toString(schemas));
+        final Schema sakila = dc.getSchemaByName("sakila");
+        assertNotNull(sakila);
 
-        Table table = dc.getSchemaByName("sakila").getTableByName("film");
+        Table table = sakila.getTableByName("film");
         Query q = new Query().from(table).select(table.getColumns());
         DataSet data = dc.executeQuery(q);
         TableModel tableModel = new DataSetTableModel(data);
@@ -199,9 +202,9 @@ public class MysqlTest extends AbstractJdbIntegrationTest {
 
         JdbcDataContext dataContext = new JdbcDataContext(getConnection());
         assertTrue(dataContext.getQueryRewriter() instanceof MysqlQueryRewriter);
-        String[] catalogNames = dataContext.getCatalogNames();
-        assertEquals("[information_schema, mysql, performance_schema, portal, sakila, world]",
-                Arrays.toString(catalogNames));
+        assertNotNull(dataContext.getSchemaByName("mysql"));
+        assertNotNull(dataContext.getSchemaByName("performance_schema"));
+        assertNotNull(dataContext.getSchemaByName("sakila"));
     }
 
     public void testGetDefaultSchema() throws Exception {
@@ -296,8 +299,6 @@ public class MysqlTest extends AbstractJdbIntegrationTest {
         }
 
         DataContext dc = new JdbcDataContext(getConnection());
-        Schema[] schemas = dc.getSchemas();
-        assertEquals(5, schemas.length);
         Schema schema = dc.getDefaultSchema();
 
         assertEquals("[Table[name=actor,type=TABLE,remarks=], " + "Table[name=address,type=TABLE,remarks=], "
@@ -335,9 +336,6 @@ public class MysqlTest extends AbstractJdbIntegrationTest {
                 "[Relationship[primaryTable=language,primaryColumns=[language_id],foreignTable=film,foreignColumns=[language_id]], Relationship[primaryTable=language,primaryColumns=[language_id],foreignTable=film,foreignColumns=[original_language_id]], Relationship[primaryTable=film,primaryColumns=[film_id],foreignTable=film_actor,foreignColumns=[film_id]], Relationship[primaryTable=film,primaryColumns=[film_id],foreignTable=film_category,foreignColumns=[film_id]], Relationship[primaryTable=film,primaryColumns=[film_id],foreignTable=inventory,foreignColumns=[film_id]]]",
                 Arrays.toString(filmTable.getRelationships()));
 
-        dc = new JdbcDataContext(getConnection(), TableType.DEFAULT_TABLE_TYPES, "sakila");
-        schemas = dc.getSchemas();
-        assertEquals(6, schemas.length);
         assertEquals("[Table[name=actor,type=TABLE,remarks=], " + "Table[name=address,type=TABLE,remarks=], "
                 + "Table[name=category,type=TABLE,remarks=], " + "Table[name=city,type=TABLE,remarks=], "
                 + "Table[name=country,type=TABLE,remarks=], " + "Table[name=customer,type=TABLE,remarks=], "
@@ -415,6 +413,37 @@ public class MysqlTest extends AbstractJdbIntegrationTest {
         assertFalse(ds.next());
     }
 
+    public void testCompiledQueries() throws Exception {
+        if (!isConfigured()) {
+            return;
+        }
+
+        DataContext dc = new JdbcDataContext(getConnection(), TableType.DEFAULT_TABLE_TYPES, "sakila");
+
+        final Query cityQuery = dc.query().from("city").select("city_id", "city").toQuery()
+                .where(dc.getColumnByQualifiedLabel("city.city_id"), OperatorType.EQUALS_TO, new QueryParameter());
+        final CompiledQuery userCompiledQuery = dc.compileQuery(cityQuery);
+
+        for (int i = 1; i <= 100; i++) {
+            System.out.println("Running test " + i);
+            List<Integer> cityIds = new ArrayList<>(1000);
+            try (final DataSet addresses = dc.query().from("address").select("city_id").execute()) {
+                while (addresses.next()) {
+                    final Row addressRow = addresses.getRow();
+                    cityIds.add((int) addressRow.getValue(0));
+                }
+            }
+
+            for(int value : cityIds) {
+                try (final DataSet users = dc.executeQuery(userCompiledQuery, value)) {
+                    while (users.next()) {
+                        assertEquals(value, users.getRow().getValue(0));
+                    }
+                }
+            }
+        }
+    }
+
     public void testWhiteSpaceColumns() throws Exception {
         if (!isConfigured()) {
             return;


[09/16] metamodel git commit: Update CHANGES.md with newest change

Posted by ka...@apache.org.
Update CHANGES.md with newest change


Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/d79c0cef
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/d79c0cef
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/d79c0cef

Branch: refs/heads/feature/5.x/swagger-docs
Commit: d79c0cefce2bbc8a5034c41c0cb257bba1e6f1ad
Parents: b648ff1
Author: Dennis Du Kr�ger <d...@hp23c.dk>
Authored: Tue Jun 14 08:32:35 2016 +0200
Committer: Dennis Du Kr�ger <d...@hp23c.dk>
Committed: Tue Jun 14 08:32:35 2016 +0200

----------------------------------------------------------------------
 CHANGES.md | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/d79c0cef/CHANGES.md
----------------------------------------------------------------------
diff --git a/CHANGES.md b/CHANGES.md
index c10eb35..817893a 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -3,6 +3,7 @@
  * [METAMODEL-1088] - Add support for aliases in MongoDB.
  * [METAMODEL-1086] - Fixed encoding issue when CsvDataContext is instantiated with InputStream.
  * [METAMODEL-1094]�- Added support for Apache Cassandra version 3.x.
+ * [METAMODEL-1093] - Close compiled ResultSets.
 
 ### Apache MetaModel 4.5.3
 


[11/16] metamodel git commit: METAMODEL-1099: Added ServiceLoader based registry of DataContexts.

Posted by ka...@apache.org.
METAMODEL-1099: Added ServiceLoader based registry of DataContexts.

Fixes #113

Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/52c3dafc
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/52c3dafc
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/52c3dafc

Branch: refs/heads/feature/5.x/swagger-docs
Commit: 52c3dafcf0f1ca6256f8da82c9825c121f833a80
Parents: b4bfc5c
Author: Kasper S�rensen <i....@gmail.com>
Authored: Sun Jul 10 21:18:34 2016 -0700
Committer: Kasper S�rensen <i....@gmail.com>
Committed: Sun Jul 10 21:18:34 2016 -0700

----------------------------------------------------------------------
 CHANGES.md                                      |   1 +
 .../apache/metamodel/ConnectionException.java   |  44 +++
 .../factory/ClasspathResourceFactory.java       |  36 +++
 .../metamodel/factory/DataContextFactory.java   |  30 ++
 .../factory/DataContextFactoryRegistry.java     |  41 +++
 .../factory/DataContextFactoryRegistryImpl.java |  84 +++++
 .../factory/DataContextProperties.java          |  92 ++++++
 .../factory/DataContextPropertiesImpl.java      | 304 +++++++++++++++++++
 .../metamodel/factory/FileResourceFactory.java  |  38 +++
 .../factory/InMemoryResourceFactory.java        |  36 +++
 .../metamodel/factory/ResourceFactory.java      |  28 ++
 .../factory/ResourceFactoryRegistry.java        |  34 +++
 .../factory/ResourceFactoryRegistryImpl.java    |  80 +++++
 .../metamodel/factory/ResourceProperties.java   |  46 +++
 .../factory/ResourcePropertiesImpl.java         |  74 +++++
 .../factory/SimpleResourceProperties.java       |  60 ++++
 ...supportedDataContextPropertiesException.java |  47 +++
 .../UnsupportedResourcePropertiesException.java |  43 +++
 .../metamodel/factory/UrlResourceFactory.java   |  48 +++
 .../apache/metamodel/util/ResourceUtils.java    |  45 +++
 ...org.apache.metamodel.factory.ResourceFactory |   4 +
 .../ResourceFactoryRegistryImplTest.java        |  72 +++++
 .../apache/metamodel/util/UrlResourceTest.java  |   8 +-
 .../metamodel/csv/CsvDataContextFactory.java    |  73 +++++
 ....apache.metamodel.factory.DataContextFactory |   1 +
 .../csv/CsvDataContextFactoryTest.java          |  57 ++++
 .../metamodel/hadoop/HdfsResourceFactory.java   |  46 +++
 ...org.apache.metamodel.factory.ResourceFactory |   1 +
 .../metamodel/jdbc/JdbcDataContextFactory.java  |  86 ++++++
 ....apache.metamodel.factory.DataContextFactory |   1 +
 .../apache/metamodel/jdbc/H2databaseTest.java   |  11 +-
 .../jdbc/JdbcDataContextFactoryTest.java        |  45 +++
 pom.xml                                         |   1 +
 33 files changed, 1609 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/52c3dafc/CHANGES.md
----------------------------------------------------------------------
diff --git a/CHANGES.md b/CHANGES.md
index 817893a..3ff4ca0 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,5 +1,6 @@
 ### Apache MetaModel 4.5.4 (work in progress)
 
+ * [METAMODEL-1099] - Created a new DataContextFactory SPI and a extensible registry of implementations based on ServiceLoader.
  * [METAMODEL-1088] - Add support for aliases in MongoDB.
  * [METAMODEL-1086] - Fixed encoding issue when CsvDataContext is instantiated with InputStream.
  * [METAMODEL-1094]�- Added support for Apache Cassandra version 3.x.

http://git-wip-us.apache.org/repos/asf/metamodel/blob/52c3dafc/core/src/main/java/org/apache/metamodel/ConnectionException.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/ConnectionException.java b/core/src/main/java/org/apache/metamodel/ConnectionException.java
new file mode 100644
index 0000000..5379f09
--- /dev/null
+++ b/core/src/main/java/org/apache/metamodel/ConnectionException.java
@@ -0,0 +1,44 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.metamodel;
+
+/**
+ * Specialized {@link MetaModelException} thrown to indicate that establishing
+ * the connection to the underlying data store of an {@link DataContext} failed.
+ */
+public class ConnectionException extends MetaModelException {
+
+    private static final long serialVersionUID = 1L;
+
+    public ConnectionException() {
+        super();
+    }
+
+    public ConnectionException(Exception cause) {
+        super(cause);
+    }
+
+    public ConnectionException(String message, Exception cause) {
+        super(message, cause);
+    }
+
+    public ConnectionException(String message) {
+        super(message);
+    }
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/52c3dafc/core/src/main/java/org/apache/metamodel/factory/ClasspathResourceFactory.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/factory/ClasspathResourceFactory.java b/core/src/main/java/org/apache/metamodel/factory/ClasspathResourceFactory.java
new file mode 100644
index 0000000..526e5f3
--- /dev/null
+++ b/core/src/main/java/org/apache/metamodel/factory/ClasspathResourceFactory.java
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.metamodel.factory;
+
+import org.apache.metamodel.util.ClasspathResource;
+import org.apache.metamodel.util.Resource;
+
+public class ClasspathResourceFactory implements ResourceFactory {
+
+    @Override
+    public boolean accepts(ResourceProperties properties) {
+        return "classpath".equals(properties.getUri().getScheme());
+    }
+
+    @Override
+    public Resource create(ResourceProperties properties) throws UnsupportedResourcePropertiesException {
+        assert accepts(properties);
+        return new ClasspathResource(properties.getUri().getPath());
+    }
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/52c3dafc/core/src/main/java/org/apache/metamodel/factory/DataContextFactory.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/factory/DataContextFactory.java b/core/src/main/java/org/apache/metamodel/factory/DataContextFactory.java
new file mode 100644
index 0000000..b9f8e3e
--- /dev/null
+++ b/core/src/main/java/org/apache/metamodel/factory/DataContextFactory.java
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.metamodel.factory;
+
+import org.apache.metamodel.ConnectionException;
+import org.apache.metamodel.DataContext;
+
+public interface DataContextFactory {
+
+    public boolean accepts(DataContextProperties properties, ResourceFactoryRegistry resourceFactoryRegistry);
+
+    public DataContext create(DataContextProperties properties, ResourceFactoryRegistry resourceFactoryRegistry)
+            throws UnsupportedDataContextPropertiesException, ConnectionException;
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/52c3dafc/core/src/main/java/org/apache/metamodel/factory/DataContextFactoryRegistry.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/factory/DataContextFactoryRegistry.java b/core/src/main/java/org/apache/metamodel/factory/DataContextFactoryRegistry.java
new file mode 100644
index 0000000..79af1ab
--- /dev/null
+++ b/core/src/main/java/org/apache/metamodel/factory/DataContextFactoryRegistry.java
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.metamodel.factory;
+
+import java.util.Collection;
+
+import org.apache.metamodel.ConnectionException;
+import org.apache.metamodel.DataContext;
+
+/**
+ * Represents a registry of {@link DataContextFactory} objects. This registry
+ * can be used to create {@link DataContext}s of varying types using the
+ * underlying factories.
+ */
+public interface DataContextFactoryRegistry {
+
+    public void addFactory(DataContextFactory factory);
+
+    public void clearFactories();
+
+    public Collection<DataContextFactory> getFactories();
+
+    public DataContext createDataContext(DataContextProperties properties)
+            throws UnsupportedDataContextPropertiesException, ConnectionException;
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/52c3dafc/core/src/main/java/org/apache/metamodel/factory/DataContextFactoryRegistryImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/factory/DataContextFactoryRegistryImpl.java b/core/src/main/java/org/apache/metamodel/factory/DataContextFactoryRegistryImpl.java
new file mode 100644
index 0000000..0dfb897
--- /dev/null
+++ b/core/src/main/java/org/apache/metamodel/factory/DataContextFactoryRegistryImpl.java
@@ -0,0 +1,84 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.metamodel.factory;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.ServiceLoader;
+
+import org.apache.metamodel.DataContext;
+
+public class DataContextFactoryRegistryImpl implements DataContextFactoryRegistry {
+
+    private static final DataContextFactoryRegistry DEFAULT_INSTANCE;
+
+    static {
+        final ResourceFactoryRegistry resourceFactoryRegistry = ResourceFactoryRegistryImpl.getDefaultInstance();
+        final DataContextFactoryRegistryImpl registry = new DataContextFactoryRegistryImpl(resourceFactoryRegistry);
+        registry.discoverFromClasspath();
+        DEFAULT_INSTANCE = registry;
+    }
+
+    public static DataContextFactoryRegistry getDefaultInstance() {
+        return DEFAULT_INSTANCE;
+    }
+
+    private final List<DataContextFactory> factories;
+    private final ResourceFactoryRegistry resourceFactoryRegistry;
+
+    public DataContextFactoryRegistryImpl(ResourceFactoryRegistry resourceFactoryRegistry) {
+        this.factories = new ArrayList<>();
+        this.resourceFactoryRegistry = resourceFactoryRegistry;
+    }
+
+    @Override
+    public void addFactory(DataContextFactory factory) {
+        factories.add(factory);
+    }
+
+    @Override
+    public void clearFactories() {
+        factories.clear();
+    }
+
+    @Override
+    public Collection<DataContextFactory> getFactories() {
+        return Collections.unmodifiableList(factories);
+    }
+
+    @Override
+    public DataContext createDataContext(DataContextProperties properties)
+            throws UnsupportedDataContextPropertiesException {
+        for (DataContextFactory factory : factories) {
+            if (factory.accepts(properties, resourceFactoryRegistry)) {
+                return factory.create(properties, resourceFactoryRegistry);
+            }
+        }
+        throw new UnsupportedDataContextPropertiesException();
+    }
+
+    public void discoverFromClasspath() {
+        final ServiceLoader<DataContextFactory> serviceLoader = ServiceLoader.load(DataContextFactory.class);
+        for (DataContextFactory factory : serviceLoader) {
+            addFactory(factory);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/52c3dafc/core/src/main/java/org/apache/metamodel/factory/DataContextProperties.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/factory/DataContextProperties.java b/core/src/main/java/org/apache/metamodel/factory/DataContextProperties.java
new file mode 100644
index 0000000..5251726
--- /dev/null
+++ b/core/src/main/java/org/apache/metamodel/factory/DataContextProperties.java
@@ -0,0 +1,92 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.metamodel.factory;
+
+import java.io.Serializable;
+import java.util.Map;
+
+import javax.sql.DataSource;
+
+import org.apache.metamodel.DataContext;
+import org.apache.metamodel.schema.TableType;
+import org.apache.metamodel.util.SimpleTableDef;
+
+/**
+ * Represents the {@link Serializable} properties used to fully describe and
+ * construct a {@link DataContext}.
+ */
+public interface DataContextProperties extends Serializable {
+
+    /**
+     * Gets the type of {@link DataContext}, such as "csv" or "jdbc".
+     * 
+     * @return
+     */
+    String getDataContextType();
+
+    /**
+     * Gets all the properties represented as a {@link Map}. Note that any
+     * unstandardized properties may also be exposed via this map.
+     * 
+     * @return
+     */
+    Map<String, Object> toMap();
+
+    ResourceProperties getResourceProperties();
+
+    Integer getColumnNameLineNumber();
+
+    Boolean isSkipEmptyLines();
+
+    Boolean isSkipEmptyColumns();
+
+    String getEncoding();
+
+    Character getSeparatorChar();
+
+    Character getQuoteChar();
+
+    Character getEscapeChar();
+
+    Boolean isFailOnInconsistentRowLength();
+
+    Boolean isMultilineValuesEnabled();
+
+    TableType[] getTableTypes();
+
+    String getCatalogName();
+
+    String getUrl();
+
+    DataSource getDataSource();
+
+    String getUsername();
+
+    String getPassword();
+
+    String getDriverClassName();
+
+    String getHostname();
+
+    Integer getPort();
+
+    String getDatabaseName();
+
+    SimpleTableDef[] getTableDefs();
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/52c3dafc/core/src/main/java/org/apache/metamodel/factory/DataContextPropertiesImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/factory/DataContextPropertiesImpl.java b/core/src/main/java/org/apache/metamodel/factory/DataContextPropertiesImpl.java
new file mode 100644
index 0000000..e66a811
--- /dev/null
+++ b/core/src/main/java/org/apache/metamodel/factory/DataContextPropertiesImpl.java
@@ -0,0 +1,304 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.metamodel.factory;
+
+import java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.sql.DataSource;
+
+import org.apache.metamodel.schema.TableType;
+import org.apache.metamodel.util.BooleanComparator;
+import org.apache.metamodel.util.NumberComparator;
+import org.apache.metamodel.util.SimpleTableDef;
+import org.apache.metamodel.util.SimpleTableDefParser;
+
+public class DataContextPropertiesImpl implements DataContextProperties {
+
+    private static final long serialVersionUID = 1L;
+
+    public static final String PROPERTY_USERNAME = "username";
+    public static final String PROPERTY_PASSWORD = "password";
+    public static final String PROPERTY_DRIVER_CLASS = "driver-class";
+    public static final String PROPERTY_HOSTNAME = "hostname";
+    public static final String PROPERTY_PORT = "port";
+    public static final String PROPERTY_DATABASE = "database";
+    public static final String PROPERTY_URL = "url";
+    public static final String PROPERTY_CATALOG_NAME = "catalog";
+    public static final String PROPERTY_RESOURCE_PROPERTIES = "resource";
+    public static final String PROPERTY_IS_MULTILINE_VALUES_ENABLED = "multiline-values";
+    public static final String PROPERTY_IS_FAIL_ON_INCONSISTENT_ROW_LENGTH = "fail-on-inconsistent-row-length";
+    public static final String PROPERTY_ESCAPE_CHAR = "escape-char";
+    public static final String PROPERTY_QUOTE_CHAR = "quote-char";
+    public static final String PROPERTY_SEPARATOR_CHAR = "separator-char";
+    public static final String PROPERTY_ENCODING = "encoding";
+    public static final String PROPERTY_SKIP_EMPTY_COLUMNS = "skip-empty-columns";
+    public static final String PROPERTY_SKIP_EMPTY_LINES = "skip-empty-lines";
+    public static final String PROPERTY_COLUMN_NAME_LINE_NUMBER = "column-name-line-number";
+    public static final String PROPERTY_DATA_CONTEXT_TYPE = "type";
+    public static final String PROPERTY_TABLE_TYPES = "table-types";
+    public static final String PROPERTY_DATA_SOURCE = "data-source";
+    public static final String PROPERTY_TABLE_DEFS = "table-defs";
+
+    private final Map<String, Object> map;
+
+    public DataContextPropertiesImpl() {
+        this(new HashMap<String, Object>());
+    }
+
+    public DataContextPropertiesImpl(Properties properties) {
+        this();
+        final Set<String> propertyNames = properties.stringPropertyNames();
+        for (String key : propertyNames) {
+            put(key, properties.get(key));
+        }
+    }
+
+    public DataContextPropertiesImpl(Map<String, Object> map) {
+        this.map = map;
+    }
+
+    public Object get(String key) {
+        return map.get(key);
+    }
+
+    public Object put(String key, Object value) {
+        return map.put(key, value);
+    }
+
+    public String getString(String key) {
+        final Object value = map.get(key);
+        if (value == null) {
+            return null;
+        }
+        return value.toString();
+    }
+
+    public Character getChar(String key) {
+        final String str = getString(key);
+        if (str == null || str.isEmpty()) {
+            return null;
+        }
+        return str.charAt(0);
+    }
+
+    public Integer getInt(String key) {
+        final Object obj = get(key);
+        if (obj == null) {
+            return null;
+        }
+        return NumberComparator.toNumber(obj).intValue();
+    }
+
+    private Boolean getBoolean(String key) {
+        final Object obj = get(key);
+        if (obj == null) {
+            return null;
+        }
+        return BooleanComparator.toBoolean(obj);
+    }
+
+    @SuppressWarnings("unchecked")
+    public Map<String, Object> getMap(String key) {
+        final Object obj = get(key);
+        if (obj == null) {
+            return null;
+        }
+        if (obj instanceof Map) {
+            return (Map<String, Object>) obj;
+        }
+        if (obj instanceof String) {
+            // TODO: Try parse as JSON
+        }
+        throw new IllegalStateException("Expected Map value for property '" + key + "'. Found " + obj.getClass()
+                .getName());
+    }
+
+    @Override
+    public String getDataContextType() {
+        return getString(PROPERTY_DATA_CONTEXT_TYPE);
+    }
+
+    public void setDataContextType(String type) {
+        put(PROPERTY_DATA_CONTEXT_TYPE, type);
+    }
+
+    @Override
+    public Map<String, Object> toMap() {
+        return map;
+    }
+
+    @Override
+    public ResourceProperties getResourceProperties() {
+        final Object resourceValue = get(PROPERTY_RESOURCE_PROPERTIES);
+        if (resourceValue == null) {
+            return null;
+        }
+        if (resourceValue instanceof String) {
+            return new SimpleResourceProperties((String) resourceValue);
+        }
+        if (resourceValue instanceof URI) {
+            return new SimpleResourceProperties((URI) resourceValue);
+        }
+        if (resourceValue instanceof Map) {
+            @SuppressWarnings("unchecked")
+            final Map<String, Object> resourceMap = (Map<String, Object>) resourceValue;
+            return new ResourcePropertiesImpl(resourceMap);
+        }
+        throw new IllegalStateException("Expected String, URI or Map value for property 'resource'. Found: "
+                + resourceValue);
+    }
+
+    @Override
+    public Integer getColumnNameLineNumber() {
+        return getInt(PROPERTY_COLUMN_NAME_LINE_NUMBER);
+    }
+
+    @Override
+    public Boolean isSkipEmptyLines() {
+        return getBoolean(PROPERTY_SKIP_EMPTY_LINES);
+    }
+
+    @Override
+    public Boolean isSkipEmptyColumns() {
+        return getBoolean(PROPERTY_SKIP_EMPTY_COLUMNS);
+    }
+
+    @Override
+    public String getEncoding() {
+        return getString(PROPERTY_ENCODING);
+    }
+
+    @Override
+    public Character getSeparatorChar() {
+        return getChar(PROPERTY_SEPARATOR_CHAR);
+    }
+
+    @Override
+    public Character getQuoteChar() {
+        return getChar(PROPERTY_QUOTE_CHAR);
+    }
+
+    @Override
+    public Character getEscapeChar() {
+        return getChar(PROPERTY_ESCAPE_CHAR);
+    }
+
+    @Override
+    public Boolean isFailOnInconsistentRowLength() {
+        return getBoolean(PROPERTY_IS_FAIL_ON_INCONSISTENT_ROW_LENGTH);
+    }
+
+    @Override
+    public Boolean isMultilineValuesEnabled() {
+        return getBoolean(PROPERTY_IS_MULTILINE_VALUES_ENABLED);
+    }
+
+    @Override
+    public TableType[] getTableTypes() {
+        final Object obj = get(PROPERTY_TABLE_TYPES);
+        if (obj == null) {
+            return null;
+        }
+        if (obj instanceof TableType[]) {
+            return (TableType[]) obj;
+        }
+        if (obj instanceof TableType) {
+            return new TableType[] { (TableType) obj };
+        }
+        if (obj instanceof String) {
+            String str = (String) obj;
+            if (str.startsWith("[") && str.endsWith("]")) {
+                str = str.substring(1, str.length() - 2);
+            }
+            final String[] tokens = str.split(",");
+            final TableType[] tableTypes = new TableType[tokens.length];
+            for (int i = 0; i < tableTypes.length; i++) {
+                tableTypes[i] = TableType.getTableType(tokens[i]);
+            }
+        }
+        throw new IllegalStateException("Expected TableType[] value for property '" + PROPERTY_TABLE_TYPES + "'. Found "
+                + obj.getClass().getName());
+    }
+
+    @Override
+    public String getCatalogName() {
+        return getString(PROPERTY_CATALOG_NAME);
+    }
+
+    @Override
+    public String getUrl() {
+        return getString(PROPERTY_URL);
+    }
+
+    @Override
+    public DataSource getDataSource() {
+        return (DataSource) get(PROPERTY_DATA_SOURCE);
+    }
+
+    @Override
+    public String getUsername() {
+        return getString(PROPERTY_USERNAME);
+    }
+
+    @Override
+    public String getPassword() {
+        return getString(PROPERTY_PASSWORD);
+    }
+
+    @Override
+    public String getDriverClassName() {
+        return getString(PROPERTY_DRIVER_CLASS);
+    }
+
+    @Override
+    public String getHostname() {
+        return getString(PROPERTY_HOSTNAME);
+    }
+
+    @Override
+    public Integer getPort() {
+        return getInt(PROPERTY_PORT);
+    }
+
+    @Override
+    public String getDatabaseName() {
+        return getString(PROPERTY_DATABASE);
+    }
+
+    @Override
+    public SimpleTableDef[] getTableDefs() {
+        final Object obj = get(PROPERTY_TABLE_DEFS);
+        if (obj instanceof SimpleTableDef[]) {
+            return (SimpleTableDef[]) obj;
+        }
+        if (obj instanceof SimpleTableDef) {
+            return new SimpleTableDef[] { (SimpleTableDef) obj };
+        }
+        if (obj instanceof String) {
+            return SimpleTableDefParser.parseTableDefs((String) obj);
+        }
+        throw new IllegalStateException("Expected SimpleTableDef[] value for property '" + PROPERTY_TABLE_DEFS
+                + "'. Found " + obj.getClass().getName());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/52c3dafc/core/src/main/java/org/apache/metamodel/factory/FileResourceFactory.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/factory/FileResourceFactory.java b/core/src/main/java/org/apache/metamodel/factory/FileResourceFactory.java
new file mode 100644
index 0000000..8da1815
--- /dev/null
+++ b/core/src/main/java/org/apache/metamodel/factory/FileResourceFactory.java
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.metamodel.factory;
+
+import org.apache.metamodel.util.FileResource;
+import org.apache.metamodel.util.Resource;
+
+public class FileResourceFactory implements ResourceFactory {
+
+    @Override
+    public boolean accepts(ResourceProperties properties) {
+        final String scheme = properties.getUri().getScheme();
+        return scheme == null || "file".equals(scheme);
+    }
+
+    @Override
+    public Resource create(ResourceProperties properties) throws UnsupportedResourcePropertiesException {
+        assert accepts(properties);
+        final String path = properties.getUri().getPath();
+        return new FileResource(path);
+    }
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/52c3dafc/core/src/main/java/org/apache/metamodel/factory/InMemoryResourceFactory.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/factory/InMemoryResourceFactory.java b/core/src/main/java/org/apache/metamodel/factory/InMemoryResourceFactory.java
new file mode 100644
index 0000000..8726441
--- /dev/null
+++ b/core/src/main/java/org/apache/metamodel/factory/InMemoryResourceFactory.java
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.metamodel.factory;
+
+import org.apache.metamodel.util.InMemoryResource;
+import org.apache.metamodel.util.Resource;
+
+public class InMemoryResourceFactory implements ResourceFactory {
+
+    @Override
+    public boolean accepts(ResourceProperties properties) {
+        return "mem".equals(properties.getUri().getScheme());
+    }
+
+    @Override
+    public Resource create(ResourceProperties properties) throws UnsupportedResourcePropertiesException {
+        assert accepts(properties);
+        return new InMemoryResource(properties.getUri().getPath());
+    }
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/52c3dafc/core/src/main/java/org/apache/metamodel/factory/ResourceFactory.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/factory/ResourceFactory.java b/core/src/main/java/org/apache/metamodel/factory/ResourceFactory.java
new file mode 100644
index 0000000..f128596
--- /dev/null
+++ b/core/src/main/java/org/apache/metamodel/factory/ResourceFactory.java
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.metamodel.factory;
+
+import org.apache.metamodel.util.Resource;
+
+public interface ResourceFactory {
+
+    public boolean accepts(ResourceProperties properties);
+
+    public Resource create(ResourceProperties properties) throws UnsupportedResourcePropertiesException;
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/52c3dafc/core/src/main/java/org/apache/metamodel/factory/ResourceFactoryRegistry.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/factory/ResourceFactoryRegistry.java b/core/src/main/java/org/apache/metamodel/factory/ResourceFactoryRegistry.java
new file mode 100644
index 0000000..2815787
--- /dev/null
+++ b/core/src/main/java/org/apache/metamodel/factory/ResourceFactoryRegistry.java
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.metamodel.factory;
+
+import java.util.Collection;
+
+import org.apache.metamodel.util.Resource;
+
+public interface ResourceFactoryRegistry {
+
+    public void addFactory(ResourceFactory factory);
+
+    public void clearFactories();
+
+    public Collection<ResourceFactory> getFactories();
+
+    public Resource createResource(ResourceProperties properties) throws UnsupportedResourcePropertiesException;
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/52c3dafc/core/src/main/java/org/apache/metamodel/factory/ResourceFactoryRegistryImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/factory/ResourceFactoryRegistryImpl.java b/core/src/main/java/org/apache/metamodel/factory/ResourceFactoryRegistryImpl.java
new file mode 100644
index 0000000..b8fae41
--- /dev/null
+++ b/core/src/main/java/org/apache/metamodel/factory/ResourceFactoryRegistryImpl.java
@@ -0,0 +1,80 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.metamodel.factory;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.ServiceLoader;
+
+import org.apache.metamodel.util.Resource;
+
+public class ResourceFactoryRegistryImpl implements ResourceFactoryRegistry {
+
+    private static final ResourceFactoryRegistry DEFAULT_INSTANCE;
+
+    static {
+        final ResourceFactoryRegistryImpl registry = new ResourceFactoryRegistryImpl();
+        registry.discoverFromClasspath();
+        DEFAULT_INSTANCE = registry;
+    }
+
+    public static ResourceFactoryRegistry getDefaultInstance() {
+        return DEFAULT_INSTANCE;
+    }
+
+    private final List<ResourceFactory> factories;
+
+    public ResourceFactoryRegistryImpl() {
+        factories = new ArrayList<>();
+    }
+
+    @Override
+    public void addFactory(ResourceFactory factory) {
+        factories.add(factory);
+    }
+
+    @Override
+    public void clearFactories() {
+        factories.clear();
+    }
+
+    @Override
+    public Collection<ResourceFactory> getFactories() {
+        return Collections.unmodifiableList(factories);
+    }
+
+    @Override
+    public Resource createResource(ResourceProperties properties) {
+        for (ResourceFactory factory : factories) {
+            if (factory.accepts(properties)) {
+                return factory.create(properties);
+            }
+        }
+        throw new UnsupportedResourcePropertiesException();
+    }
+
+    public void discoverFromClasspath() {
+        final ServiceLoader<ResourceFactory> serviceLoader = ServiceLoader.load(ResourceFactory.class);
+        for (ResourceFactory factory : serviceLoader) {
+            addFactory(factory);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/52c3dafc/core/src/main/java/org/apache/metamodel/factory/ResourceProperties.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/factory/ResourceProperties.java b/core/src/main/java/org/apache/metamodel/factory/ResourceProperties.java
new file mode 100644
index 0000000..ab56036
--- /dev/null
+++ b/core/src/main/java/org/apache/metamodel/factory/ResourceProperties.java
@@ -0,0 +1,46 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.metamodel.factory;
+
+import java.io.Serializable;
+import java.net.URI;
+import java.util.Map;
+
+import org.apache.metamodel.util.Resource;
+
+/**
+ * Represents the {@link Serializable} properties used to fully describe and
+ * construct a {@link Resource}.
+ */
+public interface ResourceProperties extends Serializable {
+
+    URI getUri();
+
+    /**
+     * Gets all the properties represented as a {@link Map}. Note that any
+     * unstandardized properties may also be exposed via this map.
+     * 
+     * @return
+     */
+    Map<String, Object> toMap();
+
+    String getUsername();
+
+    String getPassword();
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/52c3dafc/core/src/main/java/org/apache/metamodel/factory/ResourcePropertiesImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/factory/ResourcePropertiesImpl.java b/core/src/main/java/org/apache/metamodel/factory/ResourcePropertiesImpl.java
new file mode 100644
index 0000000..c27bd4f
--- /dev/null
+++ b/core/src/main/java/org/apache/metamodel/factory/ResourcePropertiesImpl.java
@@ -0,0 +1,74 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.metamodel.factory;
+
+import java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
+
+public class ResourcePropertiesImpl implements ResourceProperties {
+
+    private static final long serialVersionUID = 1L;
+
+    private final Map<String, Object> map;
+
+    public ResourcePropertiesImpl() {
+        this(new HashMap<String, Object>());
+    }
+
+    public ResourcePropertiesImpl(Map<String, Object> map) {
+        this.map = map;
+    }
+
+    private String getString(String key) {
+        final Object value = map.get(key);
+        if (value == null) {
+            return null;
+        }
+        return value.toString();
+    }
+
+    @Override
+    public URI getUri() {
+        final Object uri = map.get("uri");
+        if (uri == null) {
+            return null;
+        }
+        if (uri instanceof URI) {
+            return (URI) uri;
+        }
+        return URI.create(uri.toString());
+    }
+
+    @Override
+    public Map<String, Object> toMap() {
+        return map;
+    }
+
+    @Override
+    public String getUsername() {
+        return getString("username");
+    }
+
+    @Override
+    public String getPassword() {
+        return getString("password");
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/52c3dafc/core/src/main/java/org/apache/metamodel/factory/SimpleResourceProperties.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/factory/SimpleResourceProperties.java b/core/src/main/java/org/apache/metamodel/factory/SimpleResourceProperties.java
new file mode 100644
index 0000000..7298454
--- /dev/null
+++ b/core/src/main/java/org/apache/metamodel/factory/SimpleResourceProperties.java
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.metamodel.factory;
+
+import java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
+
+public class SimpleResourceProperties implements ResourceProperties {
+
+    private static final long serialVersionUID = 1L;
+    private final URI uri;
+
+    public SimpleResourceProperties(URI uri) {
+        this.uri = uri;
+    }
+
+    public SimpleResourceProperties(String uri) {
+        this.uri = URI.create(uri);
+    }
+
+    @Override
+    public URI getUri() {
+        return uri;
+    }
+
+    @Override
+    public Map<String, Object> toMap() {
+        final Map<String, Object> map = new HashMap<>();
+        map.put("uri", uri);
+        return map;
+    }
+
+    @Override
+    public String getUsername() {
+        return null;
+    }
+
+    @Override
+    public String getPassword() {
+        return null;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/52c3dafc/core/src/main/java/org/apache/metamodel/factory/UnsupportedDataContextPropertiesException.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/factory/UnsupportedDataContextPropertiesException.java b/core/src/main/java/org/apache/metamodel/factory/UnsupportedDataContextPropertiesException.java
new file mode 100644
index 0000000..225fa72
--- /dev/null
+++ b/core/src/main/java/org/apache/metamodel/factory/UnsupportedDataContextPropertiesException.java
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.metamodel.factory;
+
+import org.apache.metamodel.MetaModelException;
+
+/**
+ * Exception thrown if a {@link DataContextFactory} or
+ * {@link DataContextFactoryRegistry} is being invoked with
+ * {@link DataContextProperties} that are not supported by the implementation.
+ */
+public class UnsupportedDataContextPropertiesException extends MetaModelException {
+
+    private static final long serialVersionUID = 1L;
+
+    public UnsupportedDataContextPropertiesException() {
+        super();
+    }
+
+    public UnsupportedDataContextPropertiesException(Exception cause) {
+        super(cause);
+    }
+
+    public UnsupportedDataContextPropertiesException(String message, Exception cause) {
+        super(message, cause);
+    }
+
+    public UnsupportedDataContextPropertiesException(String message) {
+        super(message);
+    }
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/52c3dafc/core/src/main/java/org/apache/metamodel/factory/UnsupportedResourcePropertiesException.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/factory/UnsupportedResourcePropertiesException.java b/core/src/main/java/org/apache/metamodel/factory/UnsupportedResourcePropertiesException.java
new file mode 100644
index 0000000..abf51bb
--- /dev/null
+++ b/core/src/main/java/org/apache/metamodel/factory/UnsupportedResourcePropertiesException.java
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.metamodel.factory;
+
+import org.apache.metamodel.MetaModelException;
+
+public class UnsupportedResourcePropertiesException extends MetaModelException {
+
+    private static final long serialVersionUID = 1L;
+
+    public UnsupportedResourcePropertiesException() {
+        super();
+    }
+
+    public UnsupportedResourcePropertiesException(Exception cause) {
+        super(cause);
+    }
+
+    public UnsupportedResourcePropertiesException(String message, Exception cause) {
+        super(message, cause);
+    }
+
+    public UnsupportedResourcePropertiesException(String message) {
+        super(message);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/52c3dafc/core/src/main/java/org/apache/metamodel/factory/UrlResourceFactory.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/factory/UrlResourceFactory.java b/core/src/main/java/org/apache/metamodel/factory/UrlResourceFactory.java
new file mode 100644
index 0000000..fbca8f1
--- /dev/null
+++ b/core/src/main/java/org/apache/metamodel/factory/UrlResourceFactory.java
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.metamodel.factory;
+
+import java.net.MalformedURLException;
+import java.net.URI;
+
+import org.apache.metamodel.util.Resource;
+import org.apache.metamodel.util.UrlResource;
+
+public class UrlResourceFactory implements ResourceFactory {
+
+    @Override
+    public boolean accepts(ResourceProperties properties) {
+        final URI uri = properties.getUri();
+        switch (uri.getScheme()) {
+        case "http":
+        case "https":
+            return true;
+        }
+        return false;
+    }
+
+    @Override
+    public Resource create(ResourceProperties properties) throws UnsupportedResourcePropertiesException {
+        try {
+            return new UrlResource(properties.getUri().toURL());
+        } catch (MalformedURLException e) {
+            throw new UnsupportedResourcePropertiesException(e);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/52c3dafc/core/src/main/java/org/apache/metamodel/util/ResourceUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/metamodel/util/ResourceUtils.java b/core/src/main/java/org/apache/metamodel/util/ResourceUtils.java
index ad3426a..9e2faea 100644
--- a/core/src/main/java/org/apache/metamodel/util/ResourceUtils.java
+++ b/core/src/main/java/org/apache/metamodel/util/ResourceUtils.java
@@ -18,12 +18,57 @@
  */
 package org.apache.metamodel.util;
 
+import java.net.URI;
+
+import org.apache.metamodel.factory.ResourceFactoryRegistryImpl;
+import org.apache.metamodel.factory.ResourceProperties;
+import org.apache.metamodel.factory.SimpleResourceProperties;
+import org.apache.metamodel.factory.UnsupportedResourcePropertiesException;
+
 /**
  * Static utility methods for handling {@link Resource}s.
  */
 public class ResourceUtils {
 
     /**
+     * Creates a Resource based on a URI
+     * 
+     * @param uri
+     * @return
+     * @throws UnsupportedResourcePropertiesException
+     *             if the scheme or other part of the URI is unsupported.
+     */
+    public static Resource toResource(URI uri) throws UnsupportedResourcePropertiesException {
+        return toResource(new SimpleResourceProperties(uri));
+    }
+
+    /**
+     * Creates a Resource based on a path or URI (represented by a String)
+     * 
+     * @param uri
+     * @return
+     * @throws UnsupportedResourcePropertiesException
+     *             if the scheme or other part of the string is unsupported.
+     */
+    public static Resource toResource(String uri) throws UnsupportedResourcePropertiesException {
+        return toResource(new SimpleResourceProperties(uri));
+    }
+
+    /**
+     * Creates a Resource based on the {@link ResourceProperties} definition.
+     * 
+     * @param resourceProperties
+     * @return
+     * @throws UnsupportedResourcePropertiesException
+     *             if the provided properties cannot be handled in creation of a
+     *             resource.
+     */
+    public static Resource toResource(ResourceProperties resourceProperties)
+            throws UnsupportedResourcePropertiesException {
+        return ResourceFactoryRegistryImpl.getDefaultInstance().createResource(resourceProperties);
+    }
+
+    /**
      * Gets the parent name of a resource. For example, if the resource's
      * qualified path is /foo/bar/baz, this method will return "bar".
      * 

http://git-wip-us.apache.org/repos/asf/metamodel/blob/52c3dafc/core/src/main/resources/META-INF/services/org.apache.metamodel.factory.ResourceFactory
----------------------------------------------------------------------
diff --git a/core/src/main/resources/META-INF/services/org.apache.metamodel.factory.ResourceFactory b/core/src/main/resources/META-INF/services/org.apache.metamodel.factory.ResourceFactory
new file mode 100644
index 0000000..5bb0b9e
--- /dev/null
+++ b/core/src/main/resources/META-INF/services/org.apache.metamodel.factory.ResourceFactory
@@ -0,0 +1,4 @@
+org.apache.metamodel.factory.FileResourceFactory
+org.apache.metamodel.factory.ClasspathResourceFactory
+org.apache.metamodel.factory.UrlResourceFactory
+org.apache.metamodel.factory.InMemoryResourceFactory

http://git-wip-us.apache.org/repos/asf/metamodel/blob/52c3dafc/core/src/test/java/org/apache/metamodel/factory/ResourceFactoryRegistryImplTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/metamodel/factory/ResourceFactoryRegistryImplTest.java b/core/src/test/java/org/apache/metamodel/factory/ResourceFactoryRegistryImplTest.java
new file mode 100644
index 0000000..0122253
--- /dev/null
+++ b/core/src/test/java/org/apache/metamodel/factory/ResourceFactoryRegistryImplTest.java
@@ -0,0 +1,72 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.metamodel.factory;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+
+import org.apache.metamodel.util.ClasspathResource;
+import org.apache.metamodel.util.InMemoryResource;
+import org.apache.metamodel.util.Resource;
+import org.apache.metamodel.util.UrlResource;
+import org.junit.Test;
+
+public class ResourceFactoryRegistryImplTest {
+
+    private final ResourceFactoryRegistry registry = ResourceFactoryRegistryImpl.getDefaultInstance();
+
+    @Test
+    public void testGetQualifiedFileResource() throws Exception {
+        final File file = new File("src/test/resources/unicode-text-utf8.txt");
+        final Resource res = registry.createResource(new SimpleResourceProperties("file:///" + file.getAbsolutePath()));
+        assertTrue(res.isExists());
+        assertEquals("unicode-text-utf8.txt", res.getName());
+    }
+
+    @Test
+    public void testGetUnqualifiedRelativeFileResource() throws Exception {
+        final Resource res = registry.createResource(new SimpleResourceProperties(
+                "src/test/resources/unicode-text-utf8.txt"));
+        assertTrue(res.isExists());
+        assertEquals("unicode-text-utf8.txt", res.getName());
+    }
+
+    @Test
+    public void testGetInMemoryResource() throws Exception {
+        final Resource res = registry.createResource(new SimpleResourceProperties("mem:///foo.bar.txt"));
+        assertTrue(res instanceof InMemoryResource);
+    }
+
+    @Test
+    public void testGetClasspathResource() throws Exception {
+        final Resource res = registry.createResource(new SimpleResourceProperties("classpath:///folder/foo"));
+        assertTrue(res.isExists());
+        assertTrue(res instanceof ClasspathResource);
+    }
+
+    @Test
+    public void testGetUrlResource() throws Exception {
+        final Resource res = registry.createResource(new SimpleResourceProperties(
+                "http://metamodel.apache.org/robots.txt"));
+        assertTrue(res.isExists());
+        assertTrue(res instanceof UrlResource);
+    }
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/52c3dafc/core/src/test/java/org/apache/metamodel/util/UrlResourceTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/metamodel/util/UrlResourceTest.java b/core/src/test/java/org/apache/metamodel/util/UrlResourceTest.java
index 8478253..8054d8d 100644
--- a/core/src/test/java/org/apache/metamodel/util/UrlResourceTest.java
+++ b/core/src/test/java/org/apache/metamodel/util/UrlResourceTest.java
@@ -23,10 +23,10 @@ import junit.framework.TestCase;
 public class UrlResourceTest extends TestCase {
 
     public void testGetName() throws Exception {
-        UrlResource resource = new UrlResource("http://eobjects.org/foo.txt");
-        assertEquals("foo.txt", resource.getName());
+        UrlResource resource = new UrlResource("http://metamodel.apache.org/robots.txt");
+        assertEquals("robots.txt", resource.getName());
         
-        resource = new UrlResource("http://eobjects.org/");
-        assertEquals("http://eobjects.org/", resource.getName());
+        resource = new UrlResource("http://metamodel.apache.org/");
+        assertEquals("http://metamodel.apache.org/", resource.getName());
     }
 }

http://git-wip-us.apache.org/repos/asf/metamodel/blob/52c3dafc/csv/src/main/java/org/apache/metamodel/csv/CsvDataContextFactory.java
----------------------------------------------------------------------
diff --git a/csv/src/main/java/org/apache/metamodel/csv/CsvDataContextFactory.java b/csv/src/main/java/org/apache/metamodel/csv/CsvDataContextFactory.java
new file mode 100644
index 0000000..105fd5b
--- /dev/null
+++ b/csv/src/main/java/org/apache/metamodel/csv/CsvDataContextFactory.java
@@ -0,0 +1,73 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.metamodel.csv;
+
+import org.apache.metamodel.DataContext;
+import org.apache.metamodel.factory.DataContextFactory;
+import org.apache.metamodel.factory.DataContextProperties;
+import org.apache.metamodel.factory.ResourceFactoryRegistry;
+import org.apache.metamodel.util.FileHelper;
+import org.apache.metamodel.util.Resource;
+
+public class CsvDataContextFactory implements DataContextFactory {
+
+    public static final String PROPERTY_TYPE = "csv";
+
+    @Override
+    public boolean accepts(DataContextProperties properties, ResourceFactoryRegistry resourceFactoryRegistry) {
+        return PROPERTY_TYPE.equals(properties.getDataContextType());
+    }
+
+    @Override
+    public DataContext create(DataContextProperties properties, ResourceFactoryRegistry resourceFactoryRegistry) {
+        assert accepts(properties, resourceFactoryRegistry);
+
+        final Resource resource = resourceFactoryRegistry.createResource(properties.getResourceProperties());
+
+        final int columnNameLineNumber = getInt(properties.getColumnNameLineNumber(),
+                CsvConfiguration.DEFAULT_COLUMN_NAME_LINE);
+        final String encoding = getString(properties.getEncoding(), FileHelper.DEFAULT_ENCODING);
+        final char separatorChar = getChar(properties.getSeparatorChar(), CsvConfiguration.DEFAULT_SEPARATOR_CHAR);
+        final char quoteChar = getChar(properties.getQuoteChar(), CsvConfiguration.DEFAULT_QUOTE_CHAR);
+        final char escapeChar = getChar(properties.getEscapeChar(), CsvConfiguration.DEFAULT_ESCAPE_CHAR);
+        final boolean failOnInconsistentRowLength = getBoolean(properties.isFailOnInconsistentRowLength(), false);
+        final boolean multilineValuesEnabled = getBoolean(properties.isMultilineValuesEnabled(), true);
+
+        final CsvConfiguration configuration = new CsvConfiguration(columnNameLineNumber, encoding, separatorChar,
+                quoteChar, escapeChar, failOnInconsistentRowLength, multilineValuesEnabled);
+        return new CsvDataContext(resource, configuration);
+    }
+
+    private String getString(String value, String ifNull) {
+        return value == null ? ifNull : value;
+    }
+
+    private int getInt(Integer value, int ifNull) {
+        return value == null ? ifNull : value;
+    }
+
+    private boolean getBoolean(Boolean value, boolean ifNull) {
+        return value == null ? ifNull : value;
+    }
+
+    private char getChar(Character value, char ifNull) {
+        return value == null ? ifNull : value;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/52c3dafc/csv/src/main/resources/META-INF/services/org.apache.metamodel.factory.DataContextFactory
----------------------------------------------------------------------
diff --git a/csv/src/main/resources/META-INF/services/org.apache.metamodel.factory.DataContextFactory b/csv/src/main/resources/META-INF/services/org.apache.metamodel.factory.DataContextFactory
new file mode 100644
index 0000000..28857ad
--- /dev/null
+++ b/csv/src/main/resources/META-INF/services/org.apache.metamodel.factory.DataContextFactory
@@ -0,0 +1 @@
+org.apache.metamodel.csv.CsvDataContextFactory
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/metamodel/blob/52c3dafc/csv/src/test/java/org/apache/metamodel/csv/CsvDataContextFactoryTest.java
----------------------------------------------------------------------
diff --git a/csv/src/test/java/org/apache/metamodel/csv/CsvDataContextFactoryTest.java b/csv/src/test/java/org/apache/metamodel/csv/CsvDataContextFactoryTest.java
new file mode 100644
index 0000000..bd92a73
--- /dev/null
+++ b/csv/src/test/java/org/apache/metamodel/csv/CsvDataContextFactoryTest.java
@@ -0,0 +1,57 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.metamodel.csv;
+
+import java.util.Collection;
+
+import org.apache.metamodel.factory.DataContextFactory;
+import org.apache.metamodel.factory.DataContextFactoryRegistryImpl;
+import org.apache.metamodel.factory.DataContextPropertiesImpl;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class CsvDataContextFactoryTest {
+
+    @Test
+    public void testDiscovery() throws Exception {
+        final Collection<DataContextFactory> factories = DataContextFactoryRegistryImpl.getDefaultInstance()
+                .getFactories();
+
+        boolean found = false;
+        for (DataContextFactory factory : factories) {
+            if (factory instanceof CsvDataContextFactory) {
+                found = true;
+                break;
+            }
+        }
+
+        if (!found) {
+            Assert.fail("Expected to find CsvDataContextFactory. Found: " + factories);
+        }
+    }
+
+    @Test
+    public void testCreateDataContext() throws Exception {
+        final DataContextPropertiesImpl properties = new DataContextPropertiesImpl();
+        properties.put("type", "csv");
+        properties.put("resource", "src/test/resources/csv_people.csv");
+
+        DataContextFactoryRegistryImpl.getDefaultInstance().createDataContext(properties);
+    }
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/52c3dafc/hadoop/src/main/java/org/apache/metamodel/hadoop/HdfsResourceFactory.java
----------------------------------------------------------------------
diff --git a/hadoop/src/main/java/org/apache/metamodel/hadoop/HdfsResourceFactory.java b/hadoop/src/main/java/org/apache/metamodel/hadoop/HdfsResourceFactory.java
new file mode 100644
index 0000000..767937d
--- /dev/null
+++ b/hadoop/src/main/java/org/apache/metamodel/hadoop/HdfsResourceFactory.java
@@ -0,0 +1,46 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.metamodel.hadoop;
+
+import org.apache.metamodel.factory.ResourceFactory;
+import org.apache.metamodel.factory.ResourceProperties;
+import org.apache.metamodel.factory.UnsupportedResourcePropertiesException;
+import org.apache.metamodel.util.HdfsResource;
+import org.apache.metamodel.util.Resource;
+
+public class HdfsResourceFactory implements ResourceFactory {
+
+    /**
+     * Property that can be used
+     */
+    public static final String PROPERTY_HADOOP_CONF_DIR = "hadoop-conf-dir";
+
+    @Override
+    public boolean accepts(ResourceProperties properties) {
+        return "hdfs".equals(properties.getUri().getScheme());
+    }
+
+    @Override
+    public Resource create(ResourceProperties properties) throws UnsupportedResourcePropertiesException {
+        final Object hadoopConfDirProperty = properties.toMap().get(PROPERTY_HADOOP_CONF_DIR);
+        final String hadoopConfDir = hadoopConfDirProperty == null ? null : hadoopConfDirProperty.toString();
+        return new HdfsResource(properties.getUri().toString(), hadoopConfDir);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/52c3dafc/hadoop/src/main/resources/META-INF/services/org.apache.metamodel.factory.ResourceFactory
----------------------------------------------------------------------
diff --git a/hadoop/src/main/resources/META-INF/services/org.apache.metamodel.factory.ResourceFactory b/hadoop/src/main/resources/META-INF/services/org.apache.metamodel.factory.ResourceFactory
new file mode 100644
index 0000000..a66dba0
--- /dev/null
+++ b/hadoop/src/main/resources/META-INF/services/org.apache.metamodel.factory.ResourceFactory
@@ -0,0 +1 @@
+org.apache.metamodel.hadoop.HdfsResourceFactory

http://git-wip-us.apache.org/repos/asf/metamodel/blob/52c3dafc/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcDataContextFactory.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcDataContextFactory.java b/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcDataContextFactory.java
new file mode 100644
index 0000000..2dfe81d
--- /dev/null
+++ b/jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcDataContextFactory.java
@@ -0,0 +1,86 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.metamodel.jdbc;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+
+import javax.sql.DataSource;
+
+import org.apache.metamodel.ConnectionException;
+import org.apache.metamodel.DataContext;
+import org.apache.metamodel.factory.DataContextFactory;
+import org.apache.metamodel.factory.DataContextProperties;
+import org.apache.metamodel.factory.ResourceFactoryRegistry;
+import org.apache.metamodel.schema.TableType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class JdbcDataContextFactory implements DataContextFactory {
+
+    private static final Logger logger = LoggerFactory.getLogger(JdbcDataContextFactory.class);
+
+    public static final String PROPERTY_TYPE = "jdbc";
+
+    @Override
+    public boolean accepts(DataContextProperties properties, ResourceFactoryRegistry resourceFactoryRegistry) {
+        return PROPERTY_TYPE.equals(properties.getDataContextType());
+    }
+
+    @Override
+    public DataContext create(DataContextProperties properties, ResourceFactoryRegistry resourceFactoryRegistry)
+            throws ConnectionException {
+        final String driverClassName = properties.getDriverClassName();
+        if (driverClassName != null) {
+            try {
+                Class.forName(driverClassName);
+            } catch (ClassNotFoundException e) {
+                logger.warn("Failed to initialize driver class: {}", driverClassName, e);
+            }
+        }
+
+        final TableType[] tableTypes = properties.getTableTypes() == null ? TableType.DEFAULT_TABLE_TYPES
+                : properties.getTableTypes();
+        final String catalogName = properties.getCatalogName();
+
+        final DataSource dataSource = properties.getDataSource();
+        if (dataSource != null) {
+            return new JdbcDataContext(dataSource, tableTypes, catalogName);
+        }
+
+        final String url = properties.getUrl();
+        final String username = properties.getUsername();
+        final String password = properties.getPassword();
+
+        final Connection connection;
+        try {
+            if (username != null) {
+                connection = DriverManager.getConnection(url, username, password);
+            } else {
+                connection = DriverManager.getConnection(url);
+            }
+        } catch (SQLException e) {
+            throw new ConnectionException("Failed to open JDBC connection from URL: " + url, e);
+        }
+
+        return new JdbcDataContext(connection, tableTypes, catalogName);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/52c3dafc/jdbc/src/main/resources/META-INF/services/org.apache.metamodel.factory.DataContextFactory
----------------------------------------------------------------------
diff --git a/jdbc/src/main/resources/META-INF/services/org.apache.metamodel.factory.DataContextFactory b/jdbc/src/main/resources/META-INF/services/org.apache.metamodel.factory.DataContextFactory
new file mode 100644
index 0000000..c7c4772
--- /dev/null
+++ b/jdbc/src/main/resources/META-INF/services/org.apache.metamodel.factory.DataContextFactory
@@ -0,0 +1 @@
+org.apache.metamodel.jdbc.JdbcDataContextFactory
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/metamodel/blob/52c3dafc/jdbc/src/test/java/org/apache/metamodel/jdbc/H2databaseTest.java
----------------------------------------------------------------------
diff --git a/jdbc/src/test/java/org/apache/metamodel/jdbc/H2databaseTest.java b/jdbc/src/test/java/org/apache/metamodel/jdbc/H2databaseTest.java
index 6560247..6e21ae5 100644
--- a/jdbc/src/test/java/org/apache/metamodel/jdbc/H2databaseTest.java
+++ b/jdbc/src/test/java/org/apache/metamodel/jdbc/H2databaseTest.java
@@ -26,8 +26,6 @@ import java.util.Arrays;
 import java.util.List;
 import java.util.concurrent.TimeUnit;
 
-import junit.framework.TestCase;
-
 import org.apache.metamodel.UpdateCallback;
 import org.apache.metamodel.UpdateScript;
 import org.apache.metamodel.create.CreateTable;
@@ -48,10 +46,15 @@ import org.apache.metamodel.schema.Table;
 import org.apache.metamodel.update.Update;
 import org.apache.metamodel.util.MutableRef;
 
+import junit.framework.TestCase;
+
 /**
  * Test case that tests interaction with the H2 embedded database
  */
 public class H2databaseTest extends TestCase {
+    
+    public static final String DRIVER_CLASS = "org.h2.Driver";
+    public static final String URL_MEMORY_DATABASE = "jdbc:h2:mem:";
 
     private final String[] FIRST_NAMES = { "Suzy", "Barbara", "John", "Ken", "Billy", "Larry", "Joe", "Margareth", "Bobby",
             "Elizabeth" };
@@ -62,8 +65,8 @@ public class H2databaseTest extends TestCase {
     @Override
     protected void setUp() throws Exception {
         super.setUp();
-        Class.forName("org.h2.Driver");
-        conn = DriverManager.getConnection("jdbc:h2:mem:");
+        Class.forName(DRIVER_CLASS);
+        conn = DriverManager.getConnection(URL_MEMORY_DATABASE);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/metamodel/blob/52c3dafc/jdbc/src/test/java/org/apache/metamodel/jdbc/JdbcDataContextFactoryTest.java
----------------------------------------------------------------------
diff --git a/jdbc/src/test/java/org/apache/metamodel/jdbc/JdbcDataContextFactoryTest.java b/jdbc/src/test/java/org/apache/metamodel/jdbc/JdbcDataContextFactoryTest.java
new file mode 100644
index 0000000..9511164
--- /dev/null
+++ b/jdbc/src/test/java/org/apache/metamodel/jdbc/JdbcDataContextFactoryTest.java
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.metamodel.jdbc;
+
+import static org.junit.Assert.assertTrue;
+
+import org.apache.metamodel.DataContext;
+import org.apache.metamodel.factory.DataContextFactoryRegistryImpl;
+import org.apache.metamodel.factory.DataContextPropertiesImpl;
+import org.apache.metamodel.jdbc.dialects.H2QueryRewriter;
+import org.junit.Test;
+
+public class JdbcDataContextFactoryTest {
+
+    @Test
+    public void testCreateDataContext() throws Exception {
+        final DataContextPropertiesImpl properties = new DataContextPropertiesImpl();
+        properties.setDataContextType("jdbc");
+        properties.put("driver-class", H2databaseTest.DRIVER_CLASS);
+        properties.put("url", H2databaseTest.URL_MEMORY_DATABASE);
+
+        final DataContext dataContext = DataContextFactoryRegistryImpl.getDefaultInstance().createDataContext(
+                properties);
+        assertTrue(dataContext instanceof JdbcDataContext);
+
+        final JdbcDataContext jdbcDataContext = (JdbcDataContext) dataContext;
+        assertTrue(jdbcDataContext.getQueryRewriter() instanceof H2QueryRewriter);
+    }
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/52c3dafc/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index dad89f2..95ed697 100644
--- a/pom.xml
+++ b/pom.xml
@@ -376,6 +376,7 @@ under the License.
 							<exclude>**/src/assembly/metamodel-packaged-assembly-descriptor.xml</exclude>
 							<exclude>**/.gitignore/**</exclude>
 							<exclude>.git/**</exclude>
+							<exclude>**/src/main/resources/META-INF/services/**</exclude>
 							<exclude>**/src/test/resources/**</exclude>
 							<exclude>**/src/site/**</exclude>
 							<exclude>**/.project</exclude>


[03/16] metamodel git commit: [maven-release-plugin] prepare release MetaModel-4.5.3

Posted by ka...@apache.org.
[maven-release-plugin] prepare release MetaModel-4.5.3


Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/1a1dc0d8
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/1a1dc0d8
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/1a1dc0d8

Branch: refs/heads/feature/5.x/swagger-docs
Commit: 1a1dc0d8570b6d02579e43041601293868358817
Parents: d16d4f1
Author: kaspersorensen <i....@gmail.com>
Authored: Mon May 16 11:13:58 2016 -0700
Committer: kaspersorensen <i....@gmail.com>
Committed: Mon May 16 11:13:58 2016 -0700

----------------------------------------------------------------------
 cassandra/pom.xml            | 2 +-
 core/pom.xml                 | 2 +-
 couchdb/pom.xml              | 2 +-
 csv/pom.xml                  | 2 +-
 elasticsearch/common/pom.xml | 2 +-
 elasticsearch/native/pom.xml | 2 +-
 elasticsearch/pom.xml        | 2 +-
 elasticsearch/rest/pom.xml   | 2 +-
 excel/pom.xml                | 2 +-
 fixedwidth/pom.xml           | 2 +-
 full/pom.xml                 | 2 +-
 hadoop/pom.xml               | 2 +-
 hbase/pom.xml                | 2 +-
 jdbc/pom.xml                 | 2 +-
 json/pom.xml                 | 2 +-
 mongodb/common/pom.xml       | 2 +-
 mongodb/mongo2/pom.xml       | 2 +-
 mongodb/mongo3/pom.xml       | 2 +-
 mongodb/pom.xml              | 2 +-
 neo4j/pom.xml                | 2 +-
 openoffice/pom.xml           | 2 +-
 pojo/pom.xml                 | 2 +-
 pom.xml                      | 4 ++--
 salesforce/pom.xml           | 2 +-
 spring/pom.xml               | 2 +-
 sugarcrm/pom.xml             | 2 +-
 xml/pom.xml                  | 2 +-
 27 files changed, 28 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/1a1dc0d8/cassandra/pom.xml
----------------------------------------------------------------------
diff --git a/cassandra/pom.xml b/cassandra/pom.xml
index c622e75..9fa6e15 100644
--- a/cassandra/pom.xml
+++ b/cassandra/pom.xml
@@ -13,7 +13,7 @@
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3-SNAPSHOT</version>
+		<version>4.5.3</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-cassandra</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/1a1dc0d8/core/pom.xml
----------------------------------------------------------------------
diff --git a/core/pom.xml b/core/pom.xml
index a73276e..b38f9ef 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3-SNAPSHOT</version>
+		<version>4.5.3</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-core</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/1a1dc0d8/couchdb/pom.xml
----------------------------------------------------------------------
diff --git a/couchdb/pom.xml b/couchdb/pom.xml
index ed65212..50bb56f 100644
--- a/couchdb/pom.xml
+++ b/couchdb/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3-SNAPSHOT</version>
+		<version>4.5.3</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-couchdb</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/1a1dc0d8/csv/pom.xml
----------------------------------------------------------------------
diff --git a/csv/pom.xml b/csv/pom.xml
index 4aa9b4c..23f4b6a 100644
--- a/csv/pom.xml
+++ b/csv/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3-SNAPSHOT</version>
+		<version>4.5.3</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-csv</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/1a1dc0d8/elasticsearch/common/pom.xml
----------------------------------------------------------------------
diff --git a/elasticsearch/common/pom.xml b/elasticsearch/common/pom.xml
index 615ef42..f922dde 100644
--- a/elasticsearch/common/pom.xml
+++ b/elasticsearch/common/pom.xml
@@ -13,7 +13,7 @@
 	<parent>
 		<artifactId>MetaModel-elasticsearch</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3-SNAPSHOT</version>
+		<version>4.5.3</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 

http://git-wip-us.apache.org/repos/asf/metamodel/blob/1a1dc0d8/elasticsearch/native/pom.xml
----------------------------------------------------------------------
diff --git a/elasticsearch/native/pom.xml b/elasticsearch/native/pom.xml
index c917bb0..c9d4604 100644
--- a/elasticsearch/native/pom.xml
+++ b/elasticsearch/native/pom.xml
@@ -13,7 +13,7 @@
 	<parent>
 		<artifactId>MetaModel-elasticsearch</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3-SNAPSHOT</version>
+		<version>4.5.3</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 

http://git-wip-us.apache.org/repos/asf/metamodel/blob/1a1dc0d8/elasticsearch/pom.xml
----------------------------------------------------------------------
diff --git a/elasticsearch/pom.xml b/elasticsearch/pom.xml
index 7e049be..db3366d 100644
--- a/elasticsearch/pom.xml
+++ b/elasticsearch/pom.xml
@@ -13,7 +13,7 @@
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3-SNAPSHOT</version>
+		<version>4.5.3</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-elasticsearch</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/1a1dc0d8/elasticsearch/rest/pom.xml
----------------------------------------------------------------------
diff --git a/elasticsearch/rest/pom.xml b/elasticsearch/rest/pom.xml
index 92f7393..20a2849 100644
--- a/elasticsearch/rest/pom.xml
+++ b/elasticsearch/rest/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel-elasticsearch</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3-SNAPSHOT</version>
+		<version>4.5.3</version>
 	</parent>
 
 	<modelVersion>4.0.0</modelVersion>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/1a1dc0d8/excel/pom.xml
----------------------------------------------------------------------
diff --git a/excel/pom.xml b/excel/pom.xml
index 6e7f126..1e0d396 100644
--- a/excel/pom.xml
+++ b/excel/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3-SNAPSHOT</version>
+		<version>4.5.3</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-excel</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/1a1dc0d8/fixedwidth/pom.xml
----------------------------------------------------------------------
diff --git a/fixedwidth/pom.xml b/fixedwidth/pom.xml
index 43e4021..ba6f1b0 100644
--- a/fixedwidth/pom.xml
+++ b/fixedwidth/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3-SNAPSHOT</version>
+		<version>4.5.3</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-fixedwidth</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/1a1dc0d8/full/pom.xml
----------------------------------------------------------------------
diff --git a/full/pom.xml b/full/pom.xml
index 83c1855..1fd9162 100644
--- a/full/pom.xml
+++ b/full/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3-SNAPSHOT</version>
+		<version>4.5.3</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-full</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/1a1dc0d8/hadoop/pom.xml
----------------------------------------------------------------------
diff --git a/hadoop/pom.xml b/hadoop/pom.xml
index 8a88e6f..c488daa 100644
--- a/hadoop/pom.xml
+++ b/hadoop/pom.xml
@@ -13,7 +13,7 @@
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3-SNAPSHOT</version>
+		<version>4.5.3</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-hadoop</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/1a1dc0d8/hbase/pom.xml
----------------------------------------------------------------------
diff --git a/hbase/pom.xml b/hbase/pom.xml
index 30cd01d..b7c190b 100644
--- a/hbase/pom.xml
+++ b/hbase/pom.xml
@@ -13,7 +13,7 @@
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3-SNAPSHOT</version>
+		<version>4.5.3</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-hbase</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/1a1dc0d8/jdbc/pom.xml
----------------------------------------------------------------------
diff --git a/jdbc/pom.xml b/jdbc/pom.xml
index 7034e5c..94707f7 100644
--- a/jdbc/pom.xml
+++ b/jdbc/pom.xml
@@ -13,7 +13,7 @@
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3-SNAPSHOT</version>
+		<version>4.5.3</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-jdbc</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/1a1dc0d8/json/pom.xml
----------------------------------------------------------------------
diff --git a/json/pom.xml b/json/pom.xml
index f3e30ac..aec9e02 100644
--- a/json/pom.xml
+++ b/json/pom.xml
@@ -13,7 +13,7 @@
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3-SNAPSHOT</version>
+		<version>4.5.3</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-json</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/1a1dc0d8/mongodb/common/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/common/pom.xml b/mongodb/common/pom.xml
index 850d2f7..234b2d7 100644
--- a/mongodb/common/pom.xml
+++ b/mongodb/common/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel-mongodb</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3-SNAPSHOT</version>
+		<version>4.5.3</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-mongodb-common</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/1a1dc0d8/mongodb/mongo2/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/mongo2/pom.xml b/mongodb/mongo2/pom.xml
index 4905102..1a169ea 100644
--- a/mongodb/mongo2/pom.xml
+++ b/mongodb/mongo2/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel-mongodb</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3-SNAPSHOT</version>
+		<version>4.5.3</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-mongodb-mongo2</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/1a1dc0d8/mongodb/mongo3/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/mongo3/pom.xml b/mongodb/mongo3/pom.xml
index ae53158..059770f 100644
--- a/mongodb/mongo3/pom.xml
+++ b/mongodb/mongo3/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel-mongodb</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3-SNAPSHOT</version>
+		<version>4.5.3</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-mongodb-mongo3</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/1a1dc0d8/mongodb/pom.xml
----------------------------------------------------------------------
diff --git a/mongodb/pom.xml b/mongodb/pom.xml
index d8d6706..fbad461 100644
--- a/mongodb/pom.xml
+++ b/mongodb/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3-SNAPSHOT</version>
+		<version>4.5.3</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-mongodb</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/1a1dc0d8/neo4j/pom.xml
----------------------------------------------------------------------
diff --git a/neo4j/pom.xml b/neo4j/pom.xml
index 037c9b6..91a5a1f 100644
--- a/neo4j/pom.xml
+++ b/neo4j/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3-SNAPSHOT</version>
+		<version>4.5.3</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-neo4j</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/1a1dc0d8/openoffice/pom.xml
----------------------------------------------------------------------
diff --git a/openoffice/pom.xml b/openoffice/pom.xml
index 8b5fbfd..7d86149 100644
--- a/openoffice/pom.xml
+++ b/openoffice/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3-SNAPSHOT</version>
+		<version>4.5.3</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-openoffice</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/1a1dc0d8/pojo/pom.xml
----------------------------------------------------------------------
diff --git a/pojo/pom.xml b/pojo/pom.xml
index 915ed09..59697d5 100644
--- a/pojo/pom.xml
+++ b/pojo/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3-SNAPSHOT</version>
+		<version>4.5.3</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-pojo</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/1a1dc0d8/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 8311ca2..0a43f3d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -42,11 +42,11 @@ under the License.
 		<url>https://git-wip-us.apache.org/repos/asf?p=metamodel.git</url>
 		<connection>scm:git:http://git-wip-us.apache.org/repos/asf/metamodel.git</connection>
 		<developerConnection>scm:git:https://git-wip-us.apache.org/repos/asf/metamodel.git</developerConnection>
-		<tag>HEAD</tag>
+		<tag>MetaModel-4.5.3</tag>
 	</scm>
 	<groupId>org.apache.metamodel</groupId>
 	<artifactId>MetaModel</artifactId>
-	<version>4.5.3-SNAPSHOT</version>
+	<version>4.5.3</version>
 	<name>MetaModel</name>
 	<description>MetaModel is a library that encapsulates the differences and enhances 
 		the capabilities of different datastores. Rich querying abilities are

http://git-wip-us.apache.org/repos/asf/metamodel/blob/1a1dc0d8/salesforce/pom.xml
----------------------------------------------------------------------
diff --git a/salesforce/pom.xml b/salesforce/pom.xml
index b9b4fd5..700d015 100644
--- a/salesforce/pom.xml
+++ b/salesforce/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3-SNAPSHOT</version>
+		<version>4.5.3</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-salesforce</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/1a1dc0d8/spring/pom.xml
----------------------------------------------------------------------
diff --git a/spring/pom.xml b/spring/pom.xml
index 0c01d2b..d9615e6 100644
--- a/spring/pom.xml
+++ b/spring/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3-SNAPSHOT</version>
+		<version>4.5.3</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-spring</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/1a1dc0d8/sugarcrm/pom.xml
----------------------------------------------------------------------
diff --git a/sugarcrm/pom.xml b/sugarcrm/pom.xml
index 34bb144..d9d508f 100644
--- a/sugarcrm/pom.xml
+++ b/sugarcrm/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3-SNAPSHOT</version>
+		<version>4.5.3</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-sugarcrm</artifactId>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/1a1dc0d8/xml/pom.xml
----------------------------------------------------------------------
diff --git a/xml/pom.xml b/xml/pom.xml
index 1341185..ba5dc11 100644
--- a/xml/pom.xml
+++ b/xml/pom.xml
@@ -21,7 +21,7 @@ under the License.
 	<parent>
 		<artifactId>MetaModel</artifactId>
 		<groupId>org.apache.metamodel</groupId>
-		<version>4.5.3-SNAPSHOT</version>
+		<version>4.5.3</version>
 	</parent>
 	<modelVersion>4.0.0</modelVersion>
 	<artifactId>MetaModel-xml</artifactId>