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