JBoss Application Server (AS) 7 Jason Shepherd Middleware Support Engineer, Red Hat November 17 th , 2011
Introducing JBoss AS 7 <ul><li>Application Server </li><ul><li>Key features </li></ul><li>Java Enterprise Edition (JEE) 6 ...
Managed Beans
Context and Dependency Injection </li></ul><li>Integration Testing with Arquallian </li><ul><li>demo </li></ul></ul>
Community vs Enterprise Releases <ul><li>JBoss AS 7.0.2 current  </li><ul><li>EE 6 Web Profile </li></ul><li>JBoss AS 7.1 ...
JBoss EAP 6 based on AS 7.1 </li></ul>
Key features – Lightweight Container  <ul><li>Fast startup, < 3 sec </li><ul><li>Lazy loading of services </li></ul><li>Si...
Fast Startup <ul><li>Services are started on demand </li><ul><li>CDI beans.xml triggers CDI service (Weld) </li></ul><li>N...
Simplified Classloading <ul><li>Java EE service dependencies only </li><ul><li>/WEB-INF/beans.xml exposes org.jboss.weld.c...
Greeter cannot access org.slf4j  </li></ul></ul>com.redhat.greeter org.slf4j org.jboss.weld.core
Benefits of Java EE? <ul><li>Standard platform comprised of managed components & services </li></ul><ul><li>Write business...
Higher signal-to-noise ratio
Powerful mechanisms for free
Portable knowledge </li></ul></ul>
Drawbacks of Java EE 5 <ul><li>@Local and @Remote interfaces
Non Embeddable EJB container
Complex packaging
Verbose XML configuration
Boilerplate JNDI lookups </li></ul>
EJB 3.1 to the rescue! <ul><li>No more @Local and @Remote
Embeddable EJB container
EJBs in WAR
Annotation based configuration
EJB in light weight Web Profile </li></ul>
EE 6 Web profile– Key components <ul><ul><li>Managed Beans (JSR-330) </li></ul></ul><ul><ul><ul><li>Google and SpringSourc...
EJBs in WAR archives! </li></ul></ul></ul>
What are managed beans? <ul><li>Everyone throwing around this term  “bean” </li><ul><li>JSF
EJB
Seam
Spring
Guice
Upcoming SlideShare
Loading in …5
×

JBoss AS7 OSDC 2011

1,430 views

Published on

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

No Downloads
Views
Total views
1,430
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
69
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

JBoss AS7 OSDC 2011

  1. 1. JBoss Application Server (AS) 7 Jason Shepherd Middleware Support Engineer, Red Hat November 17 th , 2011
  2. 2. Introducing JBoss AS 7 <ul><li>Application Server </li><ul><li>Key features </li></ul><li>Java Enterprise Edition (JEE) 6 </li><ul><li>EJB 3.1
  3. 3. Managed Beans
  4. 4. Context and Dependency Injection </li></ul><li>Integration Testing with Arquallian </li><ul><li>demo </li></ul></ul>
  5. 5. Community vs Enterprise Releases <ul><li>JBoss AS 7.0.2 current </li><ul><li>EE 6 Web Profile </li></ul><li>JBoss AS 7.1 </li><ul><li>EE 6 Full Certification </li></ul><li>EAP 6 due in early 2012
  6. 6. JBoss EAP 6 based on AS 7.1 </li></ul>
  7. 7. Key features – Lightweight Container <ul><li>Fast startup, < 3 sec </li><ul><li>Lazy loading of services </li></ul><li>Simplified Classloading </li><ul><li>Deploys isolated from container </li></ul><li>User focused configuration </li><ul><li>A single configuration file </li></ul><li>Manage multiple instances at once </li><ul><li>Domain mode </li></ul><li>Smaller memory footprint </li><ul><li>Cloud readiness </li></ul></ul>
  8. 8. Fast Startup <ul><li>Services are started on demand </li><ul><li>CDI beans.xml triggers CDI service (Weld) </li></ul><li>No need to Slim unused features </li></ul>
  9. 9. Simplified Classloading <ul><li>Java EE service dependencies only </li><ul><li>/WEB-INF/beans.xml exposes org.jboss.weld.core
  10. 10. Greeter cannot access org.slf4j </li></ul></ul>com.redhat.greeter org.slf4j org.jboss.weld.core
  11. 11. Benefits of Java EE? <ul><li>Standard platform comprised of managed components & services </li></ul><ul><li>Write business logic as components </li></ul><ul><ul><li>Less code
  12. 12. Higher signal-to-noise ratio
  13. 13. Powerful mechanisms for free
  14. 14. Portable knowledge </li></ul></ul>
  15. 15. Drawbacks of Java EE 5 <ul><li>@Local and @Remote interfaces
  16. 16. Non Embeddable EJB container
  17. 17. Complex packaging
  18. 18. Verbose XML configuration
  19. 19. Boilerplate JNDI lookups </li></ul>
  20. 20. EJB 3.1 to the rescue! <ul><li>No more @Local and @Remote
  21. 21. Embeddable EJB container
  22. 22. EJBs in WAR
  23. 23. Annotation based configuration
  24. 24. EJB in light weight Web Profile </li></ul>
  25. 25. EE 6 Web profile– Key components <ul><ul><li>Managed Beans (JSR-330) </li></ul></ul><ul><ul><ul><li>Google and SpringSource submitted JSR-330 with the aim of standardising &quot;a proven, non-controversial set of annotations that make injectable classes portable across frameworks&quot; </li></ul></ul></ul><ul><ul><li>Context and Dependency Injection (CDI) </li><ul><li>Implemented with WELD on AS 7 </li></ul><li>EJB 3.1 </li><ul><li>No Local and Remote Interfaces
  26. 26. EJBs in WAR archives! </li></ul></ul></ul>
  27. 27. What are managed beans? <ul><li>Everyone throwing around this term “bean” </li><ul><li>JSF
  28. 28. EJB
  29. 29. Seam
  30. 30. Spring
  31. 31. Guice
  32. 32. CDI </li></ul><li>Need a “unified bean definition” </li></ul>
  33. 33. Managed bean specification <ul><li>Common bean definition
  34. 34. Instances managed by the container
  35. 35. Common services </li><ul><li>Lifecycle callbacks
  36. 36. Resource injections
  37. 37. Interceptors </li></ul><li>Foundation spec </li></ul>How managed beans evolved: http://www.infoq.com/news/2009/11/weld10 JSF EJB CDI JAX-RS Managed Beans
  38. 38. Resource Injection Revisited in JEE 6 <ul><li>Weakest aspect of JEE 5
  39. 39. Closed set of injectable resources </li><ul><li>@EJB
  40. 40. @PersistenceContext , @PersistenceUnit
  41. 41. @Resource (e.g., DataSource, UserTransaction) </li></ul><li>Name-based injection is fragile </li><ul><li>Not “refactor friendly”
  42. 42. Requires special tooling to validate </li></ul></ul>
  43. 43. Context and Dependency Injection (CDI) Web tier (JSF) Transactional tier (EJB)
  44. 44. What CDI provides <ul><li>Services for Java EE components </li><ul><li>Lifecycle management of stateful beans bound to well-defined c ontexts (including conversation context)
  45. 45. Automatic transaction management for web apps!
  46. 46. A type-safe approach to d ependency i njection
  47. 47. Based on Seam 2
  48. 48. Other features …
  49. 49. http://tinyurl.com/weld-reference-101 </li></ul></ul>
  50. 50. Injection 101 ... public class ManagedGreeter { @Inject Greeter g ; String message = null; public void setMessage(String m ) { this . message = g .greet( m ); } public String getMessage(){ return message ; } }
  51. 51. Welcome to CDI, EJB 3.1 session beans! @Stateless public class Greeter { public String greet(String name) { return &quot;Hello &quot; + name + &quot;!&quot; ; } }
  52. 52. Welcome to CDI, JSF! <ul><li>Use the bean directly in the JSF view </li></ul><h:outputText value = &quot;#{managedGreeter.message}&quot; />
  53. 53. From JEE 5 to JEE6 CDI JSF managed beans Facelets JSP
  54. 54. Stashing the bean in a context @RequestScoped public class ManagedGreeter { @Inject Greeter g ; String message = null; public void setMessage(String m ) { this . message = g .greet( m ); } public String getMessage(){ return message ; } }
  55. 55. Scope types and contexts <ul><li>Absence of sc ope - @Dependent </li><ul><li>Bound to lifecycle of bean holding reference </li></ul><li>Servlet scopes </li><ul><li>@ApplicationScoped
  56. 56. @RequestScoped
  57. 57. @SessionScoped </li></ul><li>JSF conversation scope - @ConversationScoped
  58. 58. Custom scopes </li><ul><li>Define scope type annot ation (e.g., @FlashScoped )
  59. 59. Implement the context API in an extension </li></ul></ul>
  60. 60. Conversation context <ul><li>Request ≤ Conversation ≪ Session </li></ul><ul><li>Boundaries demarcated by application </li></ul><ul><li>Optimistic transaction </li><ul><li>Conversation-scoped persistence context
  61. 61. No fear of exceptions on lazy fetch operations </li></ul></ul>
  62. 62. Controlling the conversation @ConversationScoped public class BookingAgent { @Inject @BookingDatabase EntityManager em ; @Inject Conversation conversation ; private Hotel selected ; private Booking booking ; public void select(Hotel h) { selected = em .find(Hotel. class , h.getId()); conversation.begin() ; } ...
  63. 63. Controlling the conversation ... public boolean confirm() { if (!isValid()) { return false ; } em .persist( booking ); conversation.end() ; return true ; } }
  64. 64. Container-oriented testing for Java EE <ul><li>ShrinkWrap </li><ul><li>Fluent API for creating Java archives </li></ul></ul>JavaArchive archive = ShrinkWrap. create ( &quot;archive.jar&quot; , JavaArchive. class ) .addClasses(MyClass. class , MyOtherClass. class ) .addResource( &quot;mystuff.properties&quot; ); <ul><li>Arquillian </li><ul><li>Integration test harness
  65. 65. Pluggable container support (embedded or remote)
  66. 66. Supports injection into test class
  67. 67. Tests can be run from IDE or build script </li></ul></ul>
  68. 68. Arquillian Maven integration < dependency > < groupId > org.jboss.arquillian.junit </ groupId > < artifactId > arquillian - junit -container </ artifactId > < version > ${arquillian.version} </ version > < scope > test </ scope > </ dependency >
  69. 69. Arquillian Remote vs. Embedded <ul><li>Remote </li><ul><li>Run on a remote server (localhost or other)
  70. 70. No startup/shutdown
  71. 71. Deployed to running container </li></ul><li>Managed </li><ul><li>Runs within the JVM
  72. 72. Startup/Shutdown managed by test harness </li></ul></ul>
  73. 73. How do I get started? <ul><li>Download JBoss AS 7 and Quickstarts </li><ul><li>http://jboss.org/jbossas </li></ul><li>Generate a project using Eclipse & JBoss Tools </li><ul><li>https://www.jboss.org/tools/ </li></ul><li>View the JBoss Quickstart documentation </li><ul><li>https://docs.jboss.org/author/display/ </li></ul><li>Read the Weld reference guide </li><ul><li>http://tinyurl.com/weld-reference-101 </li></ul><li>Browse the CDI JavaDoc </li><ul><li>http://docs.jboss.org/cdi/api/latest/ </li></ul></ul>
  74. 74. What is Openshift? <ul><li>Express </li><ul><li>Free shared-hosting
  75. 75. Java, Perl, PHP, Python, and Ruby </li></ul><li>Flex </li><ul><li>Platform-as-a-Service </li><ul><li>Auto-scaling
  76. 76. Performance monitoring
  77. 77. Application Management </li></ul><li>Java and PHP </li></ul></ul>
  78. 78. Openshift Express <ul><li>Register with an email only
  79. 79. Install the RHC command line tools
  80. 80. Create a domain </li><ul><li>app-domain.redhat.com </li></ul><li>Create an application </li><ul><li>rhc-create-app </li></ul><li>Copy app into git managed directory
  81. 81. Git push </li></ul>
  82. 82. Try JBoss AS 7 today! <ul><li>Lighting fast performance
  83. 83. Java EE 6 compliant
  84. 84. Test in the container using Arquallian
  85. 85. Deploy instantly to Openshift </li></ul>

×