<ul>Apache Aries An Open Source project for  Enterprise OSGi Applications  </ul>
<ul>Apache Aries An Open Source project for  Enterprise OSGi Applications  </ul>
<ul>Agenda </ul><ul><li>History
Community
Content
Consumers
Future </li></ul>
<ul>History </ul><ul><li>“ Aries” created as a new Apache incubator project in Sep 2009  </li></ul><ul><li>Independent of ...
<ul>Community </ul><ul><li>Currently 43 committers, contributors from Ericsson, IBM, JBoss, LinkedIn, Progress, ProSyst, S...
<ul>Aries Content includes… </ul><ul><li>Blueprint container
JPA integration
JTA integration
JMX
JNDI integration
Application assembly and deployment
META-INF/services handler
Samples </li></ul><ul>http://svn.apache.org/repos/asf/incubator/aries/trunk/ </ul>
<ul>Aries Samples </ul><ul><li>AriesTrader – Apache Geronimo DayTrader Java EE benchmark application converted to OSGi App...
Performance benchmarking </li></ul></ul><ul><li>Blog Sample  – New application to demonstrate Aries features
The Samples illustrate how to run Aries applications on a standard OSGi f/w (e.g. Equinox) + Aries + dependencies (Derby D...
http://incubator.apache.org/aries/samples.html </li></ul>
<ul>Example “Blog” Application Architecture </ul><ul>Blogging Service </ul><ul>Blog Persistence Service </ul><ul>blog-web ...
Run the Blog Sample EBA
<ul>Aries Application Assembly and Deploy </ul><ul><li>Pluggable BundleConverters
- WabConverterService </li></ul><ul>Manifest-Version : 1.0 Application-ManifestVersion : 1.0 Application-Name : Blog Appli...
<ul>Example “Blog” Application Architecture </ul><ul>Blogging Service </ul><ul>Blog Persistence Service </ul><ul>blog-web ...
<ul>Blog-biz - blueprint.xml </ul><ul>..... <li><bean id=&quot;blogEntryManager&quot; class=&quot;org.apache.aries.samples...
<property name=&quot;persistenceService&quot; ref=&quot;persistenceManager&quot;/>
Upcoming SlideShare
Loading in...5
×

Apache Aries Blog Sample

2,874

Published on

Zoe Slattery

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,874
On Slideshare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
0
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide
  • Aries is one of 36 Apache Incubator projects
  • The Aries JPA container context bundle provides a blueprint namespace for dependency injection of managed JPA resources. Managed persistence units (EntityManagerFactory objects) can be injected with or without a JTA Transaction Services implementation. Managed persistence contexts (EntityManager objects) are only available with a JTA Transaction Services implementation. Both managed persistence units and managed persistence contexts behave as per the JPA specification.
  • NamespaceHandlers registered with a property whose value is the target nameapce: props.put(&amp;quot;osgi.service.blueprint.namespace&amp;quot;, &amp;quot;http://aries.apache.org/xmlns/transactions/v1.0.0&amp;quot;); A DI container standardizing established Spring conventions XML Blueprint definition describes component configuration and scope Optionally publish and consume components to/from OSGi service registry. Simplifies unit test outside either Java EE or OSGi r/t. The Aries BP container implementation is highly extensible: Namespace handlers supported to extend the Blueprint definitions Bean interceptors can be registered by handlers Other Aries components contribute handlers – “jpa” and “jta” handlers. Some other Aries components are implemented as Blueprint bundles themselves e.g. JPA container
  • jndi-url bundle registers a JNDI ObjectFactory for “osgi:services” Contexts in the service registry (“OsgiURLContextFactory“) jndi-core bundle registers an InitialContextFactoryBuilder and ObjectFactoryBuilder with JVM. The ICFB creates a Context which looks in the SR for an ObjectFactories which can process the URI scheme. If it delegates to the osgi:services ObjectFactory then this returns the service in the SR.
  • The Aries JPA container context bundle provides a blueprint namespace for dependency injection of managed JPA resources. Managed persistence units (EntityManagerFactory objects) can be injected with or without a JTA Transaction Services implementation. Managed persistence contexts (EntityManager objects) are only available with a JTA Transaction Services implementation. Both managed persistence units and managed persistence contexts behave as per the JPA specification.
  • The Aries JPA container context bundle provides a blueprint namespace for dependency injection of managed JPA resources. Managed persistence units (EntityManagerFactory objects) can be injected with or without a JTA Transaction Services implementation. Managed persistence contexts (EntityManager objects) are only available with a JTA Transaction Services implementation. Both managed persistence units and managed persistence contexts behave as per the JPA specification.
  • Application managed JPA Need Java code to look up the EMF service From that, create EM object Surround with try...finally, need to close. Container managed BP container – uses JPA context NS handler Injects EM object into Bean, all the Programmer does is call em.persist JTA – again BP container understands the Tx and ensures that changes to the DB are Managed as transactions
  • Application managed JPA Need Java code to look up the EMF service From that, create EM object Surround with try...finally, need to close. Container managed BP container – uses JPA context NS handler Injects EM object into Bean, all the Programmer does is call em.persist JTA – again BP container understands the Tx and ensures that changes to the DB are Managed as transactions
  • Provides support for “Application managed” JPA . Each persistence bundle has its standard JPA metadata located through the Meta-Persistence bundle header. JPA Container locates a JPA Provider which can service the PU and registers a Provider-created EntityManagerFactory service for each PU in each persistence bundle EMF service lifecyce follows the persistence bundle lifecycle JPA Provider gets persistence bundle classloader from PUInfo.
  • Provides support for “Application managed” JPA . Each persistence bundle has its standard JPA metadata located through the Meta-Persistence bundle header. JPA Container locates a JPA Provider which can service the PU and registers a Provider-created EntityManagerFactory service for each PU in each persistence bundle EMF service lifecyce follows the persistence bundle lifecycle JPA Provider gets persistence bundle classloader from PUInfo.
  • Provides support for “Application managed” JPA . Each persistence bundle has its standard JPA metadata located through the Meta-Persistence bundle header. JPA Container locates a JPA Provider which can service the PU and registers a Provider-created EntityManagerFactory service for each PU in each persistence bundle EMF service lifecyce follows the persistence bundle lifecycle JPA Provider gets persistence bundle classloader from PUInfo.
  • Transcript of "Apache Aries Blog Sample"

    1. 1. <ul>Apache Aries An Open Source project for Enterprise OSGi Applications </ul>
    2. 2. <ul>Apache Aries An Open Source project for Enterprise OSGi Applications </ul>
    3. 3. <ul>Agenda </ul><ul><li>History
    4. 4. Community
    5. 5. Content
    6. 6. Consumers
    7. 7. Future </li></ul>
    8. 8. <ul>History </ul><ul><li>“ Aries” created as a new Apache incubator project in Sep 2009 </li></ul><ul><li>Independent of OSGi framework provider and integration/server runtime </li></ul><ul><li>Initial contribution included the Blueprint container implementation developed originally by the Apache Geronimo community. </li></ul><ul><li>Web Site for all resources and documentation: http://incubator.apache.org/aries/ </li></ul>
    9. 9. <ul>Community </ul><ul><li>Currently 43 committers, contributors from Ericsson, IBM, JBoss, LinkedIn, Progress, ProSyst, SAP and individuals </li></ul><ul><ul><li>http://incubator.apache.org/aries/people.html </li></ul></ul><ul><li>Creation of community is one of the primary goals of the Apache Incubator </li></ul>
    10. 10. <ul>Aries Content includes… </ul><ul><li>Blueprint container
    11. 11. JPA integration
    12. 12. JTA integration
    13. 13. JMX
    14. 14. JNDI integration
    15. 15. Application assembly and deployment
    16. 16. META-INF/services handler
    17. 17. Samples </li></ul><ul>http://svn.apache.org/repos/asf/incubator/aries/trunk/ </ul>
    18. 18. <ul>Aries Samples </ul><ul><li>AriesTrader – Apache Geronimo DayTrader Java EE benchmark application converted to OSGi Application using web and blueprint components </li></ul><ul><ul><li>Objective is to demonstrate best practices
    19. 19. Performance benchmarking </li></ul></ul><ul><li>Blog Sample – New application to demonstrate Aries features
    20. 20. The Samples illustrate how to run Aries applications on a standard OSGi f/w (e.g. Equinox) + Aries + dependencies (Derby DB, PaxWeb servlet container).
    21. 21. http://incubator.apache.org/aries/samples.html </li></ul>
    22. 22. <ul>Example “Blog” Application Architecture </ul><ul>Blogging Service </ul><ul>Blog Persistence Service </ul><ul>blog-web </ul><ul>Web application bundle </ul><ul><li>MetaPersitstence </li></ul><ul>WEB-INF/ web.xml </ul><ul>OSGI-INF/blueprint/ blueprint.xml </ul><ul>OSGI-INF/blueprint/ blueprint.xml </ul><ul>JNDI </ul><ul>META-INF/ persistence.xml </ul><ul>blog.eba </ul><ul>blog-biz </ul><ul>blog-persistence </ul><ul>blog-api </ul>
    23. 23. Run the Blog Sample EBA
    24. 24. <ul>Aries Application Assembly and Deploy </ul><ul><li>Pluggable BundleConverters
    25. 25. - WabConverterService </li></ul><ul>Manifest-Version : 1.0 Application-ManifestVersion : 1.0 Application-Name : Blog Application Application-SymbolicName : aries.sample.blog Application-Version : 1.0 Application-Content : aries.sample.blog-biz; version=&quot;[1.0.0,1.1.0)&quot;, aries.sample.blog-api; version=&quot;1.0.0&quot;, aries.sample.blog-persistence; version=&quot;1.0.0&quot;, aries.sample.blog-web; version=&quot;[1.0.0,1.0.0]” </ul><ul>Manifest-Version : 1.0 Deployment-ManifestVersion : 1.0 Application-Name : Blog Application Application-SymbolicName : aries.sample.blog Application-Version : 1.0 Deployed-Content : aries.sample.blog-biz; version= 1.0.0 , aries.sample.blog-api; version= 1.0.0 , aries.sample.blog-persistence; version= 1.0.0 , <li>aries.sample.blog-web; version=1.0.0, </li></ul><ul>Application Manifest (developer/assembler authored artefact) Enumerates constituent bundles and allowable version ranges Declares Application “externals” </ul><ul>Deployment Manifest ( generated during createApplication ) Transitively closed description of all bundles resolved at specific versions to “freeze-dry” the application. </ul>Felix File Install <ul><li>org.apache.aries.application.management </li></ul><ul>Pluggable ApplicationResolver - NoOpResolver - OBRAriesResolver </ul>
    26. 26. <ul>Example “Blog” Application Architecture </ul><ul>Blogging Service </ul><ul>Blog Persistence Service </ul><ul>blog-web </ul><ul>Web application bundle </ul><ul><li>MetaPersitstence </li></ul><ul>WEB-INF/ web.xml </ul><ul>OSGI-INF/blueprint/ blueprint.xml </ul><ul>OSGI-INF/blueprint/ blueprint.xml </ul><ul>META-INF/ persistence.xml </ul><ul>JNDI </ul><ul>blog.eba </ul><ul>blog-biz </ul><ul>blog-persistence </ul><ul>blog-api </ul>
    27. 27. <ul>Blog-biz - blueprint.xml </ul><ul>..... <li><bean id=&quot;blogEntryManager&quot; class=&quot;org.apache.aries.samples.blog.biz.BlogEntryManagerImpl&quot;>
    28. 28. <property name=&quot;persistenceService&quot; ref=&quot;persistenceManager&quot;/>
    29. 29. </bean>
    30. 30. <bean id=&quot;bloggingServiceComponent&quot; class=&quot;org.apache.aries.samples.blog.biz.BloggingServiceImpl&quot;>
    31. 31. <property name=&quot;blogEntryManager&quot; ref=&quot;blogEntryManager&quot;/>
    32. 32. <property name=&quot;blogAuthorManager&quot; ref=&quot;blogAuthorManager&quot;/>
    33. 33. </bean>
    34. 34. <service ref=&quot;bloggingServiceComponent&quot; interface=&quot;org.apache.aries.samples.blog.api.BloggingService&quot;/>
    35. 35. <reference id=&quot;persistenceManager&quot; interface=&quot;org.apache.aries.samples.blog.api.persistence.BlogPersistenceService&quot;/> </li></ul>
    36. 36. <ul>Aries Blueprint Container </ul>A static assembly and configuration of components (POJOs) ‏ <ul>Managed beans </ul><ul>publishes service </ul><ul>consumes service </ul><ul>Blueprint bundle </ul><ul>OSGI-INF/blueprint/ blueprint.xml </ul>
    37. 37. <ul>Aries JNDI integration </ul><ul><li>Provides JNDI-based access to OSGi Service Registry </li></ul><ul>< blueprint xmlns =... > < bean id = &quot;bloggingServiceComponent&quot; class = &quot;org.apache.aries.samples.blog.biz.BloggingServiceImpl&quot; > </ bean > < service ref = &quot;bloggingServiceComponent&quot; interface = &quot;org.apache.aries.samples.blog.api.BloggingService&quot; /> ... </ blueprint > </ul><ul>registerService </ul><ul>InitialContext ic = new InitialContext(); BloggingService blog= ic.lookup( &quot;osgi:services/&quot; + BloggingService. class .getName()); </ul><ul>getService </ul><ul><li>A way for a Web component to access a Blueprint component </li></ul><ul>OSGi Service Registry </ul><ul>JNDI Context </ul>
    38. 38. <ul>Example “Blog” Application Architecture </ul><ul>Blogging Service </ul><ul>Blog Persistence Service </ul><ul>blog-web </ul><ul>Web application bundle </ul><ul><li>MetaPersitstence </li></ul><ul>WEB-INF/ web.xml </ul><ul>OSGI-INF/blueprint/ blueprint.xml </ul><ul>OSGI-INF/blueprint/ blueprint.xml </ul><ul>META-INF/ persistence.xml </ul><ul>JNDI </ul><ul>blog.eba </ul><ul>blog-biz </ul><ul>blog-persistence </ul><ul>blog-api </ul>
    39. 39. <ul>Blog Sample - persistence.xml </ul><persistence-unit name=&quot;blogExample&quot; transaction-type=&quot;JTA&quot;> <description>Persistence unit for the example blogging application</description> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider> <jta-data-source>osgi:services/javax.sql.DataSource/(osgi.jndi.service.name=jdbc/blogdb) </jta-data-source> <non-jta-data-source>osgi:services/javax.sql.DataSource/(osgi.jndi.service.name=jdbc/blogdbnojta) </non-jta-data-source> <class>org.apache.aries.samples.blog.persistence.jpa.entity.AuthorImpl</class> <class>org.apache.aries.samples.blog.persistence.jpa.entity.EntryImpl</class> <exclude-unlisted-classes>true</exclude-unlisted-classes> </persistence-unit> OpenJPA
    40. 40. <ul>Aries JPA Container – Blueprint Integration </ul>Example blueprint with JPA resource injection and container-managed transactions <ul><bean id=&quot;persistenceImpl&quot; <li>class=&quot;org.apache.aries.samples.blog.persistence.jpa.BlogPersistenceServiceImpl&quot;>
    41. 41. <tx:transaction method=&quot;*&quot; value=&quot;Required&quot; />
    42. 42. <jpa:context property=&quot;entityManager&quot; unitname=&quot;blogExample&quot; />
    43. 43. </bean>
    44. 44. <service ref=&quot;persistenceImpl&quot;
    45. 45. interface=&quot;org.apache.aries.samples.blog.api.persistence.BlogPersistenceService&quot;>
    46. 46. </service> </li></ul>
    47. 47. <ul>Example “Blog” JPA persistence bundle </ul><ul><li>MetaPersistence </li></ul><ul>OSGI-INF/blueprint/ blueprint.xml </ul><ul>META-INF/ persistence.xml </ul><ul>blog-persistence </ul><ul>Blog Persistence Service </ul>The JPA container finds jpa:context and injects a managed persistence context. The declarative transactions runtime locates the transaction metadata and enforces the defined transaction behaviour <ul>Entity Manager <li>Factory Service </li></ul>The Aries JPA container uses the MetaPersistence and the persistence.xml to register the EM Factory service
    48. 48. <ul>Example “Blog” JPA persistence bundle </ul>Queue <ul>Blog Persistence Service </ul><ul><li>MetaPersistence </li></ul><ul>OSGI-INF/blueprint/ blueprint.xml </ul><ul>META-INF/ persistence.xml </ul><ul>blog-persistence </ul><ul>Entity Manager <li>Factory Service </li></ul>
    49. 49. JDBC vs JPA comparison JDBC persistence JPA persistence Number of ';' in Java source 238 86 Number of bundles used by platform 18 34
    50. 50. public void createAuthor(String email, Date dob, String name, String displayName, String bio) { try { Connection connection = dataSource.getConnection(); String sql = &quot;INSERT INTO AUTHOR VALUES (?,?,?,?,?)&quot;; PreparedStatement ppsm = connection.prepareStatement(sql); ppsm.setString(1, email); ppsm.setString(2, bio); ppsm.setString(3, displayName); if (dob != null) ppsm.setDate(4, new java.sql.Date(dob.getTime())); else ppsm.setDate(4, null); ppsm.setString(5, name); int insertRows = ppsm.executeUpdate(); ppsm.close(); connection.close(); if (insertRows != 1) throw new IllegalArgumentException(&quot;The Author &quot; + email + &quot; cannot be inserted.&quot;); } catch (SQLException e) { e.printStackTrace(); throw new IllegalArgumentException(e.getMessage()); } } createAuthor() method in JDBC persistence service implementation
    51. 51. public void createAuthor(String email, Date dob, String name, String displayName, String bio) { AuthorImpl a = new AuthorImpl(); a.setEmail(email); a.setName(name); a.setDisplayName(displayName); a.setBio(bio); a.setDob(dob); em.persist(a); } Example: createAuthor() method in JPA persistence service implementation
    52. 52. <ul>Current Aries Consumers </ul><ul><li>Aries SNAPSHOT builds available right now
    53. 53. Aries 0.1 Release will be available soon.
    54. 54. Aries components are currently used by: </li></ul><ul><ul><li>Apache Geronimo
    55. 55. Apache Felix Karaf
    56. 56. JBossOSGi
    57. 57. WebSphere Application Server </li></ul></ul>
    58. 58. <ul>Futures </ul><ul><li>There are many new application-centric features that Aries may develop including: </li></ul><ul><ul><li>message-driven blueprint components and services
    59. 59. declarative role-based security for blueprint components
    60. 60. annotation-based alternative to XML configuration
    61. 61. resource-reference metadata and bindings </li></ul></ul><ul>(Original Proposal: http://wiki.apache.org/incubator/AriesProposal) </ul><ul><li>Interested in getting involved? </li></ul><ul><ul><li>http://incubator.apache.org/aries/gettinginvolved.html </li></ul></ul>
    62. 62. <ul>The end........ </ul>
    63. 63. <ul>Aries JPA Container – Application Managed PUs </ul><ul><li>Persistence bundle </li></ul><ul><li>Bundle Manifest
    64. 64.
    65. 65. Meta-Persistence:
    66. 66. META-INF/persistence.xml </li></ul><ul><li>META-INF/
    67. 67. persistence.xml </li></ul><ul><li>OSGI-INF/blueprint/
    68. 68. blueprint.xml </li></ul>JPA container looks for MetaData persistence Headers. Locates descriptions and registers an EM Factory Service using data from - persistence.xml - JPA provider - DataSource <ul><li>JPA provider (Open JPA) </li></ul>DataSource (blogDB) JNDI Implementation of PersistenceProvider <ul><li>org.apache.aries.jpa.container </li></ul>
    69. 69. <ul>Aries JPA Container – Container Managed PUs </ul><ul><li>Persistence bundle </li></ul><ul>Bundle Manifest … Meta-Persistence: OSGI-INF/persistence.xml </ul><ul>META-INF/ <li>persistence.xml </li></ul><ul>OSGI-INF/blueprint/ blueprint.xml </ul>BP container calls service if it encounters a jpa namespace element Calls the container service to let It know there is a new client Registers EM factory shadow Against the persistence service <ul><li>org.apache.aries.jpa.blueprint.aries </li></ul><ul><li>org.apache.aries.jpa.container.context </li></ul>
    70. 70. <ul>Aries JTA transactions </ul><ul><li>Persistence bundle </li></ul><ul>Bundle Manifest … Meta-Persistence: OSGI-INF/persistence.xml </ul><ul>META-INF/ <li>persistence.xml </li></ul><ul>OSGI-INF/blueprint/ blueprint.xml </ul>BP container calls Namespace Manager service if it encounters a jta namespace element Transaction Manager service called by interceptor to start and end transactions. <ul><li>org.apache.aries.transaction.blueprint </li></ul>org.apache.aries.transaction.manager <ul><li>JTA provider (Geronimo) </li></ul>

    ×