[maven-release-plugin] copy for tag org.apache.aries.jpa-2.0.0

git-svn-id: http://svn.apache.org/repos/asf/aries/tags/org.apache.aries.jpa-2.0.0@1685808 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..2654c43
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,487 @@
+
+                                 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.
+
+
+	======================================
+	  LICENSES FOR INCLUDED DEPENDENCIES
+	======================================
+
+	All the source code for the Aries JPA project is released under the
+	license above. Additionally, the Aries JPA binary distribution
+	includes a number of third-party files that are required in
+	order to the software to function. Unless noted below, these jars
+	and resource files are also released under the ASF license above.
+
+	The exceptions are as follows:
+
+	===========================
+	  persistence-xsd.rsrc - included in the org.apache.aries.jpa.container jar, taken from:
+	    http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd)
+	  persistence_2_0-xsd.rsrc - included in the org.apache.aries.jpa.container jar, taken from:
+	    http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd)
+	===========================
+
+COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
+
+1. Definitions.
+
+   1.1. Contributor. means each individual or entity that creates or contributes to the creation of Modifications.
+
+   1.2. Contributor Version. means the combination of the Original Software, prior Modifications used by a Contributor (if any), and the Modifications made by that particular Contributor.
+
+   1.3. Covered Software. means (a) the Original Software, or (b) Modifications, or (c) the combination of files containing Original Software with files containing Modifications, in each case including portions thereof.
+
+   1.4. Executable. means the Covered Software in any form other than Source Code.
+
+   1.5. Initial Developer. means the individual or entity that first makes Original Software available under this License.
+
+   1.6. Larger Work. means a work which combines Covered Software or portions thereof with code not governed by the terms of this License.
+
+   1.7. License. means this document.
+
+   1.8. Licensable. means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently acquired, any and all of the rights conveyed herein.
+
+   1.9. Modifications. means the Source Code and Executable form of any of the following:
+
+        A. Any file that results from an addition to, deletion from or modification of the contents of a file containing Original Software or previous Modifications;
+
+        B. Any new file that contains any part of the Original Software or previous Modification; or
+
+        C. Any new file that is contributed or otherwise made available under the terms of this License.
+
+   1.10. Original Software. means the Source Code and Executable form of computer software code that is originally released under this License.
+
+   1.11. Patent Claims. means any patent claim(s), now owned or hereafter acquired, including without limitation, method, process, and apparatus claims, in any patent Licensable by grantor.
+
+   1.12. Source Code. means (a) the common form of computer software code in which modifications are made and (b) associated documentation included in or with such code.
+
+   1.13. You. (or .Your.) means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, .You. includes any entity which controls, is controlled by, or is under common control with You. For purposes of this definition, .control. means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity.
+
+2. License Grants.
+
+      2.1. The Initial Developer Grant.
+
+      Conditioned upon Your compliance with Section 3.1 below and subject to third party intellectual property claims, the Initial Developer hereby grants You a world-wide, royalty-free, non-exclusive license:
+
+         (a) under intellectual property rights (other than patent or trademark) Licensable by Initial Developer, to use, reproduce, modify, display, perform, sublicense and distribute the Original Software (or portions thereof), with or without Modifications, and/or as part of a Larger Work; and
+
+         (b) under Patent Claims infringed by the making, using or selling of Original Software, to make, have made, use, practice, sell, and offer for sale, and/or otherwise dispose of the Original Software (or portions thereof).
+
+        (c) The licenses granted in Sections 2.1(a) and (b) are effective on the date Initial Developer first distributes or otherwise makes the Original Software available to a third party under the terms of this License.
+
+        (d) Notwithstanding Section 2.1(b) above, no patent license is granted: (1) for code that You delete from the Original Software, or (2) for infringements caused by: (i) the modification of the Original Software, or (ii) the combination of the Original Software with other software or devices.
+
+    2.2. Contributor Grant.
+
+    Conditioned upon Your compliance with Section 3.1 below and subject to third party intellectual property claims, each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license:
+
+        (a) under intellectual property rights (other than patent or trademark) Licensable by Contributor to use, reproduce, modify, display, perform, sublicense and distribute the Modifications created by such Contributor (or portions thereof), either on an unmodified basis, with other Modifications, as Covered Software and/or as part of a Larger Work; and
+
+        (b) under Patent Claims infringed by the making, using, or selling of Modifications made by that Contributor either alone and/or in combination with its Contributor Version (or portions of such combination), to make, use, sell, offer for sale, have made, and/or otherwise dispose of: (1) Modifications made by that Contributor (or portions thereof); and (2) the combination of Modifications made by that Contributor with its Contributor Version (or portions of such combination).
+
+        (c) The licenses granted in Sections 2.2(a) and 2.2(b) are effective on the date Contributor first distributes or otherwise makes the Modifications available to a third party.
+
+        (d) Notwithstanding Section 2.2(b) above, no patent license is granted: (1) for any code that Contributor has deleted from the Contributor Version; (2) for infringements caused by: (i) third party modifications of Contributor Version, or (ii) the combination of Modifications made by that Contributor with other software (except as part of the Contributor Version) or other devices; or (3) under Patent Claims infringed by Covered Software in the absence of Modifications made by that Contributor.
+
+3. Distribution Obligations.
+
+      3.1. Availability of Source Code.
+      Any Covered Software that You distribute or otherwise make available in Executable form must also be made available in Source Code form and that Source Code form must be distributed only under the terms of this License. You must include a copy of this License with every copy of the Source Code form of the Covered Software You distribute or otherwise make available. You must inform recipients of any such Covered Software in Executable form as to how they can obtain such Covered Software in Source Code form in a reasonable manner on or through a medium customarily used for software exchange.
+
+      3.2. Modifications.
+      The Modifications that You create or to which You contribute are governed by the terms of this License. You represent that You believe Your Modifications are Your original creation(s) and/or You have sufficient rights to grant the rights conveyed by this License.
+
+      3.3. Required Notices.
+      You must include a notice in each of Your Modifications that identifies You as the Contributor of the Modification. You may not remove or alter any copyright, patent or trademark notices contained within the Covered Software, or any notices of licensing or any descriptive text giving attribution to any Contributor or the Initial Developer.
+
+      3.4. Application of Additional Terms.
+      You may not offer or impose any terms on any Covered Software in Source Code form that alters or restricts the applicable version of this License or the recipients. rights hereunder. You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Software. However, you may do so only on Your own behalf, and not on behalf of the Initial Developer or any Contributor. You must make it absolutely clear that any such warranty, support, indemnity or liability obligation is offered by You alone, and You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of warranty, support, indemnity or liability terms You offer.
+
+      3.5. Distribution of Executable Versions.
+      You may distribute the Executable form of the Covered Software under the terms of this License or under the terms of a license of Your choice, which may contain terms different from this License, provided that You are in compliance with the terms of this License and that the license for the Executable form does not attempt to limit or alter the recipient.s rights in the Source Code form from the rights set forth in this License. If You distribute the Covered Software in Executable form under a different license, You must make it absolutely clear that any terms which differ from this License are offered by You alone, not by the Initial Developer or Contributor. You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of any such terms You offer.
+
+      3.6. Larger Works.
+      You may create a Larger Work by combining Covered Software with other code not governed by the terms of this License and distribute the Larger Work as a single product. In such a case, You must make sure the requirements of this License are fulfilled for the Covered Software.
+
+4. Versions of the License.
+
+      4.1. New Versions.
+      Sun Microsystems, Inc. is the initial license steward and may publish revised and/or new versions of this License from time to time. Each version will be given a distinguishing version number. Except as provided in Section 4.3, no one other than the license steward has the right to modify this License.
+
+      4.2. Effect of New Versions.
+      You may always continue to use, distribute or otherwise make the Covered Software available under the terms of the version of the License under which You originally received the Covered Software. If the Initial Developer includes a notice in the Original Software prohibiting it from being distributed or otherwise made available under any subsequent version of the License, You must distribute and make the Covered Software available under the terms of the version of the License under which You originally received the Covered Software. Otherwise, You may also choose to use, distribute or otherwise make the Covered Software available under the terms of any subsequent version of the License published by the license steward.
+
+      4.3. Modified Versions.
+      When You are an Initial Developer and You want to create a new license for Your Original Software, You may create and use a modified version of this License if You: (a) rename the license and remove any references to the name of the license steward (except to note that the license differs from this License); and (b) otherwise make it clear that the license contains terms which differ from this License.
+
+5. DISCLAIMER OF WARRANTY.
+
+   COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN .AS IS. BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
+
+6. TERMINATION.
+
+      6.1. This License and the rights granted hereunder will terminate automatically if You fail to comply with terms herein and fail to cure such breach within 30 days of becoming aware of the breach. Provisions which, by their nature, must remain in effect beyond the termination of this License shall survive.
+
+      6.2. If You assert a patent infringement claim (excluding declaratory judgment actions) against Initial Developer or a Contributor (the Initial Developer or Contributor against whom You assert such claim is referred to as .Participant.) alleging that the Participant Software (meaning the Contributor Version where the Participant is a Contributor or the Original Software where the Participant is the Initial Developer) directly or indirectly infringes any patent, then any and all rights granted directly or indirectly to You by such Participant, the Initial Developer (if the Initial Developer is not the Participant) and all Contributors under Sections 2.1 and/or 2.2 of this License shall, upon 60 days notice from Participant terminate prospectively and automatically at the expiration of such 60 day notice period, unless if within such 60 day period You withdraw Your claim with respect to the Participant Software against such Participant either unilaterally or pursuant to a written agreement with Participant.
+
+      6.3. In the event of termination under Sections 6.1 or 6.2 above, all end user licenses that have been validly granted by You or any distributor hereunder prior to termination (excluding licenses granted to You by any distributor) shall survive termination.
+
+7. LIMITATION OF LIABILITY.
+
+   UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOST PROFITS, LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY RESULTING FROM SUCH PARTY.S NEGLIGENCE TO THE EXTENT APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
+
+8. U.S. GOVERNMENT END USERS.
+
+   The Covered Software is a .commercial item,. as that term is defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of .commercial computer software. (as that term is defined at 48 C.F.R. ? 252.227-7014(a)(1)) and .commercial computer software documentation. as such terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users acquire Covered Software with only those rights set forth herein. This U.S. Government Rights clause is in lieu of, and supersedes, any other FAR, DFAR, or other clause or provision that addresses Government rights in computer software under this License.
+
+9. MISCELLANEOUS.
+
+   This License represents the complete agreement concerning subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. This License shall be governed by the law of the jurisdiction specified in a notice contained within the Original Software (except to the extent applicable law, if any, provides otherwise), excluding such jurisdiction.s conflict-of-law provisions. Any litigation relating to this License shall be subject to the jurisdiction of the courts located in the jurisdiction and venue specified in a notice contained within the Original Software, with the losing party responsible for costs, including, without limitation, court costs and reasonable attorneys. fees and expenses. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not apply to this License. You agree that You alone are responsible for compliance with the United States export administration regulations (and the export control laws and regulation of any other countries) when You use, distribute or otherwise make available any Covered Software.
+
+10. RESPONSIBILITY FOR CLAIMS.
+
+   As between Initial Developer and the Contributors, each party is responsible for claims and damages arising, directly or indirectly, out of its utilization of rights under this License and You agree to work with Initial Developer and Contributors to distribute such responsibility on an equitable basis. Nothing herein is intended or shall be deemed to constitute any admission of liability.
+
+   NOTICE PURSUANT TO SECTION 9 OF THE COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL)
+
+   The code released under the CDDL shall be governed by the laws of the State of California (excluding conflict-of-law provisions). Any litigation relating to this License shall be subject to the jurisdiction of the Federal Courts of the Northern District of California and the state courts of the State of California, with venue lying in Santa Clara County, California.
+
+
+The GNU General Public License (GPL) Version 2, June 1991
+
+
+Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
+
+Preamble
+
+The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too.
+
+When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.
+
+To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.
+
+For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
+
+We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.
+
+Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.
+
+Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.
+
+The precise terms and conditions for copying, distribution and modification follow.
+
+
+TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.
+
+1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.
+
+2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
+
+   a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.
+
+   b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License.
+
+   c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
+
+3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:
+
+   a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
+
+   b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
+
+   c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.
+
+If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.
+
+4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
+
+5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.
+
+6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.
+
+7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.
+
+This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
+
+8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
+
+9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.
+
+10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.
+
+NO WARRANTY
+
+11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+END OF TERMS AND CONDITIONS
+
+
+How to Apply These Terms to Your New Programs
+
+If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
+
+To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.
+
+   One line to give the program's name and a brief idea of what it does.
+
+   Copyright (C)
+
+   This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this when it starts in an interactive mode:
+
+   Gnomovision version 69, Copyright (C) year name of author
+   Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names:
+
+   Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+   signature of Ty Coon, 1 April 1989
+   Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License.
+
+
+"CLASSPATH" EXCEPTION TO THE GPL VERSION 2
+
+Certain source files distributed by Sun Microsystems, Inc. are subject to the following clarification and special exception to the GPL Version 2, but only where Sun has expressly included in the particular source file's header the words
+
+"Sun designates this particular file as subject to the "Classpath" exception as provided by Sun in the License file that accompanied this code."
+
+Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License Version 2 cover the whole combination.
+
+As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module.? An independent module is a module which is not derived from or based on this library.? If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so.? If you do not wish to do so, delete this exception statement from your version.
+
diff --git a/NOTICE b/NOTICE
new file mode 100644
index 0000000..6a67805
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,14 @@
+
+Apache Aries
+Copyright 2009-2010 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+Aries JPA includes the persistence schemas from the JPA specifications.
+Copyright 2005-2009 Sun Microsystems, Inc. All rights reserved.
+Aries JPA elects to include this software in this distribution under the
+CDDL license.  You can obtain a copy of the License at:
+    https://glassfish.dev.java.net/public/CDDL+GPL.html
+The source code is available at:
+    https://glassfish.dev.java.net/source/browse/glassfish/
diff --git a/examples/README.md b/examples/README.md
new file mode 100644
index 0000000..0f5ca37
--- /dev/null
+++ b/examples/README.md
@@ -0,0 +1,70 @@
+# Installation instructions for jpa-examples
+
+# copy DataSource config
+cat https://svn.apache.org/repos/asf/aries/trunk/jpa/examples/org.ops4j.datasource-tasklist.cfg | tac -f etc/org.ops4j.datasource-tasklist.cfg 
+
+feature:repo-add mvn:org.ops4j.pax.jdbc/pax-jdbc-features/0.6.0-SNAPSHOT/xml/features
+feature:install scr transaction pax-jdbc-config pax-jdbc-h2 pax-jdbc-pool-dbcp2 http-whiteboard
+
+install -s mvn:org.hibernate.javax.persistence/hibernate-jpa-2.1-api/1.0.0.Final
+
+# Hibernate + Dependencies
+# Normally we would use the karaf feature but it installs the old aries jpa which we do not want
+install -s mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.antlr/2.7.7_5
+install -s mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.ant/1.8.2_2
+install -s mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.dom4j/1.6.1_5
+install -s mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.serp/1.14.1_1
+install -s mvn:com.fasterxml/classmate/0.9.0
+install -s mvn:org.javassist/javassist/3.18.1-GA
+install -s mvn:org.jboss.spec.javax.security.jacc/jboss-jacc-api_1.4_spec/1.0.2.Final
+install -s mvn:org.jboss/jandex/1.2.2.Final
+install -s mvn:org.jboss.logging/jboss-logging/3.1.4.GA
+install -s mvn:org.hibernate.common/hibernate-commons-annotations/4.0.4.Final
+install -s mvn:org.hibernate/hibernate-core/4.3.6.Final
+install -s mvn:org.hibernate/hibernate-entitymanager/4.3.6.Final
+install -s mvn:org.hibernate/hibernate-osgi/4.3.6.Final 
+
+# Eclipselink + Dependencies
+install -s mvn:org.eclipse.persistence/javax.persistence/2.1.0
+install -s mvn:org.eclipse.persistence/org.eclipse.persistence.core/2.6.0
+install -s mvn:org.eclipse.persistence/org.eclipse.persistence.asm/2.6.0
+install -s mvn:org.eclipse.persistence/org.eclipse.persistence.jpa/2.6.0
+install -s mvn:org.eclipse.persistence/org.eclipse.persistence.antlr/2.6.0
+install -s mvn:org.eclipse.persistence/org.eclipse.persistence.jpa.jpql/2.6.0
+install -s mvn:org.apache.aries.jpa/org.apache.aries.jpa.eclipselink.adapter/1.0.0-SNAPSHOT
+
+
+# Our JPA service implementation
+install -s mvn:org.apache.aries.jpa/org.apache.aries.jpa.api/2.0.0-SNAPSHOT
+install -s mvn:org.apache.aries.jpa/org.apache.aries.jpa.container/2.0.0-SNAPSHOT
+install -s mvn:org.apache.aries.jpa/org.apache.aries.jpa.support/2.0.0-SNAPSHOT
+
+# Closure based example. (Make sure to start karaf with JDK 8)
+install -s mvn:org.apache.aries.jpa.example/org.apache.aries.jpa.example.tasklist.model/2.0.0-SNAPSHOT
+install -s mvn:org.apache.aries.jpa.example/org.apache.aries.jpa.example.tasklist.ds/2.0.0-SNAPSHOT
+
+# Blueprint based example
+install -s mvn:org.apache.aries.jpa/org.apache.aries.jpa.blueprint/2.0.0-SNAPSHOT
+install -s mvn:org.apache.aries.jpa.example/org.apache.aries.jpa.example.tasklist.model/2.0.0-SNAPSHOT
+install -s mvn:org.apache.aries.jpa.example/org.apache.aries.jpa.example.tasklist.blueprint/2.0.0-SNAPSHOT
+
+
+After installing the examples you can check for the services.
+
+service:list EntityManagerFactory
+
+You should see a service for the persistence unit "tasklist".
+
+service:list TaskService
+
+You should see a service provided by either the tasklist.blueprint or tasklist.ds bundle depending on the example you installed.
+
+http://localhost:8181/tasklist
+
+If you open the above url in a webbrowser you should see a list with one task.
+Now add a task:
+http://localhost:8181/tasklist?add&taskId=4&title=Buy more coffee
+
+and check it is added to the list
+http://localhost:8181/tasklist
+
diff --git a/examples/org.ops4j.datasource-tasklist.cfg b/examples/org.ops4j.datasource-tasklist.cfg
new file mode 100644
index 0000000..6887c29
--- /dev/null
+++ b/examples/org.ops4j.datasource-tasklist.cfg
@@ -0,0 +1,3 @@
+osgi.jdbc.driver.name = H2-pool-xa
+databaseName = tasklist;create=true
+dataSourceName = tasklist
diff --git a/examples/pom.xml b/examples/pom.xml
new file mode 100644
index 0000000..ec94d22
--- /dev/null
+++ b/examples/pom.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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/xsd/maven-4.0.0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>org.apache.aries.jpa.example</groupId>
+    <artifactId>org.apache.aries.jpa.example.parent</artifactId>
+    <name>Apache Aries JPA example parent</name>
+    <packaging>pom</packaging>
+
+    <parent>
+        <groupId>org.apache.aries.jpa</groupId>
+        <artifactId>org.apache.aries.jpa.parent</artifactId>
+        <version>2.0.0</version>
+        <relativePath>../jpa-parent</relativePath>
+    </parent>
+    
+    <properties>
+        <aries.skip.version.check>true</aries.skip.version.check>
+    </properties>
+
+    <modules>
+        <module>tasklist-blueprint</module>
+        <module>tasklist-ds</module>
+        <module>tasklist-model</module>
+    </modules>
+
+</project>
+
diff --git a/examples/tasklist-blueprint/pom.xml b/examples/tasklist-blueprint/pom.xml
new file mode 100644
index 0000000..0d4e57c
--- /dev/null
+++ b/examples/tasklist-blueprint/pom.xml
@@ -0,0 +1,73 @@
+<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/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.aries.jpa.example</groupId>
+        <artifactId>org.apache.aries.jpa.example.parent</artifactId>
+        <version>2.0.0</version>
+        <relativePath>..</relativePath>
+    </parent>
+    <artifactId>org.apache.aries.jpa.example.tasklist.blueprint</artifactId>
+    <name>Apache Aries JPA example tasklist blueprint</name>
+    <packaging>bundle</packaging>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.hibernate.javax.persistence</groupId>
+            <artifactId>hibernate-jpa-2.1-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.jpa.example</groupId>
+            <artifactId>org.apache.aries.jpa.example.tasklist.model</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.jpa</groupId>
+            <artifactId>org.apache.aries.jpa.api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.transaction</groupId>
+            <artifactId>org.apache.aries.transaction.blueprint</artifactId>
+            <version>1.0.2</version>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>servlet-api</artifactId>
+            <version>2.5</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.aries.jpa</groupId>
+            <artifactId>org.apache.aries.jpa.support</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.11</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.hibernate</groupId>
+            <artifactId>hibernate-entitymanager</artifactId>
+            <version>4.3.8.Final</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.derby</groupId>
+            <artifactId>derby</artifactId>
+            <version>10.11.1.1</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+</project>
\ No newline at end of file
diff --git a/examples/tasklist-blueprint/src/main/java/org/apache/aries/jpa/example/tasklist/blueprint/impl/TaskServiceImpl.java b/examples/tasklist-blueprint/src/main/java/org/apache/aries/jpa/example/tasklist/blueprint/impl/TaskServiceImpl.java
new file mode 100644
index 0000000..cee895f
--- /dev/null
+++ b/examples/tasklist-blueprint/src/main/java/org/apache/aries/jpa/example/tasklist/blueprint/impl/TaskServiceImpl.java
@@ -0,0 +1,68 @@
+/*
+ * 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 WARRANTIESOR 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.aries.jpa.example.tasklist.blueprint.impl;
+
+import java.util.Collection;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+import org.apache.aries.jpa.example.tasklist.model.Task;
+import org.apache.aries.jpa.example.tasklist.model.TaskService;
+import org.apache.aries.transaction.annotations.Transaction;
+
+
+public class TaskServiceImpl implements TaskService {
+
+	@PersistenceContext(unitName="tasklist")
+	EntityManager em;
+	
+	@Override
+	public Task getTask(Integer id) {
+		return em.find(Task.class, id);
+	}
+
+	@Transaction
+	@Override
+	public void addTask(Task task) {
+		em.persist(task);
+		em.flush();
+	}
+
+	public Collection<Task> getTasks() {
+		return em.createQuery("select t from Task t", Task.class)
+			.getResultList();
+	}
+
+	@Transaction
+	@Override
+	public void updateTask(Task task) {
+		em.persist(task);
+	}
+
+	@Transaction
+	@Override
+	public void deleteTask(Integer id) {
+		em.remove(getTask(id));
+	}
+
+	public void setEm(EntityManager em) {
+		this.em = em;
+	}
+}
diff --git a/examples/tasklist-blueprint/src/main/java/org/apache/aries/jpa/example/tasklist/blueprint/impl/TaskServiceWithSupplier.java b/examples/tasklist-blueprint/src/main/java/org/apache/aries/jpa/example/tasklist/blueprint/impl/TaskServiceWithSupplier.java
new file mode 100644
index 0000000..01db717
--- /dev/null
+++ b/examples/tasklist-blueprint/src/main/java/org/apache/aries/jpa/example/tasklist/blueprint/impl/TaskServiceWithSupplier.java
@@ -0,0 +1,69 @@
+/*
+ * 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 WARRANTIESOR 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.aries.jpa.example.tasklist.blueprint.impl;
+
+import java.util.Collection;
+
+import javax.persistence.PersistenceContext;
+
+import org.apache.aries.jpa.example.tasklist.model.Task;
+import org.apache.aries.jpa.example.tasklist.model.TaskService;
+import org.apache.aries.jpa.supplier.EmSupplier;
+import org.apache.aries.transaction.annotations.Transaction;
+
+
+public class TaskServiceWithSupplier implements TaskService {
+
+    @PersistenceContext(unitName = "tasklist")
+    EmSupplier em;
+
+    @Override
+    public Task getTask(Integer id) {
+        return em.get().find(Task.class, id);
+    }
+
+    @Transaction
+    @Override
+    public void addTask(Task task) {
+        em.get().persist(task);
+        em.get().flush();
+    }
+
+    public Collection<Task> getTasks() {
+        return em.get().createQuery("select t from Task t", Task.class).getResultList();
+    }
+    
+    @Override
+    public void updateTask(Task task) {
+        em.get().persist(task);
+    }
+
+    @Override
+    public void deleteTask(Integer id) {
+        em.get().remove(getTask(id));
+    }
+
+    public void setEm(EmSupplier em) {
+        this.em = em;
+    }
+    
+    public void init() {
+        addTask(new Task(1, "Test", "Testdescription"));
+    }
+}
diff --git a/examples/tasklist-blueprint/src/main/java/org/apache/aries/jpa/example/tasklist/blueprint/impl/TasklistServlet.java b/examples/tasklist-blueprint/src/main/java/org/apache/aries/jpa/example/tasklist/blueprint/impl/TasklistServlet.java
new file mode 100644
index 0000000..e051ec2
--- /dev/null
+++ b/examples/tasklist-blueprint/src/main/java/org/apache/aries/jpa/example/tasklist/blueprint/impl/TasklistServlet.java
@@ -0,0 +1,74 @@
+package org.apache.aries.jpa.example.tasklist.blueprint.impl;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.text.SimpleDateFormat;
+import java.util.Collection;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.aries.jpa.example.tasklist.model.Task;
+import org.apache.aries.jpa.example.tasklist.model.TaskService;
+import org.osgi.service.component.annotations.Reference;
+
+public class TasklistServlet extends HttpServlet {
+    
+    TaskService taskService;
+
+    private static final long serialVersionUID = 34992072289535683L;
+
+    @Override
+    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
+        IOException {
+        String add = req.getParameter("add");
+        String taskId = req.getParameter("taskId");
+        String title = req.getParameter("title");
+        PrintWriter writer = resp.getWriter();
+        if (add != null) {
+            addTask(taskId, title);
+        } else if (taskId != null && taskId.length() > 0) {
+            showTask(writer, taskId);
+        } else {
+            showTaskList(writer);
+        }
+    }
+
+    private void addTask(String taskId, String title) {
+        Task task = new Task();
+        task.setId(new Integer(taskId));
+        task.setTitle(title);
+        taskService.addTask(task );
+    }
+
+    private void showTaskList(PrintWriter writer) {
+        writer.println("<h1>Tasks</h1>");
+        Collection<Task> tasks = taskService.getTasks();
+        for (Task task : tasks) {
+            writer.println("<a href=\"?taskId=" + task.getId() + "\">" + task.getTitle() + "</a><BR/>");
+        }
+    }
+
+    private void showTask(PrintWriter writer, String taskId) {
+        SimpleDateFormat sdf = new SimpleDateFormat();
+        Task task = taskService.getTask(new Integer(taskId));
+        if (task != null) {
+            writer.println("<h1>Task " + task.getTitle() + " </h1>");
+            if (task.getDueDate() != null) {
+                writer.println("Due date: " + sdf.format(task.getDueDate()) + "<br/>");
+            }
+            writer.println(task.getDescription());
+        } else {
+            writer.println("Task with id " + taskId + " not found");
+        }
+
+    }
+
+    @Reference
+    public void setTaskService(TaskService taskService) {
+        this.taskService = taskService;
+    }
+
+}
diff --git a/examples/tasklist-blueprint/src/main/resources/OSGI-INF/blueprint/context.xml b/examples/tasklist-blueprint/src/main/resources/OSGI-INF/blueprint/context.xml
new file mode 100644
index 0000000..f80a7bf
--- /dev/null
+++ b/examples/tasklist-blueprint/src/main/resources/OSGI-INF/blueprint/context.xml
@@ -0,0 +1,40 @@
+<?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. -->

+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"

+	xmlns:jpa="http://aries.apache.org/xmlns/jpan/v1.0.0"

+	xmlns:tx="http://aries.apache.org/xmlns/transactions/v1.2.0"

+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

+	xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 https://osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">

+

+	<jpa:enable />

+	<tx:enable-annotations />

+

+	<service ref="taskService" interface="org.apache.aries.jpa.example.tasklist.model.TaskService">

+	</service>

+	<bean id="taskService" class="org.apache.aries.jpa.example.tasklist.blueprint.impl.TaskServiceWithSupplier">

+		<tx:transaction method="*"/>

+	</bean>

+	<!-- <bean class="org.apache.aries.jpa.example.tasklist.blueprint.impl.TaskServiceImpl"/> -->

+    

+    <!-- 

+        We use the task service directly here to make the example smaller.

+        For a real project the UI might be in a separate bundle

+     -->

+    <bean id="tasklistServlet" class="org.apache.aries.jpa.example.tasklist.blueprint.impl.TasklistServlet">

+        <property name="taskService" ref="taskService"/>

+    </bean>

+    <service interface="javax.servlet.Servlet" ref="tasklistServlet">

+        <service-properties>

+            <entry key="alias" value="/tasklist"/>

+        </service-properties>

+    </service>

+</blueprint>
\ No newline at end of file
diff --git a/examples/tasklist-blueprint/src/test/java/org/apache/aries/jpa/tasklist/blueprint/impl/TaskServiceImplTest.java b/examples/tasklist-blueprint/src/test/java/org/apache/aries/jpa/tasklist/blueprint/impl/TaskServiceImplTest.java
new file mode 100644
index 0000000..618b129
--- /dev/null
+++ b/examples/tasklist-blueprint/src/test/java/org/apache/aries/jpa/tasklist/blueprint/impl/TaskServiceImplTest.java
@@ -0,0 +1,65 @@
+/*
+ * 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 WARRANTIESOR 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.aries.jpa.tasklist.blueprint.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+
+import org.apache.aries.jpa.example.tasklist.blueprint.impl.TaskServiceImpl;
+import org.apache.aries.jpa.example.tasklist.model.Task;
+import org.apache.aries.jpa.example.tasklist.model.TaskService;
+import org.apache.aries.jpa.supplier.EmSupplier;
+import org.apache.aries.jpa.support.impl.EMSupplierImpl;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TaskServiceImplTest {
+    @Test
+    public void testPersistence() {
+        TaskServiceImpl taskServiceImpl = new TaskServiceImpl();
+        EntityManagerFactory emf = createTestEMF();
+        EmSupplier emSupplier = new EMSupplierImpl(emf);
+        emSupplier.preCall();
+        emSupplier.get().getTransaction().begin();
+        taskServiceImpl.setEm(emSupplier.get());
+
+        TaskService taskService = taskServiceImpl;
+
+        Task task = new Task();
+        task.setId(1);
+        task.setTitle("test");
+        taskService.addTask(task);
+
+        Task task2 = taskService.getTask(1);
+        Assert.assertEquals(task.getTitle(), task2.getTitle());
+        emSupplier.get().getTransaction().commit();
+        emSupplier.postCall();
+    }
+
+    private EntityManagerFactory createTestEMF() {
+        Map<String, String> properties = new HashMap<>();
+        properties.put("javax.persistence.jdbc.driver", "org.apache.derby.jdbc.EmbeddedDriver");
+        properties.put("javax.persistence.jdbc.url", "jdbc:derby:target/test;create=true");
+        EntityManagerFactory emf = Persistence.createEntityManagerFactory("tasklist", properties);
+        return emf;
+    }
+}
diff --git a/examples/tasklist-blueprint/src/test/resources/META-INF/persistence.xml b/examples/tasklist-blueprint/src/test/resources/META-INF/persistence.xml
new file mode 100644
index 0000000..ddf8eaf
--- /dev/null
+++ b/examples/tasklist-blueprint/src/test/resources/META-INF/persistence.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
+    
+    <persistence-unit name="tasklist" transaction-type="RESOURCE_LOCAL">
+        <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
+       	<class>org.apache.aries.jpa.example.tasklist.model.Task</class>
+        <properties>
+            <property name="hibernate.dialect" value="org.hibernate.dialect.DerbyTenSevenDialect"/>
+            <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
+        </properties>
+    </persistence-unit>
+
+</persistence>
diff --git a/examples/tasklist-ds/README.txt b/examples/tasklist-ds/README.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/examples/tasklist-ds/README.txt
diff --git a/examples/tasklist-ds/pom.xml b/examples/tasklist-ds/pom.xml
new file mode 100644
index 0000000..a1e0e66
--- /dev/null
+++ b/examples/tasklist-ds/pom.xml
@@ -0,0 +1,90 @@
+<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/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.aries.jpa.example</groupId>
+        <artifactId>org.apache.aries.jpa.example.parent</artifactId>
+        <version>2.0.0</version>
+        <relativePath>..</relativePath>
+    </parent>
+    <artifactId>org.apache.aries.jpa.example.tasklist.ds</artifactId>
+    <name>Apache Aries JPA example tasklist DS</name>
+    <packaging>bundle</packaging>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.hibernate.javax.persistence</groupId>
+            <artifactId>hibernate-jpa-2.1-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.jpa.example</groupId>
+            <artifactId>org.apache.aries.jpa.example.tasklist.model</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.jpa</groupId>
+            <artifactId>org.apache.aries.jpa.api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.aries.jpa</groupId>
+            <artifactId>org.apache.aries.jpa.support</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.11</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.hibernate</groupId>
+            <artifactId>hibernate-entitymanager</artifactId>
+            <version>4.3.8.Final</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.derby</groupId>
+            <artifactId>derby</artifactId>
+            <version>10.11.1.1</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-jdk14</artifactId>
+            <version>1.7.10</version>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>servlet-api</artifactId>
+            <version>2.5</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <version>2.5.4</version>
+                <extensions>true</extensions>
+                <inherited>true</inherited>
+                <configuration>
+                    <instructions>
+                        <_dsannotations>*</_dsannotations>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>
diff --git a/examples/tasklist-ds/src/main/java/org/apache/aries/jpa/example/tasklist/ds/impl/TaskServiceImpl.java b/examples/tasklist-ds/src/main/java/org/apache/aries/jpa/example/tasklist/ds/impl/TaskServiceImpl.java
new file mode 100644
index 0000000..ab32a3f
--- /dev/null
+++ b/examples/tasklist-ds/src/main/java/org/apache/aries/jpa/example/tasklist/ds/impl/TaskServiceImpl.java
@@ -0,0 +1,115 @@
+/*
+ * 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 WARRANTIESOR 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.aries.jpa.example.tasklist.ds.impl;
+
+import java.util.Collection;
+
+import javax.persistence.EntityManager;
+
+import org.apache.aries.jpa.example.tasklist.model.Task;
+import org.apache.aries.jpa.example.tasklist.model.TaskService;
+import org.apache.aries.jpa.template.EmConsumer;
+import org.apache.aries.jpa.template.EmFunction;
+import org.apache.aries.jpa.template.JpaTemplate;
+import org.apache.aries.jpa.template.TransactionType;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Reference;
+
+@Component
+public class TaskServiceImpl implements TaskService {
+
+    private JpaTemplate jpa;
+
+    public Task getTask(final Integer id) {
+        return jpa.txExpr(TransactionType.Required, new EmFunction<Task>() {
+            public Task apply(EntityManager em) {
+                return em.find(Task.class, id);
+            }
+        });
+    }
+
+    public void addTask(final Task task) {
+        jpa.tx(new EmConsumer() {
+            public void accept(EntityManager em) {
+                    em.persist(task);
+                    em.flush();
+            }
+        });
+    }
+
+    public Collection<Task> getTasks() {
+        return jpa.txExpr(new EmFunction<Collection<Task>>() {
+            public Collection<Task> apply(EntityManager em) {
+                return em.createQuery("select t from Task t", Task.class).getResultList();
+            }
+        });
+    }
+
+    public void updateTask(final Task task) {
+        jpa.tx(new EmConsumer() {
+            public void accept(EntityManager em) {
+                em.persist(task);
+            }
+        });
+    }
+
+    public void deleteTask(final Integer id) {
+        jpa.tx(new EmConsumer() {
+            public void accept(EntityManager em) {
+                em.remove(getTask(id));
+            }
+        });
+    }
+
+    @Reference(target = "(osgi.unit.name=tasklist)")
+    public void setJpaTemplate(JpaTemplate jpa) {
+        this.jpa = jpa;
+    }
+
+    // See below for the Java 8 version with closures
+    /*
+    public Task getTask(Integer id) {
+        return jpa.txExpr(TransactionType.Required, em -> em.find(Task.class, id));
+    }
+
+    public void addTask(Task task) {
+        jpa.tx(em -> {
+            em.persist(task);
+            em.flush();
+        });
+    }
+
+    public Collection<Task> getTasks() {
+        return jpa.txExpr(em -> em.createQuery("select t from Task t", Task.class).getResultList());
+    }
+
+    public void updateTask(Task task) {
+        jpa.tx(em -> em.persist(task));
+    }
+
+    public void deleteTask(Integer id) {
+        jpa.tx(em -> em.remove(getTask(id)));
+    }
+
+    @Reference(target = "(osgi.unit.name=tasklist)")
+    public void setJpaTemplate(JpaTemplate jpa) {
+        this.jpa = jpa;
+    }
+    */
+}
diff --git a/examples/tasklist-ds/src/main/java/org/apache/aries/jpa/example/tasklist/ds/impl/TasklistAdder.java b/examples/tasklist-ds/src/main/java/org/apache/aries/jpa/example/tasklist/ds/impl/TasklistAdder.java
new file mode 100644
index 0000000..03a7ca0
--- /dev/null
+++ b/examples/tasklist-ds/src/main/java/org/apache/aries/jpa/example/tasklist/ds/impl/TasklistAdder.java
@@ -0,0 +1,45 @@
+/*
+ * 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 WARRANTIESOR 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.aries.jpa.example.tasklist.ds.impl;
+
+import org.apache.aries.jpa.example.tasklist.model.Task;
+import org.apache.aries.jpa.example.tasklist.model.TaskService;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Reference;
+
+@Component(immediate = true)
+public class TasklistAdder {
+    TaskService taskService;
+
+    @Reference
+    public void setTaskService(TaskService taskService) {
+        this.taskService = taskService;
+    }
+
+    @Activate
+    public void addDemoTask() {
+        if (taskService.getTask(1) == null) {
+            Task task = new Task();
+            task.setId(1);
+            task.setTitle("Task1");
+            taskService.addTask(task);
+        }
+    }
+}
diff --git a/examples/tasklist-ds/src/main/java/org/apache/aries/jpa/example/tasklist/ds/impl/TasklistServlet.java b/examples/tasklist-ds/src/main/java/org/apache/aries/jpa/example/tasklist/ds/impl/TasklistServlet.java
new file mode 100644
index 0000000..fbf80a6
--- /dev/null
+++ b/examples/tasklist-ds/src/main/java/org/apache/aries/jpa/example/tasklist/ds/impl/TasklistServlet.java
@@ -0,0 +1,80 @@
+package org.apache.aries.jpa.example.tasklist.ds.impl;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.text.SimpleDateFormat;
+import java.util.Collection;
+
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.aries.jpa.example.tasklist.model.Task;
+import org.apache.aries.jpa.example.tasklist.model.TaskService;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Reference;
+
+@Component(immediate = true,
+    service = { Servlet.class }, 
+    property = { "alias:String=/tasklist" }
+) 
+public class TasklistServlet extends HttpServlet {
+    
+    TaskService taskService;
+
+    private static final long serialVersionUID = 34992072289535683L;
+
+    @Override
+    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
+        IOException {
+        String add = req.getParameter("add");
+        String taskId = req.getParameter("taskId");
+        String title = req.getParameter("title");
+        PrintWriter writer = resp.getWriter();
+        if (add != null) {
+            addTask(taskId, title);
+        } else if (taskId != null && taskId.length() > 0) {
+            showTask(writer, taskId);
+        } else {
+            showTaskList(writer);
+        }
+    }
+
+    private void addTask(String taskId, String title) {
+        Task task = new Task();
+        task.setId(new Integer(taskId));
+        task.setTitle(title);
+        taskService.addTask(task );
+    }
+
+    private void showTaskList(PrintWriter writer) {
+        writer.println("<h1>Tasks</h1>");
+        Collection<Task> tasks = taskService.getTasks();
+        for (Task task : tasks) {
+            writer.println("<a href=\"?taskId=" + task.getId() + "\">" + task.getTitle() + "</a><BR/>");
+        }
+    }
+
+    private void showTask(PrintWriter writer, String taskId) {
+        SimpleDateFormat sdf = new SimpleDateFormat();
+        Task task = taskService.getTask(new Integer(taskId));
+        if (task != null) {
+            writer.println("<h1>Task " + task.getTitle() + " </h1>");
+            if (task.getDueDate() != null) {
+                writer.println("Due date: " + sdf.format(task.getDueDate()) + "<br/>");
+            }
+            writer.println(task.getDescription());
+        } else {
+            writer.println("Task with id " + taskId + " not found");
+        }
+
+    }
+
+    @Reference
+    public void setTaskService(TaskService taskService) {
+        this.taskService = taskService;
+    }
+
+}
diff --git a/examples/tasklist-ds/src/test/java/org/apache/aries/jpa/tasklist/closure/impl/TaskServiceImplTest.java b/examples/tasklist-ds/src/test/java/org/apache/aries/jpa/tasklist/closure/impl/TaskServiceImplTest.java
new file mode 100644
index 0000000..6526daf
--- /dev/null
+++ b/examples/tasklist-ds/src/test/java/org/apache/aries/jpa/tasklist/closure/impl/TaskServiceImplTest.java
@@ -0,0 +1,60 @@
+/*
+ * 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 WARRANTIESOR 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.aries.jpa.tasklist.closure.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+
+import org.apache.aries.jpa.example.tasklist.ds.impl.TaskServiceImpl;
+import org.apache.aries.jpa.example.tasklist.model.Task;
+import org.apache.aries.jpa.support.impl.EMSupplierImpl;
+import org.apache.aries.jpa.support.impl.ResourceLocalJpaTemplate;
+import org.apache.aries.jpa.template.JpaTemplate;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TaskServiceImplTest {
+    @Test
+    public void testPersistence() {
+        TaskServiceImpl taskService = new TaskServiceImpl();
+        EntityManagerFactory emf = createTestEMF();
+        EMSupplierImpl emSupplier = new EMSupplierImpl(emf);
+        JpaTemplate txManager = new ResourceLocalJpaTemplate(emSupplier);
+        taskService.setJpaTemplate(txManager);
+
+        Task task = new Task();
+        task.setId(1);
+        task.setTitle("test");
+        taskService.addTask(task);
+
+        Task task2 = taskService.getTask(1);
+        Assert.assertEquals(task.getTitle(), task2.getTitle());
+    }
+
+    private EntityManagerFactory createTestEMF() {
+        Map<String, String> properties = new HashMap<>();
+        properties.put("javax.persistence.jdbc.driver", "org.apache.derby.jdbc.EmbeddedDriver");
+        properties.put("javax.persistence.jdbc.url", "jdbc:derby:target/test;create=true");
+        EntityManagerFactory emf = Persistence.createEntityManagerFactory("tasklist", properties);
+        return emf;
+    }
+}
diff --git a/examples/tasklist-ds/src/test/resources/META-INF/persistence.xml b/examples/tasklist-ds/src/test/resources/META-INF/persistence.xml
new file mode 100644
index 0000000..8df2ef9
--- /dev/null
+++ b/examples/tasklist-ds/src/test/resources/META-INF/persistence.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
+    
+    <persistence-unit name="tasklist" transaction-type="RESOURCE_LOCAL">
+        <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
+        <class>org.apache.aries.jpa.example.tasklist.model.Task</class>
+        <properties>
+            <property name="hibernate.dialect" value="org.hibernate.dialect.DerbyTenSevenDialect"/>
+            <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
+        </properties>
+    </persistence-unit>
+
+</persistence>
diff --git a/examples/tasklist-model/pom.xml b/examples/tasklist-model/pom.xml
new file mode 100644
index 0000000..acea8ad
--- /dev/null
+++ b/examples/tasklist-model/pom.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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/xsd/maven-4.0.0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.aries.jpa.example</groupId>
+        <artifactId>org.apache.aries.jpa.example.parent</artifactId>
+        <version>2.0.0</version>
+        <relativePath>..</relativePath>
+    </parent>
+
+    <artifactId>org.apache.aries.jpa.example.tasklist.model</artifactId>
+    <name>Apache Aries JPA example tasklist model</name>
+    <packaging>bundle</packaging>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.hibernate.javax.persistence</groupId>
+            <artifactId>hibernate-jpa-2.1-api</artifactId>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <configuration>
+                    <instructions>
+                        <Meta-Persistence>META-INF/persistence.xml</Meta-Persistence>
+                        <!-- Needed for runtime enhancement -->
+                        <Import-Package>*, org.hibernate.proxy,
+                            javassist.util.proxy</Import-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>
diff --git a/examples/tasklist-model/src/main/java/org/apache/aries/jpa/example/tasklist/model/Task.java b/examples/tasklist-model/src/main/java/org/apache/aries/jpa/example/tasklist/model/Task.java
new file mode 100644
index 0000000..03e118d
--- /dev/null
+++ b/examples/tasklist-model/src/main/java/org/apache/aries/jpa/example/tasklist/model/Task.java
@@ -0,0 +1,89 @@
+/*
+ * 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 WARRANTIESOR 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.aries.jpa.example.tasklist.model;
+
+import java.util.Date;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@Entity
+@XmlRootElement
+public class Task {
+    @Id
+    Integer id;
+    String title;
+    String description;
+    Date dueDate;
+    boolean finished;
+    
+    
+    public Task() {
+    }
+    
+
+    public Task(Integer id, String title, String description) {
+        super();
+        this.id = id;
+        this.title = title;
+        this.description = description;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = new Integer(id);
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    public Date getDueDate() {
+        return dueDate;
+    }
+
+    public void setDueDate(Date dueDate) {
+        this.dueDate = dueDate;
+    }
+
+    public boolean isFinished() {
+        return finished;
+    }
+
+    public void setFinished(boolean finished) {
+        this.finished = finished;
+    }
+
+}
\ No newline at end of file
diff --git a/examples/tasklist-model/src/main/java/org/apache/aries/jpa/example/tasklist/model/TaskService.java b/examples/tasklist-model/src/main/java/org/apache/aries/jpa/example/tasklist/model/TaskService.java
new file mode 100644
index 0000000..4f01965
--- /dev/null
+++ b/examples/tasklist-model/src/main/java/org/apache/aries/jpa/example/tasklist/model/TaskService.java
@@ -0,0 +1,29 @@
+/*
+ * 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 WARRANTIESOR 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.aries.jpa.example.tasklist.model;
+
+import java.util.Collection;
+
+public interface TaskService {
+	Task getTask(Integer id);
+	void addTask(Task task);
+	void updateTask(Task task);
+	void deleteTask(Integer id);
+	Collection<Task> getTasks();
+}
diff --git a/examples/tasklist-model/src/main/resources/META-INF/persistence.xml b/examples/tasklist-model/src/main/resources/META-INF/persistence.xml
new file mode 100644
index 0000000..5023d42
--- /dev/null
+++ b/examples/tasklist-model/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
+    
+    <persistence-unit name="tasklist" transaction-type="JTA">
+        <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
+        
+        <!-- Only used when transaction-type=JTA -->
+        <jta-data-source>osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=tasklist)</jta-data-source>
+        
+        <!-- Only used when transaction-type=RESOURCE_LOCAL -->
+        <non-jta-data-source>osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=tasklist)</non-jta-data-source>
+        <properties>
+            <property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
+            <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
+        </properties>
+    </persistence-unit>
+
+</persistence>
diff --git a/itests/jpa-container-advancedtestbundle/.gitignore b/itests/jpa-container-advancedtestbundle/.gitignore
new file mode 100644
index 0000000..ea8c4bf
--- /dev/null
+++ b/itests/jpa-container-advancedtestbundle/.gitignore
@@ -0,0 +1 @@
+/target
diff --git a/itests/jpa-container-advancedtestbundle/LICENSE b/itests/jpa-container-advancedtestbundle/LICENSE
new file mode 100644
index 0000000..6b0b127
--- /dev/null
+++ b/itests/jpa-container-advancedtestbundle/LICENSE
@@ -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.
+
diff --git a/itests/jpa-container-advancedtestbundle/NOTICE b/itests/jpa-container-advancedtestbundle/NOTICE
new file mode 100644
index 0000000..424644d
--- /dev/null
+++ b/itests/jpa-container-advancedtestbundle/NOTICE
@@ -0,0 +1,8 @@
+
+Apache Aries
+Copyright 2009-2011 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+
diff --git a/itests/jpa-container-advancedtestbundle/pom.xml b/itests/jpa-container-advancedtestbundle/pom.xml
new file mode 100644
index 0000000..a5dab5c
--- /dev/null
+++ b/itests/jpa-container-advancedtestbundle/pom.xml
@@ -0,0 +1,75 @@
+<?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.aries.jpa.itest</groupId>
+        <artifactId>org.apache.aries.jpa.itest.parent</artifactId>
+        <version>2.0.0</version>
+        <relativePath>..</relativePath>
+    </parent>
+
+    <groupId>org.apache.aries.jpa</groupId>
+    <artifactId>org.apache.aries.jpa.container.advanced.itest.bundle</artifactId>
+    <packaging>bundle</packaging>
+    <name>Apache Aries JPA test bundle advanced iTests</name>
+    <description>For load time weaving and annotation scanning tests</description>
+
+    <properties>
+        <!-- Export package versions are maintained in packageinfo files -->
+        <aries.osgi.export.pkg>
+            org.apache.aries.jpa.container.advanced.itest.bundle.entities
+        </aries.osgi.export.pkg>
+        <aries.osgi.import>
+            javax.persistence;version="[1.0.0,3.0.0)",
+            org.apache.derby.jdbc,
+            *
+        </aries.osgi.import>
+        <aries.osgi.private.pkg />
+        <aries.osgi.symbolic.name>${project.groupId}.${project.artifactId}</aries.osgi.symbolic.name>
+        <aries.skip.version.check>true</aries.skip.version.check>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-jpa_2.0_spec</artifactId>
+            <version>1.1</version>
+            <scope>provided</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <configuration>
+                    <instructions>
+                        <Meta-Persistence>META-INF/persistence.xml</Meta-Persistence>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
diff --git a/itests/jpa-container-advancedtestbundle/src/main/java/org/apache/aries/jpa/container/advanced/itest/bundle/entities/Car.java b/itests/jpa-container-advancedtestbundle/src/main/java/org/apache/aries/jpa/container/advanced/itest/bundle/entities/Car.java
new file mode 100644
index 0000000..c78372d
--- /dev/null
+++ b/itests/jpa-container-advancedtestbundle/src/main/java/org/apache/aries/jpa/container/advanced/itest/bundle/entities/Car.java
@@ -0,0 +1,68 @@
+/*

+ * 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 WARRANTIESOR 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.aries.jpa.container.advanced.itest.bundle.entities;

+

+import javax.persistence.Entity;

+import javax.persistence.Id;

+

+@Entity

+public class Car {

+  @Id

+  private String numberPlate;

+  

+  private String colour;

+  

+  private int engineSize;

+  

+  private int numberOfSeats;

+

+  public String getNumberPlate() {

+    return numberPlate;

+  }

+

+  public void setNumberPlate(String numberPlate) {

+    this.numberPlate = numberPlate;

+  }

+

+  public String getColour() {

+    return colour;

+  }

+

+  public void setColour(String colour) {

+    this.colour = colour;

+  }

+

+  public int getEngineSize() {

+    return engineSize;

+  }

+

+  public void setEngineSize(int engineSize) {

+    this.engineSize = engineSize;

+  }

+

+  public int getNumberOfSeats() {

+    return numberOfSeats;

+  }

+

+  public void setNumberOfSeats(int numberOfSeats) {

+    this.numberOfSeats = numberOfSeats;

+  }

+  

+  

+}

diff --git a/itests/jpa-container-advancedtestbundle/src/main/java/org/apache/aries/jpa/container/advanced/itest/bundle/entities/packageinfo b/itests/jpa-container-advancedtestbundle/src/main/java/org/apache/aries/jpa/container/advanced/itest/bundle/entities/packageinfo
new file mode 100644
index 0000000..c72722a
--- /dev/null
+++ b/itests/jpa-container-advancedtestbundle/src/main/java/org/apache/aries/jpa/container/advanced/itest/bundle/entities/packageinfo
@@ -0,0 +1,19 @@
+#
+# 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.
+#
+version 1.0.0
diff --git a/itests/jpa-container-advancedtestbundle/src/main/resources/META-INF/persistence.xml b/itests/jpa-container-advancedtestbundle/src/main/resources/META-INF/persistence.xml
new file mode 100644
index 0000000..4ff1c65
--- /dev/null
+++ b/itests/jpa-container-advancedtestbundle/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,38 @@
+<?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. -->

+<persistence xmlns="http://java.sun.com/xml/ns/persistence"

+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

+    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"

+    version="2.0">

+

+    <persistence-unit name="test-unit" transaction-type="JTA">

+        <description>Test persistence unit for the JPA Container advanced iTests</description>

+        <properties>

+            <property name="javax.persistence.jdbc.driver"

+                value="org.apache.derby.jdbc.EmbeddedDriver-pool-xa" />

+            <property name="javax.persistence.jdbc.url" value="jdbc:derby:memory:TEST;create=true" />

+

+            <!-- These properties are creating the database on the fly. We 

+                are using them to avoid the tests having to create a database -->

+

+            <property name="openjpa.jdbc.SynchronizeMappings"

+                value="buildSchema(ForeignKeys=true)" />

+            <property name="openjpa.jdbc.DBDictionary" value="derby" />

+

+            <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>

+            <property name="hibernate.dialect"

+                value="org.hibernate.dialect.DerbyTenSevenDialect" />

+    <!--         <property name="hibernate.hbm2ddl.auto" value="create-drop" /> -->

+        </properties>

+    </persistence-unit>

+

+</persistence>

diff --git a/itests/jpa-container-blueprint-testbundle/.gitignore b/itests/jpa-container-blueprint-testbundle/.gitignore
new file mode 100644
index 0000000..ea8c4bf
--- /dev/null
+++ b/itests/jpa-container-blueprint-testbundle/.gitignore
@@ -0,0 +1 @@
+/target
diff --git a/itests/jpa-container-blueprint-testbundle/LICENSE b/itests/jpa-container-blueprint-testbundle/LICENSE
new file mode 100644
index 0000000..2654c43
--- /dev/null
+++ b/itests/jpa-container-blueprint-testbundle/LICENSE
@@ -0,0 +1,487 @@
+
+                                 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.
+
+
+	======================================
+	  LICENSES FOR INCLUDED DEPENDENCIES
+	======================================
+
+	All the source code for the Aries JPA project is released under the
+	license above. Additionally, the Aries JPA binary distribution
+	includes a number of third-party files that are required in
+	order to the software to function. Unless noted below, these jars
+	and resource files are also released under the ASF license above.
+
+	The exceptions are as follows:
+
+	===========================
+	  persistence-xsd.rsrc - included in the org.apache.aries.jpa.container jar, taken from:
+	    http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd)
+	  persistence_2_0-xsd.rsrc - included in the org.apache.aries.jpa.container jar, taken from:
+	    http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd)
+	===========================
+
+COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
+
+1. Definitions.
+
+   1.1. Contributor. means each individual or entity that creates or contributes to the creation of Modifications.
+
+   1.2. Contributor Version. means the combination of the Original Software, prior Modifications used by a Contributor (if any), and the Modifications made by that particular Contributor.
+
+   1.3. Covered Software. means (a) the Original Software, or (b) Modifications, or (c) the combination of files containing Original Software with files containing Modifications, in each case including portions thereof.
+
+   1.4. Executable. means the Covered Software in any form other than Source Code.
+
+   1.5. Initial Developer. means the individual or entity that first makes Original Software available under this License.
+
+   1.6. Larger Work. means a work which combines Covered Software or portions thereof with code not governed by the terms of this License.
+
+   1.7. License. means this document.
+
+   1.8. Licensable. means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently acquired, any and all of the rights conveyed herein.
+
+   1.9. Modifications. means the Source Code and Executable form of any of the following:
+
+        A. Any file that results from an addition to, deletion from or modification of the contents of a file containing Original Software or previous Modifications;
+
+        B. Any new file that contains any part of the Original Software or previous Modification; or
+
+        C. Any new file that is contributed or otherwise made available under the terms of this License.
+
+   1.10. Original Software. means the Source Code and Executable form of computer software code that is originally released under this License.
+
+   1.11. Patent Claims. means any patent claim(s), now owned or hereafter acquired, including without limitation, method, process, and apparatus claims, in any patent Licensable by grantor.
+
+   1.12. Source Code. means (a) the common form of computer software code in which modifications are made and (b) associated documentation included in or with such code.
+
+   1.13. You. (or .Your.) means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, .You. includes any entity which controls, is controlled by, or is under common control with You. For purposes of this definition, .control. means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity.
+
+2. License Grants.
+
+      2.1. The Initial Developer Grant.
+
+      Conditioned upon Your compliance with Section 3.1 below and subject to third party intellectual property claims, the Initial Developer hereby grants You a world-wide, royalty-free, non-exclusive license:
+
+         (a) under intellectual property rights (other than patent or trademark) Licensable by Initial Developer, to use, reproduce, modify, display, perform, sublicense and distribute the Original Software (or portions thereof), with or without Modifications, and/or as part of a Larger Work; and
+
+         (b) under Patent Claims infringed by the making, using or selling of Original Software, to make, have made, use, practice, sell, and offer for sale, and/or otherwise dispose of the Original Software (or portions thereof).
+
+        (c) The licenses granted in Sections 2.1(a) and (b) are effective on the date Initial Developer first distributes or otherwise makes the Original Software available to a third party under the terms of this License.
+
+        (d) Notwithstanding Section 2.1(b) above, no patent license is granted: (1) for code that You delete from the Original Software, or (2) for infringements caused by: (i) the modification of the Original Software, or (ii) the combination of the Original Software with other software or devices.
+
+    2.2. Contributor Grant.
+
+    Conditioned upon Your compliance with Section 3.1 below and subject to third party intellectual property claims, each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license:
+
+        (a) under intellectual property rights (other than patent or trademark) Licensable by Contributor to use, reproduce, modify, display, perform, sublicense and distribute the Modifications created by such Contributor (or portions thereof), either on an unmodified basis, with other Modifications, as Covered Software and/or as part of a Larger Work; and
+
+        (b) under Patent Claims infringed by the making, using, or selling of Modifications made by that Contributor either alone and/or in combination with its Contributor Version (or portions of such combination), to make, use, sell, offer for sale, have made, and/or otherwise dispose of: (1) Modifications made by that Contributor (or portions thereof); and (2) the combination of Modifications made by that Contributor with its Contributor Version (or portions of such combination).
+
+        (c) The licenses granted in Sections 2.2(a) and 2.2(b) are effective on the date Contributor first distributes or otherwise makes the Modifications available to a third party.
+
+        (d) Notwithstanding Section 2.2(b) above, no patent license is granted: (1) for any code that Contributor has deleted from the Contributor Version; (2) for infringements caused by: (i) third party modifications of Contributor Version, or (ii) the combination of Modifications made by that Contributor with other software (except as part of the Contributor Version) or other devices; or (3) under Patent Claims infringed by Covered Software in the absence of Modifications made by that Contributor.
+
+3. Distribution Obligations.
+
+      3.1. Availability of Source Code.
+      Any Covered Software that You distribute or otherwise make available in Executable form must also be made available in Source Code form and that Source Code form must be distributed only under the terms of this License. You must include a copy of this License with every copy of the Source Code form of the Covered Software You distribute or otherwise make available. You must inform recipients of any such Covered Software in Executable form as to how they can obtain such Covered Software in Source Code form in a reasonable manner on or through a medium customarily used for software exchange.
+
+      3.2. Modifications.
+      The Modifications that You create or to which You contribute are governed by the terms of this License. You represent that You believe Your Modifications are Your original creation(s) and/or You have sufficient rights to grant the rights conveyed by this License.
+
+      3.3. Required Notices.
+      You must include a notice in each of Your Modifications that identifies You as the Contributor of the Modification. You may not remove or alter any copyright, patent or trademark notices contained within the Covered Software, or any notices of licensing or any descriptive text giving attribution to any Contributor or the Initial Developer.
+
+      3.4. Application of Additional Terms.
+      You may not offer or impose any terms on any Covered Software in Source Code form that alters or restricts the applicable version of this License or the recipients. rights hereunder. You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Software. However, you may do so only on Your own behalf, and not on behalf of the Initial Developer or any Contributor. You must make it absolutely clear that any such warranty, support, indemnity or liability obligation is offered by You alone, and You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of warranty, support, indemnity or liability terms You offer.
+
+      3.5. Distribution of Executable Versions.
+      You may distribute the Executable form of the Covered Software under the terms of this License or under the terms of a license of Your choice, which may contain terms different from this License, provided that You are in compliance with the terms of this License and that the license for the Executable form does not attempt to limit or alter the recipient.s rights in the Source Code form from the rights set forth in this License. If You distribute the Covered Software in Executable form under a different license, You must make it absolutely clear that any terms which differ from this License are offered by You alone, not by the Initial Developer or Contributor. You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of any such terms You offer.
+
+      3.6. Larger Works.
+      You may create a Larger Work by combining Covered Software with other code not governed by the terms of this License and distribute the Larger Work as a single product. In such a case, You must make sure the requirements of this License are fulfilled for the Covered Software.
+
+4. Versions of the License.
+
+      4.1. New Versions.
+      Sun Microsystems, Inc. is the initial license steward and may publish revised and/or new versions of this License from time to time. Each version will be given a distinguishing version number. Except as provided in Section 4.3, no one other than the license steward has the right to modify this License.
+
+      4.2. Effect of New Versions.
+      You may always continue to use, distribute or otherwise make the Covered Software available under the terms of the version of the License under which You originally received the Covered Software. If the Initial Developer includes a notice in the Original Software prohibiting it from being distributed or otherwise made available under any subsequent version of the License, You must distribute and make the Covered Software available under the terms of the version of the License under which You originally received the Covered Software. Otherwise, You may also choose to use, distribute or otherwise make the Covered Software available under the terms of any subsequent version of the License published by the license steward.
+
+      4.3. Modified Versions.
+      When You are an Initial Developer and You want to create a new license for Your Original Software, You may create and use a modified version of this License if You: (a) rename the license and remove any references to the name of the license steward (except to note that the license differs from this License); and (b) otherwise make it clear that the license contains terms which differ from this License.
+
+5. DISCLAIMER OF WARRANTY.
+
+   COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN .AS IS. BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
+
+6. TERMINATION.
+
+      6.1. This License and the rights granted hereunder will terminate automatically if You fail to comply with terms herein and fail to cure such breach within 30 days of becoming aware of the breach. Provisions which, by their nature, must remain in effect beyond the termination of this License shall survive.
+
+      6.2. If You assert a patent infringement claim (excluding declaratory judgment actions) against Initial Developer or a Contributor (the Initial Developer or Contributor against whom You assert such claim is referred to as .Participant.) alleging that the Participant Software (meaning the Contributor Version where the Participant is a Contributor or the Original Software where the Participant is the Initial Developer) directly or indirectly infringes any patent, then any and all rights granted directly or indirectly to You by such Participant, the Initial Developer (if the Initial Developer is not the Participant) and all Contributors under Sections 2.1 and/or 2.2 of this License shall, upon 60 days notice from Participant terminate prospectively and automatically at the expiration of such 60 day notice period, unless if within such 60 day period You withdraw Your claim with respect to the Participant Software against such Participant either unilaterally or pursuant to a written agreement with Participant.
+
+      6.3. In the event of termination under Sections 6.1 or 6.2 above, all end user licenses that have been validly granted by You or any distributor hereunder prior to termination (excluding licenses granted to You by any distributor) shall survive termination.
+
+7. LIMITATION OF LIABILITY.
+
+   UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOST PROFITS, LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY RESULTING FROM SUCH PARTY.S NEGLIGENCE TO THE EXTENT APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
+
+8. U.S. GOVERNMENT END USERS.
+
+   The Covered Software is a .commercial item,. as that term is defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of .commercial computer software. (as that term is defined at 48 C.F.R. ? 252.227-7014(a)(1)) and .commercial computer software documentation. as such terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users acquire Covered Software with only those rights set forth herein. This U.S. Government Rights clause is in lieu of, and supersedes, any other FAR, DFAR, or other clause or provision that addresses Government rights in computer software under this License.
+
+9. MISCELLANEOUS.
+
+   This License represents the complete agreement concerning subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. This License shall be governed by the law of the jurisdiction specified in a notice contained within the Original Software (except to the extent applicable law, if any, provides otherwise), excluding such jurisdiction.s conflict-of-law provisions. Any litigation relating to this License shall be subject to the jurisdiction of the courts located in the jurisdiction and venue specified in a notice contained within the Original Software, with the losing party responsible for costs, including, without limitation, court costs and reasonable attorneys. fees and expenses. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not apply to this License. You agree that You alone are responsible for compliance with the United States export administration regulations (and the export control laws and regulation of any other countries) when You use, distribute or otherwise make available any Covered Software.
+
+10. RESPONSIBILITY FOR CLAIMS.
+
+   As between Initial Developer and the Contributors, each party is responsible for claims and damages arising, directly or indirectly, out of its utilization of rights under this License and You agree to work with Initial Developer and Contributors to distribute such responsibility on an equitable basis. Nothing herein is intended or shall be deemed to constitute any admission of liability.
+
+   NOTICE PURSUANT TO SECTION 9 OF THE COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL)
+
+   The code released under the CDDL shall be governed by the laws of the State of California (excluding conflict-of-law provisions). Any litigation relating to this License shall be subject to the jurisdiction of the Federal Courts of the Northern District of California and the state courts of the State of California, with venue lying in Santa Clara County, California.
+
+
+The GNU General Public License (GPL) Version 2, June 1991
+
+
+Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
+
+Preamble
+
+The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too.
+
+When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.
+
+To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.
+
+For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
+
+We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.
+
+Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.
+
+Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.
+
+The precise terms and conditions for copying, distribution and modification follow.
+
+
+TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.
+
+1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.
+
+2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
+
+   a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.
+
+   b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License.
+
+   c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
+
+3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:
+
+   a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
+
+   b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
+
+   c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.
+
+If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.
+
+4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
+
+5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.
+
+6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.
+
+7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.
+
+This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
+
+8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
+
+9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.
+
+10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.
+
+NO WARRANTY
+
+11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+END OF TERMS AND CONDITIONS
+
+
+How to Apply These Terms to Your New Programs
+
+If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
+
+To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.
+
+   One line to give the program's name and a brief idea of what it does.
+
+   Copyright (C)
+
+   This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this when it starts in an interactive mode:
+
+   Gnomovision version 69, Copyright (C) year name of author
+   Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names:
+
+   Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+   signature of Ty Coon, 1 April 1989
+   Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License.
+
+
+"CLASSPATH" EXCEPTION TO THE GPL VERSION 2
+
+Certain source files distributed by Sun Microsystems, Inc. are subject to the following clarification and special exception to the GPL Version 2, but only where Sun has expressly included in the particular source file's header the words
+
+"Sun designates this particular file as subject to the "Classpath" exception as provided by Sun in the License file that accompanied this code."
+
+Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License Version 2 cover the whole combination.
+
+As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module.? An independent module is a module which is not derived from or based on this library.? If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so.? If you do not wish to do so, delete this exception statement from your version.
+
diff --git a/itests/jpa-container-blueprint-testbundle/NOTICE b/itests/jpa-container-blueprint-testbundle/NOTICE
new file mode 100644
index 0000000..424644d
--- /dev/null
+++ b/itests/jpa-container-blueprint-testbundle/NOTICE
@@ -0,0 +1,8 @@
+
+Apache Aries
+Copyright 2009-2011 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+
diff --git a/itests/jpa-container-blueprint-testbundle/pom.xml b/itests/jpa-container-blueprint-testbundle/pom.xml
new file mode 100644
index 0000000..e96b69a
--- /dev/null
+++ b/itests/jpa-container-blueprint-testbundle/pom.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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.aries.jpa.itest</groupId>
+        <artifactId>org.apache.aries.jpa.itest.parent</artifactId>
+        <version>2.0.0</version>
+        <relativePath>..</relativePath>
+    </parent>
+
+    <artifactId>org.apache.aries.jpa.container.itest.bundle.blueprint</artifactId>
+    <packaging>bundle</packaging>
+    <name>Apache Aries JPA test bundle blueprint integration</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.hibernate.javax.persistence</groupId>
+            <artifactId>hibernate-jpa-2.0-api</artifactId>
+            <version>1.0.1.Final</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.transaction</groupId>
+            <artifactId>org.apache.aries.transaction.blueprint</artifactId>
+            <version>1.0.2</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.jpa</groupId>
+            <artifactId>org.apache.aries.jpa.api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <configuration>
+                    <instructions>
+                        <Export-Package>org.apache.aries.jpa.itest.testbundle.*</Export-Package>
+                        <!-- Dynamic import to for hibernate enhancement 
+                            to make sure it also works in eclipselink -->
+                        <DynamicImport-Package>org.hibernate.proxy,
+                            javassist.util.proxy</DynamicImport-Package>
+                        <Meta-Persistence>META-INF/persistence.xml</Meta-Persistence>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+    <description>Testing blueprint integration with EntityManager, EntityManagerFactory and EmSupplier injection.
+Also testing declarative transactions</description>
+</project>
diff --git a/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/itest/testbundle/entities/Car.java b/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/itest/testbundle/entities/Car.java
new file mode 100644
index 0000000..4bf4fe8
--- /dev/null
+++ b/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/itest/testbundle/entities/Car.java
@@ -0,0 +1,68 @@
+/*
+ * 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 WARRANTIESOR 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.aries.jpa.itest.testbundle.entities;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+
+@Entity
+public class Car {
+  @Id
+  private String numberPlate;
+  
+  private String colour;
+  
+  private int engineSize;
+  
+  private int numberOfSeats;
+
+  public String getNumberPlate() {
+    return numberPlate;
+  }
+
+  public void setNumberPlate(String numberPlate) {
+    this.numberPlate = numberPlate;
+  }
+
+  public String getColour() {
+    return colour;
+  }
+
+  public void setColour(String colour) {
+    this.colour = colour;
+  }
+
+  public int getEngineSize() {
+    return engineSize;
+  }
+
+  public void setEngineSize(int engineSize) {
+    this.engineSize = engineSize;
+  }
+
+  public int getNumberOfSeats() {
+    return numberOfSeats;
+  }
+
+  public void setNumberOfSeats(int numberOfSeats) {
+    this.numberOfSeats = numberOfSeats;
+  }
+  
+  
+}
diff --git a/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/itest/testbundle/service/CarService.java b/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/itest/testbundle/service/CarService.java
new file mode 100644
index 0000000..4a48f3e
--- /dev/null
+++ b/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/itest/testbundle/service/CarService.java
@@ -0,0 +1,31 @@
+/*

+ * 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 WARRANTIESOR 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.aries.jpa.itest.testbundle.service;

+

+import java.util.Collection;

+

+import org.apache.aries.jpa.itest.testbundle.entities.Car;

+

+public interface CarService {

+	Car getCar(String id);

+	void addCar(Car car);

+	Collection<Car> getCars();

+	void updateCar(Car car);

+	void deleteCar(String id);

+}

diff --git a/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/itest/testbundle/service/impl/CarServiceImpl.java b/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/itest/testbundle/service/impl/CarServiceImpl.java
new file mode 100644
index 0000000..97a2bcf
--- /dev/null
+++ b/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/itest/testbundle/service/impl/CarServiceImpl.java
@@ -0,0 +1,65 @@
+/*
+ * 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 WARRANTIESOR 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.aries.jpa.itest.testbundle.service.impl;
+
+import java.util.Collection;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+import org.apache.aries.jpa.itest.testbundle.entities.Car;
+import org.apache.aries.jpa.itest.testbundle.service.CarService;
+
+
+public class CarServiceImpl implements CarService {
+
+	@PersistenceContext(unitName="test_unit_blueprint")
+	EntityManager em;
+	
+	@Override
+	public Car getCar(String id) {
+		return em.find(Car.class, id);
+	}
+
+	@Override
+	public void addCar(Car car) {
+		em.persist(car);
+		em.flush();
+	}
+
+	public Collection<Car> getCars() {
+		return em.createQuery("select c from Car c", Car.class)
+			.getResultList();
+	}
+
+	@Override
+	public void updateCar(Car car) {
+		em.persist(car);
+	}
+
+	@Override
+	public void deleteCar(String id) {
+		em.remove(getCar(id));
+	}
+
+	public void setEm(EntityManager em) {
+		this.em = em;
+	}
+	
+}
diff --git a/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/itest/testbundle/service/impl/CarServiceWithEmfImpl.java b/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/itest/testbundle/service/impl/CarServiceWithEmfImpl.java
new file mode 100644
index 0000000..094de73
--- /dev/null
+++ b/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/itest/testbundle/service/impl/CarServiceWithEmfImpl.java
@@ -0,0 +1,71 @@
+/*
+ * 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 WARRANTIESOR 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.aries.jpa.itest.testbundle.service.impl;
+
+import java.util.Collection;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceUnit;
+
+import org.apache.aries.jpa.itest.testbundle.entities.Car;
+import org.apache.aries.jpa.itest.testbundle.service.CarService;
+
+
+public class CarServiceWithEmfImpl implements CarService {
+
+	@PersistenceUnit(unitName="test_unit_blueprint")
+	EntityManagerFactory emf;
+	
+	@Override
+	public Car getCar(String id) {
+		EntityManager em = emf.createEntityManager();
+		return em.find(Car.class, id);
+	}
+
+	@Override
+	public void addCar(Car car) {
+		EntityManager em = emf.createEntityManager();
+		em.persist(car);
+		em.flush();
+	}
+
+	public Collection<Car> getCars() {
+		EntityManager em = emf.createEntityManager();
+		return em.createQuery("select c from Car c", Car.class)
+			.getResultList();
+	}
+
+	@Override
+	public void updateCar(Car car) {
+		EntityManager em = emf.createEntityManager();
+		em.persist(car);
+	}
+
+	@Override
+	public void deleteCar(String id) {
+		EntityManager em = emf.createEntityManager();
+		em.remove(getCar(id));
+	}
+
+	public void setEmf(EntityManagerFactory emf) {
+		this.emf = emf;
+	}
+	
+}
diff --git a/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/itest/testbundle/service/impl/CarServiceWithSupplierImpl.java b/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/itest/testbundle/service/impl/CarServiceWithSupplierImpl.java
new file mode 100644
index 0000000..2c99aed
--- /dev/null
+++ b/itests/jpa-container-blueprint-testbundle/src/main/java/org/apache/aries/jpa/itest/testbundle/service/impl/CarServiceWithSupplierImpl.java
@@ -0,0 +1,66 @@
+/*
+ * 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 WARRANTIESOR 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.aries.jpa.itest.testbundle.service.impl;
+
+import java.util.Collection;
+
+import javax.persistence.PersistenceContext;
+
+import org.apache.aries.jpa.itest.testbundle.entities.Car;
+import org.apache.aries.jpa.itest.testbundle.service.CarService;
+import org.apache.aries.jpa.supplier.EmSupplier;
+
+public class CarServiceWithSupplierImpl implements CarService {
+
+	Collection<String> colours;
+
+	@PersistenceContext(unitName = "test_unit_blueprint")
+	EmSupplier em;
+
+	@Override
+	public Car getCar(String id) {
+		return em.get().find(Car.class, id);
+	}
+
+	@Override
+	public void addCar(Car car) {
+		em.get().persist(car);
+		em.get().flush();
+	}
+
+	public Collection<Car> getCars() {
+		return em.get().createQuery("select c from Car c", Car.class)
+				.getResultList();
+	}
+
+	@Override
+	public void updateCar(Car car) {
+		em.get().persist(car);
+	}
+
+	@Override
+	public void deleteCar(String id) {
+		em.get().remove(getCar(id));
+	}
+
+	public void setEm(EmSupplier em) {
+		this.em = em;
+	}
+
+}
diff --git a/itests/jpa-container-blueprint-testbundle/src/main/resources/META-INF/persistence.xml b/itests/jpa-container-blueprint-testbundle/src/main/resources/META-INF/persistence.xml
new file mode 100644
index 0000000..2537e0a
--- /dev/null
+++ b/itests/jpa-container-blueprint-testbundle/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>

+<persistence version="2.0"

+	xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

+	xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">

+

+	<persistence-unit name="test_unit_blueprint" transaction-type="JTA">

+		<description>Test persistence unit for the Blueprint test</description>

+

+		<properties>

+            <property name="javax.persistence.jdbc.driver"

+                value="org.apache.derby.jdbc.EmbeddedDriver-pool-xa" />

+            <property name="javax.persistence.jdbc.url" value="jdbc:derby:memory:TEST;create=true" />

+

+            <!-- These properties are creating the database on the fly. We 

+                are using them to avoid the tests having to create a database -->

+

+            <property name="openjpa.jdbc.SynchronizeMappings"

+                value="buildSchema(ForeignKeys=true)" />

+            <property name="openjpa.jdbc.DBDictionary" value="derby" />

+

+            <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>

+            <property name="hibernate.dialect"

+                value="org.hibernate.dialect.DerbyTenSevenDialect" />

+            <property name="hibernate.hbm2ddl.auto" value="create-drop" />

+        </properties>

+	</persistence-unit>

+    

+</persistence>

diff --git a/itests/jpa-container-blueprint-testbundle/src/main/resources/OSGI-INF/blueprint/config.xml b/itests/jpa-container-blueprint-testbundle/src/main/resources/OSGI-INF/blueprint/config.xml
new file mode 100644
index 0000000..3aeabc8
--- /dev/null
+++ b/itests/jpa-container-blueprint-testbundle/src/main/resources/OSGI-INF/blueprint/config.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>

+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"

+	xmlns:jpa="http://aries.apache.org/xmlns/jpan/v1.0.0"

+	xmlns:tx="http://aries.apache.org/xmlns/transactions/v1.2.0"

+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

+	xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0">

+

+	<jpa:enable />

+

+	<service ref="carServiceEmf"

+		interface="org.apache.aries.jpa.itest.testbundle.service.CarService">

+		<service-properties>

+			<entry key="type" value="emf" />

+		</service-properties>

+	</service>

+	

+	<bean id="carServiceEmf"

+		class="org.apache.aries.jpa.itest.testbundle.service.impl.CarServiceWithEmfImpl">

+		<tx:transaction method="*" value="Required" />

+	</bean>

+	

+	<service ref="carServiceEm"

+		interface="org.apache.aries.jpa.itest.testbundle.service.CarService">

+		<service-properties>

+			<entry key="type" value="em" />

+		</service-properties>

+	</service>

+	

+	<bean id="carServiceEm"

+		class="org.apache.aries.jpa.itest.testbundle.service.impl.CarServiceImpl">

+		<tx:transaction method="*" value="Required" />

+	</bean>

+	

+	<service ref="carServiceEmSupplier"

+		interface="org.apache.aries.jpa.itest.testbundle.service.CarService">

+		<service-properties>

+			<entry key="type" value="supplier" />

+		</service-properties>

+	</service>

+	

+	<bean id="carServiceEmSupplier"

+		class="org.apache.aries.jpa.itest.testbundle.service.impl.CarServiceWithSupplierImpl">

+		<tx:transaction method="*" value="Required" />

+	</bean>

+    

+</blueprint>

+

diff --git a/itests/jpa-container-itest/LICENSE b/itests/jpa-container-itest/LICENSE
new file mode 100644
index 0000000..6b0b127
--- /dev/null
+++ b/itests/jpa-container-itest/LICENSE
@@ -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.
+
diff --git a/itests/jpa-container-itest/NOTICE b/itests/jpa-container-itest/NOTICE
new file mode 100644
index 0000000..424644d
--- /dev/null
+++ b/itests/jpa-container-itest/NOTICE
@@ -0,0 +1,8 @@
+
+Apache Aries
+Copyright 2009-2011 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+
diff --git a/itests/jpa-container-itest/pom.xml b/itests/jpa-container-itest/pom.xml
new file mode 100644
index 0000000..7efcca9
--- /dev/null
+++ b/itests/jpa-container-itest/pom.xml
@@ -0,0 +1,496 @@
+<?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.aries.jpa.itest</groupId>
+        <artifactId>org.apache.aries.jpa.itest.parent</artifactId>
+        <version>2.0.0</version>
+        <relativePath>..</relativePath>
+    </parent>
+
+    <groupId>org.apache.aries.jpa</groupId>
+    <artifactId>org.apache.aries.jpa.container.itest</artifactId>
+    <name>Apache Aries JPA iTests</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.eclipse</groupId>
+            <artifactId>org.eclipse.osgi</artifactId>
+            <version>3.8.0.v20120529-1548</version>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.enterprise</artifactId>
+            <version>5.0.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.configadmin</artifactId>
+            <version>1.8.4</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries</groupId>
+            <artifactId>org.apache.aries.util</artifactId>
+            <version>1.0.0</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.proxy</groupId>
+            <artifactId>org.apache.aries.proxy.api</artifactId>
+            <version>1.0.0</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.proxy</groupId>
+            <artifactId>org.apache.aries.proxy.impl</artifactId>
+            <version>1.0.3</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ow2.asm</groupId>
+            <artifactId>asm-all</artifactId>
+            <version>5.0.3</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.blueprint</groupId>
+            <artifactId>org.apache.aries.blueprint.api</artifactId>
+            <version>1.0.0</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.blueprint</groupId>
+            <artifactId>org.apache.aries.blueprint.core</artifactId>
+            <version>1.4.3</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-jpa_2.0_spec</artifactId>
+            <version>1.1</version>
+            <scope>test</scope>
+        </dependency>
+        
+        <!-- Dependencies to aries jpa modules -->
+        <dependency>
+            <artifactId>org.apache.aries.jpa.api</artifactId>
+            <groupId>org.apache.aries.jpa</groupId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.jpa</groupId>
+            <artifactId>org.apache.aries.jpa.container</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.jpa</groupId>
+            <artifactId>org.apache.aries.jpa.support</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.jpa</groupId>
+            <artifactId>org.apache.aries.jpa.blueprint</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-servlet_2.5_spec</artifactId>
+            <version>1.2</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.servicemix.bundles</groupId>
+            <artifactId>org.apache.servicemix.bundles.commons-dbcp</artifactId>
+            <version>1.4_3</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.xbean</groupId>
+            <artifactId>xbean-asm4-shaded</artifactId>
+            <version>3.16</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.openjpa</groupId>
+            <artifactId>openjpa</artifactId>
+            <version>${openjpa.version}</version>
+            <scope>test</scope>
+        </dependency>
+
+        <!-- eclipselink -->
+        <dependency>
+            <groupId>org.eclipse.persistence</groupId>
+            <artifactId>javax.persistence</artifactId>
+            <version>2.1.0</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.persistence</groupId>
+            <artifactId>org.eclipse.persistence.antlr</artifactId>
+            <version>${eclipselink.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.persistence</groupId>
+            <artifactId>org.eclipse.persistence.core</artifactId>
+            <version>${eclipselink.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.persistence</groupId>
+            <artifactId>org.eclipse.persistence.jpa.jpql</artifactId>
+            <version>${eclipselink.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.persistence</groupId>
+            <artifactId>org.eclipse.persistence.asm</artifactId>
+            <version>${eclipselink.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.persistence</groupId>
+            <artifactId>org.eclipse.persistence.jpa</artifactId>
+            <version>${eclipselink.version}</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-jta_1.1_spec</artifactId>
+            <version>1.1.1</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>commons-lang</groupId>
+            <artifactId>commons-lang</artifactId>
+            <version>2.4</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-collections</groupId>
+            <artifactId>commons-collections</artifactId>
+            <version>3.2.1</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>commons-pool</groupId>
+            <artifactId>commons-pool</artifactId>
+            <version>1.5.3</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.servicemix.bundles</groupId>
+            <artifactId>org.apache.servicemix.bundles.serp</artifactId>
+            <version>1.13.1_2</version>
+        </dependency>
+        
+        <!-- hibernate -->
+        <dependency>
+            <groupId>org.apache.servicemix.bundles</groupId>
+            <artifactId>org.apache.servicemix.bundles.antlr</artifactId>
+            <version>${antlr.bundle.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.servicemix.bundles</groupId>
+            <artifactId>org.apache.servicemix.bundles.ant</artifactId>
+            <version>${ant.bundle.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.servicemix.bundles</groupId>
+            <artifactId>org.apache.servicemix.bundles.dom4j</artifactId>
+            <version>${dom4j.bundle.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.servicemix.bundles</groupId>
+            <artifactId>org.apache.servicemix.bundles.serp</artifactId>
+            <version>${serp.bundle.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>com.fasterxml</groupId>
+            <artifactId>classmate</artifactId>
+            <version>0.9.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.javassist</groupId>
+            <artifactId>javassist</artifactId>
+            <version>3.18.1-GA</version>
+        </dependency>
+        <dependency>
+            <groupId>org.jboss.spec.javax.security.jacc</groupId>
+            <artifactId>jboss-jacc-api_1.4_spec</artifactId>
+            <version>1.0.2.Final</version>
+        </dependency>
+        <dependency>
+            <groupId>org.jboss.logging</groupId>
+            <artifactId>jboss-logging</artifactId>
+            <version>3.1.4.GA</version>
+        </dependency>
+        <dependency>
+            <groupId>org.hibernate.common</groupId>
+            <artifactId>hibernate-commons-annotations</artifactId>
+            <version>4.0.4.Final</version>
+        </dependency>
+        <dependency>
+            <groupId>org.jboss</groupId>
+            <artifactId>jandex</artifactId>
+            <version>1.2.2.Final</version>
+        </dependency>
+        <dependency>
+            <groupId>org.hibernate</groupId>
+            <artifactId>hibernate-core</artifactId>
+            <version>${hibernate42.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.hibernate</groupId>
+            <artifactId>hibernate-entitymanager</artifactId>
+            <version>${hibernate42.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.hibernate</groupId>
+            <artifactId>hibernate-osgi</artifactId>
+            <version>${hibernate42.version}</version>
+        </dependency>
+        
+        <!-- Test bundles -->
+        <dependency>
+            <groupId>org.apache.aries.jpa</groupId>
+            <artifactId>org.apache.aries.jpa.container.itest.bundle</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.jpa</groupId>
+            <artifactId>org.apache.aries.jpa.container.advanced.itest.bundle</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.jpa.itest</groupId>
+            <artifactId>org.apache.aries.jpa.container.itest.bundle.blueprint</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.jpa.itest</groupId>
+            <artifactId>org.apache.aries.jpa.container.itest.bundle.blueprint</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.aries.transaction</groupId>
+            <artifactId>org.apache.aries.transaction.manager</artifactId>
+            <version>1.0.0</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.transaction</groupId>
+            <artifactId>org.apache.aries.transaction.testds</artifactId>
+            <version>1.0.0</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.transaction</groupId>
+            <artifactId>org.apache.aries.transaction.wrappers</artifactId>
+            <version>1.0.0</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.jndi</groupId>
+            <artifactId>org.apache.aries.jndi.api</artifactId>
+            <version>1.0.0</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.jndi</groupId>
+            <artifactId>org.apache.aries.jndi.core</artifactId>
+            <version>1.0.0</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.jpa</groupId>
+            <artifactId>org.apache.aries.jpa.eclipselink.adapter</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.jpa</groupId>
+            <artifactId>org.apache.aries.jpa.container.itest.bundle.eclipselink</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.jndi</groupId>
+            <artifactId>org.apache.aries.jndi.url</artifactId>
+            <version>1.0.0</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.derby</groupId>
+            <artifactId>derby</artifactId>
+            <version>10.10.2.0</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.jdbc</groupId>
+            <artifactId>pax-jdbc-derby</artifactId>
+            <version>${paxjdbc.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.jdbc</groupId>
+            <artifactId>pax-jdbc-pool-dbcp2</artifactId>
+            <version>${paxjdbc.version}</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.servicemix.bundles</groupId>
+            <artifactId>org.apache.servicemix.bundles.cglib</artifactId>
+            <version>2.1_3_4</version>
+            <scope>test</scope>
+        </dependency>
+
+        <!-- pax exam -->
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam</artifactId>
+            <version>${exam.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam-container-forked</artifactId>
+            <version>${exam.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam-junit4</artifactId>
+            <version>${exam.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam-link-mvn</artifactId>
+            <version>${exam.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.url</groupId>
+            <artifactId>pax-url-aether</artifactId>
+            <version>${url.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>ch.qos.logback</groupId>
+            <artifactId>logback-core</artifactId>
+            <version>0.9.29</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>ch.qos.logback</groupId>
+            <artifactId>logback-classic</artifactId>
+            <version>0.9.29</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.tinybundles</groupId>
+            <artifactId>tinybundles</artifactId>
+            <version>2.0.0</version>
+            <exclusions>
+                <exclusion>
+                    <artifactId>org.osgi.core</artifactId>
+                    <groupId>org.osgi</groupId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.servicemix.tooling</groupId>
+                <artifactId>depends-maven-plugin</artifactId>
+                <version>1.2</version>
+                <executions>
+                    <execution>
+                        <id>generate-depends-file</id>
+                        <goals>
+                            <goal>generate-depends-file</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <configuration>
+                    <forkMode>pertest</forkMode>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+    <profiles>
+        <profile>
+            <id>ci-build-profile</id>
+            <activation>
+                <property>
+                    <name>maven.repo.local</name>
+                </property>
+            </activation>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-surefire-plugin</artifactId>
+                        <configuration>
+                            <forkMode>pertest</forkMode>
+                            <!--
+                                when the local repo location has been specified, we need to pass
+                                on this information to PAX mvn url
+                            -->
+                            <argLine>-Dorg.ops4j.pax.url.mvn.localRepository=${maven.repo.local}</argLine>
+                        </configuration>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
+
+</project>
diff --git a/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/advanced/features/itest/EclipseLinkWeavingAndAnnotationScanningTest.java b/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/advanced/features/itest/EclipseLinkWeavingAndAnnotationScanningTest.java
new file mode 100644
index 0000000..07fd4ff
--- /dev/null
+++ b/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/advanced/features/itest/EclipseLinkWeavingAndAnnotationScanningTest.java
@@ -0,0 +1,46 @@
+/*  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.aries.jpa.advanced.features.itest;
+
+import static org.junit.Assert.assertTrue;
+
+import java.util.Arrays;
+
+import org.apache.aries.jpa.container.advanced.itest.bundle.entities.Car;
+import org.eclipse.persistence.internal.weaving.PersistenceWeaved;
+import org.junit.Test;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+
+public class EclipseLinkWeavingAndAnnotationScanningTest extends JPAWeavingAndAnnotationScanningTest {
+    @Configuration
+    public Option[] eclipseLinkConfig() {
+        return new Option[] {
+            baseOptions(), //
+            ariesJpa21(), //
+            eclipseLink(), //
+            derbyDSF(), //
+            testBundleAdvanced()
+        };
+    }
+
+    @Test
+    public void testClassIsWoven() throws Exception {
+        assertTrue("Not PersistenceCapable",
+                   Arrays.asList(Car.class.getInterfaces()).contains(PersistenceWeaved.class));
+    }
+
+}
diff --git a/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/advanced/features/itest/JPAWeavingAndAnnotationScanningTest.java b/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/advanced/features/itest/JPAWeavingAndAnnotationScanningTest.java
new file mode 100644
index 0000000..f1d1bbc
--- /dev/null
+++ b/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/advanced/features/itest/JPAWeavingAndAnnotationScanningTest.java
@@ -0,0 +1,56 @@
+/*  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.aries.jpa.advanced.features.itest;

+

+import static org.junit.Assert.assertEquals;

+

+import javax.inject.Inject;

+import javax.persistence.EntityManager;

+import javax.persistence.EntityManagerFactory;

+import javax.transaction.UserTransaction;

+

+import org.apache.aries.jpa.container.advanced.itest.bundle.entities.Car;

+import org.apache.aries.jpa.itest.AbstractJPAItest;

+import org.junit.Test;

+import org.ops4j.pax.exam.util.Filter;

+

+public abstract class JPAWeavingAndAnnotationScanningTest extends AbstractJPAItest {

+    @Inject

+    UserTransaction transaction;

+

+    @Inject

+    @Filter("(osgi.unit.name=" + TEST_UNIT + ")")

+    EntityManagerFactory emf;

+

+    @Test

+    public void testAnnotatedClassFound() throws Exception {

+        EntityManager em = emf.createEntityManager();

+        transaction.begin();

+

+        Car c = new Car();

+        c.setColour("Blue");

+        c.setNumberPlate("AB11CDE");

+        c.setNumberOfSeats(7);

+        c.setEngineSize(1900);

+        em.persist(c);

+

+        transaction.commit();

+

+        assertEquals(7, em.find(Car.class, "AB11CDE").getNumberOfSeats());

+        em.close();

+    }

+

+}

diff --git a/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/advanced/features/itest/OpenjpaWeavingAndAnnotationScanningTest.java b/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/advanced/features/itest/OpenjpaWeavingAndAnnotationScanningTest.java
new file mode 100644
index 0000000..cdbf6f1
--- /dev/null
+++ b/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/advanced/features/itest/OpenjpaWeavingAndAnnotationScanningTest.java
@@ -0,0 +1,49 @@
+/*  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.aries.jpa.advanced.features.itest;
+
+import static org.junit.Assert.assertTrue;
+
+import java.util.Arrays;
+
+import org.apache.aries.jpa.container.advanced.itest.bundle.entities.Car;
+import org.apache.openjpa.enhance.PersistenceCapable;
+import org.junit.Test;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+
+// TODO The Test persistence unit does not seem to be created. Reenable when this works 
+public class OpenjpaWeavingAndAnnotationScanningTest extends JPAWeavingAndAnnotationScanningTest {
+
+    @Configuration
+    public Option[] openjpaConfig() {
+        return new Option[] {
+            baseOptions(), //
+            openJpa(), //
+            derbyDSF(), //
+            ariesJpa20(), //
+            transactionWrapper(), //
+            testBundleAdvanced(), //
+        };
+    }
+
+    @Test
+    public void testClassIsWoven() throws Exception {
+        assertTrue("Not PersistenceCapable",
+                   Arrays.asList(Car.class.getInterfaces()).contains(PersistenceCapable.class));
+    }
+
+}
diff --git a/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/blueprint/aries/itest/BlueprintWithEmTest.java b/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/blueprint/aries/itest/BlueprintWithEmTest.java
new file mode 100644
index 0000000..1b1b77b
--- /dev/null
+++ b/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/blueprint/aries/itest/BlueprintWithEmTest.java
@@ -0,0 +1,98 @@
+/*  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.aries.jpa.blueprint.aries.itest;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.aries.jpa.itest.AbstractJPAItest;
+import org.apache.aries.jpa.itest.testbundle.entities.Car;
+import org.apache.aries.jpa.itest.testbundle.service.CarService;
+import org.junit.Assert;
+import org.junit.Test;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+
+public class BlueprintWithEmTest extends AbstractJPAItest {
+    
+	CarService carService;
+
+	@Test
+    public void testEmfAddQuery() throws Exception {
+		Map<String,String> filters = new HashMap<String,String>();
+		filters.put("type", "em");
+		carService = getService(CarService.class, "(type=em)");
+		
+		resolveBundles();
+        Car c = new Car();
+        c.setColour("Blue");
+        c.setNumberPlate("AB11EMF");
+        c.setNumberOfSeats(7);
+        c.setEngineSize(1900);
+
+        carService.addCar(c);
+
+        Car car2 = carService.getCar("AB11EMF");
+        Assert.assertEquals(c.getNumberPlate(), car2.getNumberPlate());
+    }
+
+	@Test
+    public void testEmAddQuery() throws Exception {
+		carService = getService(CarService.class, "(type=em)");
+		
+		resolveBundles();
+        Car c = new Car();
+        c.setColour("Blue");
+        c.setNumberPlate("AB11EM");
+        c.setNumberOfSeats(7);
+        c.setEngineSize(1900);
+
+        carService.addCar(c);
+
+        Car car2 = carService.getCar("AB11EM");
+        Assert.assertEquals(c.getNumberPlate(), car2.getNumberPlate());
+    }
+	
+	@Test
+    public void testSupplierAddQuery() throws Exception {
+		carService = getService(CarService.class, "(type=supplier)");
+		
+		resolveBundles();
+        Car c = new Car();
+        c.setColour("Blue");
+        c.setNumberPlate("AB11SUPPLIER");
+        c.setNumberOfSeats(7);
+        c.setEngineSize(1900);
+
+        carService.addCar(c);
+
+        Car car2 = carService.getCar("AB11SUPPLIER");
+        Assert.assertEquals(c.getNumberPlate(), car2.getNumberPlate());
+    }
+
+
+	@Configuration
+    public Option[] configuration() {
+        return new Option[] {
+            baseOptions(), //
+            ariesJpa20(), //
+            hibernate(), //
+            derbyDSF(), //
+            testBundleBlueprint(),
+            //debug()
+        };
+    }
+}
diff --git a/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/blueprint/aries/itest/BlueprintWithEmfTest.java b/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/blueprint/aries/itest/BlueprintWithEmfTest.java
new file mode 100644
index 0000000..b161f1d
--- /dev/null
+++ b/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/blueprint/aries/itest/BlueprintWithEmfTest.java
@@ -0,0 +1,94 @@
+/*  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.aries.jpa.blueprint.aries.itest;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.aries.jpa.itest.AbstractJPAItest;
+import org.apache.aries.jpa.itest.testbundle.entities.Car;
+import org.apache.aries.jpa.itest.testbundle.service.CarService;
+import org.junit.Assert;
+import org.junit.Test;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+
+public class BlueprintWithEmfTest extends AbstractJPAItest {
+    
+	@Test
+    public void testEmfAddQuery() throws Exception {
+		CarService carService = getService(CarService.class, "(type=emf)");
+		
+		resolveBundles();
+        Car c = new Car();
+        c.setColour("Blue");
+        c.setNumberPlate("AB11EMF");
+        c.setNumberOfSeats(7);
+        c.setEngineSize(1900);
+
+        carService.addCar(c);
+
+        Car car2 = carService.getCar("AB11EMF");
+        Assert.assertEquals(c.getNumberPlate(), car2.getNumberPlate());
+    }
+
+	@Test
+    public void testEmAddQuery() throws Exception {
+		CarService carService = getService(CarService.class, "(type=emf)");
+		
+		resolveBundles();
+        Car c = new Car();
+        c.setColour("Blue");
+        c.setNumberPlate("AB11EM");
+        c.setNumberOfSeats(7);
+        c.setEngineSize(1900);
+
+        carService.addCar(c);
+
+        Car car2 = carService.getCar("AB11EM");
+        Assert.assertEquals(c.getNumberPlate(), car2.getNumberPlate());
+    }
+	
+	@Test
+    public void testSupplierAddQuery() throws Exception {
+		CarService carService = getService(CarService.class, "(type=supplier)");
+		
+		resolveBundles();
+        Car c = new Car();
+        c.setColour("Blue");
+        c.setNumberPlate("AB11SUPPLIER");
+        c.setNumberOfSeats(7);
+        c.setEngineSize(1900);
+
+        carService.addCar(c);
+
+        Car car2 = carService.getCar("AB11SUPPLIER");
+        Assert.assertEquals(c.getNumberPlate(), car2.getNumberPlate());
+    }
+
+
+	@Configuration
+    public Option[] configuration() {
+        return new Option[] {
+            baseOptions(), //
+            ariesJpa20(), //
+            hibernate(), //
+            derbyDSF(), //
+            testBundleBlueprint(),
+            //debug()
+        };
+    }
+}
diff --git a/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/blueprint/aries/itest/BlueprintWithSupplierTest.java b/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/blueprint/aries/itest/BlueprintWithSupplierTest.java
new file mode 100644
index 0000000..d11f905
--- /dev/null
+++ b/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/blueprint/aries/itest/BlueprintWithSupplierTest.java
@@ -0,0 +1,91 @@
+/*  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.aries.jpa.blueprint.aries.itest;
+
+import org.apache.aries.jpa.itest.AbstractJPAItest;
+import org.apache.aries.jpa.itest.testbundle.entities.Car;
+import org.apache.aries.jpa.itest.testbundle.service.CarService;
+import org.junit.Assert;
+import org.junit.Test;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+
+public class BlueprintWithSupplierTest extends AbstractJPAItest {
+
+	@Test
+    public void testEmfAddQuery() throws Exception {
+		CarService carService = getService(CarService.class, "(type=supplier)");
+		
+		resolveBundles();
+        Car c = new Car();
+        c.setColour("Blue");
+        c.setNumberPlate("AB11EMF");
+        c.setNumberOfSeats(7);
+        c.setEngineSize(1900);
+
+        carService.addCar(c);
+
+        Car car2 = carService.getCar("AB11EMF");
+        Assert.assertEquals(c.getNumberPlate(), car2.getNumberPlate());
+    }
+
+	@Test
+    public void testEmAddQuery() throws Exception {
+		CarService carService = getService(CarService.class, "(type=em)");
+		
+		resolveBundles();
+        Car c = new Car();
+        c.setColour("Blue");
+        c.setNumberPlate("AB11EM");
+        c.setNumberOfSeats(7);
+        c.setEngineSize(1900);
+
+        carService.addCar(c);
+
+        Car car2 = carService.getCar("AB11EM");
+        Assert.assertEquals(c.getNumberPlate(), car2.getNumberPlate());
+    }
+	
+	@Test
+    public void testSupplierAddQuery() throws Exception {
+		CarService carService = getService(CarService.class, "(type=supplier)");
+		
+		resolveBundles();
+        Car c = new Car();
+        c.setColour("Blue");
+        c.setNumberPlate("AB11SUPPLIER");
+        c.setNumberOfSeats(7);
+        c.setEngineSize(1900);
+
+        carService.addCar(c);
+
+        Car car2 = carService.getCar("AB11SUPPLIER");
+        Assert.assertEquals(c.getNumberPlate(), car2.getNumberPlate());
+    }
+
+
+	@Configuration
+    public Option[] configuration() {
+        return new Option[] {
+            baseOptions(), //
+            ariesJpa20(), //
+            hibernate(), //
+            derbyDSF(), //
+            testBundleBlueprint(),
+            //debug()
+        };
+    }
+}
diff --git a/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/container/itest/EMFBuilderTest.java b/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/container/itest/EMFBuilderTest.java
new file mode 100644
index 0000000..b41b497
--- /dev/null
+++ b/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/container/itest/EMFBuilderTest.java
@@ -0,0 +1,72 @@
+/*
+ * 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 WARRANTIESOR 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.aries.jpa.container.itest;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+
+import org.apache.aries.jpa.container.itest.entities.Car;
+import org.apache.aries.jpa.itest.AbstractJPAItest;
+import org.junit.Assert;
+import org.junit.Test;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+import org.osgi.service.jpa.EntityManagerFactoryBuilder;
+
+public class EMFBuilderTest extends AbstractJPAItest {
+    @Inject
+    EntityManagerFactoryBuilder emfBuilder;
+    
+    @Test
+    public void testBuilder() throws Exception {
+        Map<String, Object> props = new HashMap<String, Object>();
+        EntityManagerFactory emf = emfBuilder.createEntityManagerFactory(props);
+        EntityManager em = emf.createEntityManager();
+        em.getTransaction().begin();
+        Car c = new Car();
+        c.setColour("Blue");
+        c.setNumberPlate("AB11CDE");
+        c.setNumberOfSeats(7);
+        c.setEngineSize(1900);
+        em.persist(c);
+        em.flush();
+        em.getTransaction().commit();
+        Car c2 = em.find(Car.class, "AB11CDE");
+        Assert.assertEquals(7, c2.getNumberOfSeats());
+        em.close();
+        emf.close();
+    }
+
+    @Configuration
+    public Option[] configuration() {
+        return new Option[] {
+            baseOptions(), //
+            ariesJpa20(), //
+            transactionWrapper(), //
+            hibernate(), //
+            testDs(),
+            testBundle()
+        };
+    }
+
+}
diff --git a/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/container/itest/EclipseLinkStartupTest.java b/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/container/itest/EclipseLinkStartupTest.java
new file mode 100644
index 0000000..ec5300f
--- /dev/null
+++ b/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/container/itest/EclipseLinkStartupTest.java
@@ -0,0 +1,44 @@
+/*  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.aries.jpa.container.itest;
+
+import org.apache.aries.jpa.itest.AbstractJPAItest;
+import org.junit.Test;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.options.AbstractProvisionControl;
+import org.ops4j.pax.exam.options.MavenArtifactProvisionOption;
+
+public class EclipseLinkStartupTest extends AbstractJPAItest {
+
+    @Test
+    public void testContextCreationWithStartingBundle() throws Exception {
+        getBundleByName("org.apache.aries.jpa.container.itest.bundle.eclipselink").start();
+        getEMF("script-test-unit");
+    }
+
+	@Configuration
+    public Option[] configuration() {
+        return new Option[] {//
+            baseOptions(),//
+            ariesJpa21(),//
+            eclipseLink(),//
+            derbyDSF(), //
+            testBundleEclipseLink().noStart(),//
+        // debug()
+        };
+    }
+}
diff --git a/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/container/itest/JPAContainerDataSourceFactoryTest.java b/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/container/itest/JPAContainerDataSourceFactoryTest.java
new file mode 100644
index 0000000..c243579
--- /dev/null
+++ b/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/container/itest/JPAContainerDataSourceFactoryTest.java
@@ -0,0 +1,117 @@
+/*  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.aries.jpa.container.itest;

+

+import static org.junit.Assert.assertEquals;

+

+import javax.inject.Inject;

+import javax.persistence.EntityManager;

+import javax.persistence.EntityManagerFactory;

+import javax.transaction.UserTransaction;

+

+import org.apache.aries.jpa.container.itest.entities.Car;

+import org.apache.aries.jpa.itest.AbstractJPAItest;

+import org.junit.Test;

+import org.ops4j.pax.exam.Configuration;

+import org.ops4j.pax.exam.Option;

+import org.ops4j.pax.exam.util.Filter;

+

+public class JPAContainerDataSourceFactoryTest extends AbstractJPAItest {

+    private static final String DSF_TEST_UNIT = "dsf-test-unit";

+    private static final String DSF_XA_TEST_UNIT = "dsf-xa-test-unit";

+    

+    @Inject

+    @Filter("(osgi.unit.name=" + DSF_TEST_UNIT + ")")

+    EntityManagerFactory emfDSF;

+    

+    @Inject

+    @Filter("(osgi.unit.name=" + DSF_XA_TEST_UNIT + ")")

+    EntityManagerFactory emfDSFXA;

+    

+    @Inject

+    UserTransaction ut;

+    

+

+    @Test

+    public void testDataSourceFactoryLifecycle() throws Exception {

+        EntityManager em = emfDSF.createEntityManager();

+        em.getTransaction().begin();

+        Car c = createCar();

+        em.persist(c);

+        em.getTransaction().commit();

+        em.close();

+

+        assertCarFound(emfDSF);

+

+        em = emfDSF.createEntityManager();

+        em.getTransaction().begin();

+        deleteCar(em, c);

+        em.getTransaction().commit();

+        em.close();

+    }

+

+    @Test

+    public void testDataSourceFactoryXALifecycle() throws Exception {

+        EntityManager em = emfDSFXA.createEntityManager();

+

+        // Use a JTA transaction to show integration

+        ut.begin();

+        em.joinTransaction();

+        Car c = createCar();

+        em.persist(c);

+        ut.commit();

+        em.close();

+

+        assertCarFound(emfDSFXA);

+

+        em = emfDSFXA.createEntityManager();

+        ut.begin();

+        em.joinTransaction();

+        deleteCar(em, c);

+        ut.commit();

+        em.close();

+    }

+

+    private Car createCar() {

+        Car c = new Car();

+        c.setNumberPlate("123456");

+        c.setColour("blue");

+        return c;

+    }

+

+    private void deleteCar(EntityManager em, Car c) {

+        c = em.merge(c);

+        em.remove(c);

+    }

+

+    private void assertCarFound(EntityManagerFactory emf) {

+        EntityManager em = emf.createEntityManager();

+        assertEquals("blue", em.find(Car.class, "123456").getColour());

+        em.close();

+    }

+

+    @Configuration

+    public Option[] configuration() {

+        return new Option[] {

+            baseOptions(), //

+            ariesJpa20(), //

+            derbyDSF(), //

+            hibernate(), //

+            testBundle()

+        };

+    }

+

+}

diff --git a/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/container/itest/JPAContainerHibernateTest.java b/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/container/itest/JPAContainerHibernateTest.java
new file mode 100644
index 0000000..3922924
--- /dev/null
+++ b/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/container/itest/JPAContainerHibernateTest.java
@@ -0,0 +1,64 @@
+/*  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.aries.jpa.container.itest;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+
+import org.apache.aries.jpa.container.itest.entities.Car;
+import org.apache.aries.jpa.itest.AbstractJPAItest;
+import org.junit.Test;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+
+public class JPAContainerHibernateTest extends AbstractJPAItest {
+    @Test
+    public void testCarCreateDelete() throws Exception {
+        resolveBundles();
+        EntityManagerFactory emf = getEMF(TEST_UNIT);
+        EntityManager em = emf.createEntityManager();
+        em.getTransaction().begin();
+        Car c = new Car();
+        c.setNumberPlate("123456");
+        c.setColour("blue");
+        em.persist(c);
+        em.getTransaction().commit();
+        em.close();
+
+        em = emf.createEntityManager();
+        em.getTransaction().begin();
+        deleteCar(em, c);
+        em.getTransaction().commit();
+        em.close();
+    }
+
+    private void deleteCar(EntityManager em, Car c) {
+        c = em.merge(c);
+        em.remove(c);
+    }
+
+    @Configuration
+    public Option[] configuration() {
+        return new Option[] {
+            baseOptions(), //
+            ariesJpa20(), //
+            testBundle(), //
+            transactionWrapper(), //
+            testDs(), //
+            hibernate()
+        };
+    }
+}
diff --git a/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/container/itest/OpenJPAContainerTest.java b/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/container/itest/OpenJPAContainerTest.java
new file mode 100644
index 0000000..aa51819
--- /dev/null
+++ b/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/container/itest/OpenJPAContainerTest.java
@@ -0,0 +1,49 @@
+/*  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.aries.jpa.container.itest;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+
+import org.apache.aries.jpa.itest.AbstractJPAItest;
+import org.junit.Test;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+
+public class OpenJPAContainerTest extends AbstractJPAItest {
+
+    @Test
+    public void findEntityManagerFactory() throws Exception {
+        EntityManagerFactory emf = getEMF(TEST_UNIT);
+        EntityManager em = emf.createEntityManager();
+        em.close();
+    }
+
+    @Configuration
+    public Option[] configuration() {
+        return new Option[] {
+            baseOptions(), //
+            ariesJpa20(), //
+            // Needed for the BP_TEST_UNIT
+            transactionWrapper(), //
+            openJpa(), //
+            testDs(), //
+            testBundle()
+        };
+
+    }
+
+}
diff --git a/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/container/itest/TCKJPATestCase.java b/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/container/itest/TCKJPATestCase.java
new file mode 100644
index 0000000..77eef5c
--- /dev/null
+++ b/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/container/itest/TCKJPATestCase.java
@@ -0,0 +1,61 @@
+/*  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.aries.jpa.container.itest;
+
+import static org.ops4j.pax.exam.CoreOptions.streamBundle;
+
+import java.io.InputStream;
+
+import javax.persistence.EntityManagerFactory;
+
+import org.apache.aries.jpa.itest.AbstractJPAItest;
+import org.junit.Assert;
+import org.junit.Test;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.tinybundles.core.TinyBundles;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Constants;
+
+/**
+ * Simulates some tests from the tck
+ */
+public class TCKJPATestCase extends AbstractJPAItest {
+
+    @Test
+	public void testEntityManagerFactoryWithIncompletePersistenceUnit() throws Exception {
+		EntityManagerFactory emf = getService(EntityManagerFactory.class, "(osgi.unit.name=incompleteTestUnit)", false); 
+		Assert.assertNull("There should be no EntityManagerFactory registered since this persistence unit is incomplete", emf);
+		Bundle testBundle = getBundleByName("incompleteTestUnit");
+		testBundle.uninstall();
+	}
+
+    @Configuration
+    public Option[] configuration() {
+    	InputStream testBundle = TinyBundles.bundle()
+    			.set(Constants.BUNDLE_SYMBOLICNAME, "incompleteTestUnit")
+    			.set("Meta-Persistence", " ")
+    			.add("META-INF/persistence.xml", this.getClass().getResourceAsStream("persistence.xml"))
+    			.build(TinyBundles.withBnd());
+        return new Option[] {
+            baseOptions(), //
+            ariesJpa20(), //
+            derbyDSF(), //
+            hibernate(), //
+            streamBundle(testBundle)
+        };
+    }
+}
diff --git a/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/container/itest/persistence.xml b/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/container/itest/persistence.xml
new file mode 100644
index 0000000..f107c55
--- /dev/null
+++ b/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/container/itest/persistence.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence xmlns="http://java.sun.com/xml/ns/persistence"
+   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
+   version="1.0">
+	<persistence-unit name="incompleteTestUnit">
+		<description>Persistence unit for testing an incomplete persistence unit</description>
+	</persistence-unit>
+</persistence>
\ No newline at end of file
diff --git a/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/context/itest/EclipseLinkContextTest.java b/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/context/itest/EclipseLinkContextTest.java
new file mode 100644
index 0000000..0f3950b
--- /dev/null
+++ b/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/context/itest/EclipseLinkContextTest.java
@@ -0,0 +1,34 @@
+/*  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.aries.jpa.context.itest;
+
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+
+public class EclipseLinkContextTest extends JPAContextTest {
+
+    @Configuration
+    public Option[] eclipseLinkConfig() {
+        return new Option[] {
+            baseOptions(), //
+            ariesJpa21(), //
+            eclipseLink(), //
+            derbyDSF(), //
+            testBundleAdvanced()
+        };
+    }
+
+}
diff --git a/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/context/itest/JPAContextTest.java b/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/context/itest/JPAContextTest.java
new file mode 100644
index 0000000..4744bf1
--- /dev/null
+++ b/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/context/itest/JPAContextTest.java
@@ -0,0 +1,196 @@
+/*  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.aries.jpa.context.itest;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.List;
+
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import javax.persistence.TypedQuery;
+import javax.transaction.UserTransaction;
+
+import org.apache.aries.jpa.container.advanced.itest.bundle.entities.Car;
+import org.apache.aries.jpa.itest.AbstractJPAItest;
+import org.apache.aries.jpa.supplier.EmSupplier;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.ops4j.pax.exam.util.Filter;
+
+public abstract class JPAContextTest extends AbstractJPAItest {
+
+    @Inject
+    UserTransaction ut;
+
+    @Inject
+    @Filter("(osgi.unit.name=test-unit)")
+    EmSupplier emSupplier;
+
+    @Before
+    public void preCall() {
+        emSupplier.preCall();
+    }
+    
+    @After
+    public void postCall() {
+        emSupplier.postCall();
+    }
+    
+    @Test
+    public void testCreateAndChange() throws Exception {
+        resolveBundles();
+        EntityManager em = emSupplier.get();
+        ut.begin();
+        em.joinTransaction();
+        try {
+            deleteCars(em);
+            Car car = new Car();
+            car.setNumberOfSeats(5);
+            car.setEngineSize(1200);
+            car.setColour("blue");
+            car.setNumberPlate("A1AAA");
+            em.persist(car);
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            ut.commit();
+        }
+        
+        Car c = em.find(Car.class, "A1AAA");
+        
+        assertEquals(5, c.getNumberOfSeats());
+        assertEquals(1200, c.getEngineSize());
+        assertEquals("blue", c.getColour());
+        
+        ut.begin();
+        try {
+            Car car = em.find(Car.class, "A1AAA");
+            car.setNumberOfSeats(2);
+            car.setEngineSize(2000);
+            car.setColour("red");
+        } finally {
+            ut.commit();
+        }
+        
+        c = em.find(Car.class, "A1AAA");
+        
+        assertEquals(2, c.getNumberOfSeats());
+        assertEquals(2000, c.getEngineSize());
+        assertEquals("red", c.getColour());
+    }
+
+    private void deleteCars(EntityManager em) {
+        Query q = em.createQuery("DELETE from Car c");
+        q.executeUpdate();
+
+        q = em.createQuery("SELECT Count(c) from Car c");
+        assertEquals(0l, q.getSingleResult());
+    }
+
+    @Test
+    public void testQueries() throws Exception {
+        final EntityManager em = emSupplier.get();
+        try {
+            ut.begin();
+            em.joinTransaction();
+            deleteCars(em);
+        } finally {
+            ut.commit();
+        }
+
+        Query countQuery = em.createQuery("SELECT Count(c) from Car c");
+        assertEquals(0l, countQuery.getSingleResult());
+
+        ut.begin();
+        em.joinTransaction();
+        try {
+            Car car = new Car();
+            car.setNumberOfSeats(5);
+            car.setEngineSize(1200);
+            car.setColour("blue");
+            car.setNumberPlate("A1AAA");
+            em.persist(car);
+
+            car = new Car();
+            car.setNumberOfSeats(7);
+            car.setEngineSize(1800);
+            car.setColour("green");
+            car.setNumberPlate("B2BBB");
+            em.persist(car);
+        } finally {
+            ut.commit();
+        }
+
+        assertEquals(2l, countQuery.getSingleResult());
+
+        TypedQuery<Car> carQuery = em.createQuery("Select c from Car c ORDER by c.engineSize",
+                                                         Car.class);
+
+        List<Car> list = carQuery.getResultList();
+        assertEquals(2l, list.size());
+
+        assertEquals(5, list.get(0).getNumberOfSeats());
+        assertEquals(1200, list.get(0).getEngineSize());
+        assertEquals("blue", list.get(0).getColour());
+        assertEquals("A1AAA", list.get(0).getNumberPlate());
+
+        assertEquals(7, list.get(1).getNumberOfSeats());
+        assertEquals(1800, list.get(1).getEngineSize());
+        assertEquals("green", list.get(1).getColour());
+        assertEquals("B2BBB", list.get(1).getNumberPlate());
+
+        ut.begin();
+        em.joinTransaction();
+        try {
+            Car car = em.find(Car.class, "A1AAA");
+            car.setNumberOfSeats(2);
+            car.setEngineSize(2000);
+            car.setColour("red");
+
+            car = em.find(Car.class, "B2BBB");
+            em.remove(car);
+
+            car = new Car();
+            car.setNumberOfSeats(2);
+            car.setEngineSize(800);
+            car.setColour("black");
+            car.setNumberPlate("C3CCC");
+            em.persist(car);
+
+        } finally {
+            ut.commit();
+        }
+
+        assertEquals(2l, countQuery.getSingleResult());
+
+        list = carQuery.getResultList();
+        assertEquals(2l, list.size());
+
+        assertEquals(2, list.get(0).getNumberOfSeats());
+        assertEquals(800, list.get(0).getEngineSize());
+        assertEquals("black", list.get(0).getColour());
+        assertEquals("C3CCC", list.get(0).getNumberPlate());
+
+        assertEquals(2, list.get(1).getNumberOfSeats());
+        assertEquals(2000, list.get(1).getEngineSize());
+        assertEquals("red", list.get(1).getColour());
+        assertEquals("A1AAA", list.get(1).getNumberPlate());
+    }
+
+}
diff --git a/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/context/itest/OpenjpaContextTest.java b/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/context/itest/OpenjpaContextTest.java
new file mode 100644
index 0000000..4dae93e
--- /dev/null
+++ b/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/context/itest/OpenjpaContextTest.java
@@ -0,0 +1,34 @@
+/*  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.aries.jpa.context.itest;
+
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+
+public class OpenjpaContextTest extends JPAContextTest {
+
+    @Configuration
+    public Option[] configuration() {
+        return new Option[] {//
+            baseOptions(), //
+            ariesJpa20(), //
+            openJpa(), //
+            derbyDSF(), //
+            testBundleAdvanced()
+        };
+    }
+
+}
diff --git a/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/itest/AbstractJPAItest.java b/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/itest/AbstractJPAItest.java
new file mode 100644
index 0000000..418c5db
--- /dev/null
+++ b/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/itest/AbstractJPAItest.java
@@ -0,0 +1,265 @@
+package org.apache.aries.jpa.itest;
+
+import static org.ops4j.pax.exam.CoreOptions.composite;
+import static org.ops4j.pax.exam.CoreOptions.frameworkProperty;
+import static org.ops4j.pax.exam.CoreOptions.junitBundles;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+import static org.ops4j.pax.exam.CoreOptions.vmOption;
+import static org.ops4j.pax.exam.CoreOptions.when;
+
+import javax.inject.Inject;
+import javax.persistence.EntityManagerFactory;
+
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.options.MavenArtifactProvisionOption;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
+import org.osgi.framework.Filter;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.util.tracker.ServiceTracker;
+
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
+public abstract class AbstractJPAItest {
+    protected static final String TEST_UNIT = "test-unit";
+    protected static final String BP_TEST_UNIT = "bp-test-unit";
+    protected static final String BP_XA_TEST_UNIT = "bp-xa-test-unit";
+    protected static final String TEST_BUNDLE_NAME = "org.apache.aries.jpa.org.apache.aries.jpa.container.itest.bundle";
+    
+    @Inject
+    protected BundleContext bundleContext;
+
+    /**
+     * TODO check calls to this. Eventually switch to EmSupplier 
+     */
+    protected EntityManagerFactory getProxyEMF(String name) {
+        return getEMF(name);
+    }
+    
+    protected EntityManagerFactory getEMF(String name) {
+        return getService(EntityManagerFactory.class, "osgi.unit.name=" + name);
+    }
+    
+    public <T> T getService(Class<T> type, String filter) {
+    	return getService(type, filter, true);
+    }
+
+    @SuppressWarnings({ "rawtypes", "unchecked" })
+	public <T> T getService(Class<T> type, String filter, boolean mandatory) {
+        ServiceTracker tracker = null;
+        try {
+        	String objClassFilter = "(" + Constants.OBJECTCLASS + "=" + type.getName() + ")";
+            String flt = filter != null ? "(&" + objClassFilter + sanitizeFilter(filter) + ")" : objClassFilter;
+            Filter osgiFilter = FrameworkUtil.createFilter(flt);
+            tracker = new ServiceTracker(bundleContext, osgiFilter, null);
+            tracker.open();
+
+            Object svc = type.cast(tracker.waitForService(10000));
+            if (svc == null && mandatory) {
+                throw new RuntimeException("Gave up waiting for service " + flt);
+            }
+            return type.cast(svc);
+        } catch (InvalidSyntaxException e) {
+            throw new IllegalArgumentException("Invalid filter", e);
+        } catch (InterruptedException e) {
+            throw new RuntimeException(e);
+        } finally {
+        	tracker.close();
+        }
+    }
+
+	public String sanitizeFilter(String filter) {
+		return filter.startsWith("(") ? filter : "(" + filter + ")";
+	}	
+		
+    
+	/**
+	 * Helps to diagnose bundles that are not resolved as it will throw a detailed exception
+	 * 
+	 * @throws BundleException
+	 */
+	public void resolveBundles() throws BundleException {
+		Bundle[] bundles = bundleContext.getBundles();
+		for (Bundle bundle : bundles) {
+			if (bundle.getState() == Bundle.INSTALLED) {
+				System.out.println("Found non resolved bundle " + bundle.getBundleId() + ":" + bundle.getSymbolicName() + ":" + bundle.getVersion());
+				bundle.start();
+			}
+		}
+	}
+	
+    public Bundle getBundleByName(String symbolicName) {
+        for (Bundle b : bundleContext.getBundles()) {
+            if (b.getSymbolicName().equals(symbolicName)) {
+                return b;
+            }
+        }
+        return null;
+    }
+
+    @SuppressWarnings("rawtypes")
+    protected ServiceReference[] getEMFRefs(String name) throws InvalidSyntaxException {
+        return bundleContext.getAllServiceReferences(EntityManagerFactory.class.getName(), "(osgi.unit.name=" + name + ")");
+    }
+    
+    private MavenArtifactProvisionOption mvnBundle(String groupId, String artifactId) {
+        return mavenBundle(groupId, artifactId).versionAsInProject();
+    }
+
+    protected Option baseOptions() {
+        String localRepo = System.getProperty("maven.repo.local");
+
+        if (localRepo == null) {
+            localRepo = System.getProperty("org.ops4j.pax.url.mvn.localRepository");
+        }
+        return composite(junitBundles(),
+                mavenBundle("org.ops4j.pax.logging", "pax-logging-api", "1.7.2"),
+                mavenBundle("org.ops4j.pax.logging", "pax-logging-service", "1.7.2"),
+                // this is how you set the default log level when using pax
+                // logging (logProfile)
+                systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
+                when(localRepo != null).useOptions(vmOption("-Dorg.ops4j.pax.url.mvn.localRepository=" + localRepo))
+                //,
+                );
+    }
+    
+    protected Option debug() {
+        return vmOption("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005");
+    }
+
+    private Option ariesJpaInternal() {
+        return composite(
+                frameworkProperty("org.osgi.framework.system.packages")
+                        .value("javax.accessibility,javax.activation,javax.activity,javax.annotation,javax.annotation.processing,javax.crypto,javax.crypto.interfaces,javax.crypto.spec,javax.imageio,javax.imageio.event,javax.imageio.metadata,javax.imageio.plugins.bmp,javax.imageio.plugins.jpeg,javax.imageio.spi,javax.imageio.stream,javax.jws,javax.jws.soap,javax.lang.model,javax.lang.model.element,javax.lang.model.type,javax.lang.model.util,javax.management,javax.management.loading,javax.management.modelmbean,javax.management.monitor,javax.management.openmbean,javax.management.relation,javax.management.remote,javax.management.remote.rmi,javax.management.timer,javax.naming,javax.naming.directory,javax.naming.event,javax.naming.ldap,javax.naming.spi,javax.net,javax.net.ssl,javax.print,javax.print.attribute,javax.print.attribute.standard,javax.print.event,javax.rmi,javax.rmi.CORBA,javax.rmi.ssl,javax.script,javax.security.auth,javax.security.auth.callback,javax.security.auth.kerberos,javax.security.auth.login,javax.security.auth.spi,javax.security.auth.x500,javax.security.cert,javax.security.sasl,javax.sound.midi,javax.sound.midi.spi,javax.sound.sampled,javax.sound.sampled.spi,javax.sql,javax.sql.rowset,javax.sql.rowset.serial,javax.sql.rowset.spi,javax.swing,javax.swing.border,javax.swing.colorchooser,javax.swing.event,javax.swing.filechooser,javax.swing.plaf,javax.swing.plaf.basic,javax.swing.plaf.metal,javax.swing.plaf.multi,javax.swing.plaf.synth,javax.swing.table,javax.swing.text,javax.swing.text.html,javax.swing.text.html.parser,javax.swing.text.rtf,javax.swing.tree,javax.swing.undo,javax.tools,javax.xml,javax.xml.bind,javax.xml.bind.annotation,javax.xml.bind.annotation.adapters,javax.xml.bind.attachment,javax.xml.bind.helpers,javax.xml.bind.util,javax.xml.crypto,javax.xml.crypto.dom,javax.xml.crypto.dsig,javax.xml.crypto.dsig.dom,javax.xml.crypto.dsig.keyinfo,javax.xml.crypto.dsig.spec,javax.xml.datatype,javax.xml.namespace,javax.xml.parsers,javax.xml.soap,"
+                               + "javax.xml.stream; version=1.0,javax.xml.stream.events; version=1.0,javax.xml.stream.util; version=1.0,"
+                               + "javax.xml.transform,javax.xml.transform.dom,javax.xml.transform.sax,javax.xml.transform.stax,javax.xml.transform.stream,javax.xml.validation,javax.xml.ws,javax.xml.ws.handler,javax.xml.ws.handler.soap,javax.xml.ws.http,javax.xml.ws.soap,javax.xml.ws.spi,javax.xml.xpath,org.ietf.jgss,org.omg.CORBA,org.omg.CORBA.DynAnyPackage,org.omg.CORBA.ORBPackage,org.omg.CORBA.TypeCodePackage,org.omg.CORBA.portable,org.omg.CORBA_2_3,org.omg.CORBA_2_3.portable,org.omg.CosNaming,org.omg.CosNaming.NamingContextExtPackage,org.omg.CosNaming.NamingContextPackage,org.omg.Dynamic,org.omg.DynamicAny,org.omg.DynamicAny.DynAnyFactoryPackage,org.omg.DynamicAny.DynAnyPackage,org.omg.IOP,org.omg.IOP.CodecFactoryPackage,org.omg.IOP.CodecPackage,org.omg.Messaging,org.omg.PortableInterceptor,org.omg.PortableInterceptor.ORBInitInfoPackage,org.omg.PortableServer,org.omg.PortableServer.CurrentPackage,org.omg.PortableServer.POAManagerPackage,org.omg.PortableServer.POAPackage,org.omg.PortableServer.ServantLocatorPackage,org.omg.PortableServer.portable,org.omg.SendingContext,org.omg.stub.java.rmi,org.w3c.dom,org.w3c.dom.bootstrap,org.w3c.dom.css,org.w3c.dom.events,org.w3c.dom.html,org.w3c.dom.ls,org.w3c.dom.ranges,org.w3c.dom.stylesheets,org.w3c.dom.traversal,org.w3c.dom.views,org.xml.sax,org.xml.sax.ext,org.xml.sax.helpers"),
+                
+                mvnBundle("org.ow2.asm", "asm-all"),
+                mvnBundle("org.apache.felix", "org.apache.felix.configadmin"),
+
+                mvnBundle("org.apache.aries.proxy", "org.apache.aries.proxy.api"),
+                mvnBundle("org.apache.aries.proxy", "org.apache.aries.proxy.impl"),
+                mvnBundle("org.apache.aries", "org.apache.aries.util"),
+                
+                mvnBundle("org.apache.aries.jndi", "org.apache.aries.jndi.api"),
+                mvnBundle("org.apache.aries.jndi", "org.apache.aries.jndi.core"),
+                mvnBundle("org.apache.aries.jndi", "org.apache.aries.jndi.url"),
+
+                mvnBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint.api"),
+                mvnBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint.core"),
+                
+                mvnBundle("org.apache.aries.jpa", "org.apache.aries.jpa.api"),
+                mvnBundle("org.apache.aries.jpa", "org.apache.aries.jpa.container"),
+                mvnBundle("org.apache.aries.jpa", "org.apache.aries.jpa.support"),
+                mvnBundle("org.apache.aries.jpa", "org.apache.aries.jpa.blueprint"),
+
+                mvnBundle("org.apache.geronimo.specs", "geronimo-jta_1.1_spec"),
+                mvnBundle("org.apache.aries.transaction", "org.apache.aries.transaction.manager"),
+                mvnBundle("org.apache.aries.transaction", "org.apache.aries.transaction.blueprint"),
+
+                mvnBundle("org.apache.derby", "derby")
+        );
+    }
+    
+    protected Option ariesJpa20() {
+        return composite(
+                ariesJpaInternal(),
+                mavenBundle("org.apache.geronimo.specs", "geronimo-jpa_2.0_spec", "1.1")
+                );
+    }
+
+    protected Option ariesJpa21() {
+        return composite(
+                ariesJpaInternal(),
+                mvnBundle("org.eclipse.persistence", "javax.persistence")
+                );
+    }
+
+    protected Option transactionWrapper() {
+        return mvnBundle("org.apache.aries.transaction", "org.apache.aries.transaction.wrappers");
+    }
+
+    protected Option eclipseLink() {
+        return composite(
+                mvnBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.commons-dbcp"),
+                mvnBundle("org.eclipse.persistence", "org.eclipse.persistence.jpa"),
+                mvnBundle("org.eclipse.persistence", "org.eclipse.persistence.core"),
+                mvnBundle("org.eclipse.persistence", "org.eclipse.persistence.asm"),
+                mvnBundle("org.eclipse.persistence", "org.eclipse.persistence.antlr"),
+                mvnBundle("org.eclipse.persistence", "org.eclipse.persistence.jpa.jpql"),
+                mvnBundle("org.apache.aries.jpa", "org.apache.aries.jpa.eclipselink.adapter")
+                );
+    }
+
+    protected Option openJpa() {
+        return composite(
+                mvnBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.cglib"), //
+                mvnBundle("commons-pool", "commons-pool"), //
+                mvnBundle("commons-lang", "commons-lang"), //
+                mvnBundle("commons-collections", "commons-collections"), //
+                mvnBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.serp"),
+                mvnBundle("org.apache.geronimo.specs", "geronimo-servlet_2.5_spec"),
+                mvnBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.commons-dbcp"),
+                mvnBundle("org.apache.xbean", "xbean-asm4-shaded"),
+                mvnBundle("org.apache.openjpa", "openjpa")
+                );
+    }
+    
+    protected Option hibernate() {
+        return composite(
+                mvnBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.antlr"),
+                mvnBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.ant"),
+                mvnBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.dom4j"),
+                mvnBundle("org.apache.servicemix.bundles" , "org.apache.servicemix.bundles.serp"),
+                mvnBundle("com.fasterxml", "classmate"),
+                mvnBundle("org.javassist", "javassist"),
+                mvnBundle("org.jboss.logging", "jboss-logging"),
+                mvnBundle("org.hibernate.common", "hibernate-commons-annotations"), 
+                mvnBundle("org.jboss", "jandex"),
+                mvnBundle("org.hibernate", "hibernate-core"),
+                mvnBundle("org.hibernate", "hibernate-entitymanager"),
+                mvnBundle("org.hibernate", "hibernate-osgi")
+                );
+    }
+
+    protected Option testDs() {
+        return mvnBundle("org.apache.aries.transaction", "org.apache.aries.transaction.testds");
+    }
+    
+    protected Option derbyDSF() {
+        return composite(
+                mvnBundle("org.ops4j.pax.jdbc", "pax-jdbc-derby"), //
+                mvnBundle("org.apache.commons", "commons-pool2"), //
+                mvnBundle("commons-logging", "commons-logging"), //
+                mvnBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.cglib"), //
+                mvnBundle("org.apache.commons", "commons-dbcp2"), //
+                mvnBundle("org.ops4j.pax.jdbc", "pax-jdbc-pool-common"), //
+                mvnBundle("org.ops4j.pax.jdbc", "pax-jdbc-pool-dbcp2") //
+            );
+    }
+    
+    protected MavenArtifactProvisionOption testBundle() {
+        return mvnBundle("org.apache.aries.jpa", "org.apache.aries.jpa.container.itest.bundle");
+    }
+
+    protected MavenArtifactProvisionOption testBundleBlueprint() {
+        return mvnBundle("org.apache.aries.jpa.itest", "org.apache.aries.jpa.container.itest.bundle.blueprint");
+    }
+
+    protected MavenArtifactProvisionOption testBundleEclipseLink() {
+        return mvnBundle("org.apache.aries.jpa", "org.apache.aries.jpa.container.itest.bundle.eclipselink");
+    }
+
+    protected MavenArtifactProvisionOption testBundleAdvanced() {
+        return mvnBundle("org.apache.aries.jpa", "org.apache.aries.jpa.container.advanced.itest.bundle");
+    }
+}
diff --git a/itests/jpa-container-testbundle-eclipselink/LICENSE b/itests/jpa-container-testbundle-eclipselink/LICENSE
new file mode 100644
index 0000000..6b0b127
--- /dev/null
+++ b/itests/jpa-container-testbundle-eclipselink/LICENSE
@@ -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.
+
diff --git a/itests/jpa-container-testbundle-eclipselink/NOTICE b/itests/jpa-container-testbundle-eclipselink/NOTICE
new file mode 100644
index 0000000..424644d
--- /dev/null
+++ b/itests/jpa-container-testbundle-eclipselink/NOTICE
@@ -0,0 +1,8 @@
+
+Apache Aries
+Copyright 2009-2011 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+
diff --git a/itests/jpa-container-testbundle-eclipselink/pom.xml b/itests/jpa-container-testbundle-eclipselink/pom.xml
new file mode 100644
index 0000000..999257b
--- /dev/null
+++ b/itests/jpa-container-testbundle-eclipselink/pom.xml
@@ -0,0 +1,97 @@
+<?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.aries.jpa.itest</groupId>
+        <artifactId>org.apache.aries.jpa.itest.parent</artifactId>
+        <version>2.0.0</version>
+        <relativePath>..</relativePath>
+    </parent>
+
+    <groupId>org.apache.aries.jpa</groupId>
+    <artifactId>org.apache.aries.jpa.container.itest.bundle.eclipselink</artifactId>
+    <packaging>bundle</packaging>
+    <name>Apache Aries JPA test bundle Eclipselink</name>
+
+    <properties>
+        <!-- Export package versions are maintained in packageinfo files -->
+        <aries.osgi.export.pkg>
+            org.apache.aries.jpa.container.itest*
+        </aries.osgi.export.pkg>
+        <aries.osgi.import>
+            javax.persistence*;version="[1.1,3.0)",
+            *
+        </aries.osgi.import>
+        <aries.osgi.private.pkg />
+        <aries.osgi.symbolic.name>${project.artifactId}</aries.osgi.symbolic.name>
+        <!-- Only test bundle -->
+        <aries.skip.version.check>true</aries.skip.version.check>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.persistence</groupId>
+            <artifactId>javax.persistence</artifactId>
+            <version>2.1.0</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <configuration>
+                    <instructions>
+                        <Meta-Persistence>META-INF/persistence.xml</Meta-Persistence>
+                    </instructions>
+                </configuration>
+            </plugin>
+            <plugin>
+                <artifactId>maven-antrun-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <phase>process-classes</phase>
+                        <configuration>
+                            <tasks>
+                                <java classname="org.eclipse.persistence.tools.weaving.jpa.StaticWeave" classpathref="maven.runtime.classpath" fork="true">
+                                    <arg line="-persistenceinfo src/main/resources target/classes target/classes" />
+                                </java>
+                            </tasks>
+                        </configuration>
+                        <goals>
+                            <goal>run</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+    <description>For testing static weaving and scripts for database setup with EclipseLink</description>
+</project>
diff --git a/itests/jpa-container-testbundle-eclipselink/src/main/java/org/apache/aries/jpa/container/itest/entities/Car.java b/itests/jpa-container-testbundle-eclipselink/src/main/java/org/apache/aries/jpa/container/itest/entities/Car.java
new file mode 100644
index 0000000..da63739
--- /dev/null
+++ b/itests/jpa-container-testbundle-eclipselink/src/main/java/org/apache/aries/jpa/container/itest/entities/Car.java
@@ -0,0 +1,68 @@
+/*
+ * 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 WARRANTIESOR 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.aries.jpa.container.itest.entities;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+
+@Entity
+public class Car {
+  @Id
+  private String numberPlate;
+  
+  private String colour;
+  
+  private int engineSize;
+  
+  private int numberOfSeats;
+
+  public String getNumberPlate() {
+    return numberPlate;
+  }
+
+  public void setNumberPlate(String numberPlate) {
+    this.numberPlate = numberPlate;
+  }
+
+  public String getColour() {
+    return colour;
+  }
+
+  public void setColour(String colour) {
+    this.colour = colour;
+  }
+
+  public int getEngineSize() {
+    return engineSize;
+  }
+
+  public void setEngineSize(int engineSize) {
+    this.engineSize = engineSize;
+  }
+
+  public int getNumberOfSeats() {
+    return numberOfSeats;
+  }
+
+  public void setNumberOfSeats(int numberOfSeats) {
+    this.numberOfSeats = numberOfSeats;
+  }
+  
+  
+}
diff --git a/itests/jpa-container-testbundle-eclipselink/src/main/java/org/apache/aries/jpa/container/itest/entities/packageinfo b/itests/jpa-container-testbundle-eclipselink/src/main/java/org/apache/aries/jpa/container/itest/entities/packageinfo
new file mode 100644
index 0000000..c72722a
--- /dev/null
+++ b/itests/jpa-container-testbundle-eclipselink/src/main/java/org/apache/aries/jpa/container/itest/entities/packageinfo
@@ -0,0 +1,19 @@
+#
+# 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.
+#
+version 1.0.0
diff --git a/itests/jpa-container-testbundle-eclipselink/src/main/resources/META-INF/persistence.xml b/itests/jpa-container-testbundle-eclipselink/src/main/resources/META-INF/persistence.xml
new file mode 100644
index 0000000..3ae7c00
--- /dev/null
+++ b/itests/jpa-container-testbundle-eclipselink/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,56 @@
+<?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. -->

+<persistence version="2.1"

+    xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

+    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence 

+             					http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">

+

+    <persistence-unit name="test-unit"

+        transaction-type="JTA">

+        <description>Test persistence unit for the JPA Container and Context iTests</description>

+        <jta-data-source>osgi:service/javax.sql.DataSource/(transactional=true)</jta-data-source>

+        <class>org.apache.aries.jpa.container.itest.entities.Car</class>

+        <exclude-unlisted-classes>true</exclude-unlisted-classes>

+        <properties>

+            <property name="eclipselink.target-database" value="Derby" />

+            <property name="eclipselink.ddl-generation" value="drop-and-create-tables" />

+            <property name="eclipselink.ddl-generation.output-mode"

+                value="database" />

+        </properties>

+    </persistence-unit>

+

+    <persistence-unit name="script-test-unit"

+        transaction-type="RESOURCE_LOCAL">

+        <properties>

+            <property name="javax.persistence.jdbc.url" value="jdbc:derby:memory:TEST;create=true" />

+            <property name="javax.persistence.jdbc.driver"

+                value="org.apache.derby.jdbc.EmbeddedDriver" />

+            <property name="eclipselink.target-database" value="Derby" />

+            <property

+                name="javax.persistence.schema-generation.database.action"

+                value="drop-and-create" />

+            <property

+                name="javax.persistence.schema-generation.create-source"

+                value="script" />

+            <property

+                name="javax.persistence.schema-generation.create-script-source"

+                value="META-INF/sql/create.sql" />

+            <property name="javax.persistence.sql-load-script-source"

+                value="META-INF/sql/data.sql" />

+            <property name="javax.persistence.schema-generation.drop-source"

+                value="script" />

+            <property

+                name="javax.persistence.schema-generation.drop-script-source"

+                value="META-INF/sql/drop.sql" />

+        </properties>

+    </persistence-unit>

+</persistence>

diff --git a/itests/jpa-container-testbundle-eclipselink/src/main/resources/META-INF/sql/create.sql b/itests/jpa-container-testbundle-eclipselink/src/main/resources/META-INF/sql/create.sql
new file mode 100644
index 0000000..13a3395
--- /dev/null
+++ b/itests/jpa-container-testbundle-eclipselink/src/main/resources/META-INF/sql/create.sql
@@ -0,0 +1,2 @@
+CREATE SCHEMA test_script

+CREATE TABLE CAR (NUMBERPLATE VARCHAR(50) PRIMARY KEY, COLOUR VARCHAR(50), ENGINESIZE INT, NUMBEROFSEATS INT)
\ No newline at end of file
diff --git a/itests/jpa-container-testbundle-eclipselink/src/main/resources/META-INF/sql/data.sql b/itests/jpa-container-testbundle-eclipselink/src/main/resources/META-INF/sql/data.sql
new file mode 100644
index 0000000..fa041da
--- /dev/null
+++ b/itests/jpa-container-testbundle-eclipselink/src/main/resources/META-INF/sql/data.sql
@@ -0,0 +1 @@
+INSERT INTO CAR (NUMBERPLATE, COLOUR, ENGINESIZE, NUMBEROFSEATS) VALUES ('AB11CDE', 'Blue', 1300, 5)
\ No newline at end of file
diff --git a/itests/jpa-container-testbundle-eclipselink/src/main/resources/META-INF/sql/drop.sql b/itests/jpa-container-testbundle-eclipselink/src/main/resources/META-INF/sql/drop.sql
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/itests/jpa-container-testbundle-eclipselink/src/main/resources/META-INF/sql/drop.sql
diff --git a/itests/jpa-container-testbundle/.gitignore b/itests/jpa-container-testbundle/.gitignore
new file mode 100644
index 0000000..ea8c4bf
--- /dev/null
+++ b/itests/jpa-container-testbundle/.gitignore
@@ -0,0 +1 @@
+/target
diff --git a/itests/jpa-container-testbundle/LICENSE b/itests/jpa-container-testbundle/LICENSE
new file mode 100644
index 0000000..6b0b127
--- /dev/null
+++ b/itests/jpa-container-testbundle/LICENSE
@@ -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.
+
diff --git a/itests/jpa-container-testbundle/NOTICE b/itests/jpa-container-testbundle/NOTICE
new file mode 100644
index 0000000..424644d
--- /dev/null
+++ b/itests/jpa-container-testbundle/NOTICE
@@ -0,0 +1,8 @@
+
+Apache Aries
+Copyright 2009-2011 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+
diff --git a/itests/jpa-container-testbundle/pom.xml b/itests/jpa-container-testbundle/pom.xml
new file mode 100644
index 0000000..407f39f
--- /dev/null
+++ b/itests/jpa-container-testbundle/pom.xml
@@ -0,0 +1,78 @@
+<?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.aries.jpa.itest</groupId>
+        <artifactId>org.apache.aries.jpa.itest.parent</artifactId>
+        <version>2.0.0</version>
+        <relativePath>..</relativePath>
+    </parent>
+
+    <groupId>org.apache.aries.jpa</groupId>
+    <artifactId>org.apache.aries.jpa.container.itest.bundle</artifactId>
+    <packaging>bundle</packaging>
+    <name>Apache Aries JPA test bundle container</name>
+
+    <properties>
+        <!-- As this is only a test bundle we skip the check -->
+        <aries.skip.version.check>true</aries.skip.version.check>
+    
+        <!-- Export package versions are maintained in packageinfo files -->
+        <aries.osgi.export.pkg>
+            org.apache.aries.jpa.container.itest.entities
+        </aries.osgi.export.pkg>
+        <aries.osgi.import>
+            javax.persistence;version="[1.0.0,3.0.0)",
+            org.hibernate.proxy;resolution:=optional,
+            javassist.util.proxy;resolution:=optional,
+            *
+        </aries.osgi.import>
+        <aries.osgi.private.pkg />
+        <aries.osgi.symbolic.name>${project.groupId}.${project.artifactId}</aries.osgi.symbolic.name>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-jpa_2.0_spec</artifactId>
+            <version>1.1</version>
+            <scope>provided</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <configuration>
+                    <instructions>
+                        <Meta-Persistence>META-INF/persistence.xml</Meta-Persistence>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+    <description>For simple tests with DataSource, DataSourceFactory</description>
+</project>
diff --git a/itests/jpa-container-testbundle/src/main/java/org/apache/aries/jpa/container/itest/entities/Car.java b/itests/jpa-container-testbundle/src/main/java/org/apache/aries/jpa/container/itest/entities/Car.java
new file mode 100644
index 0000000..da63739
--- /dev/null
+++ b/itests/jpa-container-testbundle/src/main/java/org/apache/aries/jpa/container/itest/entities/Car.java
@@ -0,0 +1,68 @@
+/*
+ * 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 WARRANTIESOR 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.aries.jpa.container.itest.entities;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+
+@Entity
+public class Car {
+  @Id
+  private String numberPlate;
+  
+  private String colour;
+  
+  private int engineSize;
+  
+  private int numberOfSeats;
+
+  public String getNumberPlate() {
+    return numberPlate;
+  }
+
+  public void setNumberPlate(String numberPlate) {
+    this.numberPlate = numberPlate;
+  }
+
+  public String getColour() {
+    return colour;
+  }
+
+  public void setColour(String colour) {
+    this.colour = colour;
+  }
+
+  public int getEngineSize() {
+    return engineSize;
+  }
+
+  public void setEngineSize(int engineSize) {
+    this.engineSize = engineSize;
+  }
+
+  public int getNumberOfSeats() {
+    return numberOfSeats;
+  }
+
+  public void setNumberOfSeats(int numberOfSeats) {
+    this.numberOfSeats = numberOfSeats;
+  }
+  
+  
+}
diff --git a/itests/jpa-container-testbundle/src/main/java/org/apache/aries/jpa/container/itest/entities/packageinfo b/itests/jpa-container-testbundle/src/main/java/org/apache/aries/jpa/container/itest/entities/packageinfo
new file mode 100644
index 0000000..c72722a
--- /dev/null
+++ b/itests/jpa-container-testbundle/src/main/java/org/apache/aries/jpa/container/itest/entities/packageinfo
@@ -0,0 +1,19 @@
+#
+# 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.
+#
+version 1.0.0
diff --git a/itests/jpa-container-testbundle/src/main/resources/META-INF/persistence.xml b/itests/jpa-container-testbundle/src/main/resources/META-INF/persistence.xml
new file mode 100644
index 0000000..4def6b2
--- /dev/null
+++ b/itests/jpa-container-testbundle/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,70 @@
+<?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.

+-->

+<persistence xmlns="http://java.sun.com/xml/ns/persistence"

+   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

+   xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"

+   version="2.0">

+  

+  <persistence-unit name="test-unit" transaction-type="RESOURCE_LOCAL">

+    <description>Test persistence unit for the JPA Container and Context iTests</description>

+    

+    <non-jta-data-source>osgi:service/javax.sql.DataSource</non-jta-data-source>

+    <properties>

+        <!-- This is to avoid compile time enhancement which would conflict with hibernate -->

+        <property name="openjpa.RuntimeUnenhancedClasses" value="supported"/>

+    

+        <!-- These properties are creating the database on the fly. We are using them to avoid the tests having

+          to create a database  -->

+        <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>

+        <property name="openjpa.jdbc.DBDictionary" value="derby"/>

+

+        <property name="hibernate.dialect" value="org.hibernate.dialect.DerbyTenSevenDialect"/>

+        <property name="hibernate.hbm2ddl.auto" value="create-drop"/>

+    </properties>

+  </persistence-unit>

+

+  <persistence-unit name="dsf-test-unit" transaction-type="RESOURCE_LOCAL">

+    <description>Test persistence unit for the JPA Container DataSourceFactory iTests</description>

+    <properties>

+        <!-- These properties are creating the database on the fly. We are using them to avoid the tests having

+          to create a database  -->

+        <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver"/>

+        <property name="javax.persistence.jdbc.url" value="jdbc:derby:memory:TEST;create=true"/>

+        <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>

+        <property name="openjpa.jdbc.DBDictionary" value="derby"/>

+        <property name="hibernate.dialect" value="org.hibernate.dialect.DerbyTenSevenDialect"/>

+        <property name="hibernate.hbm2ddl.auto" value="create-drop"/>

+    </properties>

+  </persistence-unit>

+  

+  <persistence-unit name="dsf-xa-test-unit" transaction-type="JTA">

+    <description>Test persistence unit for the JPA Container DataSourceFactory iTests</description>

+    <properties>

+     <!-- These properties are creating the database on the fly. We are using them to avoid the tests having

+          to create a database  -->

+        <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver-pool-xa"/>

+        <property name="javax.persistence.jdbc.url" value="jdbc:derby:memory:TEST;create=true"/>

+        <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>

+        <property name="openjpa.jdbc.DBDictionary" value="derby"/>

+        <property name="hibernate.dialect" value="org.hibernate.dialect.DerbyTenSevenDialect"/>

+        <property name="hibernate.hbm2ddl.auto" value="create-drop"/>

+    </properties>

+  </persistence-unit>

+</persistence>

diff --git a/itests/jpa-tck-itest/README.txt b/itests/jpa-tck-itest/README.txt
new file mode 100644
index 0000000..a0771b3
--- /dev/null
+++ b/itests/jpa-tck-itest/README.txt
@@ -0,0 +1,12 @@
+# How to run the tck tests 
+
+# First you need to retrieve the tck and deploy the test jpa test jar (these steps only need to be done once)
+# 1. Request access to the OSGi tck. http://felix.apache.org/documentation/development/using-the-osgi-compliance-tests.html
+# 2. Get and extract https://svn.apache.org/repos/tck/osgi-cts/osgi.enterprise.tests/5.0.0/osgi.ct.enterprise.jar
+# 3. deploy the test jar to maven
+    mvn install:install-file -Dfile=jar/org.osgi.test.cases.jpa-5.0.0.jar -DgroupId=org.apache.aries.tck -DartifactId=org.osgi.test.cases.jpa -Dversion=5.0.0 -Dpackaging=jar
+
+# 3. execute the commands below
+mvn clean install
+./runtests
+
diff --git a/itests/jpa-tck-itest/org.osgi.test.cases.jpa.bnd b/itests/jpa-tck-itest/org.osgi.test.cases.jpa.bnd
new file mode 100644
index 0000000..269f82a
--- /dev/null
+++ b/itests/jpa-tck-itest/org.osgi.test.cases.jpa.bnd
@@ -0,0 +1,51 @@
+# Copyright (c) OSGi Alliance (2012). All Rights Reserved.
+#
+# 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.
+
+# bnd pack for project org.osgi.test.cases.jpa
+# Thu Nov 01 12:39:45 EDT 2012
+-runpath = \
+    lib/org.eclipse.osgi-3.8.0.v20120529-1548.jar;version=file, \
+    lib/org.apache.servicemix.bundles.junit-3.8.2_2.jar;version=file;export="junit.framework;version=3.8" 
+
+-runtrace = true
+
+-target = \
+    lib/org.osgi.test.cases.jpa-5.0.0.jar;version=file,
+
+-runbundles = \
+lib/pax-logging-api-1.7.3.jar;version=file, \
+lib/pax-logging-service-1.7.3.jar;version=file, \
+lib/derbyclient-10.11.1.1.jar;version=file, \
+lib/pax-jdbc-spec-0.6.0.jar;version=file, \
+lib/pax-jdbc-derbyclient-0.6.0.jar;version=file, \
+lib/javax.persistence-2.1.0.jar;version=file, \
+lib/geronimo-jta_1.1_spec-1.1.1.jar;version=file, \
+lib/geronimo-servlet_2.5_spec-1.2.jar;version=file, \
+lib/org.apache.felix.eventadmin-1.4.2.jar;version=file, \
+lib/org.apache.felix.configadmin-1.8.0.jar;version=file, \
+lib/org.eclipse.persistence.core-2.6.0.jar;version=file, \
+lib/org.eclipse.persistence.jpa-2.6.0.jar;version=file, \
+lib/org.eclipse.persistence.antlr-2.6.0.jar;version=file, \
+lib/org.eclipse.persistence.jpa.jpql-2.6.0.jar;version=file, \
+lib/org.eclipse.persistence.asm-2.6.0.jar;version=file, \
+lib/org.apache.aries.jpa.eclipselink.adapter-2.0.0-SNAPSHOT.jar;version=file, \
+lib/org.apache.aries.jpa.container-2.0.0-SNAPSHOT.jar;version=file, \
+lib/org.osgi.test.cases.jpa-5.0.0.jar;version=file 
+
+-runproperties = \
+    report="true", \
+    osgi.resolverMode="strict"
+
+-runsystempackages=javax.xml.stream; version=1.0, javax.xml.stream.events; version=1.0, javax.xml.stream.util; version=1.0
+
diff --git a/itests/jpa-tck-itest/pom.xml b/itests/jpa-tck-itest/pom.xml
new file mode 100644
index 0000000..9ee7951
--- /dev/null
+++ b/itests/jpa-tck-itest/pom.xml
@@ -0,0 +1,187 @@
+<?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.aries.jpa.itest</groupId>
+        <artifactId>org.apache.aries.jpa.itest.parent</artifactId>
+        <version>2.0.0-SNAPSHOT</version>
+        <relativePath>..</relativePath>
+    </parent>
+
+    <groupId>org.apache.aries.jpa.itest</groupId>
+    <artifactId>jpa-tck-itest</artifactId>
+    <packaging>pom</packaging>
+
+    <dependencies>
+
+	<!-- Test cases from the tck. These need to be deployed by hand as redistribution is not allowed -->
+	<dependency>
+            <groupId>org.apache.aries.tck</groupId>
+            <artifactId>org.osgi.test.cases.jpa</artifactId>
+            <version>5.0.0</version>
+        </dependency>
+
+	<!-- Test framework -->
+        <dependency>
+            <groupId>biz.aQute.bnd</groupId>
+            <artifactId>bnd</artifactId>
+            <version>2.4.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.servicemix.bundles</groupId>
+            <artifactId>org.apache.servicemix.bundles.junit</artifactId>
+            <version>3.8.2_2</version>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse</groupId>
+            <artifactId>org.eclipse.osgi</artifactId>
+            <version>3.8.0.v20120529-1548</version>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.ops4j.pax.logging</groupId>
+            <artifactId>pax-logging-api</artifactId>
+            <version>${paxlogging.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.logging</groupId>
+            <artifactId>pax-logging-service</artifactId>
+            <version>${paxlogging.version}</version>
+            <scope>test</scope>
+        </dependency>
+
+	<!-- derbyclient + DataSourceFactory -->
+        <dependency>
+            <groupId>org.apache.derby</groupId>
+            <artifactId>derbyclient</artifactId>
+            <version>10.11.1.1</version>
+            <scope>test</scope>
+        </dependency>
+	<dependency>
+            <groupId>org.ops4j.pax.jdbc</groupId>
+            <artifactId>pax-jdbc-spec</artifactId>
+            <version>${paxjdbc.version}</version>
+        </dependency>
+	<dependency>
+            <groupId>org.ops4j.pax.jdbc</groupId>
+            <artifactId>pax-jdbc-derbyclient</artifactId>
+            <version>${paxjdbc.version}</version>
+        </dependency>
+
+        <!-- Specs -->
+        <dependency>
+            <groupId>org.eclipse.persistence</groupId>
+            <artifactId>javax.persistence</artifactId>
+            <version>2.1.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-jta_1.1_spec</artifactId>
+            <version>1.1.1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-servlet_2.5_spec</artifactId>
+            <version>1.2</version>
+        </dependency>
+
+        <!-- Needed compendium services -->
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.configadmin</artifactId>
+            <version>1.8.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.eventadmin</artifactId>
+            <version>1.4.2</version>
+            <scope>test</scope>
+        </dependency>
+
+        <!-- eclipselink -->
+        <dependency>
+            <groupId>org.eclipse.persistence</groupId>
+            <artifactId>org.eclipse.persistence.antlr</artifactId>
+            <version>${eclipselink.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.persistence</groupId>
+            <artifactId>org.eclipse.persistence.core</artifactId>
+            <version>${eclipselink.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.persistence</groupId>
+            <artifactId>org.eclipse.persistence.jpa.jpql</artifactId>
+            <version>${eclipselink.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.persistence</groupId>
+            <artifactId>org.eclipse.persistence.asm</artifactId>
+            <version>${eclipselink.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.persistence</groupId>
+            <artifactId>org.eclipse.persistence.jpa</artifactId>
+            <version>${eclipselink.version}</version>
+        </dependency>
+
+	<!-- Aries jpa -->
+        <dependency>
+            <groupId>org.apache.aries.jpa</groupId>
+            <artifactId>org.apache.aries.jpa.container</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.jpa</groupId>
+            <artifactId>org.apache.aries.jpa.eclipselink.adapter</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-dependency-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>copy-dependencies</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>copy-dependencies</goal>
+                        </goals>
+                        <configuration>
+                            <outputDirectory>target/lib</outputDirectory>
+                            <excludeTransitive>true</excludeTransitive>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+
+</project>
+
diff --git a/itests/jpa-tck-itest/runtests b/itests/jpa-tck-itest/runtests
new file mode 100755
index 0000000..83d7945
--- /dev/null
+++ b/itests/jpa-tck-itest/runtests
@@ -0,0 +1,4 @@
+cp org.osgi.test.cases.jpa.bnd target
+cd target
+java -jar lib/bnd-2.4.0.jar runtests --title osgi.ct
+cd ..
diff --git a/itests/pom.xml b/itests/pom.xml
new file mode 100644
index 0000000..bc89f27
--- /dev/null
+++ b/itests/pom.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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/xsd/maven-4.0.0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>org.apache.aries.jpa.itest</groupId>
+    <artifactId>org.apache.aries.jpa.itest.parent</artifactId>
+    <name>Apache Aries JPA itests parent</name>
+    <packaging>pom</packaging>
+	
+    <parent>
+        <groupId>org.apache.aries.jpa</groupId>	
+        <artifactId>org.apache.aries.jpa.parent</artifactId>
+        <version>2.0.0</version>
+        <relativePath>../jpa-parent</relativePath>
+    </parent>
+    
+    <properties>
+        <aries.skip.version.check>true</aries.skip.version.check>
+	<paxlogging.version>1.7.3</paxlogging.version>
+        <exam.version>4.5.0</exam.version>
+        <url.version>1.6.0</url.version>
+        <hibernate42.version>4.2.15.Final</hibernate42.version>
+        <hibernate43.version>4.2.15.Final</hibernate43.version>
+        <ant.bundle.version>1.8.2_2</ant.bundle.version>
+        <antlr.bundle.version>2.7.7_5</antlr.bundle.version>
+        <dom4j.bundle.version>1.6.1_5</dom4j.bundle.version>
+        <serp.bundle.version>1.14.1_1</serp.bundle.version>
+        <eclipselink.version>2.6.0</eclipselink.version>
+        <openjpa.version>2.3.0</openjpa.version>
+        <paxjdbc.version>0.6.0</paxjdbc.version>
+    </properties>
+
+    <modules>
+        <module>jpa-container-blueprint-testbundle</module>
+        <module>jpa-container-advancedtestbundle</module>
+        <module>jpa-container-itest</module>
+        <module>jpa-container-testbundle</module>
+        <module>jpa-container-testbundle-eclipselink</module>
+    </modules>
+
+
+</project>
+
diff --git a/jpa-api/LICENSE b/jpa-api/LICENSE
new file mode 100644
index 0000000..6b0b127
--- /dev/null
+++ b/jpa-api/LICENSE
@@ -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.
+
diff --git a/jpa-api/NOTICE b/jpa-api/NOTICE
new file mode 100644
index 0000000..424644d
--- /dev/null
+++ b/jpa-api/NOTICE
@@ -0,0 +1,8 @@
+
+Apache Aries
+Copyright 2009-2011 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+
diff --git a/jpa-api/pom.xml b/jpa-api/pom.xml
new file mode 100644
index 0000000..5eb09f8
--- /dev/null
+++ b/jpa-api/pom.xml
@@ -0,0 +1,79 @@
+<?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.aries.jpa</groupId>
+        <artifactId>org.apache.aries.jpa.parent</artifactId>
+        <version>2.0.0</version>
+        <relativePath>../jpa-parent</relativePath>
+    </parent>
+
+    <artifactId>org.apache.aries.jpa.api</artifactId>
+    <packaging>bundle</packaging>
+    <name>Apache Aries JPA Container API</name>
+
+    <properties>
+        <!-- Export package versions are maintained in packageinfo files -->
+        <aries.osgi.export.pkg>
+            org.apache.aries.jpa.supplier,
+            org.apache.aries.jpa.template
+        </aries.osgi.export.pkg>
+        <aries.osgi.import>
+        </aries.osgi.import>
+        <aries.osgi.private.pkg />
+        <lastReleaseVersion>1.0.0</lastReleaseVersion>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-jpa_2.0_spec</artifactId>
+            <version>1.1</version>
+            <scope>provided</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.aries.versioning</groupId>
+                <artifactId>org.apache.aries.versioning.plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>default-verify</id>
+                        <phase>verify</phase>
+                        <goals>
+                            <goal>version-check</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
diff --git a/jpa-api/src/main/java/org/apache/aries/jpa/supplier/EmSupplier.java b/jpa-api/src/main/java/org/apache/aries/jpa/supplier/EmSupplier.java
new file mode 100644
index 0000000..9d534e3
--- /dev/null
+++ b/jpa-api/src/main/java/org/apache/aries/jpa/supplier/EmSupplier.java
@@ -0,0 +1,42 @@
+/*
+ * 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 WARRANTIESOR 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.aries.jpa.supplier;
+
+import javax.persistence.EntityManager;
+
+/**
+ * Provides a thread safe way to use an EntityManager. - The first call must be to preCall(). This will create
+ * an EM for the current thread. - The EM can then be retrieved by calling get() and user normally - At the
+ * end postCall() has to be called to close the EntityManager If this is used on nested methods then the EM is
+ * only created / closed on the outermost calls to preCall() / postCall()
+ */
+public interface EmSupplier {
+
+    /**
+     * Is called before first access to get() in a method
+     */
+    void preCall();
+    
+    EntityManager get();
+
+    /**
+     * Is called after last access to get() in a method
+     */
+    void postCall();
+}
diff --git a/jpa-api/src/main/java/org/apache/aries/jpa/supplier/packageinfo b/jpa-api/src/main/java/org/apache/aries/jpa/supplier/packageinfo
new file mode 100644
index 0000000..c72722a
--- /dev/null
+++ b/jpa-api/src/main/java/org/apache/aries/jpa/supplier/packageinfo
@@ -0,0 +1,19 @@
+#
+# 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.
+#
+version 1.0.0
diff --git a/jpa-api/src/main/java/org/apache/aries/jpa/template/EmConsumer.java b/jpa-api/src/main/java/org/apache/aries/jpa/template/EmConsumer.java
new file mode 100644
index 0000000..e426767
--- /dev/null
+++ b/jpa-api/src/main/java/org/apache/aries/jpa/template/EmConsumer.java
@@ -0,0 +1,25 @@
+/*
+ * 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 WARRANTIESOR 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.aries.jpa.template;
+
+import javax.persistence.EntityManager;
+
+public interface EmConsumer {
+	void accept(EntityManager em);
+}
diff --git a/jpa-api/src/main/java/org/apache/aries/jpa/template/EmFunction.java b/jpa-api/src/main/java/org/apache/aries/jpa/template/EmFunction.java
new file mode 100644
index 0000000..2af4678
--- /dev/null
+++ b/jpa-api/src/main/java/org/apache/aries/jpa/template/EmFunction.java
@@ -0,0 +1,25 @@
+/*
+ * 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 WARRANTIESOR 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.aries.jpa.template;
+
+import javax.persistence.EntityManager;
+
+public interface EmFunction<R> {
+	R apply(EntityManager em);
+}
diff --git a/jpa-api/src/main/java/org/apache/aries/jpa/template/JpaTemplate.java b/jpa-api/src/main/java/org/apache/aries/jpa/template/JpaTemplate.java
new file mode 100644
index 0000000..ad70003
--- /dev/null
+++ b/jpa-api/src/main/java/org/apache/aries/jpa/template/JpaTemplate.java
@@ -0,0 +1,28 @@
+/*
+ * 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 WARRANTIESOR 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.aries.jpa.template;
+
+
+public interface JpaTemplate {
+	<R> R txExpr(TransactionType type, EmFunction<R> code);
+	void tx(TransactionType type, EmConsumer code);
+	
+	<R> R txExpr(EmFunction<R> code);
+	void tx(EmConsumer code);
+}
diff --git a/jpa-api/src/main/java/org/apache/aries/jpa/template/TransactionType.java b/jpa-api/src/main/java/org/apache/aries/jpa/template/TransactionType.java
new file mode 100644
index 0000000..1a6eee5
--- /dev/null
+++ b/jpa-api/src/main/java/org/apache/aries/jpa/template/TransactionType.java
@@ -0,0 +1,23 @@
+/**

+ * 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.aries.jpa.template;

+

+public enum TransactionType {

+	Mandatory, Never, NotSupported, Required, RequiresNew, Supports

+}

diff --git a/jpa-api/src/main/java/org/apache/aries/jpa/template/packageinfo b/jpa-api/src/main/java/org/apache/aries/jpa/template/packageinfo
new file mode 100644
index 0000000..c72722a
--- /dev/null
+++ b/jpa-api/src/main/java/org/apache/aries/jpa/template/packageinfo
@@ -0,0 +1,19 @@
+#
+# 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.
+#
+version 1.0.0
diff --git a/jpa-blueprint/osgi.bnd b/jpa-blueprint/osgi.bnd
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/jpa-blueprint/osgi.bnd
diff --git a/jpa-blueprint/pom.xml b/jpa-blueprint/pom.xml
new file mode 100644
index 0000000..afcf8e3
--- /dev/null
+++ b/jpa-blueprint/pom.xml
@@ -0,0 +1,60 @@
+<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/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.aries.jpa</groupId>
+        <artifactId>org.apache.aries.jpa.parent</artifactId>
+        <version>2.0.0</version>
+        <relativePath>../jpa-parent</relativePath>
+    </parent>
+    <artifactId>org.apache.aries.jpa.blueprint</artifactId>
+    <name>Apache Aries JPA blueprint</name>
+    <packaging>bundle</packaging>
+    
+    <properties>
+        <aries.skip.version.check>true</aries.skip.version.check>
+    </properties>
+    
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.aries.jpa</groupId>
+            <artifactId>org.apache.aries.jpa.api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.hibernate.javax.persistence</groupId>
+            <artifactId>hibernate-jpa-2.0-api</artifactId>
+            <version>1.0.1.Final</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-jta_1.1_spec</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.blueprint</groupId>
+            <artifactId>org.apache.aries.blueprint.core</artifactId>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <configuration>
+                    <instructions>
+                        <Bundle-Activator>org.apache.aries.jpa.blueprint.impl.Activator</Bundle-Activator>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+    <description>Blueprint integration for injecting EntityManager, EntityManagerFactory and EmSupplier.</description>
+</project>
diff --git a/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/Activator.java b/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/Activator.java
new file mode 100644
index 0000000..bcd8969
--- /dev/null
+++ b/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/Activator.java
@@ -0,0 +1,42 @@
+/**
+ * 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.aries.jpa.blueprint.impl;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import org.apache.aries.blueprint.NamespaceHandler;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator implements BundleActivator {
+
+    @Override
+    public void start(BundleContext context) throws Exception {
+        JpaNsHandler handler = new JpaNsHandler();
+        Dictionary<String, String> props = new Hashtable<String, String>();
+        props.put("osgi.service.blueprint.namespace", "http://aries.apache.org/xmlns/jpan/v1.0.0");
+        context.registerService(NamespaceHandler.class, handler, props);
+    }
+
+    @Override
+    public void stop(BundleContext context) throws Exception {
+    }
+
+}
diff --git a/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/JpaBeanProcessor.java b/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/JpaBeanProcessor.java
new file mode 100644
index 0000000..152a6fb
--- /dev/null
+++ b/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/JpaBeanProcessor.java
@@ -0,0 +1,150 @@
+/**

+ * 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.aries.jpa.blueprint.impl;

+

+import java.lang.reflect.Field;

+import java.util.Map;

+import java.util.concurrent.ConcurrentHashMap;

+

+import javax.persistence.EntityManager;

+import javax.persistence.EntityManagerFactory;

+import javax.persistence.PersistenceContext;

+import javax.persistence.PersistenceUnit;

+

+import org.apache.aries.blueprint.BeanProcessor;

+import org.apache.aries.blueprint.ComponentDefinitionRegistry;

+import org.apache.aries.blueprint.Interceptor;

+import org.apache.aries.jpa.blueprint.supplier.impl.EmProxyFactory;

+import org.apache.aries.jpa.blueprint.supplier.impl.EmSupplierProxy;

+import org.apache.aries.jpa.blueprint.supplier.impl.EmfProxyFactory;

+import org.apache.aries.jpa.supplier.EmSupplier;

+import org.osgi.framework.BundleContext;

+import org.osgi.framework.FrameworkUtil;

+import org.osgi.service.blueprint.reflect.BeanMetadata;

+import org.slf4j.Logger;

+import org.slf4j.LoggerFactory;

+

+public class JpaBeanProcessor implements BeanProcessor {

+    private static final Logger LOGGER = LoggerFactory.getLogger(JpaInterceptor.class);

+    public static final String JPA_PROCESSOR_BEAN_NAME = "org_apache_aries_jpan";

+    private Map<Object, EmSupplierProxy> emProxies;

+    private Map<Object, EntityManagerFactory> emfProxies;

+    private ComponentDefinitionRegistry cdr;

+

+    public JpaBeanProcessor() {

+        emProxies = new ConcurrentHashMap<Object, EmSupplierProxy>();

+        emfProxies = new ConcurrentHashMap<Object, EntityManagerFactory>();

+    }

+

+    public void setCdr(ComponentDefinitionRegistry cdr) {

+        this.cdr = cdr;

+    }

+

+    public void afterDestroy(Object bean, String beanName) {

+        EmSupplierProxy emProxy = emProxies.get(bean);

+        if (emProxy != null) {

+            emProxy.close();

+        }

+        EntityManagerFactory emfProxy = emfProxies.get(bean);

+        if (emfProxy != null) {

+        	emfProxy.close();

+        }

+    }

+

+    public Object afterInit(Object bean, String beanName, BeanCreator beanCreator, BeanMetadata beanData) {

+        return bean;

+    }

+

+    public void beforeDestroy(Object bean, String beanName) {

+    }

+

+    public Object beforeInit(Object bean, String beanName, BeanCreator beanCreator, BeanMetadata beanData) {

+        Class<?> c = bean.getClass();

+        Field field = getPersistenceField(c);

+        if (field == null) {

+            return bean;

+        }

+        BundleContext context = FrameworkUtil.getBundle(c).getBundleContext();

+        field.setAccessible(true);

+

+        PersistenceContext pcAnn = field.getAnnotation(PersistenceContext.class);

+        if (pcAnn != null) {

+        LOGGER.debug("Adding jpa/jta interceptor bean {} with class {}", beanName, c);

+

+        EmSupplierProxy supplierProxy = new EmSupplierProxy(context, pcAnn.unitName());

+	        emProxies.put(bean, supplierProxy);

+        try {

+	            field.set(bean, getEmProxy(field, supplierProxy));

+        } catch (Exception e) {

+            throw new IllegalStateException("Error setting field " + field, e);

+        }

+        Interceptor interceptor = new JpaInterceptor(supplierProxy);

+        cdr.registerInterceptorWithComponent(beanData, interceptor);

+        } else {

+        	PersistenceUnit puAnn = field.getAnnotation(PersistenceUnit.class);

+        	if(puAnn != null) {

+        		LOGGER.debug("Adding emf proxy");

+        		

+    	        EntityManagerFactory emfProxy = EmfProxyFactory.create(context, puAnn.unitName()); 

+    	        emfProxies.put(bean, emfProxy);

+    	        try {

+    	            field.set(bean, getEmfProxy(field, emfProxy));

+    	        } catch (Exception e) {

+    	            throw new IllegalStateException("Error setting field " + field, e);

+    	        }	

+        	}

+        }

+        return bean;

+    }

+

+    private Object getEmfProxy(Field field, EntityManagerFactory supplierProxy) {

+        if (field.getType() == EntityManagerFactory.class) {

+            return supplierProxy;

+        } else {

+            throw new IllegalStateException(

+                                            "Field with @PersistenceUnit is not of type EntityManagerFactory "

+                                                + field);

+        }

+    }

+

+    private Object getEmProxy(Field field, EmSupplierProxy supplierProxy) {

+        if (field.getType() == EmSupplier.class) {

+            return supplierProxy;

+        } else if (field.getType() == EntityManager.class) {

+            return EmProxyFactory.create(supplierProxy);

+        } else {

+            throw new IllegalStateException(

+                                            "Field with @PersistenceContext is not of type EntityManager or EmSupplier "

+                                                + field);

+        }

+    }

+

+    private Field getPersistenceField(Class<?> c) {

+        for (Field field : c.getDeclaredFields()) {

+            if (field.getAnnotation(PersistenceContext.class) != null) {

+                return field;

+            }

+            if (field.getAnnotation(PersistenceUnit.class) != null) {

+                return field;

+            }

+        }

+        return null;

+    }

+

+}

diff --git a/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/JpaInterceptor.java b/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/JpaInterceptor.java
new file mode 100644
index 0000000..3de3ca5
--- /dev/null
+++ b/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/JpaInterceptor.java
@@ -0,0 +1,103 @@
+/*
+ * 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.aries.jpa.blueprint.impl;
+
+import java.lang.reflect.Method;
+
+import javax.persistence.EntityManager;
+import javax.persistence.spi.PersistenceUnitTransactionType;
+
+import org.apache.aries.blueprint.Interceptor;
+import org.apache.aries.jpa.supplier.EmSupplier;
+import org.osgi.service.blueprint.reflect.ComponentMetadata;
+
+public class JpaInterceptor implements Interceptor {
+    private EmSupplier emSupplier;
+    private Boolean cachedIsResourceLocal;
+
+    public JpaInterceptor(EmSupplier emSupplier) {
+        this.emSupplier = emSupplier;
+    }
+
+    public int getRank() {
+        return 0;
+    }
+
+    public Object preCall(ComponentMetadata cm, Method m, Object... parameters) throws Throwable {
+        try {
+            emSupplier.preCall();
+            EntityManager em = emSupplier.get();
+            boolean weControlTx = isResourceLocal(em) && !em.getTransaction().isActive();
+            if (weControlTx) {
+                em.getTransaction().begin();
+            }
+            return weControlTx;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
+
+    public void postCallWithException(ComponentMetadata cm, Method m, Throwable ex, Object preCallToken) {
+        boolean weControlTx = (Boolean)preCallToken;
+        if (weControlTx) {
+            safeRollback(emSupplier.get(), ex);
+        }
+        emSupplier.postCall();
+    }
+
+    public void postCallWithReturn(ComponentMetadata cm, Method m, Object returnType, Object preCallToken)
+        throws Exception {
+        boolean weControlTx = (Boolean)preCallToken;
+        if (weControlTx) {
+            emSupplier.get().getTransaction().commit();
+        }
+        emSupplier.postCall();
+    }
+
+    private void safeRollback(EntityManager em, Throwable e) {
+        if (em != null) {
+            try {
+                em.getTransaction().rollback();
+            } catch (Exception e1) {
+            }
+        }
+    }
+
+    private boolean isResourceLocal(EntityManager em) {
+        if (cachedIsResourceLocal == null) {
+            cachedIsResourceLocal = isResourceLocalInternal(em);
+        }
+        return cachedIsResourceLocal;
+    }
+
+    /**
+     * @param em
+     * @return
+     */
+    private boolean isResourceLocalInternal(EntityManager em) {
+        PersistenceUnitTransactionType transactionType = (PersistenceUnitTransactionType)em.getProperties()
+            .get(PersistenceUnitTransactionType.class.getName());
+        if (transactionType == PersistenceUnitTransactionType.RESOURCE_LOCAL) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+}
diff --git a/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/JpaNsHandler.java b/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/JpaNsHandler.java
new file mode 100644
index 0000000..ea941e0
--- /dev/null
+++ b/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/JpaNsHandler.java
@@ -0,0 +1,120 @@
+/*
+ * 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.aries.jpa.blueprint.impl;
+
+import static org.osgi.service.jpa.EntityManagerFactoryBuilder.JPA_UNIT_NAME;
+
+import java.net.URL;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+import javax.transaction.TransactionManager;
+
+import org.apache.aries.blueprint.ComponentDefinitionRegistry;
+import org.apache.aries.blueprint.NamespaceHandler;
+import org.apache.aries.blueprint.ParserContext;
+import org.apache.aries.blueprint.mutable.MutableBeanMetadata;
+import org.apache.aries.blueprint.mutable.MutablePassThroughMetadata;
+import org.apache.aries.blueprint.mutable.MutableReferenceMetadata;
+import org.apache.aries.jpa.supplier.EmSupplier;
+import org.osgi.service.blueprint.reflect.ComponentMetadata;
+import org.osgi.service.blueprint.reflect.Metadata;
+import org.osgi.service.blueprint.reflect.ReferenceMetadata;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+public class JpaNsHandler implements NamespaceHandler {
+
+    private void parseElement(Element elt, ComponentMetadata cm, ParserContext pc) {
+        ComponentDefinitionRegistry cdr = pc.getComponentDefinitionRegistry();
+
+        if ("enable".equals(elt.getLocalName())) {
+            if (!cdr.containsComponentDefinition(JpaBeanProcessor.JPA_PROCESSOR_BEAN_NAME)) {
+                MutableBeanMetadata meta = pc.createMetadata(MutableBeanMetadata.class);
+                meta.setId(JpaBeanProcessor.JPA_PROCESSOR_BEAN_NAME);
+                meta.setRuntimeClass(JpaBeanProcessor.class);
+                meta.setProcessor(true);
+                meta.addProperty("cdr", passThrough(pc, cdr));
+                cdr.registerComponentDefinition(meta);
+            }
+        }
+    }
+
+    private MutablePassThroughMetadata passThrough(ParserContext pc, Object obj) {
+        MutablePassThroughMetadata cdrMeta = pc.createMetadata(MutablePassThroughMetadata.class);
+        cdrMeta.setObject(obj);
+        return cdrMeta;
+    }
+
+    public ComponentMetadata decorate(Node node, ComponentMetadata cm, ParserContext pc) {
+        System.out.println(cm.getId());
+        if (node instanceof Element) {
+            Element elt = (Element)node;
+            parseElement(elt, cm, pc);
+        }
+        return cm;
+    }
+
+    public Metadata parse(Element elt, ParserContext pc) {
+        parseElement(elt, pc.getEnclosingComponent(), pc);
+        return null;
+    }
+
+    public URL getSchemaLocation(String namespace) {
+        return this.getClass().getResource("/jpa10.xsd");
+    }
+
+    @SuppressWarnings("rawtypes")
+    public Set<Class> getManagedClasses() {
+        return null;
+    }
+
+    @SuppressWarnings("unchecked")
+    ComponentMetadata createEmSupplierRef(ParserContext pc, String unitName) {
+        final MutableReferenceMetadata refMetadata = pc.createMetadata(MutableReferenceMetadata.class);
+        refMetadata.setActivation(getDefaultActivation(pc));
+        refMetadata.setAvailability(ReferenceMetadata.AVAILABILITY_MANDATORY);
+        refMetadata.setRuntimeInterface(EmSupplier.class);
+        refMetadata.setInterface(EmSupplier.class.getName());
+        refMetadata.setFilter(String.format("(%s=%s)", JPA_UNIT_NAME, unitName));
+        refMetadata.setTimeout(Integer.parseInt(pc.getDefaultTimeout()));
+        refMetadata.setDependsOn((List<String>)Collections.EMPTY_LIST);
+        refMetadata.setId(pc.generateId());
+        return refMetadata;
+    }
+    
+    @SuppressWarnings("unchecked")
+    ComponentMetadata createTransactionManagerRef(ParserContext pc) {
+        final MutableReferenceMetadata refMetadata = pc.createMetadata(MutableReferenceMetadata.class);
+        refMetadata.setActivation(getDefaultActivation(pc));
+        refMetadata.setAvailability(ReferenceMetadata.AVAILABILITY_MANDATORY);
+        refMetadata.setRuntimeInterface(TransactionManager.class);
+        refMetadata.setInterface(TransactionManager.class.getName());
+        refMetadata.setTimeout(Integer.parseInt(pc.getDefaultTimeout()));
+        refMetadata.setDependsOn((List<String>)Collections.EMPTY_LIST);
+        refMetadata.setId(pc.generateId());
+        return refMetadata;
+    }
+
+    private int getDefaultActivation(ParserContext ctx) {
+        return "ACTIVATION_EAGER".equalsIgnoreCase(ctx.getDefaultActivation())
+            ? ReferenceMetadata.ACTIVATION_EAGER : ReferenceMetadata.ACTIVATION_LAZY;
+    }
+}
diff --git a/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/supplier/impl/EmProxy.java b/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/supplier/impl/EmProxy.java
new file mode 100644
index 0000000..7896d7d
--- /dev/null
+++ b/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/supplier/impl/EmProxy.java
@@ -0,0 +1,44 @@
+/*
+ * 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 WARRANTIESOR 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.aries.jpa.blueprint.supplier.impl;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+
+import javax.persistence.EntityManager;
+
+import org.apache.aries.jpa.supplier.EmSupplier;
+
+public class EmProxy implements InvocationHandler {
+    EmSupplier emSupplier;
+
+    public EmProxy(EmSupplier emSupplier) {
+        this.emSupplier = emSupplier;
+    }
+
+    @Override
+    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+        EntityManager em = emSupplier.get();
+        if (em == null) {
+            throw new IllegalStateException("EntityManager not available. Make sure you run in an @Transactional method");
+        }
+        return method.invoke(em, args);
+    }
+
+}
diff --git a/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/supplier/impl/EmProxyFactory.java b/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/supplier/impl/EmProxyFactory.java
new file mode 100644
index 0000000..bc9c978
--- /dev/null
+++ b/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/supplier/impl/EmProxyFactory.java
@@ -0,0 +1,36 @@
+/*
+ * 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 WARRANTIESOR 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.aries.jpa.blueprint.supplier.impl;
+
+import java.lang.reflect.Proxy;
+
+import javax.persistence.EntityManager;
+
+import org.apache.aries.jpa.supplier.EmSupplier;
+
+public class EmProxyFactory {
+
+    public static EntityManager create(final EmSupplier emSupplier) {
+        ClassLoader loader = EntityManager.class.getClassLoader();
+        Class<?>[] ifAr = {
+            EntityManager.class
+        };
+        return (EntityManager)Proxy.newProxyInstance(loader, ifAr, new EmProxy(emSupplier));
+    }
+}
diff --git a/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/supplier/impl/EmSupplierProxy.java b/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/supplier/impl/EmSupplierProxy.java
new file mode 100644
index 0000000..fdafcc0
--- /dev/null
+++ b/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/supplier/impl/EmSupplierProxy.java
@@ -0,0 +1,79 @@
+/*
+ * 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 WARRANTIESOR 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.aries.jpa.blueprint.supplier.impl;
+
+import static org.osgi.service.jpa.EntityManagerFactoryBuilder.JPA_UNIT_NAME;
+
+import java.io.Closeable;
+
+import javax.persistence.EntityManager;
+
+import org.apache.aries.jpa.supplier.EmSupplier;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Filter;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.util.tracker.ServiceTracker;
+
+public class EmSupplierProxy implements EmSupplier, Closeable {
+    private ServiceTracker<EmSupplier, EmSupplier> tracker;
+
+    public EmSupplierProxy(BundleContext context, String unitName) {
+        String filterS = String.format("(&(objectClass=%s)(%s=%s))", EmSupplier.class.getName(),
+                                       JPA_UNIT_NAME,
+                                       unitName);
+        Filter filter;
+        try {
+            filter = FrameworkUtil.createFilter(filterS);
+        } catch (InvalidSyntaxException e) {
+            throw new IllegalStateException(e);
+        }
+        tracker = new ServiceTracker<>(context, filter, null);
+        tracker.open();
+    }
+
+    @Override
+    public EntityManager get() {
+        return getEmSupplier().get();
+    }
+
+    @Override
+    public void close() {
+        tracker.close();
+    }
+
+    @Override
+    public void preCall() {
+        getEmSupplier().preCall();
+    }
+
+    @Override
+    public void postCall() {
+        getEmSupplier().postCall();
+    }
+
+    private EmSupplier getEmSupplier() {
+        try {
+            return tracker.waitForService(10000);
+        } catch (InterruptedException e) {
+            throw new IllegalStateException(e);
+        }
+    }
+
+}
diff --git a/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/supplier/impl/EmfProxy.java b/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/supplier/impl/EmfProxy.java
new file mode 100644
index 0000000..3169d8a
--- /dev/null
+++ b/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/supplier/impl/EmfProxy.java
@@ -0,0 +1,75 @@
+/*

+ * 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 WARRANTIESOR 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.aries.jpa.blueprint.supplier.impl;

+

+import static org.osgi.service.jpa.EntityManagerFactoryBuilder.JPA_UNIT_NAME;

+

+import java.lang.reflect.InvocationHandler;

+import java.lang.reflect.InvocationTargetException;

+import java.lang.reflect.Method;

+

+import javax.persistence.EntityManagerFactory;

+

+import org.osgi.framework.BundleContext;

+import org.osgi.framework.Filter;

+import org.osgi.framework.FrameworkUtil;

+import org.osgi.framework.InvalidSyntaxException;

+import org.osgi.util.tracker.ServiceTracker;

+

+public class EmfProxy implements InvocationHandler {

+	private ServiceTracker<EntityManagerFactory, EntityManagerFactory> tracker;

+

+	public EmfProxy(BundleContext context, String unitName) {

+		String filterS = String.format("(&(objectClass=%s)(%s=%s))",

+				EntityManagerFactory.class.getName(), JPA_UNIT_NAME, unitName);

+		Filter filter;

+		try {

+			filter = FrameworkUtil.createFilter(filterS);

+		} catch (InvalidSyntaxException e) {

+			throw new IllegalStateException(e);

+		}

+		tracker = new ServiceTracker<>(context, filter, null);

+		tracker.open();

+	}

+

+	private EntityManagerFactory getEntityManagerFactory() {

+		try {

+			return tracker.waitForService(10000);

+		} catch (InterruptedException e) {

+			throw new IllegalStateException(e);

+		}

+	}

+

+	@Override

+	public Object invoke(Object proxy, Method method, Object[] args)

+			throws Throwable {

+		Object res = null;

+

+		EntityManagerFactory delegate = getEntityManagerFactory();

+

+		try {

+			res = method.invoke(delegate, args);

+		} catch (IllegalArgumentException e) {

+			new IllegalStateException(e);

+		} catch (InvocationTargetException e) {

+			new IllegalStateException(e);

+		}

+		return res;

+	}

+}

diff --git a/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/supplier/impl/EmfProxyFactory.java b/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/supplier/impl/EmfProxyFactory.java
new file mode 100644
index 0000000..5575b13
--- /dev/null
+++ b/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/supplier/impl/EmfProxyFactory.java
@@ -0,0 +1,35 @@
+/*
+ * 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 WARRANTIESOR 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.aries.jpa.blueprint.supplier.impl;
+
+import java.lang.reflect.Proxy;
+
+import javax.persistence.EntityManagerFactory;
+
+import org.osgi.framework.BundleContext;
+
+public class EmfProxyFactory {
+
+    public static EntityManagerFactory create(BundleContext context, String unitName) {
+    	ClassLoader cl = EntityManagerFactory.class.getClassLoader();
+        Class<?>[] ifAr = new Class[] { EntityManagerFactory.class };
+        
+        return  (EntityManagerFactory) Proxy.newProxyInstance(cl, ifAr, new EmfProxy(context, unitName));
+    }
+}
diff --git a/jpa-blueprint/src/main/resources/jpa10.xsd b/jpa-blueprint/src/main/resources/jpa10.xsd
new file mode 100644
index 0000000..3a77292
--- /dev/null
+++ b/jpa-blueprint/src/main/resources/jpa10.xsd
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+
+    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.
+
+-->
+<xsd:schema xmlns="http://aries.apache.org/xmlns/jpan/v1.0.0"
+    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+	targetNamespace="http://aries.apache.org/xmlns/jpan/v1.0.0"
+    elementFormDefault="qualified"
+    attributeFormDefault="unqualified"
+    version="1.0.0">
+
+    <xsd:element name="enable" type="xsd:string"></xsd:element>
+</xsd:schema>
diff --git a/jpa-container-eclipselink-adapter/LICENSE b/jpa-container-eclipselink-adapter/LICENSE
new file mode 100644
index 0000000..6b0b127
--- /dev/null
+++ b/jpa-container-eclipselink-adapter/LICENSE
@@ -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.
+
diff --git a/jpa-container-eclipselink-adapter/NOTICE b/jpa-container-eclipselink-adapter/NOTICE
new file mode 100644
index 0000000..424644d
--- /dev/null
+++ b/jpa-container-eclipselink-adapter/NOTICE
@@ -0,0 +1,8 @@
+
+Apache Aries
+Copyright 2009-2011 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+
diff --git a/jpa-container-eclipselink-adapter/pom.xml b/jpa-container-eclipselink-adapter/pom.xml
new file mode 100644
index 0000000..91165b8
--- /dev/null
+++ b/jpa-container-eclipselink-adapter/pom.xml
@@ -0,0 +1,120 @@
+<?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.aries.jpa</groupId>
+        <artifactId>org.apache.aries.jpa.parent</artifactId>
+        <version>2.0.0</version>
+        <relativePath>../jpa-parent</relativePath>
+    </parent>
+
+    <groupId>org.apache.aries.jpa</groupId>
+    <artifactId>org.apache.aries.jpa.eclipselink.adapter</artifactId>
+    <packaging>bundle</packaging>
+    <name>Apache Aries JPA Container adapter for EclipseLink</name>
+
+    <properties>
+        <aries.osgi.export.pkg>
+        	org.apache.aries.jpa.eclipselink.adapter,
+        	org.apache.aries.jpa.eclipselink.adapter.platform
+        </aries.osgi.export.pkg>
+        <aries.osgi.import.pkg>
+			javax.persistence*;version="[2.1,3.0)",
+			org.eclipse.persistence.jpa;resolution:=optional,
+			org.eclipse.persistence.internal.weaving;resolution:=optional,
+			org.eclipse.persistence.internal.descriptors;resolution:=optional,
+			org.eclipse.persistence.queries;resolution:=optional,
+			org.eclipse.persistence.descriptors.changetracking;resolution:=optional,
+			org.eclipse.persistence.internal.identitymaps;resolution:=optional,
+			org.eclipse.persistence.sessions;resolution:=optional,
+			org.eclipse.persistence.internal.jpa.rs.metadata.model;resolution:=optional,
+			org.eclipse.persistence.indirection;resolution:=optional,
+			org.eclipse.persistence.jpa.jpql;resolution:=optional,
+			org.eclipse.persistence.jpa.jpql.parser;resolution:=optional,
+			org.eclipse.persistence.platform.server;resolution:=optional,
+            *
+        </aries.osgi.import.pkg>
+        <aries.osgi.failok>true</aries.osgi.failok>
+        <aries.osgi.activator>org.apache.aries.jpa.eclipselink.adapter.Activator</aries.osgi.activator>
+        <!-- First version -->
+        <aries.skip.version.check>true</aries.skip.version.check>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.persistence</groupId>
+            <artifactId>javax.persistence</artifactId>
+            <version>2.1.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-jta_1.1_spec</artifactId>
+            <version>1.1.1</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries</groupId>
+            <artifactId>org.apache.aries.util</artifactId>
+            <version>1.0.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.persistence</groupId>
+            <artifactId>org.eclipse.persistence.jpa</artifactId>
+            <version>2.5.2</version>
+        </dependency>
+    </dependencies>
+  
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.aries.versioning</groupId>
+                <artifactId>org.apache.aries.versioning.plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>default-verify</id>
+                        <phase>verify</phase>
+                        <goals>
+                            <goal>version-check</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
diff --git a/jpa-container-eclipselink-adapter/src/main/java/org/apache/aries/jpa/eclipselink/adapter/Activator.java b/jpa-container-eclipselink-adapter/src/main/java/org/apache/aries/jpa/eclipselink/adapter/Activator.java
new file mode 100644
index 0000000..b880ddd
--- /dev/null
+++ b/jpa-container-eclipselink-adapter/src/main/java/org/apache/aries/jpa/eclipselink/adapter/Activator.java
@@ -0,0 +1,173 @@
+/*
+// * 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 WARRANTIESOR 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.aries.jpa.eclipselink.adapter;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.BundleListener;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceFactory;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.framework.wiring.BundleRevision;
+import org.osgi.framework.wiring.BundleWire;
+import org.osgi.framework.wiring.BundleWiring;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.spi.PersistenceProvider;
+
+/**
+ * Eclipselink adapter main class.
+ * 
+ * The purpose of this class is to:
+ * <ul>
+ * <li>publish an OSGi-compatible Eclipselink {@link PersistenceProvider} service in the service registry</li>
+ * <li>intercept {@link EntityManagerFactory} creation to ensure that the Eclipselink target server (if not specified otherwise)
+ *     is OSGi compatible</li>
+ * </ul>
+ */
+public class Activator implements BundleActivator, BundleListener {
+    public static final String ECLIPSELINK_JPA_PROVIDER_BUNDLE_SYMBOLIC_NAME = "org.eclipse.persistence.jpa";
+    public static final String ECLIPSELINK_JPA_PROVIDER_CLASS_NAME = "org.eclipse.persistence.jpa.PersistenceProvider";
+    private final ConcurrentMap<Bundle, ServiceRegistration<?>> registeredProviders = new ConcurrentHashMap<Bundle, ServiceRegistration<?>>();
+    
+    private static final Logger logger = LoggerFactory.getLogger(Activator.class);
+    
+    private BundleContext context;
+    
+    public void start(BundleContext ctx) {
+        logger.debug("Starting EclipseLink adapter");
+        
+        context = ctx;
+        
+        ctx.addBundleListener(this);
+        
+        for (Bundle b : ctx.getBundles()) {
+            if ((b.getState() & (Bundle.ACTIVE | Bundle.STARTING | Bundle.RESOLVED | Bundle.STOPPING)) != 0) 
+                handlePotentialEclipseLink(b);
+        }
+    }
+    
+    public void stop(BundleContext ctx) {
+        logger.debug("Stopping EclipseLink adapter");
+
+        for (ServiceRegistration<?> reg : registeredProviders.values()) {
+          reg.unregister();
+        }
+      }
+    
+    public void bundleChanged(BundleEvent event) {
+        if ((event.getType() & (BundleEvent.RESOLVED)) != 0) {
+            handlePotentialEclipseLink(event.getBundle());
+        } else if (event.getType() == BundleEvent.UNRESOLVED | event.getType() == BundleEvent.UNINSTALLED) {
+            ServiceRegistration<?> reg = registeredProviders.remove(event.getBundle());
+            if (reg != null) {
+                reg.unregister();
+            }
+        }
+    }
+    
+    private void handlePotentialEclipseLink(Bundle b) {
+        if (b.getSymbolicName().equals(ECLIPSELINK_JPA_PROVIDER_BUNDLE_SYMBOLIC_NAME)) {
+            logger.debug("Found EclipseLink bundle {}", b);
+            
+            // make sure we can actually find the JPA provider we expect to find
+            try {
+                b.loadClass(ECLIPSELINK_JPA_PROVIDER_CLASS_NAME);
+            } catch (ClassNotFoundException cnfe) {
+                logger.debug("Did not find provider class, exiting");
+                // not one we can handle
+                return;
+            }
+            
+            if (!!!registeredProviders.containsKey(b)) {
+                logger.debug("Adding new EclipseLink provider for bundle {}", b);
+                
+                ServiceFactory<?> factory = new EclipseLinkProviderService(b);
+                
+                Hashtable<String, Object> props = new Hashtable<String, Object>();
+                props.put("org.apache.aries.jpa.container.weaving.packages", getJPAPackages(b));
+                props.put("javax.persistence.provider", ECLIPSELINK_JPA_PROVIDER_CLASS_NAME);
+                            
+                ServiceRegistration reg = context.registerService(
+                        PersistenceProvider.class.getName(), factory, props);
+                
+                ServiceRegistration old = registeredProviders.putIfAbsent(b, reg);
+                if (old != null) {
+                    reg.unregister();
+                }
+            }
+        }
+    }
+    
+    /**
+     * Get all the relevant packages that the EclipseLink JPA provider exports or persistence packages it uses itself. These are needed
+     * so that the woven proxy (for runtime enhancement) can be used later on :)
+     * 
+     * Note that differently to OpenJPA the relevant classes are actually in more than just one bundle (org.eclipse.persistence.jpa and org.eclipse.persistence.core
+     * at the time of this writing). Hence, we have to take more than just the packages of the JPA provider bundle into account ...
+     * 
+     * @param jpaBundle
+     * @return
+     */
+    private String[] getJPAPackages(Bundle jpaBundle) {
+        Set<String> result = new HashSet<String>();
+        
+        for (Bundle b : context.getBundles()) {
+            BundleWiring bw = b.adapt(BundleWiring.class);
+            if(bw != null) {
+	            List<BundleWire> wires = bw.getProvidedWires(BundleRevision.PACKAGE_NAMESPACE);
+	
+	            for (BundleWire w : wires) {
+	                String pkgName = (String) w.getCapability().getAttributes().get(BundleRevision.PACKAGE_NAMESPACE);
+	
+	                boolean add = false;
+	                if (b.equals(jpaBundle)) {
+	                    add = true;
+	                } else if (pkgName.startsWith("org.eclipse.persistence")) {
+	                    add = true;
+	                }
+	                
+	                if (add) {
+	                    String suffix = ";" + Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE + "=" + b.getSymbolicName() + ";" + Constants.BUNDLE_VERSION_ATTRIBUTE  + "=" + b.getVersion();                    
+	                    result.add(pkgName + suffix);
+	                }
+	            }
+            }
+        }
+        
+        result.add("org.apache.aries.jpa.eclipselink.adapter.platform;" + 
+                Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE + "=" + context.getBundle().getSymbolicName() + ";" + 
+                Constants.BUNDLE_VERSION_ATTRIBUTE  + "=" + context.getBundle().getVersion());        
+        
+        logger.debug("Found JPA packages {}", result);
+        
+        return result.toArray(new String[0]);
+    }
+}
diff --git a/jpa-container-eclipselink-adapter/src/main/java/org/apache/aries/jpa/eclipselink/adapter/EclipseLinkProviderService.java b/jpa-container-eclipselink-adapter/src/main/java/org/apache/aries/jpa/eclipselink/adapter/EclipseLinkProviderService.java
new file mode 100644
index 0000000..9184cf1
--- /dev/null
+++ b/jpa-container-eclipselink-adapter/src/main/java/org/apache/aries/jpa/eclipselink/adapter/EclipseLinkProviderService.java
@@ -0,0 +1,92 @@
+/*
+// * 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 WARRANTIESOR 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.aries.jpa.eclipselink.adapter;
+
+import org.apache.aries.jpa.eclipselink.adapter.platform.OSGiTSServer;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceFactory;
+import org.osgi.framework.ServiceRegistration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.lang.reflect.Constructor;
+import java.util.Map;
+
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.spi.PersistenceProvider;
+import javax.persistence.spi.PersistenceUnitInfo;
+import javax.persistence.spi.ProviderUtil;
+
+/**
+ * Service factory for generating the Eclipselink OSGi compatible provider. It proxies the provider so that
+ * we can go in at entity manager creation time and set the eclipselink target-server to be {@link OSGiTSServer}.
+ */
+@SuppressWarnings({"rawtypes", "unchecked"})
+public class EclipseLinkProviderService implements ServiceFactory {
+  private static final Logger logger = LoggerFactory.getLogger(Activator.class);
+  
+  private final Bundle eclipseLinkJpaBundle;
+    
+  public EclipseLinkProviderService(Bundle b) {
+      eclipseLinkJpaBundle = b;
+  }
+  
+  @Override
+  public Object getService(Bundle bundle, ServiceRegistration registration) {
+    logger.debug("Requested EclipseLink Provider service");
+    
+    try {
+      Class<? extends PersistenceProvider> providerClass = (Class<? extends PersistenceProvider>) eclipseLinkJpaBundle.loadClass(Activator.ECLIPSELINK_JPA_PROVIDER_CLASS_NAME);
+      Constructor<? extends PersistenceProvider> con = providerClass.getConstructor();
+      final PersistenceProvider provider = con.newInstance();
+      
+      return new PersistenceProvider() {
+        public ProviderUtil getProviderUtil() {
+          return provider.getProviderUtil();
+        }
+        
+        public EntityManagerFactory createEntityManagerFactory(String arg0, Map arg1) {
+          return provider.createEntityManagerFactory(arg0, arg1);
+        }
+        
+        public EntityManagerFactory createContainerEntityManagerFactory(PersistenceUnitInfo punit, Map props) {
+          return provider.createContainerEntityManagerFactory(new PersistenceUnitProxyWithTargetServer(punit, 
+                  eclipseLinkJpaBundle), props);
+        }
+        
+        @Override
+        public void generateSchema(PersistenceUnitInfo punit, Map arg1) {
+          provider.generateSchema(new PersistenceUnitProxyWithTargetServer(punit, 
+              eclipseLinkJpaBundle), arg1);
+        }
+
+        @Override
+        public boolean generateSchema(String arg0, Map arg1) {
+          return provider.generateSchema(arg0, arg1);
+        }
+      };
+      
+    } catch (Exception e) {
+        logger.error("An exception was caught trying to instantiate the EclipseLink JPA provider.", e);
+        return null;                
+    }
+  }
+
+  public void ungetService(Bundle bundle, ServiceRegistration registration, Object service) {}
+}
\ No newline at end of file
diff --git a/jpa-container-eclipselink-adapter/src/main/java/org/apache/aries/jpa/eclipselink/adapter/PersistenceUnitProxyWithTargetServer.java b/jpa-container-eclipselink-adapter/src/main/java/org/apache/aries/jpa/eclipselink/adapter/PersistenceUnitProxyWithTargetServer.java
new file mode 100644
index 0000000..635332a
--- /dev/null
+++ b/jpa-container-eclipselink-adapter/src/main/java/org/apache/aries/jpa/eclipselink/adapter/PersistenceUnitProxyWithTargetServer.java
@@ -0,0 +1,129 @@
+/*
+// * 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 WARRANTIESOR 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.aries.jpa.eclipselink.adapter;
+
+import java.net.URL;
+import java.util.List;
+import java.util.Properties;
+
+import javax.persistence.SharedCacheMode;
+import javax.persistence.ValidationMode;
+import javax.persistence.spi.ClassTransformer;
+import javax.persistence.spi.PersistenceUnitInfo;
+import javax.persistence.spi.PersistenceUnitTransactionType;
+import javax.sql.DataSource;
+
+import org.apache.aries.jpa.eclipselink.adapter.platform.OSGiTSServer;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.FrameworkUtil;
+
+/**
+ * Wrapper {@link PersistenceUnitInfo} object that adds the eclipselink.target-server setting (if not present)
+ * and makes sure we can load {@link OSGiTSServer} from the unit's classloader.
+ */
+public class PersistenceUnitProxyWithTargetServer implements PersistenceUnitInfo {
+  private final PersistenceUnitInfo delegate;
+    private final ClassLoader unionClassLoader; 
+    
+    public PersistenceUnitProxyWithTargetServer(PersistenceUnitInfo info, Bundle b) {
+        delegate = info;
+        unionClassLoader = new UnionClassLoader(delegate.getClassLoader(), b, 
+            FrameworkUtil.getBundle(getClass()));
+    }
+
+    public void addTransformer(ClassTransformer arg0) {
+        delegate.addTransformer(arg0);
+    }
+
+    public boolean excludeUnlistedClasses() {
+        return delegate.excludeUnlistedClasses();
+    }
+
+    public ClassLoader getClassLoader() {
+        return unionClassLoader;
+    }
+
+    public List<URL> getJarFileUrls() {
+        return delegate.getJarFileUrls();
+    }
+
+    public DataSource getJtaDataSource() {
+        return delegate.getJtaDataSource();
+    }
+
+    public List<String> getManagedClassNames() {
+        return delegate.getManagedClassNames();
+    }
+
+    public List<String> getMappingFileNames() {
+        return delegate.getMappingFileNames();
+    }
+
+    public ClassLoader getNewTempClassLoader() {
+        return delegate.getNewTempClassLoader();
+    }
+
+    public DataSource getNonJtaDataSource() {
+        return delegate.getNonJtaDataSource();
+    }
+
+    public String getPersistenceProviderClassName() {
+        return delegate.getPersistenceProviderClassName();
+    }
+
+    public String getPersistenceUnitName() {
+        return delegate.getPersistenceUnitName();
+    }
+
+    public URL getPersistenceUnitRootUrl() {
+        return delegate.getPersistenceUnitRootUrl();
+    }
+
+    public String getPersistenceXMLSchemaVersion() {
+        return delegate.getPersistenceXMLSchemaVersion();
+    }
+
+    public Properties getProperties() {
+        Properties props = delegate.getProperties();
+        
+        if (props == null) {
+            props = new Properties();
+        }
+        
+        if (!!!props.containsKey("eclipselink.target-server")) {
+            props.put("eclipselink.target-server", 
+                "org.apache.aries.jpa.eclipselink.adapter.platform.OSGiTSServer");
+        }
+        
+        return props;
+    }
+
+    public SharedCacheMode getSharedCacheMode() {
+        return delegate.getSharedCacheMode();
+    }
+
+    public PersistenceUnitTransactionType getTransactionType() {
+        return delegate.getTransactionType();
+    }
+
+    public ValidationMode getValidationMode() {
+        return delegate.getValidationMode();
+    }
+}
+  
\ No newline at end of file
diff --git a/jpa-container-eclipselink-adapter/src/main/java/org/apache/aries/jpa/eclipselink/adapter/UnionClassLoader.java b/jpa-container-eclipselink-adapter/src/main/java/org/apache/aries/jpa/eclipselink/adapter/UnionClassLoader.java
new file mode 100644
index 0000000..a4b7103
--- /dev/null
+++ b/jpa-container-eclipselink-adapter/src/main/java/org/apache/aries/jpa/eclipselink/adapter/UnionClassLoader.java
@@ -0,0 +1,93 @@
+/*

+// * 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 WARRANTIESOR 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.aries.jpa.eclipselink.adapter;

+

+import java.io.ByteArrayOutputStream;

+import java.io.Closeable;

+import java.io.IOException;

+import java.io.InputStream;

+import java.io.OutputStream;

+

+import org.osgi.framework.Bundle;

+import org.osgi.framework.BundleReference;

+

+public final class UnionClassLoader extends ClassLoader implements BundleReference{

+  

+  private static final String ORG_OSGI_FRAMEWORK = "org.osgi.framework.";

+  private static final int DOT_INDEX = ORG_OSGI_FRAMEWORK.lastIndexOf('.');

+  private final Bundle eclipseLinkBundle;

+  private final Bundle adaptorBundle;

+  

+  public UnionClassLoader(ClassLoader parentLoader, Bundle b, Bundle adaptor) {

+    super(parentLoader);

+    this.eclipseLinkBundle = b;

+    this.adaptorBundle = adaptor;

+  }

+

+  protected Class<?> findClass(String name) throws ClassNotFoundException {

+    

+    if("org.apache.aries.jpa.eclipselink.adapter.platform.OSGiTSServer".equals(name) ||

+        "org.apache.aries.jpa.eclipselink.adapter.platform.OSGiTSWrapper".equals(name)) {

+      

+      ByteArrayOutputStream baos = new ByteArrayOutputStream();

+      InputStream is = getClass().getClassLoader().getResourceAsStream(

+          name.replace('.', '/') + ".class");

+      

+      if(is == null)

+        throw new ClassNotFoundException(name);

+      

+      

+      try {

+        copy(is, baos);

+      } catch (IOException ioe) {

+        throw new ClassNotFoundException(name, ioe);

+      }

+      return defineClass(name, baos.toByteArray(), 0, baos.size());

+    } else if (name.startsWith(ORG_OSGI_FRAMEWORK) &&

+        name.lastIndexOf('.') == DOT_INDEX) {

+      return adaptorBundle.loadClass(name);

+    }

+    return eclipseLinkBundle.loadClass(name);

+  }

+

+  public Bundle getBundle() {

+    return adaptorBundle;

+  }

+  

+	private static void copy(InputStream in, OutputStream out)

+			throws IOException {

+		try {

+			int len;

+			byte[] b = new byte[1024];

+			while ((len = in.read(b)) != -1)

+				out.write(b, 0, len);

+		} finally {

+			close(in);

+		}

+	}

+

+	private static void close(Closeable c) {

+		try {

+			if (c != null)

+				c.close();

+		} catch (IOException e) {

+			c = null;

+		}

+	}

+}
\ No newline at end of file
diff --git a/jpa-container-eclipselink-adapter/src/main/java/org/apache/aries/jpa/eclipselink/adapter/platform/OSGiTSServer.java b/jpa-container-eclipselink-adapter/src/main/java/org/apache/aries/jpa/eclipselink/adapter/platform/OSGiTSServer.java
new file mode 100644
index 0000000..106e9ea
--- /dev/null
+++ b/jpa-container-eclipselink-adapter/src/main/java/org/apache/aries/jpa/eclipselink/adapter/platform/OSGiTSServer.java
@@ -0,0 +1,36 @@
+/*
+ * 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 WARRANTIESOR 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.aries.jpa.eclipselink.adapter.platform;
+
+import org.eclipse.persistence.platform.server.ServerPlatformBase;
+import org.eclipse.persistence.sessions.DatabaseSession;
+
+@SuppressWarnings("rawtypes")
+public class OSGiTSServer extends ServerPlatformBase {
+
+    public OSGiTSServer(DatabaseSession newDatabaseSession) {
+        super(newDatabaseSession);
+    }
+
+    @Override
+    public Class getExternalTransactionControllerClass() {
+        return OSGiTSWrapper.class;
+    }
+
+}
diff --git a/jpa-container-eclipselink-adapter/src/main/java/org/apache/aries/jpa/eclipselink/adapter/platform/OSGiTSWrapper.java b/jpa-container-eclipselink-adapter/src/main/java/org/apache/aries/jpa/eclipselink/adapter/platform/OSGiTSWrapper.java
new file mode 100644
index 0000000..a3ef4f0
--- /dev/null
+++ b/jpa-container-eclipselink-adapter/src/main/java/org/apache/aries/jpa/eclipselink/adapter/platform/OSGiTSWrapper.java
@@ -0,0 +1,47 @@
+/*
+ * 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 WARRANTIESOR 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.aries.jpa.eclipselink.adapter.platform;
+
+import javax.transaction.TransactionManager;
+
+import org.eclipse.persistence.transaction.JTATransactionController;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.ServiceReference;
+
+@SuppressWarnings({"rawtypes", "unchecked"})
+public class OSGiTSWrapper extends JTATransactionController {
+
+    @Override
+    protected TransactionManager acquireTransactionManager() throws Exception {
+        BundleContext ctx = FrameworkUtil.getBundle(OSGiTSWrapper.class).getBundleContext();
+        
+        if (ctx != null) {
+            ServiceReference ref = ctx.getServiceReference(TransactionManager.class.getName());
+            
+            if (ref != null) {
+                TransactionManager manager = (TransactionManager) ctx.getService(ref);
+                return manager;
+            }            
+        }
+        
+        return super.acquireTransactionManager();
+    }
+    
+}
diff --git a/jpa-container-eclipselink-adapter/src/main/resources/org/apache/aries/jpa/eclipselink/adapter/jpaEclipseLinkAdapter.properties b/jpa-container-eclipselink-adapter/src/main/resources/org/apache/aries/jpa/eclipselink/adapter/jpaEclipseLinkAdapter.properties
new file mode 100644
index 0000000..34572fa
--- /dev/null
+++ b/jpa-container-eclipselink-adapter/src/main/resources/org/apache/aries/jpa/eclipselink/adapter/jpaEclipseLinkAdapter.properties
@@ -0,0 +1,20 @@
+#
+# 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.
+#
+
+error.creating.eclipselink.provider=An exception was caught trying to instantiate the EclipseLink JPA provider.
\ No newline at end of file
diff --git a/jpa-container/LICENSE b/jpa-container/LICENSE
new file mode 100644
index 0000000..6b0b127
--- /dev/null
+++ b/jpa-container/LICENSE
@@ -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.
+
diff --git a/jpa-container/NOTICE b/jpa-container/NOTICE
new file mode 100644
index 0000000..424644d
--- /dev/null
+++ b/jpa-container/NOTICE
@@ -0,0 +1,8 @@
+
+Apache Aries
+Copyright 2009-2011 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+
diff --git a/jpa-container/pom.xml b/jpa-container/pom.xml
new file mode 100644
index 0000000..9ad565e
--- /dev/null
+++ b/jpa-container/pom.xml
@@ -0,0 +1,60 @@
+<?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/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.aries.jpa</groupId>
+        <artifactId>org.apache.aries.jpa.parent</artifactId>
+        <version>2.0.0</version>
+        <relativePath>../jpa-parent</relativePath>
+    </parent>
+    <artifactId>org.apache.aries.jpa.container</artifactId>
+    <name>Apache Aries JPA container</name>
+    <description>Implements the OSGi JPA Container from the enterprise spec. Provider a EntityManagerFactory and EntityManagerFactoryBuilder service</description>
+    <packaging>bundle</packaging>
+    
+    <properties>
+        <aries.skip.version.check>true</aries.skip.version.check>
+        <aries.osgi.export>
+            org.osgi.service.jdbc,
+            org.osgi.service.jpa
+        </aries.osgi.export>
+        <aries.osgi.activator>
+            org.apache.aries.jpa.container.impl.Activator
+        </aries.osgi.activator>
+    </properties>
+    
+    <dependencies>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.hibernate.javax.persistence</groupId>
+            <artifactId>hibernate-jpa-2.0-api</artifactId>
+            <version>1.0.1.Final</version>
+        </dependency>
+    </dependencies>
+
+</project>
\ No newline at end of file
diff --git a/jpa-container/src/main/appended-resources/META-INF/LICENSE.vm b/jpa-container/src/main/appended-resources/META-INF/LICENSE.vm
new file mode 100644
index 0000000..11aaec9
--- /dev/null
+++ b/jpa-container/src/main/appended-resources/META-INF/LICENSE.vm
@@ -0,0 +1,284 @@
+
+======================================
+  LICENSES FOR INCLUDED DEPENDENCIES
+======================================
+
+All the source code for the Aries JPA project is released under the
+license above. Additionally, the Aries JPA binary distribution
+includes a number of third-party files that are required in
+order to the software to function. Unless noted below, these jars
+and resource files are also released under the ASF license above.
+
+The exceptions are as follows:
+
+===========================
+  persistence-xsd.rsrc - included in the org.apache.aries.jpa.container jar jar, taken from:
+    http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd)
+  persistence_2_0-xsd.rsrc - included in the org.apache.aries.jpa.container jar jar, taken from:
+    http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd)
+===========================
+
+COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
+
+1. Definitions.
+
+   1.1. Contributor. means each individual or entity that creates or contributes to the creation of Modifications.
+
+   1.2. Contributor Version. means the combination of the Original Software, prior Modifications used by a Contributor (if any), and the Modifications made by that particular Contributor.
+
+   1.3. Covered Software. means (a) the Original Software, or (b) Modifications, or (c) the combination of files containing Original Software with files containing Modifications, in each case including portions thereof.
+
+   1.4. Executable. means the Covered Software in any form other than Source Code.
+
+   1.5. Initial Developer. means the individual or entity that first makes Original Software available under this License.
+
+   1.6. Larger Work. means a work which combines Covered Software or portions thereof with code not governed by the terms of this License.
+
+   1.7. License. means this document.
+
+   1.8. Licensable. means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently acquired, any and all of the rights conveyed herein.
+
+   1.9. Modifications. means the Source Code and Executable form of any of the following:
+
+        A. Any file that results from an addition to, deletion from or modification of the contents of a file containing Original Software or previous Modifications;
+
+        B. Any new file that contains any part of the Original Software or previous Modification; or
+
+        C. Any new file that is contributed or otherwise made available under the terms of this License.
+
+   1.10. Original Software. means the Source Code and Executable form of computer software code that is originally released under this License.
+
+   1.11. Patent Claims. means any patent claim(s), now owned or hereafter acquired, including without limitation, method, process, and apparatus claims, in any patent Licensable by grantor.
+
+   1.12. Source Code. means (a) the common form of computer software code in which modifications are made and (b) associated documentation included in or with such code.
+
+   1.13. You. (or .Your.) means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, .You. includes any entity which controls, is controlled by, or is under common control with You. For purposes of this definition, .control. means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity.
+
+2. License Grants.
+
+      2.1. The Initial Developer Grant.
+
+      Conditioned upon Your compliance with Section 3.1 below and subject to third party intellectual property claims, the Initial Developer hereby grants You a world-wide, royalty-free, non-exclusive license:
+
+         (a) under intellectual property rights (other than patent or trademark) Licensable by Initial Developer, to use, reproduce, modify, display, perform, sublicense and distribute the Original Software (or portions thereof), with or without Modifications, and/or as part of a Larger Work; and
+
+         (b) under Patent Claims infringed by the making, using or selling of Original Software, to make, have made, use, practice, sell, and offer for sale, and/or otherwise dispose of the Original Software (or portions thereof).
+
+        (c) The licenses granted in Sections 2.1(a) and (b) are effective on the date Initial Developer first distributes or otherwise makes the Original Software available to a third party under the terms of this License.
+
+        (d) Notwithstanding Section 2.1(b) above, no patent license is granted: (1) for code that You delete from the Original Software, or (2) for infringements caused by: (i) the modification of the Original Software, or (ii) the combination of the Original Software with other software or devices.
+
+    2.2. Contributor Grant.
+
+    Conditioned upon Your compliance with Section 3.1 below and subject to third party intellectual property claims, each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license:
+
+        (a) under intellectual property rights (other than patent or trademark) Licensable by Contributor to use, reproduce, modify, display, perform, sublicense and distribute the Modifications created by such Contributor (or portions thereof), either on an unmodified basis, with other Modifications, as Covered Software and/or as part of a Larger Work; and
+
+        (b) under Patent Claims infringed by the making, using, or selling of Modifications made by that Contributor either alone and/or in combination with its Contributor Version (or portions of such combination), to make, use, sell, offer for sale, have made, and/or otherwise dispose of: (1) Modifications made by that Contributor (or portions thereof); and (2) the combination of Modifications made by that Contributor with its Contributor Version (or portions of such combination).
+
+        (c) The licenses granted in Sections 2.2(a) and 2.2(b) are effective on the date Contributor first distributes or otherwise makes the Modifications available to a third party.
+
+        (d) Notwithstanding Section 2.2(b) above, no patent license is granted: (1) for any code that Contributor has deleted from the Contributor Version; (2) for infringements caused by: (i) third party modifications of Contributor Version, or (ii) the combination of Modifications made by that Contributor with other software (except as part of the Contributor Version) or other devices; or (3) under Patent Claims infringed by Covered Software in the absence of Modifications made by that Contributor.
+
+3. Distribution Obligations.
+
+      3.1. Availability of Source Code.
+      Any Covered Software that You distribute or otherwise make available in Executable form must also be made available in Source Code form and that Source Code form must be distributed only under the terms of this License. You must include a copy of this License with every copy of the Source Code form of the Covered Software You distribute or otherwise make available. You must inform recipients of any such Covered Software in Executable form as to how they can obtain such Covered Software in Source Code form in a reasonable manner on or through a medium customarily used for software exchange.
+
+      3.2. Modifications.
+      The Modifications that You create or to which You contribute are governed by the terms of this License. You represent that You believe Your Modifications are Your original creation(s) and/or You have sufficient rights to grant the rights conveyed by this License.
+
+      3.3. Required Notices.
+      You must include a notice in each of Your Modifications that identifies You as the Contributor of the Modification. You may not remove or alter any copyright, patent or trademark notices contained within the Covered Software, or any notices of licensing or any descriptive text giving attribution to any Contributor or the Initial Developer.
+
+      3.4. Application of Additional Terms.
+      You may not offer or impose any terms on any Covered Software in Source Code form that alters or restricts the applicable version of this License or the recipients. rights hereunder. You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Software. However, you may do so only on Your own behalf, and not on behalf of the Initial Developer or any Contributor. You must make it absolutely clear that any such warranty, support, indemnity or liability obligation is offered by You alone, and You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of warranty, support, indemnity or liability terms You offer.
+
+      3.5. Distribution of Executable Versions.
+      You may distribute the Executable form of the Covered Software under the terms of this License or under the terms of a license of Your choice, which may contain terms different from this License, provided that You are in compliance with the terms of this License and that the license for the Executable form does not attempt to limit or alter the recipient.s rights in the Source Code form from the rights set forth in this License. If You distribute the Covered Software in Executable form under a different license, You must make it absolutely clear that any terms which differ from this License are offered by You alone, not by the Initial Developer or Contributor. You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of any such terms You offer.
+
+      3.6. Larger Works.
+      You may create a Larger Work by combining Covered Software with other code not governed by the terms of this License and distribute the Larger Work as a single product. In such a case, You must make sure the requirements of this License are fulfilled for the Covered Software.
+
+4. Versions of the License.
+
+      4.1. New Versions.
+      Sun Microsystems, Inc. is the initial license steward and may publish revised and/or new versions of this License from time to time. Each version will be given a distinguishing version number. Except as provided in Section 4.3, no one other than the license steward has the right to modify this License.
+
+      4.2. Effect of New Versions.
+      You may always continue to use, distribute or otherwise make the Covered Software available under the terms of the version of the License under which You originally received the Covered Software. If the Initial Developer includes a notice in the Original Software prohibiting it from being distributed or otherwise made available under any subsequent version of the License, You must distribute and make the Covered Software available under the terms of the version of the License under which You originally received the Covered Software. Otherwise, You may also choose to use, distribute or otherwise make the Covered Software available under the terms of any subsequent version of the License published by the license steward.
+
+      4.3. Modified Versions.
+      When You are an Initial Developer and You want to create a new license for Your Original Software, You may create and use a modified version of this License if You: (a) rename the license and remove any references to the name of the license steward (except to note that the license differs from this License); and (b) otherwise make it clear that the license contains terms which differ from this License.
+
+5. DISCLAIMER OF WARRANTY.
+
+   COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN .AS IS. BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
+
+6. TERMINATION.
+
+      6.1. This License and the rights granted hereunder will terminate automatically if You fail to comply with terms herein and fail to cure such breach within 30 days of becoming aware of the breach. Provisions which, by their nature, must remain in effect beyond the termination of this License shall survive.
+
+      6.2. If You assert a patent infringement claim (excluding declaratory judgment actions) against Initial Developer or a Contributor (the Initial Developer or Contributor against whom You assert such claim is referred to as .Participant.) alleging that the Participant Software (meaning the Contributor Version where the Participant is a Contributor or the Original Software where the Participant is the Initial Developer) directly or indirectly infringes any patent, then any and all rights granted directly or indirectly to You by such Participant, the Initial Developer (if the Initial Developer is not the Participant) and all Contributors under Sections 2.1 and/or 2.2 of this License shall, upon 60 days notice from Participant terminate prospectively and automatically at the expiration of such 60 day notice period, unless if within such 60 day period You withdraw Your claim with respect to the Participant Software against such Participant either unilaterally or pursuant to a written agreement with Participant.
+
+      6.3. In the event of termination under Sections 6.1 or 6.2 above, all end user licenses that have been validly granted by You or any distributor hereunder prior to termination (excluding licenses granted to You by any distributor) shall survive termination.
+
+7. LIMITATION OF LIABILITY.
+
+   UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOST PROFITS, LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY RESULTING FROM SUCH PARTY.S NEGLIGENCE TO THE EXTENT APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
+
+8. U.S. GOVERNMENT END USERS.
+
+   The Covered Software is a .commercial item,. as that term is defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of .commercial computer software. (as that term is defined at 48 C.F.R. ? 252.227-7014(a)(1)) and .commercial computer software documentation. as such terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users acquire Covered Software with only those rights set forth herein. This U.S. Government Rights clause is in lieu of, and supersedes, any other FAR, DFAR, or other clause or provision that addresses Government rights in computer software under this License.
+
+9. MISCELLANEOUS.
+
+   This License represents the complete agreement concerning subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. This License shall be governed by the law of the jurisdiction specified in a notice contained within the Original Software (except to the extent applicable law, if any, provides otherwise), excluding such jurisdiction.s conflict-of-law provisions. Any litigation relating to this License shall be subject to the jurisdiction of the courts located in the jurisdiction and venue specified in a notice contained within the Original Software, with the losing party responsible for costs, including, without limitation, court costs and reasonable attorneys. fees and expenses. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not apply to this License. You agree that You alone are responsible for compliance with the United States export administration regulations (and the export control laws and regulation of any other countries) when You use, distribute or otherwise make available any Covered Software.
+
+10. RESPONSIBILITY FOR CLAIMS.
+
+   As between Initial Developer and the Contributors, each party is responsible for claims and damages arising, directly or indirectly, out of its utilization of rights under this License and You agree to work with Initial Developer and Contributors to distribute such responsibility on an equitable basis. Nothing herein is intended or shall be deemed to constitute any admission of liability.
+
+   NOTICE PURSUANT TO SECTION 9 OF THE COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL)
+
+   The code released under the CDDL shall be governed by the laws of the State of California (excluding conflict-of-law provisions). Any litigation relating to this License shall be subject to the jurisdiction of the Federal Courts of the Northern District of California and the state courts of the State of California, with venue lying in Santa Clara County, California.
+
+
+The GNU General Public License (GPL) Version 2, June 1991
+
+
+Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
+
+Preamble
+
+The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too.
+
+When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.
+
+To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.
+
+For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
+
+We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.
+
+Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.
+
+Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.
+
+The precise terms and conditions for copying, distribution and modification follow.
+
+
+TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.
+
+1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.
+
+2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
+
+   a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.
+
+   b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License.
+
+   c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
+
+3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:
+
+   a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
+
+   b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
+
+   c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.
+
+If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.
+
+4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
+
+5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.
+
+6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.
+
+7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.
+
+This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
+
+8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
+
+9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.
+
+10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.
+
+NO WARRANTY
+
+11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+END OF TERMS AND CONDITIONS
+
+
+How to Apply These Terms to Your New Programs
+
+If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
+
+To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.
+
+   One line to give the program's name and a brief idea of what it does.
+
+   Copyright (C)
+
+   This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this when it starts in an interactive mode:
+
+   Gnomovision version 69, Copyright (C) year name of author
+   Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names:
+
+   Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+   signature of Ty Coon, 1 April 1989
+   Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License.
+
+
+"CLASSPATH" EXCEPTION TO THE GPL VERSION 2
+
+Certain source files distributed by Sun Microsystems, Inc. are subject to the following clarification and special exception to the GPL Version 2, but only where Sun has expressly included in the particular source file's header the words
+
+"Sun designates this particular file as subject to the "Classpath" exception as provided by Sun in the License file that accompanied this code."
+
+Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License Version 2 cover the whole combination.
+
+As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module.? An independent module is a module which is not derived from or based on this library.? If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so.? If you do not wish to do so, delete this exception statement from your version.
+
diff --git a/jpa-container/src/main/appended-resources/META-INF/NOTICE.vm b/jpa-container/src/main/appended-resources/META-INF/NOTICE.vm
new file mode 100644
index 0000000..0cacb17
--- /dev/null
+++ b/jpa-container/src/main/appended-resources/META-INF/NOTICE.vm
@@ -0,0 +1,7 @@
+Aries JPA includes the persistence schemas from the JPA specifications.
+Copyright 2005-2009 Sun Microsystems, Inc. All rights reserved.
+Aries JPA elects to include this software in this distribution under the
+CDDL license.  You can obtain a copy of the License at:
+    https://glassfish.dev.java.net/public/CDDL+GPL.html
+The source code is available at:
+    https://glassfish.dev.java.net/source/browse/glassfish/
diff --git a/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/Activator.java b/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/Activator.java
new file mode 100644
index 0000000..b7ee6e8
--- /dev/null
+++ b/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/Activator.java
@@ -0,0 +1,62 @@
+/*
+ * 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 WARRANTIESOR 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.aries.jpa.container.impl;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import org.apache.aries.jpa.container.weaving.impl.TransformerRegistry;
+import org.apache.aries.jpa.container.weaving.impl.TransformerRegistrySingleton;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.hooks.weaving.WeavingHook;
+import org.osgi.util.tracker.BundleTracker;
+
+public class Activator implements BundleActivator {
+
+    private BundleTracker<Bundle> persistenceBundleManager;
+
+    @Override
+    public void start(BundleContext context) throws Exception {
+        registerWeavingHook(context, TransformerRegistrySingleton.get());
+
+        PersistenceBundleTracker customizer = new PersistenceBundleTracker(context);
+        persistenceBundleManager = new BundleTracker<>(context, Bundle.STARTING | Bundle.ACTIVE, customizer);
+        persistenceBundleManager.open();
+    }
+
+    /**
+     * ARIES-1019: Register with the highest possible service ranking to
+     * avoid ClassNotFoundException caused by interfaces added by earlier
+     * weaving hooks that are not yet visible to the bundle class loader.
+     */
+    private void registerWeavingHook(BundleContext context, TransformerRegistry tr) {
+        Dictionary<String, Object> props = new Hashtable<String, Object>(1);
+        props.put(Constants.SERVICE_RANKING, Integer.MAX_VALUE);
+        context.registerService(WeavingHook.class.getName(), tr, props);
+    }
+
+    @Override
+    public void stop(BundleContext context) throws Exception {
+        persistenceBundleManager.close();
+    }
+
+}
diff --git a/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/AriesEntityManagerFactoryBuilder.java b/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/AriesEntityManagerFactoryBuilder.java
new file mode 100644
index 0000000..4a47b19
--- /dev/null
+++ b/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/AriesEntityManagerFactoryBuilder.java
@@ -0,0 +1,58 @@
+/*
+ * 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 WARRANTIESOR 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.aries.jpa.container.impl;
+
+import java.util.Map;
+
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.spi.PersistenceProvider;
+import javax.persistence.spi.PersistenceUnitInfo;
+
+import org.osgi.service.jpa.EntityManagerFactoryBuilder;
+
+/**
+ * FIXME We are currently not configuring a DataSource for the persistence unit.
+ * It still works in the tests as the DataSource is defined in the DataSourceTracker or DSFTracker.
+ * This not fully correct though.
+ */
+public class AriesEntityManagerFactoryBuilder implements EntityManagerFactoryBuilder {
+    private static final String JAVAX_PERSISTENCE_JDBC_DRIVER = "javax.persistence.jdbc.driver";
+
+    private PersistenceProvider provider;
+    private PersistenceUnitInfo persistenceUnit;
+    private String driver;
+
+    public AriesEntityManagerFactoryBuilder(PersistenceProvider provider, PersistenceUnitInfo persistenceUnit) {
+        this.provider = provider;
+        this.persistenceUnit = persistenceUnit;
+        this.driver = (String)persistenceUnit.getProperties().get(JAVAX_PERSISTENCE_JDBC_DRIVER);
+    }
+
+    @Override
+    public EntityManagerFactory createEntityManagerFactory(Map<String, Object> props) {
+        String newDriver = (String)props.get(JAVAX_PERSISTENCE_JDBC_DRIVER);
+        if (driver == null) {
+            driver = newDriver;
+        } else if (newDriver != null && !newDriver.equals(driver)){
+            throw new IllegalArgumentException("Can not rebind to a different database driver");
+        }
+        return provider.createContainerEntityManagerFactory(persistenceUnit, props);
+    }
+
+}
diff --git a/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/DSFTracker.java b/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/DSFTracker.java
new file mode 100644
index 0000000..b5c86e6
--- /dev/null
+++ b/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/DSFTracker.java
@@ -0,0 +1,125 @@
+/*
+ * 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 WARRANTIESOR 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.aries.jpa.container.impl;
+
+import java.sql.SQLException;
+import java.util.Properties;
+
+import javax.persistence.spi.PersistenceProvider;
+import javax.persistence.spi.PersistenceUnitTransactionType;
+import javax.sql.DataSource;
+
+import org.apache.aries.jpa.container.parser.impl.PersistenceUnit;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Filter;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.jdbc.DataSourceFactory;
+import org.osgi.util.tracker.ServiceTracker;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DSFTracker extends ServiceTracker<DataSourceFactory, ManagedEMF>{
+    private static final String JDBC_DRIVER = "javax.persistence.jdbc.driver";
+    private static final String JDBC_URL = "javax.persistence.jdbc.url";
+    private static final String JDBC_USER = "javax.persistence.jdbc.user";
+    private static final String JDBC_PASSWORD = "javax.persistence.jdbc.password";
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(DSFTracker.class);
+
+
+    private PersistenceProvider provider;
+    private PersistenceUnit punit;
+
+    public DSFTracker(BundleContext context, PersistenceProvider provider, PersistenceUnit punit) {
+        super(context, createFilter(context, punit), null);
+        this.provider = provider;
+        this.punit = punit;
+    }
+
+    static Filter createFilter(BundleContext context, PersistenceUnit punit) {
+        String driverName = getDriverName(punit);
+        if (driverName == null) {
+            throw new IllegalArgumentException("No javax.persistence.jdbc.driver supplied in persistence.xml");
+        }
+        String filter = String.format("(&(objectClass=%s)(%s=%s))",
+                                      DataSourceFactory.class.getName(),
+                                      DataSourceFactory.OSGI_JDBC_DRIVER_CLASS,
+                                      driverName);
+        LOGGER.info("Tracking DataSourceFactory for punit " + punit.getPersistenceUnitName() + " with filter " + filter);
+        try {
+            return context.createFilter(filter);
+        } catch (InvalidSyntaxException e) {
+            throw new IllegalArgumentException(e);
+        }
+    }
+
+    public static String getDriverName(PersistenceUnit punit) {
+        return (String)punit.getProperties().get(JDBC_DRIVER);
+    }
+
+    @Override
+    public ManagedEMF addingService(ServiceReference<DataSourceFactory> reference) {
+        LOGGER.info("Found DataSourceFactory for " + punit.getPersistenceUnitName() + " "
+                    + getDriverName(punit));
+        try {
+            DataSourceFactory dsf = context.getService(reference);
+            DataSource ds = createDataSource(dsf);
+            if (punit.getTransactionType() == PersistenceUnitTransactionType.JTA) {
+                punit.setJtaDataSource(ds);
+            } else {
+                punit.setNonJtaDataSource(ds);
+            }
+            BundleContext containerContext = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
+            return new ManagedEMF(containerContext, punit.getBundle(), provider, punit);
+        } catch (Exception e) {
+            LOGGER.error("Error creating DataSource for punit " + punit.getPersistenceUnitName(), e);
+            return null;
+        }
+    }
+
+    private DataSource createDataSource(DataSourceFactory dsf) {
+        try {
+            Properties props = new Properties();
+            put(props, DataSourceFactory.JDBC_URL, punit, JDBC_URL);
+            put(props, DataSourceFactory.JDBC_USER, punit, JDBC_USER);
+            put(props, DataSourceFactory.JDBC_PASSWORD, punit, JDBC_PASSWORD);
+            DataSource ds = dsf.createDataSource(props);
+            return ds;
+        } catch (SQLException e) {
+            throw new RuntimeException("Error creating DataSource for persistence unit " + punit + "."
+                                       + e.getMessage(), e);
+        }
+    }
+
+    private static void put(Properties props, String destKey, PersistenceUnit punit, String sourceKey) {
+        Object value = punit.getProperties().get(sourceKey);
+        if (value != null) {
+            props.put(destKey, value);
+        }
+    }
+
+    @Override
+    public void removedService(ServiceReference<DataSourceFactory> reference, ManagedEMF managedEMF) {
+        LOGGER.info("Lost DataSourceFactory for " + punit.getPersistenceUnitName() + " " + getDriverName(punit));
+        managedEMF.close();
+        super.removedService(reference, managedEMF);
+    }
+}
diff --git a/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/DataSourceTracker.java b/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/DataSourceTracker.java
new file mode 100644
index 0000000..907dc48
--- /dev/null
+++ b/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/DataSourceTracker.java
@@ -0,0 +1,103 @@
+/*
+ * 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 WARRANTIESOR 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.aries.jpa.container.impl;
+
+import static javax.persistence.spi.PersistenceUnitTransactionType.JTA;
+
+import javax.persistence.spi.PersistenceProvider;
+import javax.persistence.spi.PersistenceUnitTransactionType;
+import javax.sql.DataSource;
+
+import org.apache.aries.jpa.container.parser.impl.PersistenceUnit;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Filter;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.util.tracker.ServiceTracker;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DataSourceTracker extends ServiceTracker<DataSource, ManagedEMF>{
+    private static final Logger LOGGER = LoggerFactory.getLogger(DataSourceTracker.class);
+
+    private PersistenceProvider provider;
+    private PersistenceUnit punit;
+
+    static final String DS_PREFIX = "osgi:service/javax.sql.DataSource";
+
+    public DataSourceTracker(BundleContext context, PersistenceProvider provider, PersistenceUnit punit) {
+        super(context, createFilter(context, punit), null);
+        this.provider = provider;
+        this.punit = punit;
+    }
+
+    static Filter createFilter(BundleContext context, PersistenceUnit punit) {
+        String dsName = getDsName(punit);
+        if (dsName == null) {
+            throw new IllegalArgumentException("No DataSource supplied in persistence.xml");
+        }
+        String subFilter = getSubFilter(dsName);
+        String filter = String.format("(&(objectClass=%s)%s)",
+                                      DataSource.class.getName(),
+                                      subFilter);
+        LOGGER.info("Tracking DataSource for punit " + punit.getPersistenceUnitName() + " with filter " + filter);
+        try {
+            return context.createFilter(filter);
+        } catch (InvalidSyntaxException e) {
+            throw new IllegalArgumentException(e);
+        }
+    }
+
+    private static String getSubFilter(String dsName) {
+        if (dsName.startsWith(DS_PREFIX)) {
+            return (dsName.length() > DS_PREFIX.length() +1) 
+                ? dsName.substring(DS_PREFIX.length()+1) 
+                : "(osgi.jndi.service.name=*)"; 
+        } else {
+            return "(osgi.jndi.service.name=" + dsName + ")";
+        }
+    }
+
+    private static String getDsName(PersistenceUnit punit) {
+        return punit.getTransactionType() == JTA ? punit.getJtaDataSourceName() : punit.getNonJtaDataSourceName();
+    }
+
+    @Override
+    public ManagedEMF addingService(ServiceReference<DataSource> reference) {
+        LOGGER.info("Found DataSource for " + punit.getPersistenceUnitName() + " " + getDsName(punit));
+        DataSource ds = context.getService(reference);
+        if (punit.getTransactionType() == PersistenceUnitTransactionType.JTA) {
+            punit.setJtaDataSource(ds);
+        } else {
+            punit.setNonJtaDataSource(ds);
+        }
+        BundleContext containerContext = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
+        return new ManagedEMF(containerContext, punit.getBundle(), provider, punit);
+    }
+
+
+    @Override
+    public void removedService(ServiceReference<DataSource> reference, ManagedEMF managedEMF) {
+        LOGGER.info("Lost DataSource for " + punit.getPersistenceUnitName() + " " + getDsName(punit));
+        managedEMF.close();
+        super.removedService(reference, managedEMF);
+    }
+
+}
diff --git a/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/ManagedEMF.java b/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/ManagedEMF.java
new file mode 100644
index 0000000..552e8dc
--- /dev/null
+++ b/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/ManagedEMF.java
@@ -0,0 +1,133 @@
+/*
+ * 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 WARRANTIESOR 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.aries.jpa.container.impl;
+
+import static org.osgi.service.jpa.EntityManagerFactoryBuilder.JPA_UNIT_NAME;
+import static org.osgi.service.jpa.EntityManagerFactoryBuilder.JPA_UNIT_PROVIDER;
+import static org.osgi.service.jpa.EntityManagerFactoryBuilder.JPA_UNIT_VERSION;
+
+import java.io.Closeable;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Map;
+
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.spi.PersistenceProvider;
+import javax.persistence.spi.PersistenceUnitInfo;
+import javax.persistence.spi.PersistenceUnitTransactionType;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.cm.ConfigurationException;
+import org.osgi.service.cm.ManagedService;
+import org.osgi.service.jpa.EntityManagerFactoryBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Creates an EntityManagerFactory(EMF) for a persistence unit and publishes it as a service.
+ * Custom properties can be configured by supplying a config admin configuriation named like
+ * the JPA_CONFIGURATION_PREFIX.<persistence unit name>.
+ */
+public class ManagedEMF implements Closeable, ManagedService {
+	private static final Logger LOGGER = LoggerFactory.getLogger(ManagedEMF.class);
+
+    private static String JPA_CONFIGURATION_PREFIX = "org.apache.aries.jpa.";
+
+    private EntityManagerFactory emf;
+    private ServiceRegistration<EntityManagerFactory> reg;
+    private ServiceRegistration<EntityManagerFactoryBuilder> regBuilder;
+    private PersistenceProvider provider;
+    private PersistenceUnitInfo persistenceUnit;
+    private Bundle bundle;
+
+    public ManagedEMF(BundleContext containerContext, Bundle bundle, PersistenceProvider provider, PersistenceUnitInfo persistenceUnit) {
+        this.provider = provider;
+        this.persistenceUnit = persistenceUnit;
+        this.bundle = bundle;
+
+        Dictionary<String, Object> configuration = new Hashtable<String, Object>();
+        configuration.put(Constants.SERVICE_PID,
+                          JPA_CONFIGURATION_PREFIX + persistenceUnit.getPersistenceUnitName());
+        containerContext.registerService(ManagedService.class.getName(), this, configuration);
+    }
+
+    public void close() {
+        try {
+            reg.unregister();
+        } catch (Exception e) {
+            // Ignore. May happen if persistence unit bundle is unloaded/updated
+        }
+        try {
+            regBuilder.unregister();
+        } catch (Exception e) {
+            // Ignore. May happen if persistence unit bundle is unloaded/updated
+        }
+        if (emf != null && emf.isOpen()) {
+            try {
+                emf.close();
+            } catch (Exception e) {
+                LOGGER.warn("Error closing EntityManagerFactory for " + persistenceUnit.getPersistenceUnitName(), e);
+            }
+        }
+        reg = null;
+        emf = null;
+    }
+
+    @Override
+    public void updated(Dictionary<String, ?> properties) throws ConfigurationException {
+        if (emf != null) {
+            close();
+        }
+        Map<String, Object> overrides = (properties != null) ? asMap(properties) : null;
+        LOGGER.info("Registering EntityManagerFactory for persistence unit " + persistenceUnit.getPersistenceUnitName());
+        if (LOGGER.isDebugEnabled()) {
+           LOGGER.debug("Using properties override " + overrides); 
+        }
+        emf = provider.createContainerEntityManagerFactory(persistenceUnit, overrides);
+        Dictionary<String, String> props = createProperties(persistenceUnit, bundle);
+        BundleContext uctx = bundle.getBundleContext();
+        reg = uctx.registerService(EntityManagerFactory.class, emf, props);
+    }
+
+    public static Dictionary<String, String> createProperties(PersistenceUnitInfo persistenceUnit, Bundle puBundle) {
+        Dictionary<String, String> props = new Hashtable<>();
+        props.put(JPA_UNIT_NAME, persistenceUnit.getPersistenceUnitName());
+        if (persistenceUnit.getPersistenceProviderClassName() != null) {
+            props.put(JPA_UNIT_PROVIDER, persistenceUnit.getPersistenceProviderClassName());
+        }
+        props.put(JPA_UNIT_VERSION, puBundle.getVersion().toString());
+        return props;
+    }
+
+    private Map<String, Object> asMap(Dictionary<String, ?> dict) {
+        Map<String, Object> map = new HashMap<String, Object>();
+        map.put(PersistenceUnitTransactionType.class.getName(), persistenceUnit.getTransactionType());
+        for (Enumeration<String> e = dict.keys(); e.hasMoreElements();) {
+            String key = e.nextElement();
+            map.put(key, dict.get(key));
+        }
+        return map;
+    }
+
+}
diff --git a/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleTracker.java b/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleTracker.java
new file mode 100644
index 0000000..cf7700f
--- /dev/null
+++ b/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleTracker.java
@@ -0,0 +1,137 @@
+/*
+ * 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 WARRANTIESOR 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.aries.jpa.container.impl;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.aries.jpa.container.parser.impl.PersistenceUnit;
+import org.apache.aries.jpa.container.parser.impl.PersistenceUnitParser;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.packageadmin.PackageAdmin;
+import org.osgi.util.tracker.BundleTrackerCustomizer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Looks for bundles containing a persistence.xml. For each persistence unit
+ * found a PersistenceProviderTracker is installed that tracks matching providers.
+ */
+@SuppressWarnings("deprecation")
+public class PersistenceBundleTracker implements BundleTrackerCustomizer<Bundle> {
+    private static final Logger LOGGER = LoggerFactory.getLogger(PersistenceBundleTracker.class);
+    Map<Bundle, Collection<PersistenceProviderTracker>> trackers;
+    private BundleContext context;
+
+    public PersistenceBundleTracker(BundleContext context) {
+        this.context = context;
+        trackers = new HashMap<Bundle, Collection<PersistenceProviderTracker>>();
+    }
+
+    public Bundle addingBundle(Bundle bundle, BundleEvent event) {
+        if (getTrackers(bundle).size() == 0) {
+            findPersistenceUnits(bundle);
+        }
+        return bundle;
+    }
+
+    public void removedBundle(Bundle bundle, BundleEvent event, Bundle object) {
+        Collection<PersistenceProviderTracker> providerTrackers = trackers.get(bundle);
+        if (providerTrackers != null) {
+            if (providerTrackers.size() > 0)  {
+                LOGGER.info("removing persistence units for " + bundle.getSymbolicName() + " " + getType(event));
+            }
+            for (PersistenceProviderTracker providerTracker : providerTrackers) {
+                providerTracker.close();
+            }
+            providerTrackers.clear();
+            trackers.remove(bundle);
+        }
+    }
+
+    private void findPersistenceUnits(Bundle bundle) {
+        ServiceReference<PackageAdmin> ref = context.getServiceReference(PackageAdmin.class);
+        PackageAdmin packageAdmin = context.getService(ref);
+        for (PersistenceUnit punit : PersistenceUnitParser.getPersistenceUnits(bundle)) {
+            punit.addAnnotated(packageAdmin);
+            trackProvider(bundle, punit);
+        }
+        context.ungetService(ref);
+    }
+
+    private void trackProvider(Bundle bundle, 
+                               PersistenceUnit punit) {
+        LOGGER.info(String.format("Found persistence unit %s in bundle %s with provider %s.",
+                                  punit.getPersistenceUnitName(), bundle.getSymbolicName(),
+                                  punit.getPersistenceProviderClassName()));
+        PersistenceProviderTracker tracker = new PersistenceProviderTracker(context, punit);
+        tracker.open();
+        getTrackers(bundle).add(tracker);
+    }
+
+    @Override
+    public void modifiedBundle(Bundle bundle, BundleEvent event, Bundle object) {
+    }
+
+    private static String getType(BundleEvent event) {
+        if (event == null) {
+            return "null";
+        }
+        int type = event.getType();
+        switch (type) {
+        case BundleEvent.INSTALLED:
+            return "INSTALLED";
+        case BundleEvent.LAZY_ACTIVATION:
+            return "LAZY_ACTIVATION";
+        case BundleEvent.RESOLVED:
+            return "RESOLVED";
+        case BundleEvent.STARTED:
+            return "STARTED";
+        case BundleEvent.STARTING:
+            return "Starting";
+        case BundleEvent.STOPPED:
+            return "STOPPED";
+        case BundleEvent.UNINSTALLED:
+        case 256: // Not sure why but this event is sent when a bundle is uninstalled
+            return "UNINSTALLED";
+        case BundleEvent.UNRESOLVED:
+            return "UNRESOLVED";
+        case BundleEvent.UPDATED:
+            return "UPDATED";
+        default:
+            return "unknown event type: " + type;
+        }
+    }
+    
+    private Collection<PersistenceProviderTracker> getTrackers(Bundle bundle) {
+        Collection<PersistenceProviderTracker> providerTrackers = trackers.get(bundle);
+        if (providerTrackers == null) {
+            providerTrackers = new ArrayList<>();
+            trackers.put(bundle, providerTrackers);
+        }
+        return providerTrackers;
+    }
+
+}
diff --git a/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceProviderTracker.java b/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceProviderTracker.java
new file mode 100644
index 0000000..673d96a
--- /dev/null
+++ b/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceProviderTracker.java
@@ -0,0 +1,156 @@
+/*
+ * 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 WARRANTIESOR 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.aries.jpa.container.impl;
+
+import java.util.Dictionary;
+
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.spi.PersistenceProvider;
+import javax.sql.DataSource;
+
+import org.apache.aries.jpa.container.parser.impl.PersistenceUnit;
+import org.apache.aries.jpa.container.weaving.impl.DummyDataSource;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Filter;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.jpa.EntityManagerFactoryBuilder;
+import org.osgi.util.tracker.ServiceTracker;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Tracks matching persistence providers for a persistence unit.
+ * If a provider is found:
+ * - an EntityManagerFactoryBuilder is installed
+ * - A DataSourceTracker is installed if the JtaDataSource refers to an OSGi service 
+ */
+public class PersistenceProviderTracker extends ServiceTracker<PersistenceProvider, StoredPerProvider> {
+    private static final String JAVAX_PERSISTENCE_PROVIDER = "javax.persistence.provider";
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(PersistenceProviderTracker.class);
+
+    private PersistenceUnit punit;
+
+    public PersistenceProviderTracker(BundleContext context, PersistenceUnit punit) {
+        super(context, createFilter(context, punit), null);
+        this.punit = punit;
+    }
+
+    private static Filter createFilter(BundleContext context, PersistenceUnit punit) {
+        String filter = null;
+        if (punit.getPersistenceProviderClassName() != null) {
+            filter = String.format("(&(objectClass=%s)(%s=%s))",
+                                   PersistenceProvider.class.getName(),
+                                   JAVAX_PERSISTENCE_PROVIDER,
+                                   punit.getPersistenceProviderClassName());
+        } else {
+            filter = String.format("(objectClass=%s)", PersistenceProvider.class.getName());
+        }
+
+        try {
+            return context.createFilter(filter);
+        } catch (InvalidSyntaxException e) {
+            throw new IllegalArgumentException(e);
+        }
+    }
+
+    @Override
+    public StoredPerProvider addingService(ServiceReference<PersistenceProvider> reference) {
+        String providerName = (String)reference.getProperty(JAVAX_PERSISTENCE_PROVIDER);
+        // FIXME should be set when creating the EMF was successful
+        if (punit.getPersistenceProviderClassName() == null) {
+            punit.setProviderClassName(providerName);
+        }
+        StoredPerProvider stored = new StoredPerProvider();
+        LOGGER.info("Found provider for " + punit.getPersistenceUnitName() + " " + punit.getPersistenceProviderClassName());
+        PersistenceProvider provider = context.getService(reference);
+
+        createAndCloseDummyEMF(provider);
+
+        stored.dsTracker = createDataSourceTracker(stored, provider, providerName);
+        EntityManagerFactoryBuilder emfBuilder = new AriesEntityManagerFactoryBuilder(provider, punit);
+        Dictionary<String, ?> props = ManagedEMF.createProperties(punit, punit.getBundle());
+        stored.reg = context.registerService(EntityManagerFactoryBuilder.class, emfBuilder , props);
+        return stored;
+    }
+
+    /**
+     * Create and close a dummy EMF to give the PersistenceProvider a chance to call
+     * punit.addTransformer(). This has to occur as early as possible as weaving needs
+     * to be done before the first entity class is loaded. So we can not wait till the
+     * real DataSource is found.
+     */
+    private void createAndCloseDummyEMF(PersistenceProvider provider) {
+        DataSource dummyDataSource = new DummyDataSource();
+        punit.setJtaDataSource(dummyDataSource);
+        punit.setNonJtaDataSource(dummyDataSource);
+        try {
+            EntityManagerFactory emf = provider.createContainerEntityManagerFactory(punit, null);
+            emf.close();
+        } catch (Exception e) {
+            LOGGER.warn(e.getMessage(), e);
+        }
+        punit.setJtaDataSource(null);
+        punit.setNonJtaDataSource(null);
+    }
+
+    private ServiceTracker<?, ?> createDataSourceTracker(StoredPerProvider stored, PersistenceProvider provider, String providerName) {
+        if (usesDataSource()) {
+            if (!usesDataSourceService()) {
+                LOGGER.warn("Persistence unit " + punit.getPersistenceUnitName() + " refers to a non OSGi service DataSource");
+                return null;
+            }
+            DataSourceTracker dsTracker = new DataSourceTracker(context, provider, punit);
+            dsTracker.open();
+            return dsTracker;
+        } else if (usesDSF()) {
+            DSFTracker dsfTracker = new DSFTracker(context, provider, punit);
+            dsfTracker.open();
+            return dsfTracker;
+        } else {
+            LOGGER.debug("Persistence unit " + punit.getPersistenceUnitName() + " does not refer a DataSource. "
+                         +"It can only be used with EntityManagerFactoryBuilder.");
+            return null;
+        }
+    }
+
+    private boolean usesDataSource() {
+        return punit.getJtaDataSourceName() != null || punit.getNonJtaDataSourceName() != null;
+    }
+
+    private boolean usesDSF() {
+        return DSFTracker.getDriverName(punit) != null;
+    }
+
+    private boolean usesDataSourceService() {
+        return punit.getJtaDataSourceName() != null && punit.getJtaDataSourceName().startsWith(DataSourceTracker.DS_PREFIX)
+            || punit.getNonJtaDataSourceName() != null && punit.getNonJtaDataSourceName().startsWith(DataSourceTracker.DS_PREFIX);
+    }
+
+    @Override
+    public void removedService(ServiceReference<PersistenceProvider> reference, StoredPerProvider stored) {
+        LOGGER.info("Lost provider for " + punit.getPersistenceUnitName() + " " + punit.getPersistenceProviderClassName());
+        if (stored.dsTracker != null) {
+            stored.dsTracker.close();
+        }
+        stored.reg.unregister();
+        super.removedService(reference, stored);
+    }
+}
diff --git a/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/StoredPerProvider.java b/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/StoredPerProvider.java
new file mode 100644
index 0000000..e190688
--- /dev/null
+++ b/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/StoredPerProvider.java
@@ -0,0 +1,28 @@
+/*
+ * 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 WARRANTIESOR 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.aries.jpa.container.impl;
+
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.jpa.EntityManagerFactoryBuilder;
+import org.osgi.util.tracker.ServiceTracker;
+
+public class StoredPerProvider {
+    ServiceTracker<?, ?> dsTracker;
+    ServiceRegistration<EntityManagerFactoryBuilder> reg;
+}
\ No newline at end of file
diff --git a/jpa-container/src/main/java/org/apache/aries/jpa/container/parser/impl/JPAAnnotationScanner.java b/jpa-container/src/main/java/org/apache/aries/jpa/container/parser/impl/JPAAnnotationScanner.java
new file mode 100644
index 0000000..71ef0e8
--- /dev/null
+++ b/jpa-container/src/main/java/org/apache/aries/jpa/container/parser/impl/JPAAnnotationScanner.java
@@ -0,0 +1,59 @@
+/*

+ * 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 WARRANTIESOR 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.aries.jpa.container.parser.impl;

+

+import java.util.ArrayList;

+import java.util.Collection;

+

+import javax.persistence.Embeddable;

+import javax.persistence.Entity;

+import javax.persistence.MappedSuperclass;

+

+import org.osgi.framework.Bundle;

+import org.osgi.framework.wiring.BundleWiring;

+

+@SuppressWarnings("deprecation")

+class JPAAnnotationScanner {

+    public static Collection<String> findJPAAnnotatedClasses(Bundle b) {

+        BundleWiring bw = b.adapt(BundleWiring.class);

+        Collection<String> resources = bw.listResources("/", "*.class", 

+            BundleWiring.LISTRESOURCES_LOCAL | BundleWiring.LISTRESOURCES_RECURSE);

+        

+        Collection<String> classes = new ArrayList<String>(); 

+        ClassLoader cl = new TempBundleDelegatingClassLoader(b, JPAAnnotationScanner.class.getClassLoader());

+        for(String s : resources) {

+          s = s.replace('/', '.').substring(0, s.length() - 6);

+          try {

+            Class<?> clazz = Class.forName(s, false, cl);

+            

+            if(clazz.isAnnotationPresent(Entity.class) ||

+               clazz.isAnnotationPresent(MappedSuperclass.class) ||

+               clazz.isAnnotationPresent(Embeddable.class)) {

+              classes.add(s);

+            }

+            

+          } catch (ClassNotFoundException cnfe) {

+            

+          } catch (NoClassDefFoundError ncdfe) {

+            

+          }

+        }

+        return classes;

+      }

+}

diff --git a/jpa-container/src/main/java/org/apache/aries/jpa/container/parser/impl/JPAHandler.java b/jpa-container/src/main/java/org/apache/aries/jpa/container/parser/impl/JPAHandler.java
new file mode 100644
index 0000000..1e70eed
--- /dev/null
+++ b/jpa-container/src/main/java/org/apache/aries/jpa/container/parser/impl/JPAHandler.java
@@ -0,0 +1,127 @@
+/*
+ * 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 WARRANTIESOR 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.aries.jpa.container.parser.impl;
+
+import java.util.Collection;
+import java.util.Stack;
+
+import javax.persistence.SharedCacheMode;
+import javax.persistence.ValidationMode;
+import javax.persistence.spi.PersistenceUnitTransactionType;
+
+import org.osgi.framework.Bundle;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * This code is responsible for parsing the persistence.xml into PersistenceUnits
+ */
+public class JPAHandler extends DefaultHandler {
+    /** The Persistence Units that we have parsed */
+    private final Stack<PersistenceUnit> persistenceUnits = new Stack<PersistenceUnit>();
+    /** The name of the current element */
+    private String elementName;
+    /** The version of the persistence.xml file */
+    /** A StringBuilder for caching the information from getCharacters */
+    private StringBuilder builder = new StringBuilder();
+    /** The bundle that contains this persistence descriptor */
+    private Bundle bundle;
+
+    /**
+     * Create a new JPA Handler for a bundle
+     * 
+     * @param bundle
+     */
+    public JPAHandler(Bundle bundle) {
+        this.bundle = bundle;
+    }
+
+    /**
+     * Collect up the characters, as element's characters may be split across multiple calls. Isn't SAX
+     * lovely...
+     */
+    @Override
+    public void characters(char[] ch, int start, int length) throws SAXException {
+        builder.append(ch, start, length);
+    }
+
+    @Override
+    public void startElement(String uri, String localName, String name, Attributes attributes)
+        throws SAXException {
+        // Do this setting first as we use it later.
+        elementName = (localName == null || "".equals(localName)) ? name : localName;
+
+        if ("persistence-unit".equals(elementName)) {
+            String tranTypeSt = attributes.getValue("transaction-type");
+            PersistenceUnitTransactionType tranType = tranTypeSt == null ? null : PersistenceUnitTransactionType.valueOf(tranTypeSt);
+            persistenceUnits.push(new PersistenceUnit(bundle, 
+                                                      attributes.getValue("name"), 
+                                                      tranType));
+        } else if ("exclude-unlisted-classes".equals(elementName))
+            persistenceUnits.peek().setExcludeUnlisted(true);
+        else if ("property".equals(elementName))
+            persistenceUnits.peek().addProperty(attributes.getValue("name"), attributes.getValue("value"));
+
+    }
+
+    @Override
+    public void endElement(String uri, String localName, String name) throws SAXException {
+        String s = builder.toString().trim();
+        // This step is VERY important, otherwise we pollute subsequent
+        // elements
+        builder = new StringBuilder();
+
+        if ("".equals(s))
+            return;
+
+        PersistenceUnit pu = persistenceUnits.peek();
+
+        if ("provider".equals(elementName))
+            pu.setProviderClassName(s);
+        else if ("jta-data-source".equals(elementName))
+            pu.setJtaDataSourceName(s);
+        else if ("non-jta-data-source".equals(elementName))
+            pu.setNonJtaDataSourceName(s);
+        else if ("class".equals(elementName))
+            pu.addClassName(s);
+        else if ("exclude-unlisted-classes".equals(elementName))
+            pu.setExcludeUnlisted(Boolean.parseBoolean(s));
+        else if ("shared-cache-mode".equals(elementName))
+            pu.setSharedCacheMode(SharedCacheMode.valueOf(s));
+          else if ("validation-mode".equals(elementName))
+            pu.setValidationMode(ValidationMode.valueOf(s));
+    }
+
+    @Override
+    public void error(SAXParseException spe) throws SAXException {
+        // We throw this exception to be caught further up and logged
+        // as an error there
+        throw spe;
+    }
+
+    /**
+     * @return The collection of persistence units that we have parsed
+     */
+    public Collection<PersistenceUnit> getPersistenceUnits() {
+        return persistenceUnits;
+    }
+
+}
diff --git a/jpa-container/src/main/java/org/apache/aries/jpa/container/parser/impl/PersistenceUnit.java b/jpa-container/src/main/java/org/apache/aries/jpa/container/parser/impl/PersistenceUnit.java
new file mode 100644
index 0000000..0765dda
--- /dev/null
+++ b/jpa-container/src/main/java/org/apache/aries/jpa/container/parser/impl/PersistenceUnit.java
@@ -0,0 +1,229 @@
+/*
+ * 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 WARRANTIESOR 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.aries.jpa.container.parser.impl;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.persistence.SharedCacheMode;
+import javax.persistence.ValidationMode;
+import javax.persistence.spi.ClassTransformer;
+import javax.persistence.spi.PersistenceUnitInfo;
+import javax.persistence.spi.PersistenceUnitTransactionType;
+import javax.sql.DataSource;
+
+import org.apache.aries.jpa.container.weaving.impl.TransformerRegistry;
+import org.apache.aries.jpa.container.weaving.impl.TransformerRegistrySingleton;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.wiring.BundleWiring;
+import org.osgi.service.packageadmin.PackageAdmin;
+
+public class PersistenceUnit implements PersistenceUnitInfo {
+
+    private Bundle bundle;
+    private ClassLoader classLoader;
+    private Set<String> classNames;
+    private boolean excludeUnlisted;
+    private DataSource jtaDataSource;
+    private String jtaDataSourceName;
+    private DataSource nonJtaDataSource;
+    private String nonJtaDataSourceName;
+    private String persistenceProviderClassName;
+    private String persistenceUnitName;
+    private String persistenceXMLSchemaVersion;
+    private Properties props;
+    private SharedCacheMode sharedCacheMode = SharedCacheMode.UNSPECIFIED;
+    private PersistenceUnitTransactionType transactionType;
+    private ValidationMode validationMode = ValidationMode.NONE;
+
+    public PersistenceUnit(Bundle bundle, String persistenceUnitName,
+                           PersistenceUnitTransactionType transactionType) {
+        this.bundle = bundle;
+        this.persistenceUnitName = persistenceUnitName;
+        this.transactionType = transactionType;
+        this.props = new Properties();
+        this.classLoader = bundle.adapt(BundleWiring.class).getClassLoader();
+        this.classNames = new HashSet<>();
+    }
+
+    public void addClassName(String className) {
+        this.classNames.add(className);
+    }
+
+    public void addProperty(String name, String value) {
+        props.put(name, value);
+    }
+
+    @Override
+    public void addTransformer(ClassTransformer transformer) {
+        TransformerRegistry reg = TransformerRegistrySingleton.get();
+        reg.addTransformer(bundle, transformer);
+    }
+
+    @Override
+    public boolean excludeUnlistedClasses() {
+        return this.excludeUnlisted;
+    }
+
+    public Bundle getBundle() {
+        return bundle;
+    }
+
+    @Override
+    public ClassLoader getClassLoader() {
+        return this.classLoader;
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public List<URL> getJarFileUrls() {
+        return Collections.EMPTY_LIST;
+    }
+
+    @Override
+    public DataSource getJtaDataSource() {
+        return this.jtaDataSource;
+    }
+
+    public String getJtaDataSourceName() {
+        return jtaDataSourceName;
+    }
+
+    @Override
+    public List<String> getManagedClassNames() {
+        ArrayList<String> names = new ArrayList<>();
+        names.addAll(classNames);
+        return names;
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public List<String> getMappingFileNames() {
+        return Collections.EMPTY_LIST;
+    }
+
+    public String getName() {
+        return persistenceUnitName;
+    }
+
+    @Override
+    public ClassLoader getNewTempClassLoader() {
+        return new TempBundleDelegatingClassLoader(bundle, classLoader);
+    }
+
+    @Override
+    public DataSource getNonJtaDataSource() {
+        return this.nonJtaDataSource;
+    }
+
+    public String getNonJtaDataSourceName() {
+        return nonJtaDataSourceName;
+    }
+
+    @Override
+    public String getPersistenceProviderClassName() {
+        return this.persistenceProviderClassName;
+    }
+
+    @Override
+    public String getPersistenceUnitName() {
+        return this.persistenceUnitName;
+    }
+
+    @Override
+    public URL getPersistenceUnitRootUrl() {
+        return bundle.getResource("/");
+    }
+
+    @Override
+    public String getPersistenceXMLSchemaVersion() {
+        return this.persistenceXMLSchemaVersion;
+    }
+
+    @Override
+    public Properties getProperties() {
+        return this.props;
+    }
+
+    @Override
+    public SharedCacheMode getSharedCacheMode() {
+        return this.sharedCacheMode;
+    }
+
+    @Override
+    public PersistenceUnitTransactionType getTransactionType() {
+        return transactionType;
+    }
+
+    @Override
+    public ValidationMode getValidationMode() {
+        return this.validationMode;
+    }
+
+    public boolean isExcludeUnlisted() {
+        return excludeUnlisted;
+    }
+
+    public void setExcludeUnlisted(boolean excludeUnlisted) {
+        this.excludeUnlisted = excludeUnlisted;
+    }
+
+    public void setJtaDataSource(DataSource jtaDataSource) {
+        this.jtaDataSource = jtaDataSource;
+    }
+
+    public void setJtaDataSourceName(String jtaDataSourceName) {
+        this.jtaDataSourceName = jtaDataSourceName;
+    }
+
+    public void setNonJtaDataSource(DataSource nonJtaDataSource) {
+        this.nonJtaDataSource = nonJtaDataSource;
+    }
+
+    public void setNonJtaDataSourceName(String nonJtaDataSourceName) {
+        this.nonJtaDataSourceName = nonJtaDataSourceName;
+    }
+
+    public void setProviderClassName(String providerClassName) {
+        this.persistenceProviderClassName = providerClassName;
+    }
+
+    public void setSharedCacheMode(SharedCacheMode sharedCacheMode) {
+        this.sharedCacheMode = sharedCacheMode;
+    }
+
+    public void setValidationMode(ValidationMode validationMode) {
+        this.validationMode = validationMode;
+    }
+
+    public void addAnnotated(PackageAdmin packageAdmin) {
+        if (!excludeUnlistedClasses()) {
+            Collection<String> detected = JPAAnnotationScanner.findJPAAnnotatedClasses(bundle);
+            for (String name : detected) {
+                addClassName(name);
+            }
+        }
+    }
+}
diff --git a/jpa-container/src/main/java/org/apache/aries/jpa/container/parser/impl/PersistenceUnitParser.java b/jpa-container/src/main/java/org/apache/aries/jpa/container/parser/impl/PersistenceUnitParser.java
new file mode 100644
index 0000000..bae654e
--- /dev/null
+++ b/jpa-container/src/main/java/org/apache/aries/jpa/container/parser/impl/PersistenceUnitParser.java
@@ -0,0 +1,187 @@
+/*
+ * 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.aries.jpa.container.parser.impl;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Dictionary;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.jar.JarEntry;
+import java.util.jar.JarInputStream;
+
+import javax.persistence.spi.PersistenceUnitTransactionType;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.osgi.framework.Bundle;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This helper can be used to locate persistence.xml files in a bundle
+ */
+public class PersistenceUnitParser {
+    private static final String DEFAULT_PERSISTENCE_LOCATION = "META-INF/persistence.xml";
+    private static final Logger _logger = LoggerFactory.getLogger("org.apache.aries.jpa.container");
+    public static final String PERSISTENCE_UNIT_HEADER = "Meta-Persistence";
+
+    /**
+     * This method locates persistence descriptor files based on a combination of the default location
+     * "META-INF/persistence.xml" and the Meta-Persistence header. Note that getEntry is used to ensure we do
+     * not alter the state of the bundle Note also that web application bundles will never return persistence
+     * descriptors
+     * @param context 
+     * 
+     * @param bundle The bundle to search
+     * @param packageAdmin 
+     * @return
+     */
+    public static Collection<PersistenceUnit> getPersistenceUnits(Bundle bundle) {
+        Collection<PersistenceUnit> punits = new ArrayList<PersistenceUnit>();
+        Dictionary<String, String> headers = bundle.getHeaders();
+        String metaPersistence = headers.get(PERSISTENCE_UNIT_HEADER);
+
+        Set<String> locations = new HashSet<String>();
+        if (metaPersistence == null) {
+            return punits;
+        }
+
+        if (!metaPersistence.isEmpty()) {
+            // Split apart the header to get the individual entries
+            for (String s : metaPersistence.split(",")) {
+                locations.add(s.trim());
+            }
+        }
+        
+        if (!locations.contains(DEFAULT_PERSISTENCE_LOCATION)) {
+            locations.add(DEFAULT_PERSISTENCE_LOCATION);
+        }
+
+        // Find the file and add it to our list
+        for (String location : locations) {
+            try {
+                InputStream is = locateFile(bundle, location);
+                if (is != null) {
+                    parse(bundle, location, is, punits);
+                }
+            } catch (Exception e) {
+                _logger.error("exception.while.locating.descriptor", e);
+                return Collections.emptySet();
+            }
+        }
+        
+        return punits;
+    }
+
+    private static void parse(Bundle bundle, String location, InputStream is, Collection<PersistenceUnit> punits) {
+        SAXParserFactory parserFactory = SAXParserFactory.newInstance();
+        try {
+            SAXParser parser = parserFactory.newSAXParser();
+            JPAHandler handler = new JPAHandler(bundle);
+            parser.parse(is, handler);
+            punits.addAll(handler.getPersistenceUnits());
+//            for (PersistenceUnit punit : punits) {
+                //validate(punit);
+//            }
+        } catch (Exception e) {
+            throw new RuntimeException("persistence.description.parse.error", e);
+        } finally {
+            safeClose(is);
+        }
+    }
+
+    private static void validate(PersistenceUnit punit) {
+        if (punit.getTransactionType() == null) {
+            throw new IllegalArgumentException("No transaction type specified for persistence unit " + punit.getName());
+        }
+        if (punit.getTransactionType() == PersistenceUnitTransactionType.JTA) {
+            if (punit.getJtaDataSourceName() == null) {
+                throw new IllegalArgumentException("Must specify jta-data-source for persistence unit " + punit.getName());
+            }
+        }
+        if (punit.getTransactionType() == PersistenceUnitTransactionType.RESOURCE_LOCAL) {
+            if (punit.getNonJtaDataSourceName() == null) {
+                throw new IllegalArgumentException("Must specify non-jta-data-source for persistence unit " + punit.getName());
+            }
+        }
+    }
+
+    private static void safeClose(InputStream is) {
+        if (is != null) {
+            try {
+                is.close();
+            } catch (IOException e) {
+                // No logging necessary, just consume
+            }
+        }
+    }
+
+    /**
+     * Locate a persistence descriptor file in a bundle based on a String name.
+     * 
+     * @param bundle
+     * @param persistenceXmlFiles
+     * @param jarLocation
+     * @throws IOException
+     */
+    private static InputStream locateFile(Bundle bundle, String location) throws IOException {
+        // There is nothing for an empty location
+        InputStream is = null;
+        if ("".equals(location)) {
+            return null;
+        }
+
+        // If there is a '!' then we have to look in a jar
+        int bangIndex = location.indexOf('!');
+        // No '!', getEntry will do
+        if (bangIndex == -1) {
+            URL url = bundle.getEntry(location);
+
+            if (url != null)
+                is = url.openStream();
+
+        } else {
+            // There was a '!', find the jar
+            URL url = bundle.getEntry(location.substring(0, bangIndex));
+
+            if (url != null) {
+                // Remember to trim off the "!/"
+                String toLocate = location.substring(bangIndex + 2);
+
+                @SuppressWarnings("resource")
+                JarInputStream jis = new JarInputStream(url.openStream());
+                JarEntry entry = jis.getNextJarEntry();
+
+                while (entry != null) {
+                    if (entry.getName().equals(toLocate)) {
+                        is = jis;
+                        break;
+                    }
+                    entry = jis.getNextJarEntry();
+                }
+            }
+        }
+        return is;
+    }
+}
diff --git a/jpa-container/src/main/java/org/apache/aries/jpa/container/parser/impl/TempBundleDelegatingClassLoader.java b/jpa-container/src/main/java/org/apache/aries/jpa/container/parser/impl/TempBundleDelegatingClassLoader.java
new file mode 100644
index 0000000..4c0a293
--- /dev/null
+++ b/jpa-container/src/main/java/org/apache/aries/jpa/container/parser/impl/TempBundleDelegatingClassLoader.java
@@ -0,0 +1,199 @@
+/*
+ * 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 WARRANTIESOR 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.aries.jpa.container.parser.impl;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.UndeclaredThrowableException;
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.util.Deque;
+import java.util.Enumeration;
+import java.util.LinkedList;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.wiring.BundleRevision;
+import org.osgi.framework.wiring.BundleWire;
+import org.osgi.framework.wiring.BundleWiring;
+
+/**
+ * This is a simple temporary ClassLoader that delegates to the Bundle,
+ * but does not call loadClass. It is used by the PersistenceUnitInfo
+ */
+public class TempBundleDelegatingClassLoader extends ClassLoader {
+
+  private static final boolean CONTEXT_TRACKING_ENABLED; 
+  
+  static {
+	boolean enabled = true;
+    try {
+    	Class.forName("org.osgi.framework.wiring.BundleWiring");
+    } catch (ClassNotFoundException cnfe) {
+    	enabled = false;
+    }
+    CONTEXT_TRACKING_ENABLED = enabled;
+  }
+	
+  private final Bundle bundle;
+
+  private final ThreadLocal<Deque<Bundle>> currentLoadingBundle = new ThreadLocal<Deque<Bundle>>(){
+	@Override
+	protected Deque<Bundle> initialValue() {
+		return new LinkedList<Bundle>();
+	}
+  };
+  
+  public TempBundleDelegatingClassLoader(Bundle b, ClassLoader parent) {
+    super(parent);
+    bundle = b;
+  }
+  
+  @Override
+  protected Class<?> findClass(String className) throws ClassNotFoundException {
+    String classResName = className.replace('.', '/').concat(".class");
+    
+    //Don't use loadClass, just load the bytes and call defineClass
+    Bundle currentContext = currentLoadingBundle.get().peek();
+    InputStream is;
+    if(currentContext == null) {
+      is = getResourceAsStream(classResName);
+    } else {
+      is = getResourceInBundleAsStream(classResName, currentContext);
+    }
+    
+    if(is == null)
+      throw new ClassNotFoundException(className);
+    
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    
+    byte[] buff = new byte[4096];
+    try {
+      try {
+        int read = is.read(buff);
+        while(read >0) {
+          baos.write(buff, 0, read);
+          read = is.read(buff);
+        }
+      }finally {
+        is.close();
+      }
+    } catch (IOException ioe) {
+      throw new ClassNotFoundException(className, ioe);
+    } 
+    
+    buff = baos.toByteArray();
+
+    if(CONTEXT_TRACKING_ENABLED) {
+    	updateContext(currentContext, className);
+    }
+    try {
+    	return defineClass(className, buff, 0, buff.length);
+    } finally {
+    	if(CONTEXT_TRACKING_ENABLED) {
+        	currentLoadingBundle.get().pop();
+        }
+    }
+  }
+
+  private void updateContext(Bundle currentContext, String className) {
+	if(currentContext == null) {
+		currentContext = bundle;
+	}
+	
+	int idx = className.lastIndexOf('.');
+	String packageName = (idx == -1) ? "" : className.substring(0, idx);
+	
+	Bundle contextToSet = currentContext;
+	
+	BundleWiring wiring = currentContext.adapt(BundleWiring.class);
+	for(BundleWire wire : wiring.getRequiredWires(BundleRevision.PACKAGE_NAMESPACE)) {
+	  if(wire.getCapability().getAttributes().get(BundleRevision.PACKAGE_NAMESPACE).equals(packageName)) {
+	    contextToSet = wire.getProviderWiring().getBundle();
+	    break;
+	  }
+	}
+	currentLoadingBundle.get().push(contextToSet);
+  }
+
+@Override
+  protected URL findResource(final String resName)
+  {
+    return findResourceInBundle(resName, bundle);
+  }
+  
+  protected URL findResourceInBundle(final String resName, final Bundle inBundle)
+  {
+    //Bundle.getResource requires privileges that the client may not have but we need
+    //use a doPriv so that only this bundle needs the privileges
+    return AccessController.doPrivileged(new PrivilegedAction<URL>() {
+
+      public URL run()
+      {
+        return inBundle.getResource(resName);
+      }
+    });
+  }
+
+  private InputStream getResourceInBundleAsStream(final String resName, final Bundle inBundle) {
+	  URL url = findResourceInBundle(resName, inBundle);
+	  try {
+		return (url == null) ? null : url.openStream();
+	} catch (IOException e) {
+		return null;
+	}
+  }
+  
+  @Override
+  protected Enumeration<URL> findResources(final String resName) throws IOException
+  {
+    return findResourcesInBundle(resName, bundle);
+  }
+  
+  protected Enumeration<URL> findResourcesInBundle(final String resName, final Bundle inBundle) throws IOException
+  {
+    Enumeration<URL> resources = null;
+    try {
+      //Bundle.getResources requires privileges that the client may not have but we need
+      //use a doPriv so that only this bundle needs the privileges
+      resources = AccessController.doPrivileged(new PrivilegedExceptionAction<Enumeration<URL>>() {
+
+        public Enumeration<URL> run() throws IOException
+        {
+          return inBundle.getResources(resName);
+        }
+      });
+    } catch(PrivilegedActionException pae) {
+      //thrownException can never be a RuntimeException, as that would escape
+      //the doPriv normally
+      Exception thrownException = pae.getException();
+      if (thrownException instanceof IOException) {
+        throw (IOException)thrownException;
+      } else {
+        // This code should never get called, but we don't
+        // want to gobble the exception if we see it.
+        throw new UndeclaredThrowableException(thrownException);
+      }
+    }
+    return resources;
+  }
+}
diff --git a/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/DummyDataSource.java b/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/DummyDataSource.java
new file mode 100644
index 0000000..6d57359
--- /dev/null
+++ b/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/DummyDataSource.java
@@ -0,0 +1,97 @@
+package org.apache.aries.jpa.container.weaving.impl;
+
+import java.io.PrintWriter;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
+
+import javax.sql.DataSource;
+
+/**
+ * DummyDataSource to be able to create the EMF before DataSource is ready
+ */
+public final class DummyDataSource implements DataSource {
+    
+    /**
+     * Simply tries to avoid that calling code runs into NPE
+     */
+    private final class DummyHandler implements InvocationHandler {
+        public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+            ClassLoader classLoader = this.getClass().getClassLoader();
+            if (method.getReturnType() == DatabaseMetaData.class) {
+                Class<?>[] ifAr = new Class[] {
+                    DatabaseMetaData.class
+                };
+                return Proxy.newProxyInstance(classLoader, ifAr, this);
+            }
+            if (method.getReturnType() == int.class) {
+                return new Integer(0);
+            }
+            if (method.getReturnType() == boolean.class) {
+                return new Boolean(false);
+            }
+            if (method.getReturnType() == String.class) {
+                return "";
+            }
+            if (method.getReturnType() == ResultSet.class) {
+                Class<?>[] ifAr = new Class[] {
+                    ResultSet.class
+                };
+                return Proxy.newProxyInstance(classLoader, ifAr, this);
+            }
+            return null;
+        }
+    }
+    
+    @Override
+    public <T> T unwrap(Class<T> iface) throws SQLException {
+        return null;
+    }
+
+    @Override
+    public boolean isWrapperFor(Class<?> iface) throws SQLException {
+        return false;
+    }
+
+    @Override
+    public void setLoginTimeout(int seconds) throws SQLException {
+    }
+
+    @Override
+    public void setLogWriter(PrintWriter out) throws SQLException {
+    }
+
+    @Override
+    public java.util.logging.Logger getParentLogger() throws SQLFeatureNotSupportedException {
+        return null;
+    }
+
+    @Override
+    public int getLoginTimeout() throws SQLException {
+        return 0;
+    }
+
+    @Override
+    public PrintWriter getLogWriter() throws SQLException {
+        return null;
+    }
+
+    @Override
+    public Connection getConnection(String username, String password) throws SQLException {
+        InvocationHandler handler = new DummyHandler();
+        ClassLoader classLoader = this.getClass().getClassLoader();
+        return (Connection)Proxy.newProxyInstance(classLoader, new Class[] {
+            Connection.class
+        }, handler);
+    }
+
+    @Override
+    public Connection getConnection() throws SQLException {
+        return getConnection(null, null);
+    }
+}
diff --git a/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/JPAWeavingHook.java b/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/JPAWeavingHook.java
new file mode 100644
index 0000000..9992e2c
--- /dev/null
+++ b/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/JPAWeavingHook.java
@@ -0,0 +1,134 @@
+/*

+ * 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 WARRANTIESOR 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.aries.jpa.container.weaving.impl;

+

+import java.util.ArrayList;

+import java.util.Collection;

+import java.util.Collections;

+import java.util.HashMap;

+import java.util.LinkedHashSet;

+import java.util.Map;

+

+import javax.persistence.spi.ClassTransformer;

+

+import org.osgi.framework.Bundle;

+import org.osgi.framework.hooks.weaving.WeavingException;

+import org.osgi.framework.hooks.weaving.WeavingHook;

+import org.osgi.framework.hooks.weaving.WovenClass;

+import org.osgi.framework.wiring.BundleWiring;

+import org.slf4j.Logger;

+import org.slf4j.LoggerFactory;

+

+/**

+ * This weaving hook delegates to any registered {@link ClassTransformer} instances for a given bundle

+ */

+public class JPAWeavingHook implements WeavingHook, TransformerRegistry {

+    private static final Logger LOGGER = LoggerFactory.getLogger(JPAWeavingHook.class);

+

+    /**

+     * This constructor should not be called directly, the {@link JPAWeavingHookFactory} should be used to

+     * ensure that Weaving support is available.

+     */

+    JPAWeavingHook() {

+    }

+

+    /**

+     * With luck we will only have one persistence unit per bundle, but if we don't we'll need to call them

+     * until one of them does a transform or we run out.

+     */

+    private final Map<Bundle, LinkedHashSet<ClassTransformer>> registeredTransformers = new HashMap<Bundle, LinkedHashSet<ClassTransformer>>();

+

+    public void weave(WovenClass wovenClass) {

+        BundleWiring wiring = wovenClass.getBundleWiring();

+        Bundle bundle = wiring.getBundle();

+        ClassLoader cl = wiring.getClassLoader();

+        Collection<ClassTransformer> transformersToTry = getTransformers(bundle);

+        if (transformersToTry.size() == 0 && wovenClass.getClassName().endsWith("Car")) {

+            LOGGER.error("Loading " + wovenClass.getClassName() + " before transformer is present");

+            //for (StackTraceElement el : Thread.currentThread().getStackTrace()) {

+//                LOGGER.info(el.toString());

+//            }

+        }

+        for (ClassTransformer transformer : transformersToTry) {

+

+            if (transformClass(wovenClass, cl, transformer)) {

+                LOGGER.info("Weaving " + wovenClass.getClassName() + " using " + transformer.getClass().getName());

+                break;

+            };

+        }

+    }

+

+    @SuppressWarnings("unchecked")

+    private synchronized Collection<ClassTransformer> getTransformers(Bundle bundle) {

+        LinkedHashSet<ClassTransformer> transformers = registeredTransformers.get(bundle);

+        return transformers != null ? new ArrayList<ClassTransformer>(transformers) : Collections.EMPTY_LIST;

+    }

+

+    private boolean transformClass(WovenClass wovenClass, ClassLoader cl, ClassTransformer transformer)

+        throws ThreadDeath, OutOfMemoryError {

+        try {

+            byte[] result = transformer

+                .transform(cl, 

+                           wovenClass.getClassName(),

+                           wovenClass.getDefinedClass(), 

+                           wovenClass.getProtectionDomain(),

+                           wovenClass.getBytes());

+            if (result != null) {

+                wovenClass.setBytes(result);

+                wovenClass.getDynamicImports().add("org.eclipse.persistence.*");

+                wovenClass.getDynamicImports().add("org.apache.openjpa.*");

+                

+                return true;

+            }

+        } catch (Throwable t) {

+            if (t instanceof ThreadDeath)

+                throw (ThreadDeath)t;

+            else if (t instanceof OutOfMemoryError)

+                throw (OutOfMemoryError)t;

+            else {

+                Bundle b = wovenClass.getBundleWiring().getBundle();

+                String msg = String.format("Weaving failure", wovenClass.getClassName(),

+                                           b.getSymbolicName(), b.getVersion(), transformer);

+                throw new WeavingException(msg, t);

+            }

+        }

+        return false;

+    }

+

+    public synchronized void addTransformer(Bundle pBundle, ClassTransformer transformer) {

+        LOGGER.info("Adding transformer " + transformer.getClass().getName());

+        LinkedHashSet<ClassTransformer> transformers = registeredTransformers.get(pBundle);

+        if (transformers == null) {

+            transformers = new LinkedHashSet<ClassTransformer>();

+            registeredTransformers.put(pBundle, transformers);

+        }

+        transformers.add(transformer);

+    }

+

+    public synchronized void removeTransformer(Bundle pBundle, ClassTransformer transformer) {

+        LinkedHashSet<ClassTransformer> set = registeredTransformers.get(pBundle);

+        if (set == null || !set.remove(transformer)) {

+            throw new IllegalStateException("Transformer " + transformer + " not registered");

+        }

+        if (set.isEmpty()) {

+            registeredTransformers.remove(pBundle);

+        }

+    }

+

+}

diff --git a/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/TransformerRegistry.java b/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/TransformerRegistry.java
new file mode 100644
index 0000000..b499cc2
--- /dev/null
+++ b/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/TransformerRegistry.java
@@ -0,0 +1,47 @@
+/*

+ * 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 WARRANTIESOR 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.aries.jpa.container.weaving.impl;

+

+import javax.persistence.spi.ClassTransformer;

+

+import org.osgi.framework.Bundle;

+

+/**

+ * {@link ClassTransformer} instances should be registered with the

+ * instance of this interface returned by {@link TransformerRegistrySingleton#getTransformerRegistry()}

+ */

+public interface TransformerRegistry {

+

+  /**

+   * Register a new transformer with the WeavingHook

+   * 

+   * @param pBundle  The persistence bundle to weave

+   * @param transformer  The transformer to weave with

+   * @param provider The provider to provide packages from

+   */

+  public void addTransformer(Bundle pBundle, ClassTransformer transformer);

+  

+  

+  /**

+   * Remove a given transformer from this weaving hook. This must be 

+   * @param pBundle

+   * @param transformer

+   */

+  public void removeTransformer(Bundle pBundle, ClassTransformer transformer);

+}

diff --git a/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/TransformerRegistrySingleton.java b/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/TransformerRegistrySingleton.java
new file mode 100644
index 0000000..8e49b8a
--- /dev/null
+++ b/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/TransformerRegistrySingleton.java
@@ -0,0 +1,34 @@
+/*

+ * 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 WARRANTIESOR 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.aries.jpa.container.weaving.impl;

+

+

+/**

+ * This class is used to get hold of the active {@link TransformerRegistry} for this bundle.

+ */

+public class TransformerRegistrySingleton {

+    private static TransformerRegistry _instance;

+

+    public static TransformerRegistry get() {

+        if (_instance == null) {

+            _instance = new JPAWeavingHook();

+        }

+        return _instance;

+    }

+}

diff --git a/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/WrappingTransformer.java b/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/WrappingTransformer.java
new file mode 100644
index 0000000..4c2918d
--- /dev/null
+++ b/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/WrappingTransformer.java
@@ -0,0 +1,95 @@
+/*

+ * 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 WARRANTIESOR 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.aries.jpa.container.weaving.impl;

+

+import java.lang.instrument.IllegalClassFormatException;

+import java.security.ProtectionDomain;

+import java.util.Collection;

+import java.util.HashSet;

+

+import javax.persistence.spi.ClassTransformer;

+

+import org.osgi.framework.Bundle;

+import org.osgi.framework.Constants;

+import org.osgi.framework.ServiceReference;

+import org.osgi.framework.wiring.BundleCapability;

+import org.osgi.framework.wiring.BundleRevision;

+import org.osgi.framework.wiring.BundleWiring;

+

+class WrappingTransformer implements ClassTransformer {

+    private final ClassTransformer delegate;

+    private final Collection<String> packageImportsToAdd = new HashSet<String>();

+

+    public WrappingTransformer(ClassTransformer delegate, ServiceReference<?> persistenceProvider) {

+

+        if (delegate == null)

+            throw new NullPointerException("Transformer delegate may not be null");

+

+        if (persistenceProvider == null) {

+            throw new NullPointerException("PersistenceProvider may not be null");

+        }

+

+        this.delegate = delegate;

+

+        Object packages = persistenceProvider.getProperty("org.apache.aries.jpa.container.weaving.packages");

+

+        if (packages instanceof String[]) {

+            for (String s : (String[])packages) {

+                packageImportsToAdd.add(s);

+            }

+        } else {

+            Bundle provider = persistenceProvider.getBundle();

+            String suffix = ";" + Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE + "=" + provider.getSymbolicName()

+                            + ";" + Constants.BUNDLE_VERSION_ATTRIBUTE + "=" + provider.getVersion();

+

+            BundleRevision br = provider.adapt(BundleWiring.class).getRevision();

+            for (BundleCapability bc : br.getDeclaredCapabilities(BundleRevision.PACKAGE_NAMESPACE)) {

+                packageImportsToAdd.add(bc.getAttributes().get(BundleRevision.PACKAGE_NAMESPACE) + suffix);

+            }

+        }

+    }

+

+    public WrappingTransformer(ClassTransformer transformer) {

+        delegate = transformer;

+    }

+

+    public byte[] transform(ClassLoader arg0, String arg1, Class<?> arg2, ProtectionDomain arg3, byte[] arg4)

+        throws IllegalClassFormatException {

+        return delegate.transform(arg0, arg1, arg2, arg3, arg4);

+    }

+

+    public Collection<String> getPackagesToAdd() {

+        return packageImportsToAdd;

+    }

+

+    public int hashCode() {

+        return delegate.hashCode();

+    }

+

+    public boolean equals(Object o) {

+        if (o instanceof WrappingTransformer)

+            return delegate == ((WrappingTransformer)o).delegate;

+

+        return false;

+    }

+

+    public String toString() {

+        return "Transformer: " + delegate.toString() + " Packages to add: " + packageImportsToAdd;

+    }

+}

diff --git a/jpa-container/src/test/java/org/apache/aries/jpa/container/impl/DataSourceTrackerTest.java b/jpa-container/src/test/java/org/apache/aries/jpa/container/impl/DataSourceTrackerTest.java
new file mode 100644
index 0000000..fda0407
--- /dev/null
+++ b/jpa-container/src/test/java/org/apache/aries/jpa/container/impl/DataSourceTrackerTest.java
@@ -0,0 +1,60 @@
+/*
+ * 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 WARRANTIESOR 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.aries.jpa.container.impl;
+
+import static org.mockito.Mockito.atLeastOnce;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import javax.persistence.spi.PersistenceUnitTransactionType;
+
+import org.apache.aries.jpa.container.impl.DataSourceTracker;
+import org.apache.aries.jpa.container.parser.impl.PersistenceUnit;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.InvalidSyntaxException;
+
+public class DataSourceTrackerTest {
+    
+    @Test
+    public void testCreateFilterFull() throws InvalidSyntaxException {
+        PersistenceUnit punit = mock(PersistenceUnit.class);
+        when(punit.getJtaDataSourceName()).thenReturn("osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=tasklist)");
+        when(punit.getTransactionType()).thenReturn(PersistenceUnitTransactionType.JTA);
+        BundleContext context = mock(BundleContext.class);
+        
+        DataSourceTracker.createFilter(context, punit);
+
+        verify(context, atLeastOnce()).createFilter(Mockito.eq("(&(objectClass=javax.sql.DataSource)(osgi.jndi.service.name=tasklist))"));
+    }
+    
+    @Test
+    public void testCreateFilterSimple() throws InvalidSyntaxException {
+        PersistenceUnit punit = mock(PersistenceUnit.class);
+        when(punit.getJtaDataSourceName()).thenReturn("tasklist");
+        when(punit.getTransactionType()).thenReturn(PersistenceUnitTransactionType.JTA);
+        BundleContext context = mock(BundleContext.class);
+        
+        DataSourceTracker.createFilter(context, punit);
+
+        verify(context, atLeastOnce()).createFilter(Mockito.eq("(&(objectClass=javax.sql.DataSource)(osgi.jndi.service.name=tasklist))"));
+    }
+}
diff --git a/jpa-container/src/test/java/org/apache/aries/jpa/container/impl/PropsConfigurationTest.java b/jpa-container/src/test/java/org/apache/aries/jpa/container/impl/PropsConfigurationTest.java
new file mode 100644
index 0000000..dc8042e
--- /dev/null
+++ b/jpa-container/src/test/java/org/apache/aries/jpa/container/impl/PropsConfigurationTest.java
@@ -0,0 +1,97 @@
+/*

+ * 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 WARRANTIESOR 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.aries.jpa.container.impl;

+

+import static org.mockito.Mockito.atLeastOnce;

+import static org.mockito.Mockito.mock;

+import static org.mockito.Mockito.verify;

+import static org.mockito.Mockito.when;

+

+import java.util.Dictionary;

+import java.util.Hashtable;

+import java.util.Map;

+

+import javax.persistence.EntityManagerFactory;

+import javax.persistence.spi.PersistenceProvider;

+import javax.persistence.spi.PersistenceUnitInfo;

+import javax.persistence.spi.PersistenceUnitTransactionType;

+

+import org.apache.aries.jpa.container.impl.ManagedEMF;

+import org.junit.Test;

+import org.mockito.Mockito;

+import org.osgi.framework.Bundle;

+import org.osgi.framework.BundleContext;

+import org.osgi.framework.InvalidSyntaxException;

+import org.osgi.framework.Version;

+import org.osgi.service.cm.ConfigurationException;

+

+public class PropsConfigurationTest {

+

+    @SuppressWarnings({

+        "unchecked", "rawtypes"

+    })

+    @Test

+    public void testEmfWithoutProps() throws InvalidSyntaxException, ConfigurationException {

+        PersistenceUnitInfo punit = mock(PersistenceUnitInfo.class);

+        when(punit.getPersistenceUnitName()).thenReturn("test-props");

+        when(punit.getPersistenceProviderClassName())

+            .thenReturn("org.eclipse.persistence.jpa.PersistenceProvider");

+        when(punit.getTransactionType()).thenReturn(PersistenceUnitTransactionType.JTA);

+        BundleContext context = mock(BundleContext.class);

+        Bundle bundle = mock(Bundle.class);

+        when(bundle.getBundleContext()).thenReturn(context);

+        when(bundle.getVersion()).thenReturn(new Version("4.3.1"));

+        PersistenceProvider provider = mock(PersistenceProvider.class);

+

+        ManagedEMF emf = new ManagedEMF(context, bundle, provider, punit);

+        emf.updated(null);

+        emf.close();

+        verify(provider, atLeastOnce()).createContainerEntityManagerFactory(Mockito.eq(punit),

+                                                                            Mockito.eq((Map)null));

+        verify(context, atLeastOnce()).registerService(Mockito.eq(EntityManagerFactory.class),

+                                                       Mockito.any(EntityManagerFactory.class),

+                                                       Mockito.any(Dictionary.class));

+    }

+

+    @SuppressWarnings("unchecked")

+    @Test

+    public void testEmfWithProps() throws InvalidSyntaxException, ConfigurationException {

+        PersistenceUnitInfo punit = mock(PersistenceUnitInfo.class);

+        when(punit.getPersistenceUnitName()).thenReturn("test-props");

+        when(punit.getPersistenceProviderClassName())

+            .thenReturn("org.eclipse.persistence.jpa.PersistenceProvider");

+        when(punit.getTransactionType()).thenReturn(PersistenceUnitTransactionType.JTA);

+        BundleContext context = mock(BundleContext.class);

+        Bundle bundle = mock(Bundle.class);

+        when(bundle.getBundleContext()).thenReturn(context);

+        when(bundle.getVersion()).thenReturn(new Version("4.3.1"));

+        PersistenceProvider provider = mock(PersistenceProvider.class);

+        Dictionary<String, Object> props = new Hashtable<String, Object>();

+        props.put("hibernate.hbm2ddl.auto", "create-drop");

+        ManagedEMF emf = new ManagedEMF(context, bundle, provider, punit);

+        emf.updated(null);

+        emf.close();

+

+        verify(provider, atLeastOnce()).createContainerEntityManagerFactory(Mockito.eq(punit),

+                                                                            Mockito.anyMap());

+        verify(context, atLeastOnce()).registerService(Mockito.eq(EntityManagerFactory.class),

+                                                       Mockito.any(EntityManagerFactory.class),

+                                                       Mockito.any(Dictionary.class));

+    }

+}

diff --git a/jpa-parent/pom.xml b/jpa-parent/pom.xml
new file mode 100644
index 0000000..06e3d2c
--- /dev/null
+++ b/jpa-parent/pom.xml
@@ -0,0 +1,93 @@
+<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/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.aries</groupId>
+        <artifactId>parent</artifactId>
+        <version>2.0.1</version>
+        <relativePath>../../parent</relativePath>
+    </parent>
+
+    <groupId>org.apache.aries.jpa</groupId>
+    <artifactId>org.apache.aries.jpa.parent</artifactId>
+    <version>2.0.0</version>
+
+    <name>Apache Aries JPA parent</name>
+    <packaging>pom</packaging>
+    
+    <dependencies>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <version>1.7.10</version>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.11</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-all</artifactId>
+            <version>1.8.2</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-jdk14</artifactId>
+            <version>1.7.10</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>org.hibernate.javax.persistence</groupId>
+                <artifactId>hibernate-jpa-2.1-api</artifactId>
+                <version>1.0.0.Final</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.geronimo.specs</groupId>
+                <artifactId>geronimo-jta_1.1_spec</artifactId>
+                <version>1.1.1</version>
+            </dependency>
+            <dependency>
+                <groupId>org.osgi</groupId>
+                <artifactId>org.osgi.core</artifactId>
+                <version>4.3.1</version>
+            </dependency>
+            <dependency>
+                <groupId>org.osgi</groupId>
+                <artifactId>org.osgi.compendium</artifactId>
+                <version>4.3.1</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.aries.blueprint</groupId>
+                <artifactId>org.apache.aries.blueprint.core</artifactId>
+                <version>1.4.2</version>
+                <scope>provided</scope>
+            </dependency>
+
+        </dependencies>
+    </dependencyManagement>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <source>1.7</source>
+                    <target>1.7</target>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+  <scm>
+    <connection>scm:svn:http://svn.apache.org/repos/asf/aries/tags/org.apache.aries.jpa-2.0.0/org.apache.aries.jpa.parent</connection>
+    <developerConnection>scm:svn:https://svn.apache.org/repos/asf/aries/tags/org.apache.aries.jpa-2.0.0/org.apache.aries.jpa.parent</developerConnection>
+    <url>scm:svn:http://svn.apache.org/repos/asf/aries/tags/org.apache.aries.jpa-2.0.0/org.apache.aries.jpa.parent</url>
+  </scm>
+</project>
diff --git a/jpa-support/pom.xml b/jpa-support/pom.xml
new file mode 100644
index 0000000..03e2e7c
--- /dev/null
+++ b/jpa-support/pom.xml
@@ -0,0 +1,56 @@
+<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/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.aries.jpa</groupId>
+        <artifactId>org.apache.aries.jpa.parent</artifactId>
+        <version>2.0.0</version>
+        <relativePath>../jpa-parent</relativePath>
+    </parent>
+    <artifactId>org.apache.aries.jpa.support</artifactId>
+    <name>Apache Aries JPA support</name>
+    <packaging>bundle</packaging>
+
+    <properties>
+        <aries.skip.version.check>true</aries.skip.version.check>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.aries.jpa</groupId>
+            <artifactId>org.apache.aries.jpa.api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.hibernate.javax.persistence</groupId>
+            <artifactId>hibernate-jpa-2.0-api</artifactId>
+            <version>1.0.1.Final</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-jta_1.1_spec</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <configuration>
+                    <instructions>
+                        <Bundle-Activator>org.apache.aries.jpa.support.osgi.impl.Activator</Bundle-Activator>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+    <description>Builds upon JPA container and provides EmSupplier and JPATemplate service per persistence unit. These make it easier to use EntityManager in a thread safe way</description>
+</project>
diff --git a/jpa-support/src/main/java/org/apache/aries/jpa/support/impl/AbstractJpaTemplate.java b/jpa-support/src/main/java/org/apache/aries/jpa/support/impl/AbstractJpaTemplate.java
new file mode 100644
index 0000000..3dadf3f
--- /dev/null
+++ b/jpa-support/src/main/java/org/apache/aries/jpa/support/impl/AbstractJpaTemplate.java
@@ -0,0 +1,50 @@
+/*
+ * 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 WARRANTIESOR 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.aries.jpa.support.impl;
+
+import javax.persistence.EntityManager;
+
+import org.apache.aries.jpa.template.EmConsumer;
+import org.apache.aries.jpa.template.EmFunction;
+import org.apache.aries.jpa.template.JpaTemplate;
+import org.apache.aries.jpa.template.TransactionType;
+
+public abstract class AbstractJpaTemplate implements JpaTemplate {
+
+	@Override
+	public void tx(final TransactionType type, final EmConsumer code) {
+		txExpr(type, new EmFunction<Object>() {
+			public Object apply(EntityManager em) {
+				code.accept(em);
+				return null;
+			}
+		});
+	}
+
+	@Override
+	public <R> R txExpr(final EmFunction<R> code) {
+		return txExpr(TransactionType.Required, code);
+	}
+
+	@Override
+	public void tx(final EmConsumer code) {
+		tx(TransactionType.Required, code);
+	}
+
+}
diff --git a/jpa-support/src/main/java/org/apache/aries/jpa/support/impl/EMSupplierImpl.java b/jpa-support/src/main/java/org/apache/aries/jpa/support/impl/EMSupplierImpl.java
new file mode 100644
index 0000000..c5832b0
--- /dev/null
+++ b/jpa-support/src/main/java/org/apache/aries/jpa/support/impl/EMSupplierImpl.java
@@ -0,0 +1,170 @@
+/*
+ * 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 WARRANTIESOR 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.aries.jpa.support.impl;
+
+import java.util.Collections;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+
+import org.apache.aries.jpa.supplier.EmSupplier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Thread safe way to use an EntityManager.
+ * 
+ * Before the EMF is closed the close() method has to be called to make
+ * sure all EMs are closed.
+ */
+public class EMSupplierImpl implements EmSupplier {
+    private static final long DEFAULT_SHUTDOWN_WAIT_SECS = 10;
+    private static Logger LOG = LoggerFactory.getLogger(EMSupplierImpl.class);
+    private EntityManagerFactory emf;
+    private AtomicBoolean shutdown;
+    private long shutdownWaitTime = DEFAULT_SHUTDOWN_WAIT_SECS;
+    private TimeUnit shutdownWaitTimeUnit = TimeUnit.SECONDS;
+
+    private final ThreadLocal<EntityManager> localEm;
+
+    // Counts how deeply nested the calls on this EM are
+    private final ThreadLocal<AtomicInteger> usageCount;
+    private Set<EntityManager> emSet;
+    private CountDownLatch emsToShutDown;
+    
+
+    public EMSupplierImpl(final EntityManagerFactory emf) {
+        this.emf = emf;
+        this.shutdown = new AtomicBoolean(false);
+        this.localEm = new ThreadLocal<EntityManager>();
+        this.emSet = Collections.newSetFromMap(new ConcurrentHashMap<EntityManager, Boolean>());
+        this.usageCount = new ThreadLocal<AtomicInteger>() {
+            @Override
+            protected AtomicInteger initialValue() {
+                return new AtomicInteger(0);
+            }
+        };
+    }
+
+    private EntityManager createEm(EntityManagerFactory emf) {
+        LOG.debug("Creating EntityManager");
+        EntityManager em = emf.createEntityManager();
+        emSet.add(em);
+        return em;
+    }
+
+    /**
+     * Allows to retrieve one EntityManager per thread. Creates the EntityManager if none is present for the
+     * thread. If the EM on the thread is closed it will be replaced by a fresh one.
+     */
+    @Override
+    public EntityManager get() {
+        EntityManager em = this.localEm.get();
+        if (em == null) {
+            LOG.warn("No EntityManager present on this thread. Remember to call preCall() first");
+        }
+        return em;
+    }
+
+
+    @Override
+    public void preCall() {
+        if (shutdown.get()) {
+            throw new IllegalStateException("This EntityManagerFactory is being shut down. Can not enter a new EM enabled method");
+        }
+        int count = this.usageCount.get().incrementAndGet();
+        if (count == 1) {
+            EntityManager em = createEm(emf);
+            emSet.add(em);
+            localEm.set(em);
+        }
+    }
+
+    @Override
+    public void postCall() {
+        int count = this.usageCount.get().decrementAndGet();
+        if (count == 0) {
+            // Outermost call finished
+            closeAndRemoveLocalEm();
+        } else if (count < 0) {
+            throw new IllegalStateException("postCall() called without corresponding preCall()");
+        }
+    }
+
+    private synchronized void closeAndRemoveLocalEm() {
+        EntityManager em = localEm.get();
+        em.close();
+        emSet.remove(em);
+        localEm.remove();
+        if (shutdown.get()) {
+            emsToShutDown.countDown();
+        }
+    }
+
+    /**
+     * Closes all EntityManagers that were opened by this Supplier.
+     * It will first wait for the EMs to be closed by the running threads.
+     * If this times out it will shutdown the remaining EMs itself.
+     * @return true if clean close, false if timeout occured
+     */
+    public boolean close() {
+        synchronized (this) {
+            shutdown.set(true);
+            emsToShutDown = new CountDownLatch(emSet.size());
+        }
+        try {
+            emsToShutDown.await(shutdownWaitTime, shutdownWaitTimeUnit);
+        } catch (InterruptedException e) {
+        }
+        return shutdownRemaining();
+    }
+
+    private synchronized boolean shutdownRemaining() {
+        boolean clean = (emSet.size() == 0); 
+        if  (!clean) {
+            LOG.warn("{} EntityManagers still open after timeout. Shutting them down now", emSet.size());
+        }
+        for (EntityManager em : emSet) {
+            closeEm(em);
+        }
+        emSet.clear();
+        return clean;
+    }
+
+    private void closeEm(EntityManager em) {
+        try {
+            if (em.isOpen()) {
+                em.close();
+            }
+        } catch (Exception e) {
+            LOG.warn("Error closing EntityManager", e);
+        }
+    }
+
+    public void setShutdownWait(long shutdownWaitTime, TimeUnit shutdownWaitTimeUnit) {
+        this.shutdownWaitTime = shutdownWaitTime;
+        this.shutdownWaitTimeUnit = shutdownWaitTimeUnit;
+    }
+}
diff --git a/jpa-support/src/main/java/org/apache/aries/jpa/support/impl/ResourceLocalJpaTemplate.java b/jpa-support/src/main/java/org/apache/aries/jpa/support/impl/ResourceLocalJpaTemplate.java
new file mode 100644
index 0000000..8729e5e
--- /dev/null
+++ b/jpa-support/src/main/java/org/apache/aries/jpa/support/impl/ResourceLocalJpaTemplate.java
@@ -0,0 +1,72 @@
+/*
+ * 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 WARRANTIESOR 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.aries.jpa.support.impl;
+
+import javax.persistence.EntityManager;
+
+import org.apache.aries.jpa.supplier.EmSupplier;
+import org.apache.aries.jpa.template.EmFunction;
+import org.apache.aries.jpa.template.TransactionType;
+
+public class ResourceLocalJpaTemplate extends AbstractJpaTemplate {
+    private EmSupplier emSupplier;
+
+    public ResourceLocalJpaTemplate(EmSupplier emSupplier) {
+        this.emSupplier = emSupplier;
+    }
+
+    @Override
+    public <R> R txExpr(TransactionType type, EmFunction<R> code) {
+        EntityManager em = null;
+        boolean weControlTx = false;
+        if (type != TransactionType.Required) {
+            throw new IllegalStateException("Only transation propagation type REQUIRED is supported");
+        }
+        try {
+            emSupplier.preCall();
+            em = emSupplier.get();
+            weControlTx = !em.getTransaction().isActive();
+            if (weControlTx) {
+                em.getTransaction().begin();
+            }
+            R result = (R)code.apply(em);
+            if (weControlTx) {
+                em.getTransaction().commit();
+            }
+            return result;
+        } catch (Exception e) {
+            if (weControlTx) {
+                safeRollback(em, e);
+            }
+            throw new RuntimeException(e);
+        } finally {
+            emSupplier.postCall();
+        }
+    }
+
+    private void safeRollback(EntityManager em, Exception e) {
+        if (em != null) {
+            try {
+                em.getTransaction().rollback();
+            } catch (Exception e1) {
+            }
+        }
+    }
+
+}
diff --git a/jpa-support/src/main/java/org/apache/aries/jpa/support/impl/XAJpaTemplate.java b/jpa-support/src/main/java/org/apache/aries/jpa/support/impl/XAJpaTemplate.java
new file mode 100644
index 0000000..dfe6e99
--- /dev/null
+++ b/jpa-support/src/main/java/org/apache/aries/jpa/support/impl/XAJpaTemplate.java
@@ -0,0 +1,87 @@
+/*
+ * 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 WARRANTIESOR 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.aries.jpa.support.impl;
+
+import javax.persistence.EntityManager;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+
+import org.apache.aries.jpa.supplier.EmSupplier;
+import org.apache.aries.jpa.support.xa.impl.TransactionAttribute;
+import org.apache.aries.jpa.support.xa.impl.TransactionToken;
+import org.apache.aries.jpa.template.EmFunction;
+import org.apache.aries.jpa.template.TransactionType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class XAJpaTemplate extends AbstractJpaTemplate {
+    private static final Logger LOGGER = LoggerFactory.getLogger(XAJpaTemplate.class);
+    protected EmSupplier emSupplier;
+    protected TransactionManager tm;
+
+    public XAJpaTemplate(EmSupplier emSupplier, TransactionManager tm) {
+        this.emSupplier = emSupplier;
+        this.tm = tm;
+    }
+
+    @Override
+    public <R> R txExpr(TransactionType type, EmFunction<R> code) {
+        EntityManager em = null;
+        TransactionToken tranToken = null;
+        TransactionAttribute ta = TransactionAttribute.fromType(type);
+        try {
+            tranToken = ta.begin(tm);
+            emSupplier.preCall();
+            em = emSupplier.get();
+            em.joinTransaction();
+            R result = (R)code.apply(em);
+            return result;
+        } catch (Throwable ex) {
+            safeRollback(tranToken, ex);
+            throw new RuntimeException(ex);
+        } finally {
+            try {
+                ta.finish(tm, tranToken);
+                emSupplier.postCall();
+            } catch (Exception e) {
+                // We are throwing an exception, so we don't error it out
+                LOGGER.debug("exception.during.tx.finish", e);
+                throw new RuntimeException("Exception during finish of transaction", e);
+            }
+        }
+    }
+
+    private void safeRollback(TransactionToken token, Throwable ex) {
+        try {
+            Transaction tran = token.getActiveTransaction();
+            if (tran != null) {
+                if (ex instanceof RuntimeException || ex instanceof Error) {
+                    tran.setRollbackOnly();
+                } else {
+                    // declared exception, we don't set rollback
+                }
+            }
+        } catch (Exception e) {
+            // we do not throw the exception since there already is one, but we
+            // need to log it
+            LOGGER.warn("exception.during.tx.cleanup", e);
+        }
+    }
+
+}
diff --git a/jpa-support/src/main/java/org/apache/aries/jpa/support/osgi/impl/Activator.java b/jpa-support/src/main/java/org/apache/aries/jpa/support/osgi/impl/Activator.java
new file mode 100644
index 0000000..c222c77
--- /dev/null
+++ b/jpa-support/src/main/java/org/apache/aries/jpa/support/osgi/impl/Activator.java
@@ -0,0 +1,39 @@
+/*
+ * 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 WARRANTIESOR 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.aries.jpa.support.osgi.impl;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator implements BundleActivator {
+
+    private EMFTracker emfTracker;
+
+    @Override
+    public void start(BundleContext context) throws Exception {
+        emfTracker = new EMFTracker(context);
+        emfTracker.open();
+    }
+
+    @Override
+    public void stop(BundleContext context) throws Exception {
+        emfTracker.close();
+    }
+
+}
diff --git a/jpa-support/src/main/java/org/apache/aries/jpa/support/osgi/impl/EMFTracker.java b/jpa-support/src/main/java/org/apache/aries/jpa/support/osgi/impl/EMFTracker.java
new file mode 100644
index 0000000..d8b863b
--- /dev/null
+++ b/jpa-support/src/main/java/org/apache/aries/jpa/support/osgi/impl/EMFTracker.java
@@ -0,0 +1,126 @@
+/*
+ * 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 WARRANTIESOR 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.aries.jpa.support.osgi.impl;
+
+import static org.osgi.service.jpa.EntityManagerFactoryBuilder.JPA_UNIT_NAME;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.spi.PersistenceUnitTransactionType;
+
+import org.apache.aries.jpa.supplier.EmSupplier;
+import org.apache.aries.jpa.support.impl.EMSupplierImpl;
+import org.apache.aries.jpa.support.impl.ResourceLocalJpaTemplate;
+import org.apache.aries.jpa.template.JpaTemplate;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * Tracks EntityManagerFactory services and publishes a Supplier<EntityManager> for each.
+ * IF the persistence unit uses JTA a TMTracker is created. If it uses RESOURCE_LOCAL as 
+ * ResourceLocalJpaTemplate is created.
+ */
+@SuppressWarnings("rawtypes")
+public class EMFTracker extends ServiceTracker {
+
+    @SuppressWarnings("unchecked")
+    public EMFTracker(BundleContext context) {
+        super(context, EntityManagerFactory.class, null);
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public Object addingService(ServiceReference reference) {
+        String unitName = (String)reference.getProperty(JPA_UNIT_NAME);
+        if (unitName == null) {
+            return null;
+        }
+        BundleContext bContext = reference.getBundle().getBundleContext();
+        TrackedEmf tracked = new TrackedEmf();
+        tracked.emf = (EntityManagerFactory)bContext.getService(reference);
+        tracked.emSupplier = new EMSupplierImpl(tracked.emf);
+        tracked.emSupplierReg = bContext.registerService(EmSupplier.class, tracked.emSupplier,
+                                                         getEmSupplierProps(unitName));
+
+        if (getTransactionType(tracked.emf) == PersistenceUnitTransactionType.RESOURCE_LOCAL) {
+            JpaTemplate txManager = new ResourceLocalJpaTemplate(tracked.emSupplier);
+            tracked.rlTxManagerReg = bContext.registerService(JpaTemplate.class, txManager,
+                                                          rlTxManProps(unitName));
+        } else {
+            tracked.tmTracker = new TMTracker(bContext, tracked.emSupplier, unitName);
+            tracked.tmTracker.open();
+        }
+        return tracked;
+    }
+
+    /**
+     * 
+     * @param emf
+     * @return
+     */
+    private PersistenceUnitTransactionType getTransactionType(EntityManagerFactory emf) {
+        PersistenceUnitTransactionType transactionType = (PersistenceUnitTransactionType) emf.getProperties()
+        		.get(PersistenceUnitTransactionType.class.getName());
+        if(transactionType == PersistenceUnitTransactionType.RESOURCE_LOCAL) {
+        	return PersistenceUnitTransactionType.RESOURCE_LOCAL;
+        } else {
+        	return PersistenceUnitTransactionType.JTA;
+        }
+    }
+
+    private Dictionary<String, String> getEmSupplierProps(String unitName) {
+        Dictionary<String, String> props = new Hashtable<>();
+        props.put(JPA_UNIT_NAME, unitName);
+        return props;
+    }
+
+    private Dictionary<String, String> rlTxManProps(String unitName) {
+        Dictionary<String, String> props = new Hashtable<>();
+        props.put(JPA_UNIT_NAME, unitName);
+        props.put(TMTracker.TRANSACTION_TYPE, "RESOURCE_LOCAL");
+        return props;
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public void removedService(ServiceReference reference, Object trackedO) {
+        TrackedEmf tracked = (TrackedEmf)trackedO;
+        if (tracked.tmTracker != null) {
+            tracked.tmTracker.close();
+        }
+        if (tracked.rlTxManagerReg != null) {
+            tracked.rlTxManagerReg.unregister();
+        }
+        tracked.emSupplier.close();
+        tracked.emSupplierReg.unregister();
+        super.removedService(reference, tracked.emf);
+    }
+
+    static class TrackedEmf {
+        ServiceRegistration emSupplierReg;
+        EMSupplierImpl emSupplier;
+        ServiceRegistration rlTxManagerReg;
+        EntityManagerFactory emf;
+        TMTracker tmTracker;
+    }
+}
diff --git a/jpa-support/src/main/java/org/apache/aries/jpa/support/osgi/impl/TMTracker.java b/jpa-support/src/main/java/org/apache/aries/jpa/support/osgi/impl/TMTracker.java
new file mode 100644
index 0000000..a32d0a4
--- /dev/null
+++ b/jpa-support/src/main/java/org/apache/aries/jpa/support/osgi/impl/TMTracker.java
@@ -0,0 +1,76 @@
+/*
+ * 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 WARRANTIESOR 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.aries.jpa.support.osgi.impl;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import javax.transaction.TransactionManager;
+
+import org.apache.aries.jpa.supplier.EmSupplier;
+import org.apache.aries.jpa.support.impl.XAJpaTemplate;
+import org.apache.aries.jpa.template.JpaTemplate;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.jpa.EntityManagerFactoryBuilder;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * Is created for an EntityManagerFactory with JTA transactions and creates
+ * an XaJpaTemplate for it as soon as the TransactionManager service is present.
+ */
+@SuppressWarnings("rawtypes")
+public class TMTracker extends ServiceTracker<TransactionManager, ServiceRegistration> {
+    static final String TRANSACTION_TYPE = "transaction.type";
+
+    private final EmSupplier emSupplier;
+    private final String unitName;
+
+    public TMTracker(BundleContext context, EmSupplier emSupplier, String unitName) {
+        super(context, TransactionManager.class, null);
+        this.emSupplier = emSupplier;
+        this.unitName = unitName;
+    }
+
+    @Override
+    public ServiceRegistration addingService(ServiceReference<TransactionManager> ref) {
+        TransactionManager tm = context.getService(ref);
+        XAJpaTemplate txManager = new XAJpaTemplate(emSupplier, tm);
+        return context.registerService(JpaTemplate.class, txManager, xaTxManProps(unitName));
+    }
+
+    private Dictionary<String, String> xaTxManProps(String unitName) {
+        Dictionary<String, String> txmanProperties = new Hashtable<>();
+        txmanProperties.put(EntityManagerFactoryBuilder.JPA_UNIT_NAME, unitName);
+        txmanProperties.put(TRANSACTION_TYPE, "JTA");
+        return txmanProperties;
+    }
+
+    @Override
+    public void removedService(ServiceReference<TransactionManager> reference, ServiceRegistration reg) {
+        try {
+            reg.unregister();
+            context.ungetService(reference);
+        } catch (Exception e) {
+            // Ignore. May happen if persistence unit bundle is unloaded / updated
+        }
+    }
+
+}
diff --git a/jpa-support/src/main/java/org/apache/aries/jpa/support/xa/impl/TransactionAttribute.java b/jpa-support/src/main/java/org/apache/aries/jpa/support/xa/impl/TransactionAttribute.java
new file mode 100644
index 0000000..d9bfe0c
--- /dev/null
+++ b/jpa-support/src/main/java/org/apache/aries/jpa/support/xa/impl/TransactionAttribute.java
@@ -0,0 +1,185 @@
+/*
+ * 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.aries.jpa.support.xa.impl;
+
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.InvalidTransactionException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.Status;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+
+import org.apache.aries.jpa.template.TransactionType;
+
+/**
+ * TODO This is copied from aries transaction. We could share this code
+ */
+public enum TransactionAttribute {
+    MANDATORY
+    {
+      public TransactionToken begin(TransactionManager man) throws SystemException
+      {
+        if (man.getStatus() == Status.STATUS_NO_TRANSACTION) {
+          throw new IllegalStateException("This method has transaction attr MANADATORY but no active transaction was found.");
+        }
+
+        return new TransactionToken(man.getTransaction(), null, MANDATORY);
+      }
+    },
+    NEVER
+    {
+      public TransactionToken begin(TransactionManager man) throws SystemException
+      {
+        if (man.getStatus() == Status.STATUS_ACTIVE) {
+          throw new IllegalStateException("This method has transactui attr NEVER but a transaction is active.");
+        }
+
+        return new TransactionToken(null, null, NEVER);
+      }
+    },
+    NOTSUPPORTED
+    {
+      public TransactionToken begin(TransactionManager man) throws SystemException
+      {
+        if (man.getStatus() == Status.STATUS_ACTIVE) {
+          return new TransactionToken(null, man.suspend(), this);
+        }
+
+        return new TransactionToken(null, null, NOTSUPPORTED);
+      }
+
+      public void finish(TransactionManager man, TransactionToken tranToken) throws SystemException,
+          InvalidTransactionException, IllegalStateException
+      {
+        Transaction tran = tranToken.getSuspendedTransaction();
+        if (tran != null) {
+          man.resume(tran);
+        }
+      }
+    },
+    REQUIRED
+    {
+      public TransactionToken begin(TransactionManager man) throws SystemException, NotSupportedException
+      {
+        if (man.getStatus() == Status.STATUS_NO_TRANSACTION) {
+          man.begin();
+          return new TransactionToken(man.getTransaction(), null, REQUIRED, true);
+        }
+
+        return new TransactionToken(man.getTransaction(), null, REQUIRED);
+      }
+
+      public void finish(TransactionManager man, TransactionToken tranToken) throws SystemException,
+          InvalidTransactionException, IllegalStateException, SecurityException, RollbackException,
+          HeuristicMixedException, HeuristicRollbackException
+      {
+        if (tranToken.isCompletionAllowed()) {
+          if (man.getStatus() == Status.STATUS_MARKED_ROLLBACK) {
+            man.rollback();
+          } else {
+            man.commit();
+          }
+        }
+      }
+    },
+    REQUIRESNEW
+    {
+      public TransactionToken begin(TransactionManager man) throws SystemException, NotSupportedException,
+          InvalidTransactionException, IllegalStateException
+      {
+        TransactionToken tranToken;
+        if (man.getStatus() == Status.STATUS_ACTIVE) {
+          tranToken = new TransactionToken(null, man.suspend(), REQUIRESNEW);
+        } else {
+          tranToken = new TransactionToken(null, null, REQUIRESNEW);
+        }
+
+        try {
+          man.begin();
+        } catch (SystemException e) {
+          man.resume(tranToken.getSuspendedTransaction());
+          throw e;
+        } catch (NotSupportedException e) {
+          man.resume(tranToken.getSuspendedTransaction());
+          throw e;
+        }
+        
+        tranToken.setActiveTransaction(man.getTransaction());
+        tranToken.setCompletionAllowed(true);
+        
+        return tranToken;
+      }
+
+      public void finish(TransactionManager man, TransactionToken tranToken) throws SystemException,
+          InvalidTransactionException, IllegalStateException, SecurityException, RollbackException,
+          HeuristicMixedException, HeuristicRollbackException
+      {
+        if (tranToken.isCompletionAllowed()) {
+          if (man.getStatus() == Status.STATUS_MARKED_ROLLBACK) {
+            man.rollback();
+          } else {
+            man.commit();
+          }
+        }
+
+        Transaction tran = tranToken.getSuspendedTransaction();
+        if (tran != null) {
+          man.resume(tran);
+        }
+      }
+    },
+    SUPPORTS
+    {
+      public TransactionToken begin(TransactionManager man) throws SystemException, NotSupportedException,
+          InvalidTransactionException, IllegalStateException
+      {
+          if (man.getStatus() == Status.STATUS_ACTIVE) {
+              return new TransactionToken(man.getTransaction(), null, SUPPORTS);
+          }
+
+          return new TransactionToken(null, null, SUPPORTS);
+      }
+    };
+
+    public static TransactionAttribute fromValue(String value)
+    {
+      return valueOf(value.toUpperCase());
+    }
+    
+    public static TransactionAttribute fromType(TransactionType type)
+    {
+      return valueOf(type.name().toUpperCase());
+    }
+
+    public TransactionToken begin(TransactionManager man) throws SystemException, NotSupportedException,
+        InvalidTransactionException, IllegalStateException
+    {
+      return null;
+    }
+
+    public void finish(TransactionManager man, TransactionToken tranToken) throws SystemException,
+        InvalidTransactionException, IllegalStateException, SecurityException, RollbackException,
+        HeuristicMixedException, HeuristicRollbackException
+    {
+
+    }
+}
diff --git a/jpa-support/src/main/java/org/apache/aries/jpa/support/xa/impl/TransactionToken.java b/jpa-support/src/main/java/org/apache/aries/jpa/support/xa/impl/TransactionToken.java
new file mode 100644
index 0000000..1e3fff2
--- /dev/null
+++ b/jpa-support/src/main/java/org/apache/aries/jpa/support/xa/impl/TransactionToken.java
@@ -0,0 +1,76 @@
+/*
+ * 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.aries.jpa.support.xa.impl;
+
+import javax.transaction.Transaction;
+
+public class TransactionToken
+{
+   private Transaction activeTransaction;
+   private Transaction suspendedTransaction;
+   private TransactionAttribute transactionAttribute;
+   private boolean isCompletionAllowed;
+   
+   public TransactionToken(Transaction activeTransaction, Transaction suspendedTransaction,
+           TransactionAttribute transactionAttribute)
+   {
+    this(activeTransaction, suspendedTransaction, transactionAttribute, false);
+   }
+
+   TransactionToken(Transaction activeTransaction, Transaction suspendedTransaction,
+           TransactionAttribute transactionAttribute, boolean isCompletionAllowed)
+   {
+       this.activeTransaction = activeTransaction;
+       this.suspendedTransaction = suspendedTransaction;
+       this.transactionAttribute = transactionAttribute;
+       this.isCompletionAllowed = isCompletionAllowed;
+   }
+
+   public Transaction getActiveTransaction() {
+       return activeTransaction;
+   }
+
+   public void setActiveTransaction(Transaction activeTransaction) {
+       this.activeTransaction = activeTransaction;
+   }
+
+   public Transaction getSuspendedTransaction() {
+       return suspendedTransaction;
+   }
+
+   public void setSuspendedTransaction(Transaction suspendedTransaction) {
+       this.suspendedTransaction = suspendedTransaction;
+   }
+
+   public TransactionAttribute getTransactionAttribute() {
+       return transactionAttribute;
+   }
+
+   public void setTransactionStrategy(TransactionAttribute transactionAttribute) {
+       this.transactionAttribute = transactionAttribute;
+   }
+
+   public boolean isCompletionAllowed() {
+       return isCompletionAllowed;
+   }
+
+   public void setCompletionAllowed(boolean isCompletionAllowed) {
+       this.isCompletionAllowed = isCompletionAllowed;
+   }
+}
\ No newline at end of file
diff --git a/jpa-support/src/test/java/org/apache/aries/jpa/impl/EmSupplierTest.java b/jpa-support/src/test/java/org/apache/aries/jpa/impl/EmSupplierTest.java
new file mode 100644
index 0000000..709cad6
--- /dev/null
+++ b/jpa-support/src/test/java/org/apache/aries/jpa/impl/EmSupplierTest.java
@@ -0,0 +1,98 @@
+/*
+ * 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 WARRANTIESOR 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.aries.jpa.impl;
+
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.util.concurrent.Executors;
+import java.util.concurrent.Semaphore;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+
+import org.apache.aries.jpa.support.impl.EMSupplierImpl;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class EmSupplierTest {
+
+    @Test
+    public void lifeCycleTest() {
+        EntityManagerFactory emf = mockEmf();
+        EMSupplierImpl emSupplier = new EMSupplierImpl(emf);
+        
+        Assert.assertNull("No EM may be present at start", emSupplier.get());
+
+        emSupplier.preCall();
+        EntityManager em = emSupplier.get();
+        Assert.assertNotNull("EM should be present after preCall", em);
+        emSupplier.preCall();
+        Assert.assertSame("Same EM for inner preCall", em, emSupplier.get());
+        
+        emSupplier.postCall();
+        Assert.assertSame("EM must still be the same after inner postCall", em, emSupplier.get());
+        
+        emSupplier.postCall();
+        Assert.assertNull("EM must be null after outer postCall", emSupplier.get());
+        
+        boolean clean = emSupplier.close();
+        Assert.assertTrue("Shutdown should be clean", clean);
+    }
+
+    private EntityManagerFactory mockEmf() {
+        EntityManagerFactory emf = mock(EntityManagerFactory.class);
+        EntityManager em = mock(EntityManager.class);
+        when(emf.createEntityManager()).thenReturn(em);
+        return emf;
+    }
+    
+    @Test
+    public void uncleanLifeCycleTest() {
+        EntityManagerFactory emf = mockEmf();
+        EMSupplierImpl emSupplier = new EMSupplierImpl(emf);
+        emSupplier.setShutdownWait(100, MILLISECONDS);
+        emSupplier.preCall();
+        boolean clean = emSupplier.close();
+        Assert.assertFalse("Shutdown should be unclean", clean);
+    }
+    
+    @Test
+    public void asyncCleanLifeCycleTest() throws InterruptedException {
+        EntityManagerFactory emf = mockEmf();
+        final EMSupplierImpl emSupplier = new EMSupplierImpl(emf);
+        final Semaphore preCallSem = new Semaphore(0);
+        Runnable command = new Runnable() {
+            
+            @Override
+            public void run() {
+                emSupplier.preCall();
+                preCallSem.release();
+                emSupplier.postCall();
+            }
+        };
+        Executors.newSingleThreadExecutor().execute(command);
+        preCallSem.acquire();
+        // EMs not closed when close is called but are closed before timeout 
+        boolean clean = emSupplier.close();
+        Assert.assertTrue("Shutdown should be clean", clean);
+    }
+
+}
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..e9880dd
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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/xsd/maven-4.0.0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>org.apache.aries.jpa</groupId>
+    <artifactId>org.apache.aries.jpa.main</artifactId>
+    <name>Apache Aries JPA parent</name>
+    <version>2.0.0</version>
+    <packaging>pom</packaging>
+    
+    <parent>
+        <groupId>org.apache.aries</groupId>
+        <artifactId>parent</artifactId>
+        <version>2.0.1</version>
+        <relativePath>../parent/pom.xml</relativePath>
+    </parent>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+    
+    <scm>
+	<connection>scm:svn:http://svn.apache.org/repos/asf/aries/tags/org.apache.aries.jpa-2.0.0</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/aries/tags/org.apache.aries.jpa-2.0.0</developerConnection>
+        <url>http://svn.apache.org/viewvc/aries/tags/org.apache.aries.jpa-2.0.0</url>
+    </scm>
+
+    <modules>
+    	<module>jpa-api</module>
+    	<module>jpa-container</module>
+        <module>jpa-support</module>
+        <module>jpa-blueprint</module>
+        <module>jpa-container-eclipselink-adapter</module>
+        <module>examples</module>
+        <module>itests</module>
+        <module>jpa-parent</module>
+    </modules>
+
+
+</project>
+