You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by bu...@apache.org on 2014/07/01 08:39:30 UTC

svn commit: r914540 - in /websites/staging/olingo/trunk/content: ./ doc/tutorials/CustomODataJPAProcessor.html

Author: buildbot
Date: Tue Jul  1 06:39:30 2014
New Revision: 914540

Log:
Staging update by buildbot for olingo

Added:
    websites/staging/olingo/trunk/content/doc/tutorials/CustomODataJPAProcessor.html
Modified:
    websites/staging/olingo/trunk/content/   (props changed)

Propchange: websites/staging/olingo/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Tue Jul  1 06:39:30 2014
@@ -1 +1 @@
-1606988
+1606990

Added: websites/staging/olingo/trunk/content/doc/tutorials/CustomODataJPAProcessor.html
==============================================================================
--- websites/staging/olingo/trunk/content/doc/tutorials/CustomODataJPAProcessor.html (added)
+++ websites/staging/olingo/trunk/content/doc/tutorials/CustomODataJPAProcessor.html Tue Jul  1 06:39:30 2014
@@ -0,0 +1,155 @@
+<!DOCTYPE html>
+<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
+<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
+<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
+<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
+    <head>
+        <meta charset="utf-8">
+        <meta http-equiv="expires" content="0">
+            <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
+                <title></title>
+                <meta name="description" content="Apache Olingo provides libraries which enable developers to implement OData producers and OData consumers. The available OData Java library implements OData version 2.0. In future on goal is to provide an OData 4.0 compliant library once the OData standard is published at OASIS. The focus within the community is currently on the Java technology but it is up to the community to discuss if other environments find interest.">
+                    <meta name="viewport" content="width=device-width">
+                        
+                    <link rel="stylesheet" href="/css/bootstrap.min.css">
+                            <style>
+                                body {
+                                    padding-top: 60px;
+                                    padding-bottom: 40px;
+                                }
+                                </style>
+                                <link rel="stylesheet" href="/css/bootstrap-responsive.min.css">
+                                <link rel="stylesheet" href="/css/main.css">
+                                    
+                                <script src="/js/vendor/modernizr-2.6.2-respond-1.1.0.min.js"></script>
+                                    </head>
+    <body>
+        <!--[if lt IE 7]>
+         <p class="chromeframe">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">activate Google Chrome Frame</a> to improve your experience.</p>
+         <![endif]-->
+        
+        <!-- This code is taken from http://twitter.github.com/bootstrap/examples/hero.html -->
+        <div class="navbar navbar-inverse  navbar-fixed-top">
+            <div class="navbar-inner">
+                <div class="container">
+                    <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
+                        <span class="icon-bar"></span>
+                        <span class="icon-bar"></span>
+                        <span class="icon-bar"></span>
+                    </a>
+                    <img class="brand" src="/img/OlingoOrangeTM.png" style="width:42px;" />
+                    <a class="brand" href="/">Apache Olingo&trade;</a>
+                   <div class="nav-collapse collapse">
+                        <ul class="nav">
+                            <li class="dropdown">
+                                <a href="#" class="dropdown-toggle" data-toggle="dropdown">ASF <b class="caret"></b></a>
+                                <ul class="dropdown-menu">
+                                    <li><a href="http://www.apache.org/foundation/">ASF Home</a></li>
+                                    <li><a href="http://projects.apache.org/">Projects</a></li>
+                                    <li><a href="http://people.apache.org/">People</a></li>
+                                    <li><a href="http://www.apache.org/foundation/getinvolved.html">Get Involved</a></li>
+                                    <li><a href="http://www.apache.org/dyn/closer.cgi">Download</a></li>
+                                    <li><a href="http://www.apache.org/security/">Security</a></li>
+                                    <li><a href="http://www.apache.org/foundation/sponsorship.html">Support Apache</a></li>
+                                </ul>
+                            </li>
+                            <li><a href="/">Home</a></li>
+                            <li><a href="http://www.apache.org/licenses/">License</a></li> 
+                            <li><a href="/download.html">Download</a></li>
+                            <li><a href="/documentation.html">Documentation</a></li>
+                            <li><a href="/support.html">Support</a></li>
+                        </ul>
+                        <form class="navbar-form pull-right" name="search" id="search" action="http://www.google.com/search" method="get">
+                            <input value="olingo.apache.org" name="sitesearch" type="hidden"/>
+                            <input class="span2" type="text" name="q" id="query">
+                                <input class="btn"type="submit" id="submit" value="Search">
+                                    </form>
+                    </div><!--/.nav-collapse -->
+                </div>
+            </div>
+        </div>
+        
+        <div class="container">
+            
+            
+            
+            <h2 id="custom-odata-jpa-processor">Custom OData JPA Processor</h2>
+<p>OData JPA Processor Library along with transforming an existing JPA model as EDM with no or minimalistic coding also processes the OData request and generates the OData response. However, at times it is required for an application using OData JPA Processor Library to perform some pre-processing of requests and post-processing of responses. To enable this in the application, following steps needs to be performed. </p>
+<p>Custom OData JPA Processor is supported from Apache Olingo release 1.1.0 onwards.</p>
+<ol>
+<li>
+<p>Write a Custom OData JPA Processor by extending the class <code>org.apache.olingo.odata2.jpa.processor.api.ODataJPAProcessor</code>. 
+In the code snippet below, pre-process and post-process are two private methods that can be written to process the request and response. The instance variable (part of ODataJPAProcessor) <code>jpaProcessor</code> can be used to process the OData request. The <code>jpaProcessor</code> returns the JPA entities after processing the OData request. The instance variable <code>responseBuilder</code> can be used for building the OData response from the processed JPA entities.</p>
+<div class="codehilite"><pre><span class="n">public</span> <span class="n">class</span> <span class="n">CustomODataJPAProcessor</span> <span class="n">extends</span> <span class="n">ODataJPAProcessor</span><span class="p">{</span>
+
+  <span class="p">@</span><span class="n">Override</span>
+  <span class="n">public</span> <span class="n">ODataResponse</span> <span class="n">readEntitySet</span><span class="p">(</span><span class="n">final</span> <span class="n">GetEntitySetUriInfo</span> <span class="n">uriParserResultView</span><span class="p">,</span> <span class="n">final</span> <span class="n">String</span> <span class="n">contentType</span><span class="p">)</span>
+     <span class="n">throws</span> <span class="n">ODataException</span> <span class="p">{</span>
+
+   <span class="o">/*</span> <span class="n">Pre</span> <span class="n">Process</span> <span class="n">Step</span> <span class="o">*/</span>
+   <span class="n">preprocess</span> <span class="p">(</span> <span class="p">);</span>
+
+   <span class="n">List</span><span class="o">&lt;</span><span class="n">Object</span><span class="o">&gt;</span> <span class="n">jpaEntities</span> <span class="p">=</span> <span class="n">jpaProcessor</span><span class="p">.</span><span class="n">process</span><span class="p">(</span><span class="n">uriParserResultView</span><span class="p">);</span>
+
+   <span class="o">/*</span> <span class="n">Post</span> <span class="n">Process</span> <span class="n">Step</span> <span class="o">*/</span>
+   <span class="n">postProcess</span><span class="p">(</span> <span class="p">);</span>
+
+   <span class="n">ODataResponse</span> <span class="n">oDataResponse</span> <span class="p">=</span>
+       <span class="n">responseBuilder</span><span class="p">.</span><span class="n">build</span><span class="p">(</span><span class="n">uriParserResultView</span><span class="p">,</span> <span class="n">jpaEntities</span><span class="p">,</span> <span class="n">contentType</span><span class="p">);</span>
+
+   <span class="k">return</span> <span class="n">oDataResponse</span><span class="p">;</span>
+  <span class="p">}</span>
+
+ <span class="p">}</span>
+</pre></div>
+
+
+<ol>
+<li>
+<p>Write a Custom OData JPA Service Factory 
+Implement an OData JPA service factory to create an OData service with custom OData JPA Processor. The default service factory <code>org.apache.olingo.odata2.jpa.processor.api.ODataJPAServiceFactory</code> part of the library cannot be used. Hence, create a class by extending <code>org.apache.olingo.odata2.api.ODataServiceFactory</code>. Follow the steps below to hook an existing flow to a custom OData JPA Processor. Copy the entire code from <code>ODataJPAServiceFactory</code> and replace the code as shown below. </p>
+<p>ODataSingleProcessor odataJPAProcessor = accessFactory.createODataProcessor(oDataJPAContext);</p>
+</li>
+</ol>
+<p>with </p>
+<div class="codehilite"><pre><span class="n">ODataSingleProcessor</span> <span class="n">odataJPAProcessor</span> <span class="p">=</span> <span class="n">new</span> <span class="n">CustomODataJPAProcessor</span><span class="p">(</span><span class="n">oDataJPAContext</span><span class="p">);</span>
+</pre></div>
+
+
+</li>
+</ol>
+            
+            
+            
+            
+            <hr>
+            
+            <footer>                 
+                <div align="center"><p>Copyright © 2013-2014, The Apache Software Foundation<br>
+                Apache Olingo, Olingo, Apache, the Apache feather, and 
+the Apache Olingo project logo are trademarks of the Apache Software 
+Foundation.</p></div>
+        <hr>
+        <div align="center"><small><a href="http://olingo.staging.apache.org/doc/privacy.html">Privacy</a></small></div>
+            </footer>
+            
+        </div> <!-- /container -->
+        
+        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
+        <script>window.jQuery || document.write('<script src="js/vendor/jquery-1.10.1.min.js"><\/script>')</script>
+        
+        <script src="/js/vendor/bootstrap.min.js"></script>
+        
+        <script src="/js/main.js"></script>
+        
+<script>
+  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
+  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
+  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
+  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
+
+  ga('create', 'UA-44963757-1', 'apache.org');
+  ga('send', 'pageview');
+
+</script>    </body>
+</html>