geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jb...@apache.org
Subject svn commit: r905795 [1/2] - in /geronimo/sandbox/jbohn/daytrader-bp-new: assemblies/web/ assemblies/web/daytrader-eba-all/ assemblies/web/daytrader-eba-all/src/ assemblies/web/daytrader-eba-all/src/main/ assemblies/web/daytrader-eba-all/src/main/assemb...
Date Tue, 02 Feb 2010 21:04:47 GMT
Author: jbohn
Date: Tue Feb  2 21:04:37 2010
New Revision: 905795

URL: http://svn.apache.org/viewvc?rev=905795&view=rev
Log:
add mode for jpa application managed and new assembly that includes all availaable persistence modes

Added:
    geronimo/sandbox/jbohn/daytrader-bp-new/assemblies/web/daytrader-eba-all/
    geronimo/sandbox/jbohn/daytrader-bp-new/assemblies/web/daytrader-eba-all/pom.xml   (with props)
    geronimo/sandbox/jbohn/daytrader-bp-new/assemblies/web/daytrader-eba-all/src/
    geronimo/sandbox/jbohn/daytrader-bp-new/assemblies/web/daytrader-eba-all/src/main/
    geronimo/sandbox/jbohn/daytrader-bp-new/assemblies/web/daytrader-eba-all/src/main/assembly/
    geronimo/sandbox/jbohn/daytrader-bp-new/assemblies/web/daytrader-eba-all/src/main/assembly/assembly.xml   (with props)
    geronimo/sandbox/jbohn/daytrader-bp-new/assemblies/web/daytrader-eba-all/src/main/resources/
    geronimo/sandbox/jbohn/daytrader-bp-new/assemblies/web/daytrader-eba-all/src/main/resources/META-INF/
    geronimo/sandbox/jbohn/daytrader-bp-new/assemblies/web/daytrader-eba-all/src/main/resources/META-INF/APPLICATION.MF
    geronimo/sandbox/jbohn/daytrader-bp-new/assemblies/web/daytrader-eba-all/src/main/resources/META-INF/LICENSE
    geronimo/sandbox/jbohn/daytrader-bp-new/assemblies/web/daytrader-eba-all/src/main/resources/META-INF/NOTICE
    geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-persist-jpa-am/   (with props)
    geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-persist-jpa-am/pom.xml   (with props)
    geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-persist-jpa-am/src/
    geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-persist-jpa-am/src/main/
    geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-persist-jpa-am/src/main/java/
    geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-persist-jpa-am/src/main/java/org/
    geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-persist-jpa-am/src/main/java/org/apache/
    geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-persist-jpa-am/src/main/java/org/apache/geronimo/
    geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-persist-jpa-am/src/main/java/org/apache/geronimo/samples/
    geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-persist-jpa-am/src/main/java/org/apache/geronimo/samples/daytrader/
    geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-persist-jpa-am/src/main/java/org/apache/geronimo/samples/daytrader/persist/
    geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-persist-jpa-am/src/main/java/org/apache/geronimo/samples/daytrader/persist/jpa/
    geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-persist-jpa-am/src/main/java/org/apache/geronimo/samples/daytrader/persist/jpa/TradeJpaAm.java   (with props)
    geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-persist-jpa-am/src/main/resources/
    geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-persist-jpa-am/src/main/resources/META-INF/
    geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-persist-jpa-am/src/main/resources/META-INF/LICENSE
    geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-persist-jpa-am/src/main/resources/META-INF/NOTICE
    geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-persist-jpa-am/src/main/resources/META-INF/persistence.xml   (with props)
    geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-persist-jpa-am/src/main/resources/OSGI-INF/
    geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-persist-jpa-am/src/main/resources/OSGI-INF/blueprint/
    geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-persist-jpa-am/src/main/resources/OSGI-INF/blueprint/blueprint.xml   (with props)
    geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-persist-jpa/src/main/resources/META-INF/persistence.xml
      - copied, changed from r899740, geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-entities/src/main/resources/META-INF/persistence.xml
Modified:
    geronimo/sandbox/jbohn/daytrader-bp-new/assemblies/web/pom.xml
    geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-core/src/main/java/org/apache/geronimo/samples/daytrader/core/TradeDBManagerImpl.java
    geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-entities/pom.xml
    geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-entities/src/main/resources/META-INF/persistence.xml
    geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-persist-jdbc/src/main/java/org/apache/geronimo/samples/daytrader/persist/jdbc/TradeJDBCDirect.java
    geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-persist-jpa/pom.xml
    geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-persist-jpa/src/main/java/org/apache/geronimo/samples/daytrader/persist/jpa/TradeJPADirect.java
    geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-util/src/main/java/org/apache/geronimo/samples/daytrader/util/TradeConfig.java
    geronimo/sandbox/jbohn/daytrader-bp-new/modules/pom.xml

Added: geronimo/sandbox/jbohn/daytrader-bp-new/assemblies/web/daytrader-eba-all/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/jbohn/daytrader-bp-new/assemblies/web/daytrader-eba-all/pom.xml?rev=905795&view=auto
==============================================================================
--- geronimo/sandbox/jbohn/daytrader-bp-new/assemblies/web/daytrader-eba-all/pom.xml (added)
+++ geronimo/sandbox/jbohn/daytrader-bp-new/assemblies/web/daytrader-eba-all/pom.xml Tue Feb  2 21:04:37 2010
@@ -0,0 +1,180 @@
+<?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">
+    <modelVersion>4.0.0</modelVersion>
+    
+    <parent>
+        <groupId>org.apache.geronimo.daytrader.assemblies</groupId>
+        <artifactId>web</artifactId>
+        <version>1.0.0</version>
+    </parent>
+    
+    <groupId>org.apache.geronimo.daytrader.assemblies.web</groupId>
+    <artifactId>daytrader-eba-all</artifactId>    
+    <packaging>pom</packaging>
+    <name>DayTrader :: Assemblies - All Modes - EBA</name>
+    <description>An EBA version of Daytrader</description>
+    
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.geronimo.daytrader.modules</groupId>
+            <artifactId>daytrader-util</artifactId>
+            <version>${version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.daytrader.modules</groupId>
+            <artifactId>daytrader-core</artifactId>
+            <version>${version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.daytrader.modules</groupId>
+            <artifactId>daytrader-api</artifactId>
+            <version>${pom.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.daytrader.modules</groupId>
+            <artifactId>daytrader-entities</artifactId>
+            <version>${version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.daytrader.modules</groupId>
+            <artifactId>daytrader-persist-jdbc</artifactId>
+            <version>${version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.daytrader.modules</groupId>
+            <artifactId>daytrader-persist-jpa</artifactId>
+            <version>${version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.daytrader.modules</groupId>
+            <artifactId>daytrader-persist-jpa-am</artifactId>
+            <version>${version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.daytrader.modules</groupId>
+            <artifactId>daytrader-web</artifactId>
+            <version>${version}</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <!-- Copy dependencies for eba into a common location - eba-jars -->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-dependency-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>copy</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>copy</goal>
+                        </goals>
+                        <configuration>
+                          <artifactItems>
+                            <artifactItem>
+                              <groupId>org.apache.geronimo.daytrader.modules</groupId>
+                              <artifactId>daytrader-util</artifactId>
+                              <outputDirectory>${project.build.directory}/eba-jars</outputDirectory>
+                            </artifactItem>
+                            <artifactItem>
+                              <groupId>org.apache.geronimo.daytrader.modules</groupId>
+                              <artifactId>daytrader-core</artifactId>
+                              <outputDirectory>${project.build.directory}/eba-jars</outputDirectory>
+                            </artifactItem>
+                            <artifactItem>
+                              <groupId>org.apache.geronimo.daytrader.modules</groupId>
+                              <artifactId>daytrader-api</artifactId>
+                              <outputDirectory>${project.build.directory}/eba-jars</outputDirectory>
+                            </artifactItem>
+                            <artifactItem>
+                              <groupId>org.apache.geronimo.daytrader.modules</groupId>
+                              <artifactId>daytrader-entities</artifactId>
+                              <outputDirectory>${project.build.directory}/eba-jars</outputDirectory>
+                            </artifactItem>
+                            <artifactItem>
+                              <groupId>org.apache.geronimo.daytrader.modules</groupId>
+                              <artifactId>daytrader-persist-jdbc</artifactId>
+                              <outputDirectory>${project.build.directory}/eba-jars</outputDirectory>
+                            </artifactItem>
+                            <artifactItem>
+                              <groupId>org.apache.geronimo.daytrader.modules</groupId>
+                              <artifactId>daytrader-persist-jpa</artifactId>
+                              <outputDirectory>${project.build.directory}/eba-jars</outputDirectory>
+                            </artifactItem>
+                            <artifactItem>
+                              <groupId>org.apache.geronimo.daytrader.modules</groupId>
+                              <artifactId>daytrader-persist-jpa-am</artifactId>
+                              <outputDirectory>${project.build.directory}/eba-jars</outputDirectory>
+                            </artifactItem>
+                            <artifactItem>
+                                <groupId>org.apache.geronimo.daytrader.modules</groupId>
+                                <artifactId>daytrader-web</artifactId>
+                                <outputDirectory>${project.build.directory}/eba-jars</outputDirectory>
+                            </artifactItem>
+                          </artifactItems>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+
+            <!-- Use the maven-assembly-plugin to create the eba content as a jar -->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-assembly-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>create-eba-as-jar</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>attached</goal>
+                        </goals>
+                        <configuration>
+                            <descriptors>
+                                <descriptor>${pom.basedir}/src/main/assembly/assembly.xml</descriptor>
+                            </descriptors>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+
+            <!-- Use the maven-antrun-plugin to copy the jar as an eba - NOTE: we can't move the file because maven still expects to install the artifact -->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-antrun-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>copy-jar-to-eba</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>run</goal>
+                        </goals>
+                        <configuration>
+                            <tasks>
+                                <copy file="${project.build.directory}/${project.build.finalName}.jar" tofile="${project.build.directory}/${project.build.finalName}.eba"/>
+                            </tasks>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+
+        </plugins>
+    </build>
+</project>

Propchange: geronimo/sandbox/jbohn/daytrader-bp-new/assemblies/web/daytrader-eba-all/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/jbohn/daytrader-bp-new/assemblies/web/daytrader-eba-all/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/jbohn/daytrader-bp-new/assemblies/web/daytrader-eba-all/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: geronimo/sandbox/jbohn/daytrader-bp-new/assemblies/web/daytrader-eba-all/src/main/assembly/assembly.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/jbohn/daytrader-bp-new/assemblies/web/daytrader-eba-all/src/main/assembly/assembly.xml?rev=905795&view=auto
==============================================================================
--- geronimo/sandbox/jbohn/daytrader-bp-new/assemblies/web/daytrader-eba-all/src/main/assembly/assembly.xml (added)
+++ geronimo/sandbox/jbohn/daytrader-bp-new/assemblies/web/daytrader-eba-all/src/main/assembly/assembly.xml Tue Feb  2 21:04:37 2010
@@ -0,0 +1,46 @@
+<?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.
+-->
+
+<assembly>
+    
+    <formats>
+        <format>jar</format>
+    </formats>
+
+    <includeBaseDirectory>false</includeBaseDirectory>
+
+    <fileSets>
+        <fileSet>
+            <directory>target/eba-jars</directory>
+            <outputDirectory>/</outputDirectory>
+            <includes>
+                <include>**/*.jar</include>
+                <include>**/*.war</include>
+            </includes>
+        </fileSet>
+
+        <fileSet>
+            <directory>src/main/resources</directory>
+            <outputDirectory>/</outputDirectory>
+            <includes>
+                <include>META-INF/**</include>
+            </includes>
+        </fileSet>
+    </fileSets>
+
+</assembly>

Propchange: geronimo/sandbox/jbohn/daytrader-bp-new/assemblies/web/daytrader-eba-all/src/main/assembly/assembly.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/jbohn/daytrader-bp-new/assemblies/web/daytrader-eba-all/src/main/assembly/assembly.xml
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/jbohn/daytrader-bp-new/assemblies/web/daytrader-eba-all/src/main/assembly/assembly.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: geronimo/sandbox/jbohn/daytrader-bp-new/assemblies/web/daytrader-eba-all/src/main/resources/META-INF/APPLICATION.MF
URL: http://svn.apache.org/viewvc/geronimo/sandbox/jbohn/daytrader-bp-new/assemblies/web/daytrader-eba-all/src/main/resources/META-INF/APPLICATION.MF?rev=905795&view=auto
==============================================================================
--- geronimo/sandbox/jbohn/daytrader-bp-new/assemblies/web/daytrader-eba-all/src/main/resources/META-INF/APPLICATION.MF (added)
+++ geronimo/sandbox/jbohn/daytrader-bp-new/assemblies/web/daytrader-eba-all/src/main/resources/META-INF/APPLICATION.MF Tue Feb  2 21:04:37 2010
@@ -0,0 +1,15 @@
+Manifest-Version: 1.0
+Application-ManifestVersion: 1.0
+Application-Name: Daytrader EBA
+Application-SymbolicName: daytrader.eba
+Application-Version: 1.0
+Application-Content: org.apache.geronimo.daytrader.modules.daytrader-util;version=1.0.0,
+ org.apache.geronimo.daytrader.modules.daytrader-api;version=1.0.0,
+ org.apache.geronimo.daytrader.modules.daytrader-core;version=1.0.0,
+ org.apache.geronimo.daytrader.modules.daytrader-persist-jdbc;version=1.0.0,
+ org.apache.geronimo.daytrader.modules.daytrader-persist-jpa;version=1.0.0,
+ org.apache.geronimo.daytrader.modules.daytrader-persist-jpa-am;version=1.0.0,
+ org.apache.geronimo.daytrader.modules.daytrader-entities;version=1.0.0,
+ org.apache.geronimo.daytrader.modules.daytrader-web;version=1.0.0
+
+

Added: geronimo/sandbox/jbohn/daytrader-bp-new/assemblies/web/daytrader-eba-all/src/main/resources/META-INF/LICENSE
URL: http://svn.apache.org/viewvc/geronimo/sandbox/jbohn/daytrader-bp-new/assemblies/web/daytrader-eba-all/src/main/resources/META-INF/LICENSE?rev=905795&view=auto
==============================================================================
--- geronimo/sandbox/jbohn/daytrader-bp-new/assemblies/web/daytrader-eba-all/src/main/resources/META-INF/LICENSE (added)
+++ geronimo/sandbox/jbohn/daytrader-bp-new/assemblies/web/daytrader-eba-all/src/main/resources/META-INF/LICENSE Tue Feb  2 21:04:37 2010
@@ -0,0 +1,203 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed 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.
+

Added: geronimo/sandbox/jbohn/daytrader-bp-new/assemblies/web/daytrader-eba-all/src/main/resources/META-INF/NOTICE
URL: http://svn.apache.org/viewvc/geronimo/sandbox/jbohn/daytrader-bp-new/assemblies/web/daytrader-eba-all/src/main/resources/META-INF/NOTICE?rev=905795&view=auto
==============================================================================
--- geronimo/sandbox/jbohn/daytrader-bp-new/assemblies/web/daytrader-eba-all/src/main/resources/META-INF/NOTICE (added)
+++ geronimo/sandbox/jbohn/daytrader-bp-new/assemblies/web/daytrader-eba-all/src/main/resources/META-INF/NOTICE Tue Feb  2 21:04:37 2010
@@ -0,0 +1,9 @@
+Apache Geronimo 
+Copyright 2003-2010 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
+Portions of this software were developed at IBM and donated to the 
+ASF under the Apache 2.0 license.  The former work was referred to 
+as Trade 6.

Modified: geronimo/sandbox/jbohn/daytrader-bp-new/assemblies/web/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/jbohn/daytrader-bp-new/assemblies/web/pom.xml?rev=905795&r1=905794&r2=905795&view=diff
==============================================================================
--- geronimo/sandbox/jbohn/daytrader-bp-new/assemblies/web/pom.xml (original)
+++ geronimo/sandbox/jbohn/daytrader-bp-new/assemblies/web/pom.xml Tue Feb  2 21:04:37 2010
@@ -33,6 +33,7 @@
     <modules>
         <module>daytrader-eba-jdbc</module>
         <module>daytrader-eba-jpa</module>
+        <module>daytrader-eba-all</module>
     </modules>
 
 </project>

Modified: geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-core/src/main/java/org/apache/geronimo/samples/daytrader/core/TradeDBManagerImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-core/src/main/java/org/apache/geronimo/samples/daytrader/core/TradeDBManagerImpl.java?rev=905795&r1=905794&r2=905795&view=diff
==============================================================================
--- geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-core/src/main/java/org/apache/geronimo/samples/daytrader/core/TradeDBManagerImpl.java (original)
+++ geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-core/src/main/java/org/apache/geronimo/samples/daytrader/core/TradeDBManagerImpl.java Tue Feb  2 21:04:37 2010
@@ -47,7 +47,7 @@
 
     private static String dsName = TradeConfig.DATASOURCE;
 
-    private static DataSource datasource = null;
+    private DataSource dataSource = null;
 
     private static InitialContext context;
 
@@ -64,6 +64,14 @@
     }
 
     /**
+     * set data source
+     */
+    public void setDataSource(DataSource dataSource) {
+            this.dataSource = dataSource;
+    }
+
+
+    /**
      * Return a String containing the DBProductName configured for
      * the current DataSource
      * 
@@ -375,21 +383,21 @@
     /*
      * Lookup the TradeData datasource
      */
-    private void getDataSource() throws Exception {
-        if (datasource == null) {
+    private void lookupDataSource() throws Exception {
+        if (dataSource == null) {
             context = new InitialContext();
-            datasource = (DataSource) context.lookup(dsName);
+            dataSource = (DataSource) context.lookup(dsName);
         }
     }
 
     /*
-     * Allocate a new connection to the datasource
+     * Allocate a new connection to the dataSource
      */
     private Connection getConn() throws Exception {
 
         Connection conn = null;
-        getDataSource();
-        conn = datasource.getConnection();
+        lookupDataSource();
+        conn = dataSource.getConnection();
         conn.setAutoCommit(false);
         if (Log.doTrace()) {
             synchronized (lock) {

Modified: geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-entities/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-entities/pom.xml?rev=905795&r1=905794&r2=905795&view=diff
==============================================================================
--- geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-entities/pom.xml (original)
+++ geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-entities/pom.xml Tue Feb  2 21:04:37 2010
@@ -127,7 +127,6 @@
                     <instructions>
                         <Bundle-SymbolicName>${pom.groupId}.${pom.artifactId}</Bundle-SymbolicName>
                         <Bundle-Version>${pom.version}</Bundle-Version>
-                        <Meta-Persistence>META-INF/persistence.xml</Meta-Persistence>
                         <Export-Package>
                             org.apache.geronimo.samples.daytrader.beans;version=1.0.0
                         </Export-Package>

Modified: geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-entities/src/main/resources/META-INF/persistence.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-entities/src/main/resources/META-INF/persistence.xml?rev=905795&r1=905794&r2=905795&view=diff
==============================================================================
--- geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-entities/src/main/resources/META-INF/persistence.xml (original)
+++ geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-entities/src/main/resources/META-INF/persistence.xml Tue Feb  2 21:04:37 2010
@@ -17,7 +17,7 @@
 -->
 <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
 
-    <persistence-unit transaction-type="JTA" name="daytrader">
+    <persistence-unit transaction-type="RESOURCE_LOCAL" name="daytrader">
         <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
           <jta-data-source>javax.sql.DataSource/(osgi.jndi.serviceName=jdbc/TradeDataSource)</jta-data-source> 
           <non-jta-data-source>javax.sql.DataSource/(osgi.jndi.serviceName=jdbc/NoTxTradeDataSource)</non-jta-data-source> 
@@ -32,7 +32,7 @@
         <properties>
             <property name="openjpa.BrokerImpl" value="non-finalizing" /> 
             <property name="openjpa.Sequence" value="table(Table=OPENJPASEQ, Increment=100)"/>
-            <property name="openjpa.jdbc.UpdateManager" value="com.ibm.ws.persistence.jdbc.kernel.OperationOrderUpdateManager(batchLimit=0)" /> 
+            <property name="openjpa.jdbc.UpdateManager" value="org.apache.openjpa.jdbc.kernel.BatchingConstraintUpdateManager"/>
         </properties>
         
         
@@ -45,7 +45,7 @@
         <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema"/>
         <property name="openjpa.Multithreaded" value="true"/>
         <property name="openjpa.Compatibility" value="flushBeforeDetach=false"/>
-        <property name="openjpa.jdbc.UpdateManager" value="org.apache.openjpa.jdbc.kernel.BatchingConstraintUpdateManager"/>
+        <property name="openjpa.jdbc.UpdateManager" value="com.ibm.ws.persistence.jdbc.kernel.OperationOrderUpdateManager(batchLimit=0)" /> 
       </properties>
       -->
     </persistence-unit>

Modified: geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-persist-jdbc/src/main/java/org/apache/geronimo/samples/daytrader/persist/jdbc/TradeJDBCDirect.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-persist-jdbc/src/main/java/org/apache/geronimo/samples/daytrader/persist/jdbc/TradeJDBCDirect.java?rev=905795&r1=905794&r2=905795&view=diff
==============================================================================
--- geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-persist-jdbc/src/main/java/org/apache/geronimo/samples/daytrader/persist/jdbc/TradeJDBCDirect.java (original)
+++ geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-persist-jdbc/src/main/java/org/apache/geronimo/samples/daytrader/persist/jdbc/TradeJDBCDirect.java Tue Feb  2 21:04:37 2010
@@ -70,7 +70,7 @@
 
     private static String dsName = TradeConfig.DATASOURCE;
 
-    private static DataSource datasource = null;
+    private DataSource dataSource = null;
 
     private static BigDecimal ZERO = new BigDecimal(0.0);
 
@@ -97,6 +97,13 @@
     }
 
     /**
+     * set data source
+     */
+    public void setDataSource(DataSource dataSource) {
+            this.dataSource = dataSource;
+    }
+
+    /**
      * setInSession
      */
     public void setInSession(boolean inSession) {
@@ -1472,10 +1479,10 @@
     /*
      * Lookup the TradeData datasource
      */
-    private void getDataSource() throws Exception {
-        if (datasource == null) {
+    private void lookupDataSource() throws Exception {
+        if (dataSource == null) {
             context = new InitialContext();
-            datasource = (DataSource) context.lookup(dsName);
+            dataSource = (DataSource) context.lookup(dsName);
         }
     }
 
@@ -1485,8 +1492,8 @@
     private Connection getConn() throws Exception {
 
         Connection conn = null;
-        getDataSource();
-        conn = datasource.getConnection();
+        lookupDataSource();
+        conn = dataSource.getConnection();
         conn.setAutoCommit(false);
         if (Log.doTrace()) {
             synchronized (lock) {

Propchange: geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-persist-jpa-am/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Feb  2 21:04:37 2010
@@ -0,0 +1,3 @@
+.classpath
+.project
+.settings

Added: geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-persist-jpa-am/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-persist-jpa-am/pom.xml?rev=905795&view=auto
==============================================================================
--- geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-persist-jpa-am/pom.xml (added)
+++ geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-persist-jpa-am/pom.xml Tue Feb  2 21:04:37 2010
@@ -0,0 +1,93 @@
+<?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">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.geronimo.daytrader</groupId>
+        <artifactId>modules</artifactId>
+        <version>1.0.0</version>
+    </parent>
+
+    <groupId>org.apache.geronimo.daytrader.modules</groupId>
+    <artifactId>daytrader-persist-jpa-am</artifactId>
+    <packaging>bundle</packaging>
+    <name>DayTrader :: Modules - Persist JPA App Managed</name>
+    <description>Daytrader Persist JPA App Managed Module</description>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.geronimo.daytrader.modules</groupId>
+            <artifactId>daytrader-util</artifactId>
+            <version>${pom.version}</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.daytrader.modules</groupId>
+            <artifactId>daytrader-api</artifactId>
+            <version>${pom.version}</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.daytrader.modules</groupId>
+            <artifactId>daytrader-entities</artifactId>
+            <version>${pom.version}</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-jpa_1.0_spec</artifactId>
+            <scope>provided</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <resources>
+            <resource>
+                <directory>${basedir}/src/main/resources</directory>
+                <filtering>true</filtering>
+            </resource>
+        </resources>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <configuration>
+                    <instructions>
+                        <Bundle-SymbolicName>${pom.groupId}.${pom.artifactId}</Bundle-SymbolicName>
+                        <Bundle-Version>${pom.version}</Bundle-Version>
+                        <Meta-Persistence>META-INF/persistence.xml</Meta-Persistence>
+                        <Export-Package>
+                            <!--org.apache.geronimo.samples.daytrader.persist.jpa;version=1.0.0-->
+                        </Export-Package>
+                        <Import-Package>
+                            org.apache.geronimo.samples.daytrader.api;version=1.0,
+                            org.apache.geronimo.samples.daytrader.beans;version=1.0,
+                            org.apache.geronimo.samples.daytrader.persistence.api;version=1.0,
+                            org.apache.geronimo.samples.daytrader.util;version=1.0,
+                            javax.persistence;version=1.0.0
+                        </Import-Package>
+                        <Private-Package>
+                            org.apache.geronimo.samples.daytrader.persist.jpa
+                        </Private-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>

Propchange: geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-persist-jpa-am/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-persist-jpa-am/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-persist-jpa-am/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-persist-jpa-am/src/main/java/org/apache/geronimo/samples/daytrader/persist/jpa/TradeJpaAm.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-persist-jpa-am/src/main/java/org/apache/geronimo/samples/daytrader/persist/jpa/TradeJpaAm.java?rev=905795&view=auto
==============================================================================
--- geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-persist-jpa-am/src/main/java/org/apache/geronimo/samples/daytrader/persist/jpa/TradeJpaAm.java (added)
+++ geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-persist-jpa-am/src/main/java/org/apache/geronimo/samples/daytrader/persist/jpa/TradeJpaAm.java Tue Feb  2 21:04:37 2010
@@ -0,0 +1,979 @@
+/**
+ *  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.geronimo.samples.daytrader.persist.jpa;
+
+import java.math.BigDecimal;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+import javax.persistence.PersistenceUnit;
+import javax.persistence.Query;
+
+import org.apache.geronimo.samples.daytrader.api.TradeServices;
+import org.apache.geronimo.samples.daytrader.beans.AccountDataBeanImpl;
+import org.apache.geronimo.samples.daytrader.beans.AccountProfileDataBeanImpl;
+import org.apache.geronimo.samples.daytrader.beans.HoldingDataBeanImpl;
+import org.apache.geronimo.samples.daytrader.beans.OrderDataBeanImpl;
+import org.apache.geronimo.samples.daytrader.beans.QuoteDataBeanImpl;
+import org.apache.geronimo.samples.daytrader.persistence.api.AccountDataBean;
+import org.apache.geronimo.samples.daytrader.persistence.api.AccountProfileDataBean;
+import org.apache.geronimo.samples.daytrader.persistence.api.HoldingDataBean;
+import org.apache.geronimo.samples.daytrader.persistence.api.MarketSummaryDataBean;
+import org.apache.geronimo.samples.daytrader.persistence.api.OrderDataBean;
+import org.apache.geronimo.samples.daytrader.persistence.api.QuoteDataBean;
+import org.apache.geronimo.samples.daytrader.util.FinancialUtils;
+import org.apache.geronimo.samples.daytrader.util.Log;
+import org.apache.geronimo.samples.daytrader.util.TradeConfig;
+
+/**
+ * TradeJpaAm uses JPA via a Application Managed (AM)
+ * entity managers to implement the business methods of the
+ * Trade online broker application. These business methods
+ * represent the features and operations that can be performed
+ * by customers of the brokerage such as login, logout, get a
+ * stock quote, buy or sell a stock, etc. and are specified in
+ * the {@link
+ * org.apache.geronimo.samples.daytrader.TradeServices}
+ * interface
+ * 
+ * @see org.apache.geronimo.samples.daytrader.TradeServices
+ * 
+ */
+
+public class TradeJpaAm implements TradeServices {
+
+    @PersistenceUnit(unitName="daytrader-am")
+    private static EntityManagerFactory emf;
+
+    private static BigDecimal ZERO = new BigDecimal(0.0);
+
+    private static boolean initialized = false;
+
+    /**
+     * Zero arg constructor for TradeJpaAm
+     */
+    public TradeJpaAm() {
+    }
+
+    public void setEmf (EntityManagerFactory em) { 
+        emf = em;
+    }
+
+    public void init() {
+        if (initialized)
+            return;
+        if (Log.doTrace())
+            Log.trace("TradeJpaAm:init -- *** initializing");
+
+        if (Log.doTrace())
+            Log.trace("TradeJpaAm:init -- +++ initialized");
+
+        initialized = true;
+    }
+
+    public void destroy() {
+        try {
+            if (!initialized)
+                return;
+            Log.trace("TradeJpaAm:destroy");
+        }
+        catch (Exception e) {
+            Log.error("TradeJpaAm:destroy", e);
+        }
+
+    }
+
+    public MarketSummaryDataBean getMarketSummary() {
+        MarketSummaryDataBean marketSummaryData;
+
+        /*
+         * Creating entiManager
+         */
+        EntityManager entityManager = emf.createEntityManager();
+
+        try {
+            if (Log.doTrace())
+                Log.trace("TradeJpaAm:getMarketSummary -- getting market summary");
+
+            // Find Trade Stock Index Quotes (Top 100 quotes)
+            // ordered by their change in value
+            Collection<QuoteDataBean> quotes;
+
+            Query query = entityManager.createNamedQuery("quoteejb.quotesByChange");
+            quotes = query.getResultList();
+
+            QuoteDataBean[] quoteArray = (QuoteDataBean[]) quotes.toArray(new QuoteDataBean[quotes.size()]);
+            ArrayList<QuoteDataBean> topGainers = new ArrayList<QuoteDataBean>(
+                                                                              5);
+            ArrayList<QuoteDataBean> topLosers = new ArrayList<QuoteDataBean>(5);
+            BigDecimal TSIA = FinancialUtils.ZERO;
+            BigDecimal openTSIA = FinancialUtils.ZERO;
+            double totalVolume = 0.0;
+
+            if (quoteArray.length > 5) {
+                for (int i = 0; i < 5; i++)
+                    topGainers.add(quoteArray[i]);
+                for (int i = quoteArray.length - 1; i >= quoteArray.length - 5; i--)
+                    topLosers.add(quoteArray[i]);
+
+                for (QuoteDataBean quote : quoteArray) {
+                    BigDecimal price = quote.getPrice();
+                    BigDecimal open = quote.getOpen();
+                    double volume = quote.getVolume();
+                    TSIA = TSIA.add(price);
+                    openTSIA = openTSIA.add(open);
+                    totalVolume += volume;
+                }
+                TSIA = TSIA.divide(new BigDecimal(quoteArray.length),
+                                   FinancialUtils.ROUND);
+                openTSIA = openTSIA.divide(new BigDecimal(quoteArray.length),
+                                           FinancialUtils.ROUND);
+            }
+
+            marketSummaryData = new MarketSummaryDataBean(TSIA, openTSIA,
+                                                          totalVolume, topGainers, topLosers);
+        }
+        catch (Exception e) {
+            Log.error("TradeJpaAm:getMarketSummary", e);
+            throw new RuntimeException("TradeJpaAm:getMarketSummary -- error ", e);
+        }
+        /*
+         * closing entitymanager
+         */
+        entityManager.close();
+
+        return marketSummaryData;
+    }
+
+    public OrderDataBean buy(String userID, String symbol, double quantity, int orderProcessingMode) {
+        OrderDataBean order = null;
+        BigDecimal total;
+        /*
+         * creating entitymanager
+         */
+        EntityManager entityManager = emf.createEntityManager();
+
+        try {
+            if (Log.doTrace())
+                Log.trace("TradeJpaAm:buy", userID, symbol, quantity, orderProcessingMode);
+
+            entityManager.getTransaction().begin();
+
+            AccountProfileDataBeanImpl profile = entityManager.find(AccountProfileDataBeanImpl.class, userID);
+            AccountDataBean account = profile.getAccount();
+
+            QuoteDataBeanImpl quote = entityManager.find(QuoteDataBeanImpl.class, symbol);
+
+            HoldingDataBeanImpl holding = null; // The holding will be created by this buy order
+
+            order = createOrder( account, (QuoteDataBean) quote, (HoldingDataBean) holding, "buy", quantity, entityManager);
+
+            // order = createOrder(account, quote, holding, "buy", quantity);
+            // UPDATE - account should be credited during completeOrder
+
+            BigDecimal price = quote.getPrice();
+            BigDecimal orderFee = order.getOrderFee();
+            BigDecimal balance = account.getBalance();
+            total = (new BigDecimal(quantity).multiply(price)).add(orderFee);
+            account.setBalance(balance.subtract(total));
+
+            // commit the transaction before calling completeOrder
+            entityManager.getTransaction().commit();
+
+            if (orderProcessingMode == TradeConfig.SYNCH)
+                completeOrder(order.getOrderID(), false);
+            else if (orderProcessingMode == TradeConfig.ASYNCH_2PHASE)
+                queueOrder(order.getOrderID(), true);
+        }
+        catch (Exception e) {
+            Log.error("TradeJpaAm:buy(" + userID + "," + symbol + "," + quantity + ") --> failed", e);
+            /* On exception - cancel the order */
+            // TODO figure out how to do this with JPA
+            if (order != null)
+                order.cancel();
+
+            entityManager.getTransaction().rollback();
+
+            // throw new EJBException(e);
+            throw new RuntimeException(e);
+        }
+        if (entityManager != null) {
+            entityManager.close();
+            entityManager = null;
+        }
+
+        // after the purchase or sell of a stock, update the stocks volume and
+        // price
+        updateQuotePriceVolume(symbol, TradeConfig.getRandomPriceChangeFactor(), quantity);
+
+        return order;
+    }
+
+    public OrderDataBean sell(String userID, Integer holdingID,
+                              int orderProcessingMode) {
+        EntityManager entityManager = emf.createEntityManager();
+
+        OrderDataBean order = null;
+        BigDecimal total;
+        try {
+            entityManager.getTransaction().begin();
+            if (Log.doTrace())
+                Log.trace("TradeJpaAm:sell", userID, holdingID, orderProcessingMode);
+
+            AccountProfileDataBeanImpl profile = entityManager.find(AccountProfileDataBeanImpl.class, userID);
+
+            AccountDataBean account = profile.getAccount();
+            HoldingDataBeanImpl holding = entityManager.find(HoldingDataBeanImpl.class, holdingID);
+
+            if (holding == null) {
+                Log.error("TradeJpaAm:sell User " + userID
+                          + " attempted to sell holding " + holdingID
+                          + " which has already been sold");
+
+                OrderDataBean orderData = new OrderDataBeanImpl();
+                orderData.setOrderStatus("cancelled");
+
+                entityManager.persist(orderData);
+
+                if (entityManager != null) {
+                    entityManager.close();
+                    entityManager = null;
+
+                }
+                entityManager.getTransaction().commit();
+                return orderData;
+            }
+
+            QuoteDataBean quote = holding.getQuote();
+            double quantity = holding.getQuantity();
+
+            order = createOrder(account, quote, holding, "sell", quantity,
+                                entityManager);
+            // UPDATE the holding purchase data to signify this holding is
+            // "inflight" to be sold
+            // -- could add a new holdingStatus attribute to holdingEJB
+            holding.setPurchaseDate(new java.sql.Timestamp(0));
+
+            // UPDATE - account should be credited during completeOrder
+            BigDecimal price = quote.getPrice();
+            BigDecimal orderFee = order.getOrderFee();
+            BigDecimal balance = account.getBalance();
+            total = (new BigDecimal(quantity).multiply(price)).subtract(orderFee);
+
+            account.setBalance(balance.add(total));
+
+            // commit the transaction before calling completeOrder
+            entityManager.getTransaction().commit();
+
+            if (orderProcessingMode == TradeConfig.SYNCH)
+                completeOrder(order.getOrderID(), false);
+            else if (orderProcessingMode == TradeConfig.ASYNCH_2PHASE)
+                queueOrder(order.getOrderID(), true);
+
+        }
+        catch (Exception e) {
+            Log.error("TradeJpaAm:sell(" + userID + "," + holdingID + ") --> failed", e);
+            // TODO figure out JPA cancel
+            if (order != null)
+                order.cancel();
+
+            entityManager.getTransaction().rollback();
+
+            throw new RuntimeException("TradeJpaAm:sell(" + userID + "," + holdingID + ")", e);
+        }
+
+        if (entityManager != null) {
+            entityManager.close();
+            entityManager = null;
+        }
+
+        if (!(order.getOrderStatus().equalsIgnoreCase("cancelled")))
+            //after the purchase or sell of a stock, update the stocks volume and price
+            updateQuotePriceVolume(order.getSymbol(), TradeConfig.getRandomPriceChangeFactor(), order.getQuantity());
+
+        return order;
+    }
+
+    public void queueOrder(Integer orderID, boolean twoPhase) {
+        Log
+        .error("TradeJpaAm:queueOrder() not implemented for this runtime mode");
+        throw new UnsupportedOperationException(
+                                               "TradeJpaAm:queueOrder() not implemented for this runtime mode");
+    }
+
+    public OrderDataBean completeOrder(Integer orderID, boolean twoPhase)
+    throws Exception {
+        EntityManager entityManager = emf.createEntityManager();
+        OrderDataBeanImpl order = null;
+
+        if (Log.doTrace())
+            Log.trace("TradeJpaAm:completeOrder", orderID + " twoPhase=" + twoPhase);
+
+        order = entityManager.find(OrderDataBeanImpl.class, orderID);
+        order.getQuote();
+
+        if (order == null) {
+            Log.error("TradeJpaAm:completeOrder -- Unable to find Order " + orderID + " FBPK returned " + order);
+            return null;
+        }
+
+        if (order.isCompleted()) {
+            throw new RuntimeException("Error: attempt to complete Order that is already completed\n" + order);
+        }
+
+        AccountDataBean account = order.getAccount();
+        QuoteDataBean quote = order.getQuote();
+        HoldingDataBean holding = order.getHolding();
+        BigDecimal price = order.getPrice();
+        double quantity = order.getQuantity();
+
+        String userID = account.getProfile().getUserID();
+
+        if (Log.doTrace())
+            Log.trace("TradeJpaAm:completeOrder--> Completing Order "
+                      + order.getOrderID() + "\n\t Order info: " + order
+                      + "\n\t Account info: " + account + "\n\t Quote info: "
+                      + quote + "\n\t Holding info: " + holding);
+
+        HoldingDataBean newHolding = null;
+        if (order.isBuy()) {
+            /*
+             * Complete a Buy operation - create a new Holding for the Account -
+             * deduct the Order cost from the Account balance
+             */
+
+            newHolding = createHolding(account, quote, quantity, price, entityManager);
+        }
+
+        try {
+            entityManager.getTransaction().begin();
+
+            if (newHolding != null) {
+                order.setHolding(newHolding);
+            }
+
+            if (order.isSell()) {
+                /*
+                 * Complete a Sell operation - remove the Holding from the Account -
+                 * deposit the Order proceeds to the Account balance
+                 */
+                if (holding == null) {
+                    Log.error("TradeJpaAm:completeOrder -- Unable to sell order " + order.getOrderID() + " holding already sold");
+                    order.cancel();
+                    entityManager.getTransaction().commit();
+                    return order;
+                }
+                else {
+                    entityManager.remove(holding);
+                    order.setHolding(null);
+                }
+            }
+
+            order.setOrderStatus("closed");
+
+            order.setCompletionDate(new java.sql.Timestamp(System.currentTimeMillis()));
+
+            if (Log.doTrace())
+                Log.trace("TradeJpaAm:completeOrder--> Completed Order "
+                          + order.getOrderID() + "\n\t Order info: " + order
+                          + "\n\t Account info: " + account + "\n\t Quote info: "
+                          + quote + "\n\t Holding info: " + holding);
+
+            entityManager.getTransaction().commit();
+        }
+        catch (Exception e) {
+            e.printStackTrace();
+            entityManager.getTransaction().rollback();
+        }
+
+        if (entityManager != null) {
+            entityManager.close();
+            entityManager = null;
+        }
+
+        return order;
+    }
+
+    public void cancelOrder(Integer orderID, boolean twoPhase) {
+        EntityManager entityManager = emf.createEntityManager();
+
+        if (Log.doTrace())
+            Log.trace("TradeJpaAm:cancelOrder", orderID + " twoPhase=" + twoPhase);
+
+        OrderDataBeanImpl order = entityManager.find(OrderDataBeanImpl.class, orderID);
+        /*
+         * managed transaction
+         */
+        try {
+            entityManager.getTransaction().begin();
+            order.cancel();
+            entityManager.getTransaction().commit();
+        }
+        catch (Exception e) {
+            entityManager.getTransaction().rollback();
+            entityManager.close();
+            entityManager = null;
+        }
+        entityManager.close();
+    }
+
+    public void orderCompleted(String userID, Integer orderID) {
+        if (Log.doActionTrace())
+            Log.trace("TradeAction:orderCompleted", userID, orderID);
+        if (Log.doTrace())
+            Log.trace("OrderCompleted", userID, orderID);
+    }
+
+    public Collection<OrderDataBean> getOrders(String userID) {
+        if (Log.doTrace())
+            Log.trace("TradeJpaAm:getOrders", userID);
+        EntityManager entityManager = emf.createEntityManager();
+        AccountProfileDataBeanImpl profile = entityManager.find(AccountProfileDataBeanImpl.class, userID);
+        AccountDataBean account = profile.getAccount();
+        entityManager.close();
+        return account.getOrders();
+    }
+
+    public Collection<OrderDataBean> getClosedOrders(String userID) {
+
+        if (Log.doTrace())
+            Log.trace("TradeJpaAm:getClosedOrders", userID);
+        EntityManager entityManager = emf.createEntityManager();
+
+        try {
+
+            // Get the primary keys for all the closed Orders for this
+            // account.
+            /*
+             * managed transaction
+             */
+            entityManager.getTransaction().begin();
+            Query query = entityManager.createNamedQuery("orderejb.closedOrders");
+            query.setParameter("userID", userID);
+
+            entityManager.getTransaction().commit();
+            Collection results = query.getResultList();
+            Iterator itr = results.iterator();
+            // Spin through the orders to populate the lazy quote fields
+            while (itr.hasNext()) {
+                OrderDataBeanImpl thisOrder = (OrderDataBeanImpl) itr.next();
+                thisOrder.getQuote();
+            }
+
+            if (TradeConfig.jpaLayer == TradeConfig.OPENJPA) {
+                Query updateStatus = entityManager.createNamedQuery("orderejb.completeClosedOrders");
+                /*
+                 * managed transaction
+                 */
+                try {
+                    entityManager.getTransaction().begin();
+                    updateStatus.setParameter("userID", userID);
+
+                    updateStatus.executeUpdate();
+                    entityManager.getTransaction().commit();
+                }
+                catch (Exception e) {
+                    entityManager.getTransaction().rollback();
+                    entityManager.close();
+                    entityManager = null;
+                }
+            }
+            else if (TradeConfig.jpaLayer == TradeConfig.HIBERNATE) {
+                /*
+                 * Add logic to do update orders operation, because JBoss5'
+                 * Hibernate 3.3.1GA DB2Dialect and MySQL5Dialect do not work
+                 * with annotated query "orderejb.completeClosedOrders" defined
+                 * in OrderDatabean
+                 */
+                Query findaccountid = entityManager.createNativeQuery(
+                                                        "select "
+                                                        + "a.ACCOUNTID, "
+                                                        + "a.LOGINCOUNT, "
+                                                        + "a.LOGOUTCOUNT, "
+                                                        + "a.LASTLOGIN, "
+                                                        + "a.CREATIONDATE, "
+                                                        + "a.BALANCE, "
+                                                        + "a.OPENBALANCE, "
+                                                        + "a.PROFILE_USERID "
+                                                        + "from accountejb a where a.profile_userid = ?",
+                                                        org.apache.geronimo.samples.daytrader.beans.AccountDataBeanImpl.class);
+                findaccountid.setParameter(1, userID);
+                AccountDataBeanImpl account = (AccountDataBeanImpl) findaccountid.getSingleResult();
+                Integer accountid = account.getAccountID();
+                Query updateStatus = entityManager.createNativeQuery("UPDATE orderejb o SET o.orderStatus = 'completed' WHERE "
+                                                                     + "o.orderStatus = 'closed' AND o.ACCOUNT_ACCOUNTID  = ?");
+                updateStatus.setParameter(1, accountid.intValue());
+                updateStatus.executeUpdate();
+            }
+            if (entityManager != null) {
+                entityManager.close();
+                entityManager = null;
+            }
+            return results;
+        }
+        catch (Exception e) {
+            Log.error("TradeJpaAm.getClosedOrders", e);
+            entityManager.close();
+            entityManager = null;
+            throw new RuntimeException(
+                                      "TradeJpaAm.getClosedOrders - error", e);
+
+        }
+
+    }
+
+    public QuoteDataBean createQuote(String symbol, String companyName, BigDecimal price) {
+
+        EntityManager entityManager = emf.createEntityManager();
+        try {
+            QuoteDataBeanImpl quote = new QuoteDataBeanImpl(symbol, companyName, 0, price, price, price, price, 0);
+            /*
+             * managed transaction
+             */
+            try {
+                entityManager.getTransaction().begin();
+                entityManager.persist(quote);
+                entityManager.getTransaction().commit();
+            }
+            catch (Exception e) {
+                entityManager.getTransaction().rollback();
+            }
+
+            if (Log.doTrace())
+                Log.trace("TradeJpaAm:createQuote-->" + quote);
+
+            if (entityManager != null) {
+                entityManager.close();
+                entityManager = null;
+            }
+            return quote;
+        }
+        catch (Exception e) {
+            Log.error("TradeJpaAm:createQuote -- exception creating Quote", e);
+            entityManager.close();
+            entityManager = null;
+            throw new RuntimeException(e);
+        }
+    }
+
+    public QuoteDataBean getQuote(String symbol) {
+        if (Log.doTrace())
+            Log.trace("TradeJpaAm:getQuote", symbol);
+        EntityManager entityManager = emf.createEntityManager();
+
+        QuoteDataBeanImpl qdb = entityManager.find(QuoteDataBeanImpl.class, symbol);
+
+        if (entityManager != null) {
+            entityManager.close();
+            entityManager = null;
+        }
+        return qdb;
+    }
+
+    public Collection<QuoteDataBean> getAllQuotes() {
+        if (Log.doTrace())
+            Log.trace("TradeJpaAm:getAllQuotes");
+        EntityManager entityManager = emf.createEntityManager();
+
+        Query query = entityManager.createNamedQuery("quoteejb.allQuotes");
+
+        if (entityManager != null) {
+            entityManager.close();
+            entityManager = null;
+
+        }
+        return query.getResultList();
+    }
+
+    public QuoteDataBean updateQuotePriceVolume(String symbol,
+                                                BigDecimal changeFactor, double sharesTraded) {
+        if (!TradeConfig.getUpdateQuotePrices()) {
+            return new QuoteDataBeanImpl();
+        }
+
+        if (Log.doTrace())
+            Log.trace("TradeJpaAm:updateQuote", symbol, changeFactor);
+
+        /*
+         * Add logic to determine JPA layer, because JBoss5' Hibernate 3.3.1GA
+         * DB2Dialect and MySQL5Dialect do not work with annotated query
+         * "quoteejb.quoteForUpdate" defined in QuoteDataBeanImpl
+         */
+        EntityManager entityManager = emf.createEntityManager();
+        QuoteDataBeanImpl quote = null;
+        if (TradeConfig.jpaLayer == TradeConfig.HIBERNATE) {
+            quote = entityManager.find(QuoteDataBeanImpl.class, symbol);
+        } else if (TradeConfig.jpaLayer == TradeConfig.OPENJPA) {
+  
+            Query q = entityManager.createNamedQuery("quoteejb.quoteForUpdate");
+            q.setParameter(1, symbol);
+  
+            quote = (QuoteDataBeanImpl) q.getSingleResult();
+        }
+
+        BigDecimal oldPrice = quote.getPrice();
+
+        if (quote.getPrice().equals(TradeConfig.PENNY_STOCK_PRICE)) {
+            changeFactor = TradeConfig.PENNY_STOCK_RECOVERY_MIRACLE_MULTIPLIER;
+        }
+
+        BigDecimal newPrice = changeFactor.multiply(oldPrice).setScale(2, BigDecimal.ROUND_HALF_UP);
+
+        /*
+         * managed transaction
+         */
+
+        try {
+
+            quote.setPrice(newPrice);
+            quote.setVolume(quote.getVolume() + sharesTraded);
+            quote.setChange((newPrice.subtract(quote.getOpen()).doubleValue()));
+
+            entityManager.getTransaction().begin();
+            entityManager.merge(quote);
+            entityManager.getTransaction().commit();
+        }
+        catch (Exception e) {
+            entityManager.getTransaction().rollback();
+        }
+
+        if (entityManager != null) {
+            entityManager.close();
+            entityManager = null;
+        }
+
+        this.publishQuotePriceChange(quote, oldPrice, changeFactor, sharesTraded);
+
+        return quote;
+    }
+
+    public Collection<HoldingDataBean> getHoldings(String userID) {
+        if (Log.doTrace())
+            Log.trace("TradeJpaAm:getHoldings", userID);
+        EntityManager entityManager = emf.createEntityManager();
+        /*
+         * managed transaction
+         */
+        entityManager.getTransaction().begin();
+
+        Query query = entityManager.createNamedQuery("holdingejb.holdingsByUserID");
+        query.setParameter("userID", userID);
+
+        entityManager.getTransaction().commit();
+        Collection<HoldingDataBean> holdings = query.getResultList();
+        /*
+         * Inflate the lazy data memebers
+         */
+        Iterator itr = holdings.iterator();
+        while (itr.hasNext()) {
+            ((HoldingDataBean) itr.next()).getQuote();
+        }
+
+        entityManager.close();
+        entityManager = null;
+        return holdings;
+    }
+
+    public HoldingDataBean getHolding(Integer holdingID) {
+        if (Log.doTrace())
+            Log.trace("TradeJpaAm:getHolding", holdingID);
+        EntityManager entityManager = emf.createEntityManager();
+        return entityManager.find(HoldingDataBeanImpl.class, holdingID);
+    }
+
+    public AccountDataBean getAccountData(String userID) {
+        if (Log.doTrace())
+            Log.trace("TradeJpaAm:getAccountData", userID);
+
+        EntityManager entityManager = emf.createEntityManager();
+
+        AccountProfileDataBeanImpl profile = entityManager.find(AccountProfileDataBeanImpl.class, userID);
+        /*
+         * Inflate the lazy data memebers
+         */
+        AccountDataBean account = profile.getAccount();
+        account.getProfile();
+
+        // Added to populate transient field for account
+        account.setProfileID(profile.getUserID());
+        entityManager.close();
+        entityManager = null;
+
+        return account;
+    }
+
+    public AccountProfileDataBean getAccountProfileData(String userID) {
+        if (Log.doTrace())
+            Log.trace("TradeJpaAm:getProfileData", userID);
+        EntityManager entityManager = emf.createEntityManager();
+
+        AccountProfileDataBeanImpl apb = entityManager.find(AccountProfileDataBeanImpl.class, userID);
+        entityManager.close();
+        entityManager = null;
+        return apb;
+    }
+
+    public AccountProfileDataBean updateAccountProfile(String userID, String password, String fullName, String address, String email, String creditcard) throws Exception {
+
+        EntityManager entityManager = emf.createEntityManager();
+
+        if (Log.doTrace())
+            Log.trace("TradeJpaAm:updateAccountProfileData", userID);
+        /*
+         * // Retrieve the previous account profile in order to get account
+         * data... hook it into new object AccountProfileDataBean temp =
+         * entityManager.find(AccountProfileDataBean.class,
+         * profileData.getUserID()); // In order for the object to merge
+         * correctly, the account has to be hooked into the temp object... // -
+         * may need to reverse this and obtain the full object first
+         * 
+         * profileData.setAccount(temp.getAccount());
+         * 
+         * //TODO this might not be correct temp =
+         * entityManager.merge(profileData); //System.out.println(temp);
+         */
+
+        AccountProfileDataBeanImpl temp = entityManager.find(AccountProfileDataBeanImpl.class, userID);
+        temp.setAddress(address);
+        temp.setPassword(password);
+        temp.setFullName(fullName);
+        temp.setCreditCard(creditcard);
+        temp.setEmail(email);
+        /*
+         * Managed Transaction
+         */
+        try {
+
+            entityManager.getTransaction().begin();
+            entityManager.merge(temp);
+            entityManager.getTransaction().commit();
+            entityManager.close();
+        }
+        catch (Exception e) {
+            entityManager.getTransaction().rollback();
+            entityManager.close();
+            entityManager = null;
+        }
+
+        return temp;
+    }
+
+    public AccountDataBean login(String userID, String password)
+    throws Exception {
+
+        EntityManager entityManager = emf.createEntityManager();
+
+        AccountProfileDataBeanImpl profile = entityManager.find(AccountProfileDataBeanImpl.class, userID);
+
+        if (profile == null) {
+            throw new RuntimeException("No such user: " + userID);
+        }
+        /*
+         * Managed Transaction
+         */
+        entityManager.getTransaction().begin();
+        entityManager.merge(profile);
+
+        AccountDataBean account = profile.getAccount();
+
+        if (Log.doTrace())
+            Log.trace("TradeJpaAm:login", userID, password);
+
+        account.login(password);
+        entityManager.getTransaction().commit();
+        if (Log.doTrace())
+            Log.trace("TradeJpaAm:login(" + userID + "," + password + ") success" + account);
+        entityManager.close();
+        return account;
+    }
+
+    public void logout(String userID) {
+        if (Log.doTrace())
+            Log.trace("TradeJpaAm:logout", userID);
+        EntityManager entityManager = emf.createEntityManager();
+
+        AccountProfileDataBeanImpl profile = entityManager.find(AccountProfileDataBeanImpl.class, userID);
+        AccountDataBean account = profile.getAccount();
+
+        /*
+         * Managed Transaction
+         */
+        try {
+            entityManager.getTransaction().begin();
+            account.logout();
+            entityManager.getTransaction().commit();
+            entityManager.close();
+        }
+        catch (Exception e) {
+            entityManager.getTransaction().rollback();
+            entityManager.close();
+            entityManager = null;
+        }
+
+        if (Log.doTrace())
+            Log.trace("TradeJpaAm:logout(" + userID + ") success");
+    }
+
+    public AccountDataBean register(String userID, String password, String fullname, 
+                                    String address, String email, String creditcard,
+                                    BigDecimal openBalance) {
+        AccountDataBeanImpl account = null;
+        AccountProfileDataBeanImpl profile = null;
+        EntityManager entityManager = emf.createEntityManager();
+
+        if (Log.doTrace())
+            Log.trace("TradeJpaAm:register", userID, password, fullname, address, email, creditcard, openBalance);
+
+        // Check to see if a profile with the desired userID already exists
+
+        profile = entityManager.find(AccountProfileDataBeanImpl.class, userID);
+
+        if (profile != null) {
+            Log.error("Failed to register new Account - AccountProfile with userID(" + userID + ") already exists");
+            return null;
+        }
+        else {
+            profile = new AccountProfileDataBeanImpl(userID, password, fullname,
+                                                 address, email, creditcard);
+            account = new AccountDataBeanImpl(0, 0, null, new Timestamp(System.currentTimeMillis()), openBalance, openBalance, userID);
+            profile.setAccount((AccountDataBean)account);
+            account.setProfile((AccountProfileDataBean)profile);
+            /*
+             * managed Transaction
+             */
+            try {
+                entityManager.getTransaction().begin();
+                entityManager.persist(profile);
+                entityManager.persist(account);
+                entityManager.getTransaction().commit();
+            }
+            catch (Exception e) {
+                entityManager.getTransaction().rollback();
+                entityManager.close();
+                entityManager = null;
+            }
+        }
+
+
+        return account;
+    }
+
+    /*
+     * NO LONGER USE
+     */
+
+    private void publishQuotePriceChange(QuoteDataBean quote,
+                                         BigDecimal oldPrice, BigDecimal changeFactor, double sharesTraded) {
+        if (!TradeConfig.getPublishQuotePriceChange())
+            return;
+        Log.error("TradeJpaAm:publishQuotePriceChange - is not implemented for this runtime mode");
+        throw new UnsupportedOperationException("TradeJpaAm:publishQuotePriceChange - is not implemented for this runtime mode");
+    }
+
+    /*
+     * new Method() that takes EntityManager as a parameter
+     */
+    private OrderDataBean createOrder(AccountDataBean account,
+                                      QuoteDataBean quote, HoldingDataBean holding, String orderType,
+                                      double quantity, EntityManager entityManager) {
+        OrderDataBeanImpl order;
+        if (Log.doTrace())
+            Log.trace("TradeJpaAm:createOrder(orderID=" + " account="
+                      + ((account == null) ? null : account.getAccountID())
+                      + " quote=" + ((quote == null) ? null : quote.getSymbol())
+                      + " orderType=" + orderType + " quantity=" + quantity);
+        try {
+            order = new OrderDataBeanImpl(orderType, 
+                                      "open", 
+                                      new Timestamp(System.currentTimeMillis()), 
+                                      null, 
+                                      quantity, 
+                                      quote.getPrice().setScale(FinancialUtils.SCALE, FinancialUtils.ROUND),
+                                      TradeConfig.getOrderFee(orderType), 
+                                      account, 
+                                      quote, 
+                                      holding);
+                entityManager.persist(order);
+        }
+        catch (Exception e) {
+            Log.error("TradeJpaAm:createOrder -- failed to create Order", e);
+            throw new RuntimeException("TradeJpaAm:createOrder -- failed to create Order", e);
+        }
+        return order;
+    }
+
+    private HoldingDataBean createHolding(AccountDataBean account,
+                                          QuoteDataBean quote, double quantity, BigDecimal purchasePrice,
+                                          EntityManager entityManager) throws Exception {
+        HoldingDataBeanImpl newHolding = new HoldingDataBeanImpl(quantity,
+                                                         purchasePrice, new Timestamp(System.currentTimeMillis()),
+                                                         account, quote);
+        try {
+            /*
+             * manage transactions
+             */
+            entityManager.getTransaction().begin();
+            entityManager.persist(newHolding);
+            entityManager.getTransaction().commit();
+        }
+        catch (Exception e) {
+            entityManager.getTransaction().rollback();
+            entityManager.close();
+            entityManager = null;
+        }
+        return newHolding;
+    }
+
+    public double investmentReturn(double investment, double NetValue)
+    throws Exception {
+        if (Log.doTrace())
+            Log.trace("TradeJpaAm:investmentReturn");
+
+        double diff = NetValue - investment;
+        double ir = diff / investment;
+        return ir;
+    }
+
+    public QuoteDataBean pingTwoPhase(String symbol) throws Exception {
+        Log
+        .error("TradeJpaAm:pingTwoPhase - is not implemented for this runtime mode");
+        throw new UnsupportedOperationException("TradeJpaAm:pingTwoPhase - is not implemented for this runtime mode");
+    }
+
+    class quotePriceComparator implements java.util.Comparator {
+        public int compare(Object quote1, Object quote2) {
+            double change1 = ((QuoteDataBean) quote1).getChange();
+            double change2 = ((QuoteDataBean) quote2).getChange();
+            return new Double(change2).compareTo(change1);
+        }
+    }
+
+    /**
+     * Get mode - returns the persistence mode (TradeConfig.JPA)
+     * 
+     * @return int mode
+     */
+    public int getMode() {
+        return TradeConfig.JPA_AM;
+    }
+
+}

Propchange: geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-persist-jpa-am/src/main/java/org/apache/geronimo/samples/daytrader/persist/jpa/TradeJpaAm.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-persist-jpa-am/src/main/java/org/apache/geronimo/samples/daytrader/persist/jpa/TradeJpaAm.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-persist-jpa-am/src/main/java/org/apache/geronimo/samples/daytrader/persist/jpa/TradeJpaAm.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message