JAVA BEANS JSP - Standard Tag Library (JSTL) JAVA Enterprise Edition.
Java Enterprise Edition 6 Overview
-
Upload
eugene-bogaart -
Category
Technology
-
view
2.839 -
download
3
description
Transcript of Java Enterprise Edition 6 Overview
1
Developer at ease with Java EE 6
JavaNight@capgeminiDecember 7, 2009
Eugene BogaartSolution ArchitectSun Microsystems NL
1
2
Java EE: Past & Present
JPEJPEProjectProject
J2EE 1.2J2EE 1.2ServletServlet JSPJSPEJBEJB JMSJMS
RMI/IIOPRMI/IIOP
Enterprise Java Enterprise Java PlatformPlatform
J2EE 1.3J2EE 1.3CMPCMP
ConnectorConnectorArchitectureArchitecture
RobustnessRobustness
J2EE 1.4J2EE 1.4WebWeb
Services Services Management Management DeploymentDeployment
Async. Async. ConnectorConnector
Java EE 5Java EE 5 Ease of Ease of Development Development AnnotationsAnnotations EJB 3.0EJB 3.0 PersistencePersistence New and New and Updated Updated Web Services Web Services
Java EE 6 Pruning Extensibility Profiles Ease of Development EJB Lite RESTful Services Dependency Ejection
Web Profile
WebWebServicesServices
Ease ofEase ofDevelopmentDevelopment
RightsizingRightsizing
3
Java EE 6 Overview
4
Rightsizing the Platform: Profiles
• Decouple specifications to allow more combinations
• Expand potiential licensee ecosystem
• Profiles> Targeted technology bundles> Web Profile
Platform Flexibility
5
• Profiles are targeted bundles of technologies• (Simple) rules set by platform spec• Profiles can be subsets, supersets or overlapping• First profile: the Web Profile• Decoupling of specs to allow more combinations• Future profiles defined in the Java Community
Process
Profiles
6
Rightsizing the Platform
• Fully functional mid-sized profile
• Actively discussed> Expert Group> Industry
• Technologies> Servlet 3.0, EJB Lite 3.1, JPA 2.0, JSP
2.2, EL 1.2, JSTL 1.2, JSF 2.0, JTA 1.1, JSR 45, Common Annotations
Web Profile
9
Rightsizing the Platform
• Some technologies optional> Optional in next release> Deleted in subsequent release> Marked in Javadocs
• Pruning list> JAX-RPC> EJB 2.x Entity Beans> JAXR> JSR-85 (Rules based Auth & Audit)
Pruning (Deprecation)
11
Rightsizing the Platform
• Embrace open source libraries and frameworks
• Zero-configuration, drag-n-drop web frameworks> Servlets, servlet filters> Framework context listeners
are discovered & registered• Plugin library jars using Web
Fragments
Extensibility
12
Ease of Development
• Continue Java EE 5 advancements• Primary focus: Web Tier• Multiple areas easier to use: EJB 3.1• General Principles
> Annotation-based programming model> Reduce or eliminate need for
deployment descriptors> Traditional API for advanced users
Extensibility
15
Ease of Development
Adding an EJB to a Web Application
BuyBooks.warBuyBooks.war ShoppingCartShoppingCartEJB ClassEJB Class
ShoppingCart.jarShoppingCart.jar
BuyBooks.earBuyBooks.ear
ShoppingCartShoppingCartEJB ClassEJB Class
BuyBooks.warBuyBooks.war
16
Ease of Development - Annotations
Servlet in Java EE 5: Create two source files<!--Deployment descriptor web.xml
--><web-app>
<servlet><servlet-name>MyServlet
</servlet-name> <servlet-class> com.foo.MyServlet </servlet-class> </servlet> <servlet-mapping> <servlet-name>MyServlet </servlet-name> <url-pattern>/myApp/* </url-pattern> </servlet-mapping> ... </web-app>
/* Code in Java Class */package com.foo;public class MyServlet extends HttpServlet {public void doGet(HttpServletRequest req,HttpServletResponse res) {
...
}
...
}
17
Ease of Development - Annotations
Servlet in Java EE 5: Java Class/* Code in Java Class */package com.foo;public class MyServlet extends HttpServlet {
public void doGet(HttpServletRequest req,HttpServletResponse res) {
/* doGet body */ }
}
18
Ease of Development - Annotations
Servlet in Java EE 5: Descriptor<!--Deployment descriptor web.xml --><web-app>
<servlet><servlet-name>MyServlet
</servlet-name> <servlet-class> com.foo.MyServlet </servlet-class> </servlet> <servlet-mapping> <servlet-name>MyServlet </servlet-name> <url-pattern>/myApp/* </url-pattern> </servlet-mapping> ... </web-app>
19
Ease of Development - Annotations
Java EE 6 Servlet: Single Source file (many cases)
package com.foo;@WebServlet(name=”MyServlet”, urlPattern=”/myApp/*”)public class MyServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res)
{...
}
20
DemoJava EE 6
21
Servlet 3.0Other annotation for servlets• @ServletContextListener• @ServletFilter• @FilterMapping(urlPattern=”/foo”)
SKIP
32
Enterprise Java Beans3.1 Lite Highlights
33
EJB 3.1 Sample Simple Singleton @Singletonpublic class SharedBean {
private SharedData shared;
@PostConstruct private void init() { shared = ...; } public int getXYZ() { return shared.xyz; }}
34
Singleton Client@Stateless public class FooBean { // Inject reference to Singleton bean @EJB private SharedBean shared;
public void foo() { int xyz = shared.getXYZ(); ... }}
35
EJB 3.1 Sample – Calendar Timer@Stateless
public class TimerBean {
@Schedule(dayOfWeek=”Sun”) public void onSunday() { ... periodically do some work ...
}}
36
EJB 3.1 No Local Business InterfaceJust a bean class@Stateless
public class HelloWorldBean {/* no interface */ public String hello(String name) { return “hello, “ + name; }}//Still a EJB reference@EJB HelloWorldBean hello;hello.hello(“David”);
37
EJB 3.1 Lite• Simple, modern subset of EJB for use outside of the
full platform• Contents:
> Session beans (stateful, stateless, singletons)> Transaction and security attributes> Interceptors> Annotations/ejb-jar.xml
• Embeddable container API• Beans looked up by global name
38
JavaServer Faces 2.0 Highlights
39
JavaServer Faces 2.0• Top Five Goals
> Make custom components much easier to develop > Ajax support> Page description language (PDL)> Reduce the configuration burden> Provide for better compatibility between JSF component
libraries from different vendors
40
Ingredients of a JavaServer Faces Component+Ajax solution• Resource Delivery Mechanism• Partial Tree Traversal• Partial Page Update• Ajaxification Capability
• Ajax Enabled Components
↑ In JSF 2.0 Spec
↓ In Component Library
41
Ingredients of a JavaServer Faces component+Ajax solution
Resource Delivery Mechanism
• Delivers static resources to the user-agent in response to HTTP GET requests
• Includes support for localized, versioned resources and resource libraries
42
Ingredients of a JavaServer Faces component+Ajax solutionPartial Tree Traversal
43
Ingredients of a JavaServer Faces Component+Ajax solutionPartial Page Update
44
Ingredients of a JavaServer Faces Component+Ajax solution
Ajaxification Capability• A way to give ajax capability to existing JavaServer
Faces components without writing any JavaScript™ language
• Common approaches include> AjaxZone tag, enclose region to ajaxify> AjaxSupport tag, nest inside of component to ajaxify
45
Ingredients of a JavaServer Faces Component+Ajax solution
Ajax Enabled Components• Such components always build on top of the
previous ingredients• Current offerings are tightly coupled to their specific
implementation of the previous ingredients.• By standardizing the foundations upon which these
components build, we can guarantee interoperability between them.
46
Wrapup
47
Java Enterprise Edition 6
• Public reviews complete• Final and released• IDE support from NB 6.8• & GlassFish v3
> Reference Implementation
Status
48
NetBeans & Java EE 6
New: (Java EE 6)• Java EE6 Web Projects with profiles & EJBs in
web Apps• EJB 3.1 project support• RESTful web services (JAX-RS 1.1), GlassFish
Metro 2.0 web services (JAX-WS 2.2), JAXB 2.2 • Java Persistence JPA 2.0, deployment, debugging
and profiling with GlassFish v3 application server
Version 6.8 (released this Month)
49
NetBeans & Java EE 6
More updates on • Java Server Faces 2.0 • JavaFX 1.2.1• Kenai.Com: Connected Developer• Ruby & PHP• Maven• C/C++
Version 6.8 (released this Month)
• And much more
50
Participate!
• Learn about Java EE 6 with NetBeans 6.8• Download GlassFish V3 (incl with NB 6.8 Full)• Send feedback on the component technologies.• Participate.• Contribute.• Enjoy!
Page 1
1
Developer at ease with Java EE 6
JavaNight@capgeminiDecember 7, 2009
Eugene BogaartSolution ArchitectSun Microsystems NL
1
Page 2
2
Java EE: Past & Present
JPEJPEProjectProject
J2EE 1.2J2EE 1.2ServletServlet JSPJSPEJBEJB JMSJMS
RMI/IIOPRMI/IIOP
Enterprise Java Enterprise Java PlatformPlatform
J2EE 1.3J2EE 1.3CMPCMP
ConnectorConnectorArchitectureArchitecture
RobustnessRobustness
J2EE 1.4J2EE 1.4WebWeb
Services Services Management Management DeploymentDeployment
Async. Async. ConnectorConnector
Java EE 5Java EE 5 Ease of Ease of Development Development AnnotationsAnnotations EJB 3.0EJB 3.0 PersistencePersistence New and New and Updated Updated Web Services Web Services
Java EE 6 Pruning Extensibility Profiles Ease of Development EJB Lite RESTful Services Dependency Ejection
Web Profile
WebWebServicesServices
Ease ofEase ofDevelopmentDevelopment
RightsizingRightsizing
Each release of Java EE or J2EE had an overarching umbrella theme. J2EE 1.2 defined the overall platform as we know it today. 1.3 built on top of 1.2 adding robustness and introduced features like connector architecture.
J2EE 1.4 focussed on Web Services primarily through the 109 specification. With Java EE 5, there was a recognition that perhaps the platform should be easier to program with. Consequently a lot of effort was put into using Annotations and allow for ease of development with Java EE 5. Apart from annotations with EJB 3.0 – EJBs were made easier to program with and JPA i.e. persistence specification was added.
With EE 6 – there is a recoginition that as we have added features over the years, the platform has grown big. Consequently the theme has been “Right Sizing” the platform. We will delve into what rightsizing is and how it is achieved.
EE 6 also continues on the ease of development theme set by Java EE 5. Almost all the spec have some ease of use annotations introduced.
Page 3
3
Java EE 6 Overview
●Make the platform:● Easier to use● More flexible, adaptable● Easier to learn● Easier to evolve going forward●
Major New Features●Profiles●Pruning●Extensibility●Ease of development
Page 4
4
Rightsizing the Platform: Profiles
• Decouple specifications to allow more combinations
• Expand potiential licensee ecosystem
• Profiles> Targeted technology bundles> Web Profile
Platform Flexibility
As part of right sizing – the notion of profiles was defined. Right sizing is really right sizing for you. The idea is to allow multiple specifications to be coupled in a manner such that they satisify a business need. For example – the web profile targets the web development needs. You could have additional profiles for eg: a telco profile that will target the telco market.
This gives companies an opportuniity to build and license a profile that they are specialized in. What this means for you as a developer, adopter or a company is that you will have a large ecosystem of licensed products to choose from. This increased set of choices can help you choose the product that meets your specific requirements.
Page 5
5
• Profiles are targeted bundles of technologies• (Simple) rules set by platform spec• Profiles can be subsets, supersets or overlapping• First profile: the Web Profile• Decoupling of specs to allow more combinations• Future profiles defined in the Java Community
Process
Profiles
Page 6
6
Rightsizing the Platform
• Fully functional mid-sized profile
• Actively discussed> Expert Group> Industry
• Technologies> Servlet 3.0, EJB Lite 3.1, JPA 2.0, JSP
2.2, EL 1.2, JSTL 1.2, JSF 2.0, JTA 1.1, JSR 45, Common Annotations
Web Profile
An example of profile is the web profile.
The web profile is targeted to the “modern” web applications. The way web applications are written have changed since the first servlet specification came about. .Most web applications have significant requirements in the areas of transaction management, security and persistence. Such requirements can be readily addressed by technologies that have been part of the Java EE platform for quite some time, such as the Enterprise JavaBeans (EJB) 3.x technology and the Java Persistence API, but that are rarely supported by “plain” servlet containers. By incorporating many of these APIs, the Web Profile aims at raising the bar for what should be considered a basic stack for the development of web applications using the Java platform.
Targeting “modern” web applications then implies offering a reasonably complete stack, composed of standard APIs, and capable out-of-the-box of addressing the needs of a large class of web applications. Furthermore, this stack should be easy to grow, so as to address any remaining developer needs.
Against this drive towards completeness, one wishes to balance a desire to limit the footprint of web containers, both in physical and in conceptual terms. From the point of view of developers learning the Web Profile, it is more valuable to have a small, focused profile, with as little overlap between technologies as possible, rather than a more powerful but overly complex one, with redundant APIs.
Page 9
9
Rightsizing the Platform
• Some technologies optional> Optional in next release> Deleted in subsequent release> Marked in Javadocs
• Pruning list> JAX-RPC> EJB 2.x Entity Beans> JAXR> JSR-85 (Rules based Auth & Audit)
Pruning (Deprecation)
- admitting the fact that the platform grew. Some technologies did not have the adoption in the market place or the underlying technology did not have the adoption.- UDDI – JAXR- Same with JSR-85.- Pruning makes it optional.As the APIs are trimmed down, the Expert Group hopes to reduce the need for APIs that may have limited appeal by providing more extensibility points within the specification. These interfaces and plug-in points should make it easier to create technologies that extend that platform whilst remaining well integrated into it, and may help the specification itself regain some of its focus.
Page 11
11
Rightsizing the Platform
• Embrace open source libraries and frameworks
• Zero-configuration, drag-n-drop web frameworks> Servlets, servlet filters> Framework context listeners
are discovered & registered• Plugin library jars using Web
Fragments
Extensibility
- Container Initializer: Framework writer defines the kinds of resources it handles. At runtime the Container delegates requests to it. The framework serves the request. - The framework writer defines a CI. The developer does not need to do anything. The framework is bootstrapped by simply by including in the class path- The second technique is for an application developer to bundle the framework with the app.In this case the framework writer has defined a web-fragment.xml that indicates the kind of resources it serves. At runtime, the container gives the framework an opportunity to serve the requests.
- In GF we have actually refactored JSP, JSF containers to be plugged in this way with GF v3. Additionally scripting containers have also been integrated this way. With this technology – you will be able to integrate third party frameworks into your existing Java EE 6 installations.
Page 12
12
Ease of Development
• Continue Java EE 5 advancements• Primary focus: Web Tier• Multiple areas easier to use: EJB 3.1• General Principles
> Annotation-based programming model> Reduce or eliminate need for
deployment descriptors> Traditional API for advanced users
Extensibility
Page 15
15
Ease of Development
Adding an EJB to a Web Application
BuyBooks.warBuyBooks.war ShoppingCartShoppingCartEJB ClassEJB Class
ShoppingCart.jarShoppingCart.jar
BuyBooks.earBuyBooks.ear
ShoppingCartShoppingCartEJB ClassEJB Class
BuyBooks.warBuyBooks.war
●Ejb 3.1 ●Simplified packaging●Singleton beans: @Singleton●No interface view: one source file per bean●Calendar timers: @Schedule(dayOfWeek=“Mon,Wed”)●Global JNDI names for beans
● java:global/(app)/(module)/(bean)#(interface)
Page 16
16
Ease of Development - Annotations
Servlet in Java EE 5: Create two source files<!--Deployment descriptor web.xml
--><web-app>
<servlet><servlet-name>MyServlet
</servlet-name> <servlet-class> com.foo.MyServlet </servlet-class> </servlet> <servlet-mapping> <servlet-name>MyServlet </servlet-name> <url-pattern>/myApp/* </url-pattern> </servlet-mapping> ... </web-app>
/* Code in Java Class */package com.foo;public class MyServlet extends HttpServlet {public void doGet(HttpServletRequest req,HttpServletResponse res) {
...
}
...
}
Page 17
17
Ease of Development - Annotations
Servlet in Java EE 5: Java Class/* Code in Java Class */package com.foo;public class MyServlet extends HttpServlet {
public void doGet(HttpServletRequest req,HttpServletResponse res) {
/* doGet body */ }
}
Page 18
18
Ease of Development - Annotations
Servlet in Java EE 5: Descriptor<!--Deployment descriptor web.xml --><web-app>
<servlet><servlet-name>MyServlet
</servlet-name> <servlet-class> com.foo.MyServlet </servlet-class> </servlet> <servlet-mapping> <servlet-name>MyServlet </servlet-name> <url-pattern>/myApp/* </url-pattern> </servlet-mapping> ... </web-app>
Page 19
19
Ease of Development - Annotations
Java EE 6 Servlet: Single Source file (many cases)
package com.foo;@WebServlet(name=”MyServlet”, urlPattern=”/myApp/*”)public class MyServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res)
{...
}
Page 20
20
DemoJava EE 6
Page 21
21
Servlet 3.0Other annotation for servlets• @ServletContextListener• @ServletFilter• @FilterMapping(urlPattern=”/foo”)
SKIP
Page 32
32
Enterprise Java Beans3.1 Lite Highlights
Page 33
33
EJB 3.1 Sample Simple Singleton @Singletonpublic class SharedBean {
private SharedData shared;
@PostConstruct private void init() { shared = ...; } public int getXYZ() { return shared.xyz; }}
Everytime, the container starts, the init () will call.
Page 34
34
Singleton Client@Stateless public class FooBean { // Inject reference to Singleton bean @EJB private SharedBean shared;
public void foo() { int xyz = shared.getXYZ(); ... }}
Client is calling this Singleton session bean.
Page 35
35
35
EJB 3.1 Sample – Calendar Timer@Stateless
public class TimerBean {
@Schedule(dayOfWeek=”Sun”) public void onSunday() { ... periodically do some work ...
}}
Page 36
36
36
EJB 3.1 No Local Business InterfaceJust a bean class@Stateless
public class HelloWorldBean {/* no interface */ public String hello(String name) { return “hello, “ + name; }}//Still a EJB reference@EJB HelloWorldBean hello;hello.hello(“David”);
● Sometimes separate local business interface isn't needed
● Better to completely remove interface from developer's view than to generate it
● Result : “no-interface” view● Just a bean class● All public bean class methods exposed to
client● Same behavior and client programming model
as Local view● Client still acquires an EJB reference
instead of calling new()● Not available to Remote clients
Page 37
37
EJB 3.1 Lite• Simple, modern subset of EJB for use outside of the
full platform• Contents:
> Session beans (stateful, stateless, singletons)> Transaction and security attributes> Interceptors> Annotations/ejb-jar.xml
• Embeddable container API• Beans looked up by global name
Page 38
38
JavaServer Faces 2.0 Highlights
Page 39
39
JavaServer Faces 2.0• Top Five Goals
> Make custom components much easier to develop > Ajax support> Page description language (PDL)> Reduce the configuration burden> Provide for better compatibility between JSF component
libraries from different vendors
Page 40
40
Ingredients of a JavaServer Faces Component+Ajax solution• Resource Delivery Mechanism• Partial Tree Traversal• Partial Page Update• Ajaxification Capability
• Ajax Enabled Components
↑ In JSF 2.0 Spec
↓ In Component Library
Page 41
41
Ingredients of a JavaServer Faces component+Ajax solution
Resource Delivery Mechanism
• Delivers static resources to the user-agent in response to HTTP GET requests
• Includes support for localized, versioned resources and resource libraries
Page 42
42
Ingredients of a JavaServer Faces component+Ajax solutionPartial Tree Traversal
Page 43
43
Ingredients of a JavaServer Faces Component+Ajax solutionPartial Page Update
Page 44
44
Ingredients of a JavaServer Faces Component+Ajax solution
Ajaxification Capability• A way to give ajax capability to existing JavaServer
Faces components without writing any JavaScript™ language
• Common approaches include> AjaxZone tag, enclose region to ajaxify> AjaxSupport tag, nest inside of component to ajaxify
Page 45
45
Ingredients of a JavaServer Faces Component+Ajax solution
Ajax Enabled Components• Such components always build on top of the
previous ingredients• Current offerings are tightly coupled to their specific
implementation of the previous ingredients.• By standardizing the foundations upon which these
components build, we can guarantee interoperability between them.
Page 46
46
Wrapup
Page 47
47
Java Enterprise Edition 6
• Public reviews complete• Final and released• IDE support from NB 6.8• & GlassFish v3
> Reference Implementation
Status
And Open Source can really lower TCO.
Many critics say that open source isn’t less expensive as that even though up front costs are less – there are other factors that increase overall costs.
But Sun’s Enterprise Quality open source solves these issues by:
Lower Initial CostLower Annual CostsPay only at the point of value (not up front)Lower skills required (than standard open source) because we make it enterprise quality, pre-bundle, add value addsAnd we add additional value adds to open source which other proprietary vendors add to increase performance, configuration mgmt, version controlAnd we add tools to increase productivity
Page 48
48
NetBeans & Java EE 6
New: (Java EE 6)• Java EE6 Web Projects with profiles & EJBs in
web Apps• EJB 3.1 project support• RESTful web services (JAX-RS 1.1), GlassFish
Metro 2.0 web services (JAX-WS 2.2), JAXB 2.2 • Java Persistence JPA 2.0, deployment, debugging
and profiling with GlassFish v3 application server
Version 6.8 (released this Month)
Web Projects with Java EE 6 and Java EE 6 Web profiles, EJBs in web applications EJB 3.1 support, EJB project file wizard also supports Singleton session type RESTful web services (JAX-RS 1.1), GlassFish Metro 2.0 web services (JAX-WS 2.2), JAXB 2.2 Java Persistence JPA 2.0, deployment, debugging and profiling with GlassFish v3 application server
Page 49
49
NetBeans & Java EE 6
More updates on • Java Server Faces 2.0 • JavaFX 1.2.1• Kenai.Com: Connected Developer• Ruby & PHP• Maven• C/C++
Version 6.8 (released this Month)
• And much more
Web Projects with JavaServer Faces 2.0 (Facelets)• Code & namespace completion and error hints, doc popups, & tag auto-import for Facelets • Editor support for Facelets libraries, composite components, expression language, including generators for JSF and HTML forms • Customizable JSF components palette generates JSF forms and JSF data tables from entities • New File wizard generates customizable CRUD (create/read/update/delete) JSF pages from entities • Broader usage of annotations instead of deployment descriptors
JavaFX
• Added support for the latest JavaFX SDK 1.2.1 • Improved code completion • Editor Hints: Fix Imports, Surround With, Implements Abstract Methods, and more •Improved navigation: Hyperlinks, Go to Type, Find Usages Full JIRA support
Kenai.com (Connected Developer)
(plugin from update center) Project dashboard with more member and project details, improved search and navigation, easier project sharing Improved instant messenger integration: Online presence, private and group chat with Kenai members, easy to add links to code / files /issues / stack traces to messages Improved issue tracker integration
Page 50
50
50
Participate!
• Learn about Java EE 6 with NetBeans 6.8• Download GlassFish V3 (incl with NB 6.8 Full)• Send feedback on the component technologies.• Participate.• Contribute.• Enjoy!