Enterprise Architecture

45
Confidential and Proprietary AAA NCNU © 2008, 2009 Enterprise Architecture Java SE / Java EE Training Awareness M. Reha, Enterprise Architecture 2009-04-10, v0.1

description

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 - PowerPoint PPT Presentation

Transcript of Enterprise Architecture

Page 1: Enterprise Architecture

Confidential and ProprietaryAAA NCNU © 2008, 2009

Enterprise Architecture

Java SE / Java EE Training

Awareness

M. Reha, Enterprise Architecture2009-04-10, v0.1

Page 2: Enterprise Architecture

22

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

Page 3: Enterprise Architecture

3

Course #1

Introduction to the Java Language and the Java Platform

Page 4: Enterprise Architecture

44

Course Objectives

> Learn about the history of Java.> Learn about the Java Platform.> Learn what the fundamentals of the Java language.

Page 5: Enterprise Architecture

55

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

Page 6: Enterprise Architecture

6

What is Java?

Java EE Application Server

WebSphere, Oracle WebLogic, JBoss, etc

Java Virtual Machine (JVM)Sun, IBM, Oracle, Apple, etc.

JDK (for SE and EE)Compilers, tools,

documentation for the developer

Browser

Web PagesPortlets

Java AppletJavaFX Applet

Java Desktop Application

(Swing, Console, JavaFX)

Mobile Application and Consumer

(Java ME, JavaFX, JavaTV)

Java EE RuntimeImplements the Java EE API’s

Java SE RuntimeAlso referred to as JREImplements Java SE API’sImplements Java SE for CDC

Java is a programming language!Java used as a platform to build applications ranging from web,

desktop, mobile, and more!

Java Virtual Machine (JVM)Nokia, Philips, Sony,

Page 7: Enterprise Architecture

77

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.

Page 8: Enterprise Architecture

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

Page 9: Enterprise Architecture

99

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!)

Page 10: Enterprise Architecture

1010

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

Page 11: Enterprise Architecture

1111

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)!

Page 12: Enterprise Architecture

1212

Java SE 6 – JDK and JRE

Image Courtesy of Sun http://java.sun.com/javase/6/docs/

Page 13: Enterprise Architecture

13

Course #2

Example Java SE Programming

Page 14: Enterprise Architecture

1414

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.

Page 15: Enterprise Architecture

1515

“Hello World” in the Java Programming Language

Object

Data / State

Behavior / Operations

HelloWorld

private String message;private int count;

public sayHello();

Name of ObjectIn Java == ObjectName.java

Also known as a Class

The Objects internal data, attributes, or object state

The Objects behavior, methods, or operations

Page 16: Enterprise Architecture

1616

“Hello World” in the Java Programming Language

Page 17: Enterprise Architecture

1717

More “Hello World” in the Java Programming Language

HelloWorld

public sayLoudHellIo();private someUtility();

Extends the behavior of HelloWorld

private String message;

public sayHello();private setText();

BaseHello

Page 18: Enterprise Architecture

1818

More “Hello World” in the Java Programming Language

Page 19: Enterprise Architecture

19

Course #3

Introduction to Java EE

Page 20: Enterprise Architecture

2020

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.

Page 21: Enterprise Architecture

2121

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.

Page 22: Enterprise Architecture

2222

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

Page 23: Enterprise Architecture

23

J2EE Platform from post .COM era (2002-2004)

J2EE 1.3 – 1.4

WebJSP

Servlet

EJBSessionEntityMDB

JAX

-R

PC

JAX

-R

JAX

B

JMX

JAA

S

JMS

Mail

JTA

JCA

J2SE 1.3 – 1.4

AW

T

Sw

ing

Java 2D

Java 3D

JavaBe

an

JDB

C

JND

I

JNI

RM

I

Application ServerContainers and Services for UI, Business, Database

SecurityAdministration and Deployment

Value Add Services (Proprietary Frameworks etc.)

Client (mostly browser based)

Web ApplicationUI: HTML, CSS/DHTML, JavaScript, AJAX, Applets, Flash

Application Logic, Business Logic, Data Access LogicEnterprise Application Integration (EAI)

Govern

ance

Standards, B

est Practices/G

uidelinesA

rchitecture Review

Boards etc.

Design PatternsMVCDAO

CommandFactory

Business DelegateBusiness Façade

DecoratorValue Object

**

SD

LC

and

Develop

men

t Tools

XP, Scrum

, RU

P, Waterfall

Eclipse, IB

M W

SAD

/RA

D, N

etBeans, JB

uilder, IntelliJC

ode Analyzers (C

heckstyle, FindBugs), U

nit Test Fram

eworks (JU

nit, TestN

G)

Open SourceStruts 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)

SSOOSCache/EHCache (Cache)

*

Integration/MiddlewareBusiness Rule Engine

ETLMessaging/MQ

FTPWeb Services

Proprietary Scripts etc.Screen Scraping

*

Utilities and Core ServicesLogging (Wrapper)Tracing (Wrapper)

Exception FrameworkBase Classes/FrameworksAlert (like HP Open View)

Cache (Wrapper)Static Data

Security/SSO*

Page 24: Enterprise Architecture

2424

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).

Page 25: Enterprise Architecture

25

J2EE Web 1.5/2.0 Application Architecture (2005-present)

J2EE Application Server (now some open source)

EE 5

J2SE 5Java, Ruby, Groovy, Python, Scala

Utilities and Core Services

Logging/Tracing (Wrapper)Exception Framework

Base Classes/FrameworksAlert (like HP Open View)

Cache (Wrapper)Static Data

Security/SSO*

Open SourceStruts2 (MVC)

Apache Commons (Utility)iBatis (Persistence)

iText (PDF)POE (MS Docs)

Quartz (Timer Service)Apache Axis (Web Services)OSCache/EHCache (Cache)

*

Object Model

Application Domain Model

Web Application

Open JDK

SpringDI

AOPSpringMVC

WebFlowSecurity

PresentationHTML, CSS, JavaScript, AJAX

JSF, SpringMVC, JSP, Servlets, JSTLFacelets, Seam, Spring WebFlow

BusinessPOJO (via Spring or Session)

Message Driven BeansTimer BeansWeb Services

Data AccessJDBC, SQL, SP

JPA/Hibernate/TopLink/iBatis

Client (not just browser based anymore)

Struts2 Framework

Rails/Grails Framework

GWT Framework

Business Rule Engine

SOAESB, BPM

WS-*UDDIWSDLXML

OLTP DB Legacy SystemsAnd

Legacy DBOr DW

EAIJCAETL

JMS/MQ

Page 26: Enterprise Architecture

2626

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!

Page 27: Enterprise Architecture

27

Course #4

Example Java EE Programming

Page 28: Enterprise Architecture

2828

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.

Page 29: Enterprise Architecture

2929

The Layers of a Java EE Application

BrowserDesktop browser, mobile phone, STB, TV

Client Layer

Java EE Application Layers

Presentation LayerCreates views for

presentation, handling form data, and navigation

JSP or Web framework such as JSF, Struts, or SpringMVC with HTML,

CSS, and JavaScript

Business Layer Implements business services and enterprise

integration services

EJB, Web Services, Message Driven Beans,

Timer Beans, SpringBeans

Persistence Layer Implements data persistence services

JPA, Hibernate, iBatis, SQL, JDBC

Page 30: Enterprise Architecture

3030

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

Page 31: Enterprise Architecture

3131

The MVC Design Pattern Diagram 1

Enterprise Servers and Data Sources

Browser

Application Server

JSP (View) JavaBean(Model)

ResponseRequest

Controller

Services

Forward

Page 32: Enterprise Architecture

3232

The MVC Design Pattern Diagram 2

Browser

JSP (View)

JavaBean(Model)

ResponseRequest (POST)

Controller

Forward

Business Tier

Error JSPSystemException

ApplicationException

Event Handler

To Error JSP(from System

Exception)

Data binding with tag lbrary

Include JS, CSS

Include Page Fragments

Requestor

Session

xhtml xhtml

Include Tab Libs

Delegate

Page 33: Enterprise Architecture

3333

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)

Page 34: Enterprise Architecture

3434

The Business Layer Diagram 1

Business Delegate

SystemException

ApplicationException

Interface

Business Service 1

DAO 1 DAO 2 DAO 3 Service 2

Transaction Mgr

Tran

sact

ion

Bou

ndar

y

Begin Tx

End Tx

Facade

Interface Interface Interface Interface

Implemtation

Config

Business Rules

Factory

Client

TO

TO

TO

Page 35: Enterprise Architecture

3535

The Business Layer Diagram 2

SystemException

ApplicationException

Business Service 1

DAO 1 DAO 2 DAO 3 Service 2

Transaction Mgr

Tran

sact

ion

Bou

ndar

y

Begin Tx

End Tx

Facade

Interface Interface Interface Interface

Dependency Injection:

DAO1, DAO2, DAO3, and

Service 1 and 2

Interface + Implemtation

Business Rules

Client

TO

TO

Configor

Annotations

Configor

Annotations

Page 36: Enterprise Architecture

3636

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

Page 37: Enterprise Architecture

3737

“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 ………

Page 38: Enterprise Architecture

3838

“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

Page 39: Enterprise Architecture

3939

“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

Page 40: Enterprise Architecture

4040

“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)

Page 41: Enterprise Architecture

4141

“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

Page 42: Enterprise Architecture

4242

“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)!

Page 43: Enterprise Architecture

4343

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.

Page 44: Enterprise Architecture

44

Appendix

Page 45: Enterprise Architecture

4545

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