summaryrefslogtreecommitdiffstats
path: root/site/trunk/site-publish/sca-java-implementationjpa.html
diff options
context:
space:
mode:
Diffstat (limited to 'site/trunk/site-publish/sca-java-implementationjpa.html')
-rw-r--r--site/trunk/site-publish/sca-java-implementationjpa.html251
1 files changed, 251 insertions, 0 deletions
diff --git a/site/trunk/site-publish/sca-java-implementationjpa.html b/site/trunk/site-publish/sca-java-implementationjpa.html
new file mode 100644
index 0000000000..e2bd90ebcb
--- /dev/null
+++ b/site/trunk/site-publish/sca-java-implementationjpa.html
@@ -0,0 +1,251 @@
+
+<!--
+
+ 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.
+-->
+
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<HTML>
+ <HEAD>
+ <!-- generateKeywords macro -->
+ <META name="description" content="Apache Tuscany">
+ <META name="keywords" content="apache, apache tuscany, tuscany, service, services, fabric, soa, service oriented architecture, sca, service component architecture, das, sdo, csa, ruby, opensource">
+ <!-- generateKeywords macro end -->
+
+ <LINK type="text/css" rel="stylesheet" href="http://tuscany.apache.org/stylesheets/default.css">
+ <LINK rel="SHORTCUT ICON" href="https://cwiki.apache.org/confluence/display/TUSCANY/$images/favicon.ico">
+ <TITLE>Apache Tuscany : SCA Java implementation.jpa</TITLE>
+ <META http-equiv="Content-Type" content="text/html;charset=UTF-8"></HEAD>
+
+ <BODY onload="init()">
+ <!-- topNav macro -->
+ <TABLE valign="top" border="0" cellspacing="0" cellpadding="0" width="100%" background="http://tuscany.apache.org/images/TuscanyLogoNEW_Text_120px_bg.jpg">
+ <TR>
+ <TD valing="top" align="left">
+ <A href="https://cwiki.apache.org/confluence/pages/viewpage.action?spaceKey=TUSCANY&title=$siteroot"><IMG src="http://tuscany.apache.org/images/TuscanyLogoNEW_Text_120px_bg.jpg" height="91" width="25" border="0"></A>
+ </TD>
+ <TD>
+ <A href="http://tuscany.apache.org/"><IMG src="http://tuscany.apache.org/images/TuscanyLogo.jpg" border="0"></A>
+ </TD>
+
+ <TD width="100%">
+ &nbsp;
+ </TD>
+
+ <!-- Adds the edit page link to the top banner-->
+ <TD valign="bottom">
+ <DIV style="padding: 2px 10px; margin: 0px;">
+ <A href="https://cwiki.apache.org/confluence/pages/editpage.action?pageId=109001">
+ <IMG src="http://tuscany.apache.org/images/notep_16.gif" height="16" width="16" border="0" align="absmiddle" title="Edit Page"></A>
+ </DIV>
+ </TD>
+
+ </TR>
+ </TABLE>
+ <!-- topNav macro end -->
+
+ <!-- breadCrumbs macro -->
+ <TABLE border="0" cellpadding="2" cellspacing="0" width="100%">
+ <TR class="topBar">
+ <TD align="left" valign="middle" class="topBarDiv" nowrap="true" width="100%">
+ &nbsp;<A href="home.html" title="Apache Tuscany">Apache Tuscany</A>&nbsp;&gt;&nbsp;<A href="home.html" title="Home">Home</A>&nbsp;&gt;&nbsp;<A href="sca-overview.html" title="SCA Overview">SCA Overview</A>&nbsp;&gt;&nbsp;<A href="sca-java.html" title="SCA Java">SCA Java</A>&nbsp;&gt;&nbsp;<A href="java-sca-documentation-menu.html" title="Java SCA Documentation Menu">Java SCA Documentation Menu</A>&nbsp;&gt;&nbsp;<A href="" title="SCA Java implementation.jpa">SCA Java implementation.jpa</A>
+ </TD>
+
+ <TD align="right" valign="middle" class="topBarDiv" align="left" nowrap="true">
+ <A href="http://mail-archives.apache.org/mod_mbox/tuscany-user">User List</A> | <A href="http://mail-archives.apache.org/mod_mbox/tuscany-dev">Dev List</A> | <A href="http://issues.apache.org/jira/browse/Tuscany">Issue Tracker</A>&nbsp;&nbsp;
+ </TD>
+ </TR>
+ </TABLE>
+ <!-- breadCrumbs macro end -->
+
+
+ <TABLE border="0" cellpadding="0" width="100%" bgcolor="#FFFFFF">
+ <TR>
+ <TD align="left" valign="top">
+
+ <!-- pageContent macro -->
+ <DIV id="PageContent">
+
+ <DIV class="pagecontent">
+ <DIV class="wiki-content">
+ <DIV class="panelMacro"><TABLE class="infoMacro"><COLGROUP><COL width="24"><COL></COLGROUP><TR><TD valign="top"><IMG src="https://cwiki.apache.org/confluence/images/icons/emoticons/information.gif" width="16" height="16" align="absmiddle" alt="" border="0"></TD><TD><B>Disclaimer</B><BR>Work in progress, or should I say : Ideas in progress</TD></TR></TABLE></DIV>
+
+<H1><A name="SCAJavaimplementation.jpa-InjectionofJPAEntityManagerFactory%2FEntityManager"></A>Injection of JPA Entity Manager Factory/Entity Manager</H1>
+
+<P> The injection of JPA Entity Manager Factory/Entity Manager would allow sharing of EMFs across multiple components, this would be useful in scenarios where you have conversation. In this case, the runtime would be responsible for making sure the EM would be created and closed transparently for the application developer based on the conversation.</P>
+
+<H1><A name="SCAJavaimplementation.jpa-JPADataServices"></A>JPA Data Services</H1>
+
+<P>In this case, we would be extending the SCA programming model to expose services that interact with a persistent layer in a declarative fashion hiding the implementation details from the service developer.It's all about simplicity, allowing a service to be defined without explicitly coding the persistence layer. This would be a new Tuscany Component Type named Implementaiton.JPA. A developer would provide the business objects that would by JPA to do the OR mapping, and a business interface that would be introspect by Tuscany to properly make the JPA calls to the persistence layer to retrieve the information. Information on how to connect to the data source would be done in the composite, and we could provide some annotations to read</P>
+
+<H4><A name="SCAJavaimplementation.jpa-BusinessObject"></A>Business Object</H4>
+
+<P> The business object can be defined as per JPA programming model. You can define it as a JPA Entity and make use of JPA annotations, or use the ORM.xml as well.</P>
+<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
+<PRE class="code-java">
+@Entity
+<SPAN class="code-keyword">public</SPAN> class Customer {
+
+ @Id <SPAN class="code-keyword">protected</SPAN> <SPAN class="code-object">int</SPAN> id;
+ @Basic <SPAN class="code-keyword">protected</SPAN> <SPAN class="code-object">String</SPAN> name;
+ @Basic <SPAN class="code-keyword">protected</SPAN> <SPAN class="code-object">String</SPAN> phone;
+
+ <SPAN class="code-keyword">public</SPAN> <SPAN class="code-object">int</SPAN> getId() {
+ <SPAN class="code-keyword">return</SPAN> id;
+ }
+
+ <SPAN class="code-keyword">public</SPAN> void setId(<SPAN class="code-object">int</SPAN> id) {
+ <SPAN class="code-keyword">this</SPAN>.id = id;
+ }
+
+ <SPAN class="code-keyword">public</SPAN> <SPAN class="code-object">String</SPAN> getName() {
+ <SPAN class="code-keyword">return</SPAN> name;
+ }
+
+ <SPAN class="code-keyword">public</SPAN> void setName(<SPAN class="code-object">String</SPAN> name) {
+ <SPAN class="code-keyword">this</SPAN>.name = name;
+ }
+
+ <SPAN class="code-keyword">public</SPAN> <SPAN class="code-object">String</SPAN> getPhone() {
+ <SPAN class="code-keyword">return</SPAN> phone;
+ }
+
+ <SPAN class="code-keyword">public</SPAN> void setPhone(<SPAN class="code-object">String</SPAN> phone) {
+ <SPAN class="code-keyword">this</SPAN>.phone = phone;
+ }
+}
+</PRE>
+</DIV></DIV>
+
+<H4><A name="SCAJavaimplementation.jpa-BusinessInterface"></A>Business Interface</H4>
+
+<P> The Business interface would define the access to the JPA entities, and we would introduce Java Annotations to bind a specific method to a JPA query.</P>
+<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
+<PRE class="code-java">
+<SPAN class="code-keyword">import</SPAN> org.osoa.sca.annotations.Remotable;
+
+@Remotable
+<SPAN class="code-keyword">public</SPAN> <SPAN class="code-keyword">interface</SPAN> CustomerService {
+
+ Customer[] getCustomers();
+
+ void setCustomer(Customer customer);
+
+ @Query(SELECT c FROM customer c WHERE c.name = '<SPAN class="code-quote">&quot; + $1 + &quot;</SPAN>'&quot;)
+ Customer queryCustomerByName(<SPAN class="code-object">String</SPAN> name);
+
+}
+</PRE>
+</DIV></DIV>
+
+<P> We would use some Convention over Configuration to bind the interfaces methods to proper database activities :</P>
+
+<DIV class="table-wrap">
+<TABLE class="confluenceTable"><TBODY>
+<TR>
+<TD class="confluenceTd"> Method </TD>
+<TD class="confluenceTd"> Correspondent db operation </TD>
+</TR>
+<TR>
+<TD class="confluenceTd"> createXXX </TD>
+<TD class="confluenceTd"> Insert a new entity on the db. A collection of new entities should also be supported </TD>
+</TR>
+<TR>
+<TD class="confluenceTd"> getXXX </TD>
+<TD class="confluenceTd"> Read a given entity from the db <BR class="atl-forced-newline"> A method signature with no parameters read a collection. </TD>
+</TR>
+<TR>
+<TD class="confluenceTd"> setXXX </TD>
+<TD class="confluenceTd"> Update a previously existent entity on the db. </TD>
+</TR>
+<TR>
+<TD class="confluenceTd"> deleteXXX </TD>
+<TD class="confluenceTd"> Remove a previously existent entity on the db. </TD>
+</TR>
+<TR>
+<TD class="confluenceTd"> queryXXX </TD>
+<TD class="confluenceTd"> Execute a query on the db. <BR class="atl-forced-newline"> We would introduce a Java Annotation to bind a given query to the method invocation </TD>
+</TR>
+</TBODY></TABLE>
+</DIV>
+
+
+<P> Note that introspection will be required by the runtime to properly identify the operation type being requested. Based on this introspection, the runtime will also be responsible for any necessary conversion to the proper collection being expected as a result.</P>
+
+<H4><A name="SCAJavaimplementation.jpa-Composite"></A>Composite</H4>
+
+<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
+<PRE class="code-java">
+&lt;composite xmlns=<SPAN class="code-quote">&quot;http:<SPAN class="code-comment">//www.osoa.org/xmlns/sca/1.0&quot;</SPAN>
+</SPAN> xmlns:tuscany=<SPAN class="code-quote">&quot;http:<SPAN class="code-comment">//tuscany.apache.org/xmlns/sca/1.0&quot;</SPAN>
+</SPAN> targetNamespace=<SPAN class="code-quote">&quot;http:<SPAN class="code-comment">//sample/implementation.jpa&quot;</SPAN>
+</SPAN> name=<SPAN class="code-quote">&quot;customer&quot;</SPAN>&gt;
+
+ &lt;component name=<SPAN class="code-quote">&quot;CustomerServiceComponent&quot;</SPAN>&gt;
+ &lt;tuscany:implementation.jpa&gt;
+ &lt;tuscany:persistence-unit name=<SPAN class="code-quote">&quot;customer&quot;</SPAN>&gt;
+ &lt;tuscany:class&gt;assets.Customer&lt;/tuscany:class&gt;
+ &lt;/tuscany:persistence-unit&gt;
+
+ &lt;tuscany:connectionInfo&gt;
+ &lt;tuscany:connectionProperties
+ driverClass=<SPAN class="code-quote">&quot;org.apache.derby.jdbc.EmbeddedDriver&quot;</SPAN>
+ databaseURL=<SPAN class="code-quote">&quot;jdbc:derby:target/test-classes/customer; create = <SPAN class="code-keyword">true</SPAN>&quot;</SPAN>
+ loginTimeout=<SPAN class="code-quote">&quot;600000&quot;</SPAN>/&gt;
+ &lt;/tuscany:connectionInfo&gt;
+ &lt;/tuscany:implementation.jpa&gt;
+ &lt;/component&gt;
+
+&lt;/composite&gt;
+</PRE>
+</DIV></DIV>
+
+
+<H1><A name="SCAJavaimplementation.jpa-Benefits"></A>Benefits</H1>
+
+<UL>
+ <LI>Simplify the programming model for accessing data, hiding some of the API details required for this kind of components</LI>
+ <LI>Allow exposing data services trough multiple SCA Bindings (e.g ws, json-rpc, feeds, etc)</LI>
+</UL>
+
+ </DIV>
+ </DIV>
+ </DIV>
+ <!-- pageContent macro end -->
+
+ </TD>
+ </TR>
+ </TABLE>
+
+ <!-- footer macro -->
+ <SCRIPT src="http://www.google-analytics.com/urchin.js" type="text/javascript">
+ </SCRIPT>
+ <SCRIPT type="text/javascript">
+ _uacct = "UA-1174707-5";
+ urchinTracker();
+ </SCRIPT>
+
+ <A href="http://www.statcounter.com/" target="_blank"><IMG src="http://c26.statcounter.com/counter.php?sc_project=2619156&java=0&security=94bd7e7d&invisible=0" alt="website stats" border="0"></A>
+
+ <DIV class="footer">
+ Copyright � 2003-2012, The Apache Software Foundation&nbsp;&nbsp;</BR>
+ Apache Tuscany and the Apache Tuscany project logo are trademarks of The Apache Software Foundation.
+ </DIV>
+ <!-- footer macro end -->
+
+ </BODY>
+</HTML>