1 / 45

Enterprise Architecture

Enterprise Architecture. Java SE / Java EE Training Awareness. M. Reha, Enterprise Architecture 2009-04-10, v0.1. Agenda. Course #1: Introduction to the Java Language and the Java Platform Course #2: “Hello World” Java programming example Encapsulation, Inheritance, Interfaces

magar
Download Presentation

Enterprise Architecture

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Enterprise Architecture Java SE / Java EE Training Awareness M. Reha, Enterprise Architecture 2009-04-10, v0.1

  2. Agenda • Course #1: • Introduction to the Java Language and the Java Platform • Course #2: • “Hello World” Java programming example • Encapsulation, Inheritance, Interfaces • Course #3: • Introduction to the Java EE Platform • Course #4: • “Hello World” Java EE web application programming example • Web Tier, Business/Services Tier, Persistence Tier 2

  3. Course #1 Introduction to the Java Language and the Java Platform

  4. Course Objectives Learn about the history of Java. Learn about the Java Platform. Learn what the fundamentals of the Java language. 4

  5. What is Java? Is Java just a programming language? What is the JDK? What is Java Standard Edition (Java SE)? What is Java Enterprise Edition (Java EE)? What is the JVM? What is a Java EE Application Server? What is a Java Applet? What is Java Swing? What is a Java Portlet What else? Java ME – Java Mobile Edition (for mobile phones / devices) Java RT – Java Real Time (for embedded real time applications) Java TV – Java for TV (for TV and Set Top Box applications) Java DB – Java based RDBMS Java Card – Java for Smart Cards Java FX – Java building next generation RIA’s 5

  6. Java Desktop Application (Swing, Console, JavaFX) Web Pages Portlets Java Applet JavaFX Applet Mobile Application and Consumer (Java ME, JavaFX, JavaTV) Browser Java EE Application Server WebSphere, Oracle WebLogic, JBoss, etc Java EE Runtime Implements the Java EE API’s Java SE Runtime Also referred to as JRE Implements Java SE API’s Implements Java SE for CDC Java Virtual Machine (JVM) Sun, IBM, Oracle, Apple, etc. JDK (for SE and EE) Compilers, tools, documentation for the developer Java Virtual Machine (JVM) Nokia, Philips, Sony, What is Java? Java is a programming language!Java used as a platform to build applications ranging from web, desktop, mobile, and more!

  7. Introduction to the Java Programming Language Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities. Java applications are typically compiled to byte-code that can run on any Java virtual machine (JVM) regardless of computer architecture. The original and reference implementation Java compilers, virtual machines, and class libraries were developed by Sun from 1995. As of May 2007, in compliance with the specifications of the Java Community Process, Sun made available most of their Java technologies as free software under the GNU General Public License. 7

  8. History of the Java Platform • Java SE Platform: • JDK 1.0 released in January 1996 • JDK 1.1 released in February 1997 • J2SE 1.2 released in January 1998 • J2SE 1.3 released in May 2000 • J2SE 1.4 released in February 2002 • J2SE 5.0 released in September 2004 • J2SE 6.0 released in December 2006 • J2SE 7.0 released in end of 2010 • Java EE Platform: • Java Platform Edition JPE announced in May 1998 • J2EE 1.2 released in December 1999 (peak of the .COM era) • J2EE 1.3 released in September 2001 (end of .COM era) • J2EE 1.4 released in November 2003 • EE 5 released in May 2006 • EE 6 scheduled release for the end of 2008 (approval of JCP specification) • Lots of enterprises are still on J2EE 1.3 from 2002! • The Portlet Specification was not released until October 2003. We are here in 2002! We have some ability to leverage J2SE 5.0 Java RI will be based on J2SE5.0 We are here in 2003! Java RI will be based on EE 5

  9. Java Language – Language Basics • Java is a strongly typed language. This means all variables must be declared with a type before using. • Example: int count = 0 • int is the type for a variable called count that is initialized to 0 • Java Primitives are defined by the Java Language (and are reserved keywords) and are very similar in syntax to the C/C++ programming language: • byte, short, int, long, float, double, boolean, char • There are wrapper classes for most primitive types (Integer class wraps an int) • Java Operators are special symbols that perform specific operations on one or more operands (much like the C/C++ language): • ++ --, * /, >> <<, == !=, < >, & | ^, && || • Java Control Flow statements for program control and decision making and are very similar to to the C/C++ programming language: • if else, switch, while, do while, for • exception handling (not really flow control!) 9

  10. Java Language – Classes and Objects • Java was the first Internet “aware” and Security “aware” object orientated programming language. • (Almost) everything declared in Java defined by a Object implemented in a Class. One of the first main stream object oriented languages. • Object: • An object is a software bundle of related state and behavior. Software objects are often used to model the real-world objects that you find in everyday life. • Real-world objects share two characteristics: They all have state and behavior. • Class: • A class is a blueprint or prototype from which objects are created. • Created by using the new Java keyword. Example: ClassA a = new ClassA(); • Unused classes are removed from memory via the Garbage Collector • There is (in theory) no memory management coding required by programmer • Classes can inherit state and behavior from other classes through Inheritance. • ClassA extends ClassB • Classes can define contracts with the outside world (or other classes) through interfaces. • ClassA implements ClassB 10

  11. Java Language – Runtime Library A library of classes that are included as part of the Java Standard Edition which are implemented in ALL Java Runtime distributions (IBM, Oracle/JRockit, Sun, etc.). Utility: I/O, String, Date, Time, Calendar, Internationalization, Math, Collection, … Networking: HTTP, Cookies, TCP URL and Sockets, and UDP Datagrams, … Database: JDBC, Prepared Statements, ResultSets, Transactions, … Component Model: JavaBean, … Multimedia: Sound, 2D Graphics, 3D Graphics (extension lib), … User Interface: AWT, Swing, Applet, … Web Services: XML, SOAP Misc: JNI, JMX, RMI, Serialization, Logging, Zip, Regular Expressions, … System: Threads, Concurrency (Locks, Mutex, etc), Security, JNDI, … Deployment: Java Web Start, Java Plug-In, … These are all documented in the Java Development Kit (JDK)! 11

  12. Java SE 6 – JDK and JRE Image Courtesy of Sun http://java.sun.com/javase/6/docs/ 12

  13. Course #2 Example Java SE Programming

  14. Course Objectives Learn what a simple Java class looks like. Learn about Encapsulation. Learn about Inheritance and Interfaces. Walk through a “Hello World” console application. 14

  15. “Hello World” in the Java Programming Language Object Data / State HelloWorld Behavior / Operations private String message; private int count; public sayHello(); Name of Object In Java == ObjectName.java Also known as a Class The Objects internal data, attributes, or object state The Objects behavior, methods, or operations Encapsulation 15

  16. “Hello World” in the Java Programming Language 16

  17. More “Hello World” in the Java Programming Language HelloWorld BaseHello private String message; public sayHello(); private setText(); public sayLoudHellIo(); private someUtility(); Extends the behavior of HelloWorld Inheritance 17

  18. More “Hello World” in the Java Programming Language 18

  19. Course #3 Introduction to Java EE

  20. Course Objectives Learn about the history of the Java EE Platform. Learn about basic technologies in the Java EE Platform. Learn about current trends of the Java EE Platform. 20

  21. What is Enterprise Java a.k.a. Java EE? Java EE defines standard API’s for building web applications. Introduced right before the .COM era started. The Java EE Standard is defined by Sun and the JCP. There have been lots of contributions from the Open Source Community to fill in gaps from the Java EE Standard and enrich the capabilities for building web applications. A Java EE Application Server implements the Java EE Standard and provides a platform to execute web applications. Sometimes the Application Server vendor “enhances” the platform by adding value added features and capabilities such as Administration Consoles, Debugging facilities, and Monitoring. A Java EE Application Server is rapidly becoming a commodity with a number of very robust and scalable open source alternatives now available on the market. 21

  22. Introduction to the Java EE Stack? • Web Tier Technologies: • Servlet – lowest level (above protocols and sockets) to handle HTTP request • Java Server Pages – markup (like HTML tags) to build dynamic pages • Java Standard Template Library – standard tags for conditional, loops, etc. • Java Server Faces – web framework (built from JSP) • Business/Service Tier Technologies: • Enterprise Java Bean EJB – business components • JTA – transaction API • Persistence Tier Technologies: • JDBC – lowest level database programming • Java Persistence API JPA – Object Relational Mapping framework • Integration Technologies: • Java Connector Architecture JCA – API to access legacy systems (like SAP) • Java Messaging Service JMX – send JMS messages (like MQ) • Web Services JAX-WS, JAX-B, JAX-R – web service stack support 22

  23. Client (mostly browser based) Governance Standards, Best Practices/Guidelines Architecture Review Boards etc. Utilities and Core Services Logging (Wrapper) Tracing (Wrapper) Exception Framework Base Classes/Frameworks Alert (like HP Open View) Cache (Wrapper) Static Data Security/SSO * Web Application UI: HTML, CSS/DHTML, JavaScript, AJAX, Applets, Flash Application Logic, Business Logic, Data Access Logic Enterprise Application Integration (EAI) SDLC and Development Tools XP, Scrum, RUP, Waterfall Eclipse, IBM WSAD/RAD, NetBeans, JBuilder, IntelliJ Code Analyzers (Checkstyle, FindBugs), Unit Test Frameworks (JUnit, TestNG) Application Server Containers and Services for UI, Business, Database Security Administration and Deployment Value Add Services (Proprietary Frameworks etc.) Open Source Struts 1.x (MVC) JSTL (Tag Library) MyFaces/Sun JSF RI Apache Commons (Utility) Apache Log4j (Logging) Hibernate(Persistence) iBatis (Persistence) iText (PDF) POE (MS Docs) Quartz (Timer Service) Castor (XML Framework) Apache Xerces/Xalan (XML) Apache Axis (Web Services) SSO OSCache/EHCache (Cache) * J2EE 1.3 – 1.4 EJB Session Entity MDB Web JSP Servlet JAX-RPC JAX-R JAXB JMX JAAS JMS Mail JTA JCA Design Patterns MVC DAO Command Factory Business Delegate Business Façade Decorator Value Object * * J2SE 1.3 – 1.4 Integration/Middleware Business Rule Engine ETL Messaging/MQ FTP Web Services Proprietary Scripts etc. Screen Scraping * AWT Swing Java 2D Java 3D JavaBean JDBC JNDI RMI JNI J2EE Platform from post .COM era (2002-2004)

  24. J2EE Platform Observations from 2002-2004 Leveraged lots of open source libraries to fill in the J2EE specification gaps (like Web MVC Framework, XML, Web Services). Soon there would be competing and redundant technologies such as XML, Web Services, Logging, etc.. The Enterprise and Application Architect definitely had their work cut out for them. What technologies do we use? Some J2EE specifications were of little value to the enterprise (for example, Entity Beans (CMP or BMP) and Stateful EJB’s…..J2EE 1.2 only supported remote Session Beans!). Enterprise Integration was tightly coupled and reuse of enterprise assets not fully thought out or realized. Application Servers often provided proprietary (and competing) technologies and frameworks (Portlets, Web, Security, etc.). Lots of programming models to learn. Governance was often over looked causing lots of inconsistencies in architecture and duplication of code/frameworks. Most development methodologies were still very “water fall”. XP was just taking off. Development Tools needed improving. Generally there was very high TCO for 1st generation (MVC-1) and 2nd generation (MVC-2) applications. De-facto Standard Application Servers: WebLogic, WebSphere, and some Oracle. Increasing frustration with J2EE standard (some of it was justified and some was not). 24

  25. Web Application Utilities and Core Services Logging/Tracing (Wrapper) Exception Framework Base Classes/Frameworks Alert (like HP Open View) Cache (Wrapper) Static Data Security/SSO * Object Model Application Domain Model Struts2 Framework Business Rule Engine Presentation HTML, CSS, JavaScript, AJAX JSF, SpringMVC, JSP, Servlets, JSTL Facelets, Seam, Spring WebFlow Rails/Grails Framework GWT Framework SOA ESB, BPM WS-* UDDI WSDL XML EAI JCA ETL JMS/MQ Business POJO (via Spring or Session) Message Driven Beans Timer Beans Web Services Open Source Struts2 (MVC) Apache Commons (Utility) iBatis (Persistence) iText (PDF) POE (MS Docs) Quartz (Timer Service) Apache Axis (Web Services) OSCache/EHCache (Cache) * Data Access JDBC, SQL, SP JPA/Hibernate/TopLink/iBatis OLTP DB Legacy Systems And Legacy DB Or DW J2EE Application Server (now some open source) EE 5 Spring DI AOP SpringMVC WebFlow Security Open JDK J2SE 5 Java, Ruby, Groovy, Python, Scala J2EE Web 1.5/2.0 Application Architecture (2005-present) Client (not just browser based anymore)

  26. Observations from 2005-2007 Move away from Struts 1.x or proprietary frameworks to newer web frameworks like JSF (plus Facelets, Seam, and Ajax4Jsf) or Struts2 or SpringMVC (with WebFlow). Move toward annotation based configuration (versus mass of XML configuration files). Less Open Source required (due to maturity of EE specification, Spring, and open source application servers like JBoss, Glassfish, Tomcat 5/6). Apache Foundation, Spring, Craig McClanahan (JSF),Rod Johnson(String/EJB3), Gavin King(Hibernate/JPA) were really influencing and pushing the Java/J2EE platform forward. Spring Framework getting lots of traction in the industry (dependency injection (simple but powerful!), POJO based for simpler programming model, AOP (for security, transactions, tracing, etc), wrappers for integration with EJB, WS, etc.). NetBeans IDE is becoming a viable and powerful IDE (Eclipse finally has some competition). Eclipse Foundation followed suite and also released Eclipse Europa. No need to buy a J2EE IDE now. Rather then reinvent we must reuse in the Enterprise, move from vertical applications to Enterprise wide applications => SOA and leverage full Web Service stack, ESB, BPM. New EE web applications can be built much quicker and with much less code. My last project, using JSF and Spring and iBatis, was built with 50% less code, delivered on time (actually over delivered by adding more features requested from our customer), and was 25% under budget. Google influence => Google Web Toolkit, Google Docs, Google Maps, etc. Sun and Microsoft finally working together (WS-* in 2006) => that is a good thing for everybody! 26

  27. Course #4 Example Java EE Programming

  28. Course Objectives Learn about the layers of a Java EE application. Learn a few common/popular design patterns. Walk through a “Hello World” web application. 28

  29. The Layers of a Java EE Application Java EE Application Layers Client Layer Desktop browser, mobile phone, STB, TV Browser Creates views for presentation, handling form data, and navigation JSP or Web framework such as JSF, Struts, or SpringMVC with HTML, CSS, and JavaScript Presentation Layer Implements business services and enterprise integration services EJB, Web Services, Message Driven Beans, Timer Beans, SpringBeans Business Layer Persistence Layer Implements data persistence services JPA, Hibernate, iBatis, SQL, JDBC N-Tier Architecture 29

  30. The Presentation Layer • Designed using a very popular MVC design pattern used to build Presentation Layer. • Implemented by all major web frameworks. • Helps to enforce separation of concerns so you don’t mix presentation logic, business logic, and persistence logic together. • Used to render HTML (generally) to a browser. • Model View Controller • Model: data from business services to display • View: views or web pages • Controller: handles page events and navigation between pages 30

  31. The MVC Design Pattern Diagram 1 31

  32. The MVC Design Pattern Diagram 2 32

  33. The Business Layer • Driven by your business use cases defined by your business requirements. • Implements your business services. • Should be designed using interfaces (design by contract). • Can be a façade to other enterprise services deployed on an ESB or other SOA infrastructure. • Acts as façade to persistence layer or enterprise data services. • Supports other responsibilities: • Transaction Management (using a service container) • Security (using a service container) 33

  34. The Business Layer Diagram 1 34

  35. The Business Layer Diagram 2 35

  36. The Persistence Layer • Designed using the CRUD design pattern. • Is simply responsible for persistence of your entity or domain object model. • Should not be aware of transaction boundaries. • Supported today by modern Object Relational Mapping (ORM) frameworks such as JPA, Hibernate, and iBatis. • C R U D operations: • Create: add or insert operation • Read: read operation • Update: update operation • Delete: delete operation 36

  37. “Hello World” Java EE Web Application • Can you really build a working N-Tier Hello World web application in less then 10 classes? • Let’s go build a simple web application ……… 37

  38. “Hello World” Application • 2 UI Events: • Button click handler for the ‘Test Me’ button • Button click handler for the ‘Save Me’ button • 2 Business Use Cases: • Validate the Model • Business Rule: If Name is ‘Mark’ then Model can be persisted • Save the Model • Model: • Simple JavaBean that just has a Name attribute 38

  39. “Hello World” Web Tier Implementation • View => JSF Page • Controller => JSF Event Handler class • The 2 UI Events are implemented in a JSF Event Handler class • Business service is injected into this class • The Model => clean separation between Web Application Model and the Domain Model, so we don’t mix UI data with our Business data Event Driven Web Tier Design! 39

  40. “Hello World” Business Tier Implementation • Uses Stateless EJB 3.0 JavaBeans. • Uses Container Managed Transactions • DAO is injected into this class • Implements our 2 business use cases • Can be designed using Noun’s and Verbs discovered when you write your use case. • Validate the Model • Validate is the verb and the Noun is Model => validate(Model) • Save the Model • Save is the verb and the Noun is Model => save(Model) Use Case Driven Business Tier Design! 40

  41. “Hello World” Data Access Tier Implementation • Implements standard CRUD operations via an Interface • Uses Stateless EJB 3.0 JavaBeans (DI issue with EE5). • Forces Transactions to be declared external to DAO • JPA support is injected into this class • Implements our single Update CRUD use case CRUD Driven Data Access Tier Design! 41

  42. “Hello World” Conclusion • A simple Java EE 5 web application was written using 3 implementation classes, 2 interfaces, 2 model classes, 1 Controller class, and 1 JSF page. • This demo application made use of EE 5 dependency injection and container managed transactions, which virtually eliminated the need to implement any infrastructure classes (and lots of old design patterns). • This demo application could have been enhanced by using more elaborate use of Base Classes, which you develop as part of a standard corporate Application Framework. • It really is that easy (if you are using modern technology)! 42

  43. Where Can I Learn More? • Go to the Java TCC site to links for lots of good industry references. • Go read the AAA-NCNU Java Standards. • Go read the AAA-NCNU Java Best Practices. • Get my Java EE Application Design Template. • Get the Java Reference Implementation. 43

  44. Appendix

  45. References Anonymous. 2009. Wikipedia. Retrieved April 10, 2009 from http://www.wikipedia.com Sun Java Tutorials, Retrieved May 14, 2009 from http://java.sun.com/docs/books/tutorial/java/concepts/index.html 45

More Related