beyond j2ee 1 4
play

Beyond J2EE 1.4 Peter Trger Hasso-Plattner-Institute University of - PowerPoint PPT Presentation

Beyond J2EE 1.4 Peter Trger Hasso-Plattner-Institute University of Potsdam Agenda J2EE Future JSR Process, EE 5, EJB 3 Sun AppServer 9, JBoss 5, OpenEJB Dependency Injection & Inversion of Control Hivemind, Spring,


  1. Beyond J2EE 1.4 Peter Tröger Hasso-Plattner-Institute University of Potsdam

  2. Agenda � J2EE Future � JSR Process, EE 5, EJB 3 � Sun AppServer 9, JBoss 5, OpenEJB � Dependency Injection & Inversion of Control � Hivemind, Spring, PicoContainer, Plexus, Yan, Avalon, Tapestry � Object-relational persistence � Hibernate, XMLBeans, Castor � Servlet-based frameworks - Struts � Sources: Sun JSR & GlassFish material, Martin Fowler homepage, different project sites

  3. JSR Process � Java Community Process (JCP) for development of specifications (since 1995) � Initiation (approved by executive committee) � Early draft (for review by the public domain) � Public draft (reference implementation, compatibility toolkit) � Maintenance (document updates) � Java Specification Request (JSR) � Proposed and final specifications for Java platform � Review / approval process

  4. Java EE 5 Platform � Next version of J2EE platform � Latest versions of Java technology � Enterprise JavaBeans (EJB) 3.0 (JSR-220) � JavaServer Faces (JSF) 1.2 (JSR-252) � Servlet 2.5 � JavaServer Pages (JSP) 2.1 � Java API for Web Services (JAX-WS) 2.0 (JSR-224) � Web Services Metadata (JSR-181) � Java Architecture for XML Binding (JAXB) 2.0 (JSR-222) � Java Persistence 1.0 (JSR-220) � Common Annotations 1.0 (JSR-250) � Streaming API for XML (StAX) 1.0 (JSR-173)

  5. Java Enterprise System Application Platform Suite Zur Anzeige wird der QuickTime™ Dekompressor „TIFF (LZW)“ benötigt.

  6. Java EE 5 Major Features � Simplified web service support � More web service standards support � Simplified EJB development � New persistence API � Easier web applications with JavaServer Faces � Most specs available for review � Spec at Proposed Final Draft state - Q4 2005 � Java EE 5 SDK Beta release - Q1 2006 � Java EE 5 Final release - Q2 2006

  7. Project GlassFish � Open Source Java EE 5 Application Server � Sun AppServer Platform Edition 9 � Open access to code and binaries � Integrates with NetBeans, Sun Java Studio Enterprise, Eclipse � Standard Edition � Advanced security, self-managing, self-healing � Clustering, multi-machine administration � Enterprise Edition � Support for high availability

  8. Grizzly HTTP Framework � Highly scalable HTTP path � Thousands of connections with few Java threads � Uses lower level Java NIO primitives � Easy-to-use, high-performance APIs for socket communication � Brings non-blocking sockets to the HTTP processing layer � Integrates with current Apache Tomcat HTTP Connector architecture (Tomcat 3,4,5) � Replaces Apache Tomcat Coyote HTTP front-end and thread pool � High-performance buffers and parsing classes

  9. Fast Infoset � Optimized Binary XML transport mechanism - fast web services � Transparently used by web service communication stack � TS-7187

  10. GlassFish JBI Integration � Java Business Integration (JBI) standard � JSR 208 � SOA-way of Enterprise Application Integration � Normalized Message Router � OpenESB - Enterprise Service Bus product, out-of-box support for SOAP and JMS � Java EE web services (EJBs and Servlets) are automatically enabled in Normalized Message Router � JAXWS communication can be routed in-process to Normalized Message Router

  11. EJB 3.0 � Coordinated in JSR 220 � POJO-based programming (Plain Old Java Object) � No more Home interfaces � Backward compatibility � Extensive use of annotations, reduced need for deployment descriptors � Specification of default behavior, reduces configuration overhead � Dependency injection with annotations � Improved EJB-QL (Update, Delete, Inner / Outer Join, SQL) � Manager concept for entity bean POJOs � Less checked exceptions � Improved performance Read-only beans � Relationship pre-fetching �

  12. Annotations as Descriptors Only RUNTIME annotations used � Available in class file, read by runtime, simplifies container development � Deployment descriptors overwrite annotation configuration � Annotation for business interface and references � Business interfaces are optionally generated � Lifetime management through annotated functions � (@PreDestroy, @PostConstruct) @Stateless @Remote public class HelloWorldBean { public String getHello() { return „Hello World“; } @PreDestroy cleanUp() { // logic before destruction of the instance }}

  13. EJB 3 Example @Stateless public class PayrollBean implements Payroll { @Resource DataSource empDB; public void setBenefitsDeduction (int empId, double deduction) { ... Connection conn = empDB.getConnection(); ... } ... } ---------------------------------------------------- @EJB ShoppingCart myCart; Collection widgets = myCart.startToShop(“widgets”);

  14. EE 5 Web Service Example @WebService(name=”MySimpleWS”); public class RandomClass { @WebMethod public String sayHello (String s) {...} public void unpublished() {...} } ------------------------------------------------------- @WebServiceRef ( wsdlLocation= ” http://localhost:8080/SayHelloService?WSDL ”);) static javaone.SayHelloService wsService; public static void main(String[] args) { javaone.SayHello wsPort = wsService.getHello(); wsPort.sayHello(“FOSS.in Attendees”); }

  15. AOP through Interceptors public class MyInterceptor { @AroundInvoke public Object myInterceptionMethod( InvocationContext inv) throws Exception { // Code for advice return inv.proceed(); } @Interceptors ({„org.example.MyInterceptor"}) public class HelloWorldBean {...}

  16. Java 6 (“Mustang”) � Coordinated in JSR 270 � Development snapshots / sources available � New bytecode verifier for improved performance � JFC / Swing / AWT improvement, Java 2D API, better internationalization � Java Compiler API (JSR 199) � XML and Web Services (XML Signatures, JAX-WS 2.0, JAXB 2.0, JDBC 4.0, JMX 1.3) � Set of improvements for Java 5 features � Sources available

  17. Open Source Efforts beyond J2EE 1.4 � Huge amount of activities to build alternatives to the J2EE 1.4 technologies � Interfaces are good abstraction, but where does the interface implementation class come from ? � Heavyweight complexity � Component wiring as main problem � lightweight containers

  18. Component Wiring – The Problem public interface MovieFinder { List findAll(); class MovieLister { private MovieFinder finder ; public MovieLister() { finder = new ColonDelimitedMovieFinder ("movies1.txt"); } public Movie[] moviesDirectedBy(String arg) { List allMovies = finder.findAll(); for (Iterator it = allMovies.iterator(); it.hasNext();) { Movie movie = (Movie) it.next(); if (!movie.getDirector().equals(arg)) it.remove(); } return (Movie[]) allMovies.toArray(new Movie[allMovies.size()]); } }

  19. Component Wiring Through Dependency Injection � Assembling of ‚plugin‘-style components through „ Inversion of Control“ (IoC) � Separate assembler object injects an implementation into the plugin-using component � Prevents tight coupling of specific interface implementation and interface users � „Dependency Injection“ pattern

  20. Dependency Injection – Constructor Injection � Parameterized constructor of interface user takes injected implementation � Configuration code about injected objects � In different class (PicoContainer project) � In XML file (NanoContainer project) � Client asks IoC framework for instance public void testWithPico() { MutablePicoContainer pico = configureContainer(); MovieLister lister = (MovieLister)pico.getComponentInstance(MovieLister.class); Movie[] movies = lister.moviesDirectedBy("Sergio Leone"); ...}

  21. PicoContainer Example class MovieLister... public MovieLister(MovieFinder finder) { this.finder = finder; } class ColonMovieFinder... public ColonMovieFinder(String filename) { this.filename = filename; } private MutablePicoContainer configureContainer() { MutablePicoContainer pico = new DefaultPicoContainer(); Parameter[] finderParams = { new ConstantParameter("movies1.txt") }; pico.registerComponentImplementation ( MovieFinder.class , // the interface ColonMovieFinder.class , // the implementation finderParams ); pico.registerComponentImplementation(MovieLister.class); return pico; }

  22. Dependency Injection – Setter Injection � Assembler hands dependency instances through a setter method after instantiation � No atomic setting like with constructor injection � Main concept in the Spring framework public void testWithSpring() throws Exception { ApplicationContext ctx = new FileSystemXmlApplicationContext("spring.xml"); MovieLister lister = (MovieLister) ctx.getBean("MovieLister"); Movie[] movies = lister.moviesDirectedBy("Sergio Leone"); }

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend