openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] OpenJPA > OpenTrader
Date Tue, 24 Aug 2010 20:06:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1810/9/5/_/styles/combined.css?spaceKey=openjpa&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/openjpa/OpenTrader">OpenTrader</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~ppoddar@apache.org">Pinaki
Poddar</a>
    </h4>
        <br/>
                         <h4>Changes (8)</h4>
                                 
    
<div id="page-diffs">
            <table class="diff" cellpadding="0" cellspacing="0">
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >      Edit  {{build.properties}} to
point to the dependent libraries you have downloaded. The file contains the instructions as
comments.  <br> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">
  h5. 2.2 Run Ant <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">
  h5. 2.2 Compile with Ant <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">
     Compile the application. Compilation involves three separate compilation process. First
the plain old {{javac}} compilation. Followed by GWT cross-compiler that translates Java code
into JavaScript. And finally OpenJPA compilation that adds few bytecodes to the persistent
classes to manage their persistent behavior (which is also known as bytecode enhancement).
<br> <br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-changed-words">{{<span
class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">
</span>$</span> ant compile}} <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">
     will compile the source code, then compile it for GWT then compile it for OpenJPA. Compiling
for GWT will take ages. Even though it only compiles for a single browser (FireFox).  <br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-added-words"style="background-color:
#dfd;">GWT Compiler takes ages. Even though it only compiles for a single browser (FireFox).</span>
This is controlled by the following directives in the module descriptor {{OpenTrader.gwt.xml}}
<br></td></tr>
            <tr><td class="diff-unchanged" > <br>     {code:xml} <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" > !OpenTrader-screenshot.gif! <br>
<br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">
<br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">In
this page, you can place a trade offer to sell or buy some stocks. To really commit a trade
you will need a matching offer. Now as a trader offer can only match to another trader&#39;s
offer, you need to open another browser page with a different name. In FireFox, the tab will
show the Trader name. Now if one Trader makes an offer that match another Trader&#39;s
offer, then clicking the {{Sell}} or {{Buy}} button will commit the trade and will appear
on the Trading History Window. Also notice the Server Log window. That will display SQL issued
for every action by the server. You will also notice SQL being logged even if you are not
pressing any buttons. Thatis because the Market Data Panel (the one in th etop-left corner)
is refreshing the market prices for the Stocks by a periodic call to the server. As the stock
prices change, that change is reflected on the gain/loss column of the waiting trade offers.
All this dynamic partial update occurs in the same browser page -- that is what GWT offers.
<br></td></tr>
        </table>
</div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h1><a name="OpenTrader-OpenTrader%3Aatransactional%2CwebapplicationwithGoogleWebToolkit%2COpenJPA%2FSliceonTomcat"></a>OpenTrader:
a transactional, web application with Google Web Toolkit, OpenJPA/Slice on Tomcat</h1>

<p>OpenTrader is a sample web application to demonstrate integration and interaction
of Google Web Toolkit, OpenJPA and Tomcat Servlet Container. <br/>
Follow the steps to view OpenTrader source code, build the application, deploy it in your
favorite application container and run it in your favorite browser.</p>

<h3><a name="OpenTrader-1.Getthesourcecode"></a>1. Get the source code</h3>

<p>   OpenTrader source code is available as one of the OpenJPA examples. Checkout the
source files in a directory.</p>

<p>   <tt>$ svn checkout   <a href="https://svn.apache.org/repos/asf/openjpa/trunk/openjpa-examples/opentrader"
class="external-link" rel="nofollow">https://svn.apache.org/repos/asf/openjpa/trunk/openjpa-examples/opentrader</a></tt></p>

<p>  The source tree comes with </p>
<ul>
	<li>Ant build script: <tt>build.xml</tt> and <tt>build.properties</tt></li>
	<li>Java source code for OpenTrader application under <tt>src/main/java</tt></li>
	<li>GWT module descriptor  : <tt>OpenTrader.gwt.xml</tt> under <tt>src/main/java/org/apache/openjpa/trader</tt></li>
	<li>Persistence descriptor : <tt>persistence.xml</tt> under <tt>src/main/resources/META-INF</tt></li>
	<li>web descriptor         : <tt>web.xml</tt> under <tt>src/main/resources/WEB-INF</tt></li>
	<li>cascading style sheet  : <tt>OpenTrader.css</tt> under <tt>src/main/resources/css</tt></li>
</ul>



<h3><a name="OpenTrader-2.Build"></a>2. Build</h3>

<p>   To build OpenTrader you will require following other libraries. </p>
<ul>
	<li><b>Google Web Toolkit</b>: We have built it with GWT version 2.0.4
which can be downloaded from <a href="http://google-web-toolkit.googlecode.com/files/gwt-2.0.4.zip"
class="external-link" rel="nofollow">here</a>.</li>
	<li><b>cobogw widget library</b>: Provides rounded panel not using them
seems to be too un-cool. Download version 1.3.1 from <a href="http://code.google.com/p/cobogw/downloads/list"
class="external-link" rel="nofollow">here</a>.</li>
	<li>and, of course, <b>OpenJPA libraries</b>: OpenJPA now comes with all
its dependencies neatly packaged in a single jar including the JPA API. Download from <a
href="http://www.apache.org/dyn/closer.cgi/openjpa/2.0.0/apache-openjpa-2.0.0-binary.zip"
class="external-link" rel="nofollow">this site</a>.</li>
</ul>


<h5><a name="OpenTrader-2.1Configurebuildenvironment"></a>2.1 Configure
build environment </h5>

<p>      Edit  <tt>build.properties</tt> to point to the dependent libraries
you have downloaded. The file contains the instructions as comments. </p>

<h5><a name="OpenTrader-2.2CompilewithAnt"></a>2.2 Compile with Ant</h5>

<p>      Compile the application. Compilation involves three separate compilation process.
First the plain old <tt>javac</tt> compilation. Followed by GWT cross-compiler
that translates Java code into JavaScript. And finally OpenJPA compilation that adds few bytecodes
to the persistent classes to manage their persistent behavior (which is also known as bytecode
enhancement).</p>

<p>      <tt>$ ant compile</tt></p>

<p>      GWT Compiler takes ages. Even though it only compiles for a single browser
(FireFox). This is controlled by the following directives in the module descriptor <tt>OpenTrader.gwt.xml</tt></p>

     <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
        <span class="code-tag">&lt;set-property name=<span class="code-quote">"user.agent"</span>
value=<span class="code-quote">"gecko1_8"</span>/&gt;</span> 
     </pre>
</div></div>

<h3><a name="OpenTrader-3.Run"></a>3. Run</h3>

<p>    You can run either in <em>hosted</em> mode - an environment provided
by GWT to run within a Jetty container - or in a proper servlet container such as Tomcat,
Geronimo or GlassFish or even heavy-duty ones such as WebSphere or Weblogic. In either case,
you have to configure the <tt>persistence.xml</tt> found under <tt>src/main/resources/META-INF</tt>.
This descriptor specifies the database used by OpenTrader.</p>

     <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
        <span class="code-tag">&lt;property name=<span class="code-quote">"openjpa.ConnectionDriverName"</span>
value=<span class="code-quote">"com.mysql.jdbc.Driver"</span>/&gt;</span>
        <span class="code-tag">&lt;property name=<span class="code-quote">"openjpa.ConnectionURL"</span>
value=<span class="code-quote">"jdbc:mysql://localhost/exchange"</span>/&gt;</span>
        <span class="code-tag">&lt;property name=<span class="code-quote">"openjpa.ConnectionUserName"</span>
value=<span class="code-quote">"whoami"</span>/&gt;</span>
        <span class="code-tag">&lt;property name=<span class="code-quote">"openjpa.ConnectionPassword"</span>
value=<span class="code-quote">"secret"</span>/&gt;</span>
     </pre>
</div></div>

<p>    Also edit the <tt>jdbc.driver</tt> in <tt>build.properties</tt>
for the driver/database you have selected.</p>

<p>    Now, for hosted mode, simply fire Ant as<br/>
     {{ $ ant devmode}}</p>

<p>    This should again take a very long time and pop open a horrible looking Swing
console titled <b>GWT Development Mode</b>. Go to <b>Development Mode</b>
tab and click <b>Launch Default Browser</b>. On my FireFox browser, that opens
up the page <tt><a href="http://127.0.0.1:8888/OpenTrader.html?gwt.codesvr=127.0.0.1:9997"
class="external-link" rel="nofollow">http://127.0.0.1:8888/OpenTrader.html?gwt.codesvr=127.0.0.1:9997</a></tt>.
If all goes well, at this point your browser will prompt you with a welcome dialog box</p>

<p><span class="image-wrap" style=""><img src="/confluence/download/attachments/23335925/OpenTrader-login.gif?version=1&amp;modificationDate=1282678934447"
style="border: 0px solid black" /></span></p>

<p>Once you have entered OpenTrader, the browser application looks like <br/>
 <span class="image-wrap" style=""><img src="/confluence/download/attachments/23335925/OpenTrader-screenshot.GIF?version=1&amp;modificationDate=1282679584731"
style="border: 0px solid black" /></span></p>

<p>In this page, you can place a trade offer to sell or buy some stocks. To really commit
a trade you will need a matching offer. Now as a trader offer can only match to another trader's
offer, you need to open another browser page with a different name. In FireFox, the tab will
show the Trader name. Now if one Trader makes an offer that match another Trader's offer,
then clicking the <tt>Sell</tt> or <tt>Buy</tt> button will commit
the trade and will appear on the Trading History Window. Also notice the Server Log window.
That will display SQL issued for every action by the server. You will also notice SQL being
logged even if you are not pressing any buttons. Thatis because the Market Data Panel (the
one in th etop-left corner) is refreshing the market prices for the Stocks by a periodic call
to the server. As the stock prices change, that change is reflected on the gain/loss column
of the waiting trade offers. All this dynamic partial update occurs in the same browser page
&#8211; that is what GWT offers.</p>
    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/openjpa/OpenTrader">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=23335925&revisedVersion=4&originalVersion=3">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/openjpa/OpenTrader?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message