Repository: olingo-odata2 Updated Branches: refs/heads/master 55dfc129c -> 41d99109b
[OLINGO-312] Support for passing Mapping Model as a Input Stream. Implement the method getJPAEdmMappingModelStream method of JPAEdmExtension interface to return a Stream of Mapping Model. The mapping model stream should be a XML document adhering to JPAEDMMappingModel.xsd Signed-off-by: Chandan V A <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/olingo-odata2/repo Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata2/commit/41d99109 Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata2/tree/41d99109 Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata2/diff/41d99109 Branch: refs/heads/master Commit: 41d99109b00f03da69072c4cab542db4cea1df1c Parents: 55dfc12 Author: Chandan V A <[email protected]> Authored: Sun Jun 15 13:14:15 2014 +0530 Committer: Chandan V A <[email protected]> Committed: Sun Jun 15 13:14:15 2014 +0530 ---------------------------------------------------------------------- .../odata2/jpa/processor/api/model/JPAEdmExtension.java | 9 +++++++++ .../core/access/model/JPAEdmMappingModelService.java | 11 ++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/41d99109/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/JPAEdmExtension.java ---------------------------------------------------------------------- diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/JPAEdmExtension.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/JPAEdmExtension.java index 18f43a0..c8c0f8f 100644 --- a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/JPAEdmExtension.java +++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/model/JPAEdmExtension.java @@ -18,6 +18,8 @@ ******************************************************************************/ package org.apache.olingo.odata2.jpa.processor.api.model; +import java.io.InputStream; + /** * The interface provides methods to extend JPA EDM containers. * @@ -47,4 +49,11 @@ public interface JPAEdmExtension { */ public void extendJPAEdmSchema(JPAEdmSchemaView view); + /** + * Implement this method to provide a stream of Mapping model. + * @return + * a stream of mapping model XML as per JPAEDMMappingModel.xsd + */ + public InputStream getJPAEdmMappingModelStream(); + } http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/41d99109/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/model/JPAEdmMappingModelService.java ---------------------------------------------------------------------- diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/model/JPAEdmMappingModelService.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/model/JPAEdmMappingModelService.java index dd453ac..4b5d396 100644 --- a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/model/JPAEdmMappingModelService.java +++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/model/JPAEdmMappingModelService.java @@ -38,13 +38,12 @@ public class JPAEdmMappingModelService implements JPAEdmMappingModelAccess { boolean mappingModelExists = true; private JPAEdmMappingModel mappingModel; + private InputStream mappingModelStream = null; private String mappingModelName; public JPAEdmMappingModelService(final ODataJPAContext ctx) { - mappingModelName = ctx.getJPAEdmMappingModel(); - if (mappingModelName == null) { - mappingModelExists = false; - } + mappingModelExists = (mappingModelName = ctx.getJPAEdmMappingModel()) == null ? + (((mappingModelStream = ctx.getJPAEdmExtension().getJPAEdmMappingModelStream()) == null) ? false : true) : true; } @Override @@ -194,8 +193,10 @@ public class JPAEdmMappingModelService implements JPAEdmMappingModelAccess { } protected InputStream loadMappingModelInputStream() { + if (mappingModelStream != null) { + return mappingModelStream; + } InputStream is = JPAEdmMappingModelService.class.getClassLoader().getResourceAsStream("../../" + mappingModelName); - return is; }
