System Integration

advertisement

Java 2 Platform, Enterprise Edition

(J2EE)

An Overview

蔡 文 能

交通大學資訊工程學系 tsaiwn@csie.nctu.edu.tw

1

What Is J2EE ?

• Java 2 Enterprise Edition

• There are 3 different specifications within the Java framework (J2SE, J2ME, J2EE)

• Created to provide a simple, unified standard for distributed applications through a component based application model

• Specification is managed by a consortium of industry leaders

2

Some useful online references

• http://java.sun.com

• http://java.sun.com/j2ee

• http://java.sun.com/j2ee/tutorial/index.html

3

J2EE and Other Java 2 Platform Editions

Source: Computer , August 2000

J2EE, J2SE, J2ME 4

J2EE and Other Java 2 Platform Editions

J2EE, J2SE, J2ME

Source: Sun Microsystems, Inc.

5

Java Development and Runtime Environment

Source: P.J. Perrone and V.S.R.R. Chaganti, Building Java Enterprise Systems with J2EE 6

Java 2 Platform Runtime Architecture

Source: P.J. Perrone and V.S.R.R. Chaganti, Building Java Enterprise Systems with J2EE

7

Java 2 Platform, Standard Edition (J2SE 1.3)

Source: Sun Microsystems, Inc., http://java.sun.com/j2se/1.3/ 8

Java 2 Platform, Standard Edition (J2SE 1.4)

Source: Sun Microsystems, Inc., http://java.sun.com/j2se/1.4/

9

Why J2EE ?

• A stand alone program

• Client/Server

(2-Tier)

– BBS, News, FTP, Telnet, …

• Traditional (non-component) N-Tier Systems

– 3-tier application: Browser – WEB Server – DBMS

• New trend:

– Component N-Tier Systems

(J2EE Architecture)

See figures on next slides

10

2-Tier Database Access

• Client Tier – Presentation, Business Logic

• Data Tier – Database Management Services

Source: Sun Microsystems, Inc., JDBC 3.0 Specification 11

Traditional(non-component) N-Tier Systems

• Client Tier – Presentation Logic

• Application Tier – Business Logic

• Data Tier – Database Management Services

12

Source: Sun Microsystems, Inc., JDBC 3.0 Specification

Component N-Tier Systems

J2EE Architecture

Applet

Container

Web Tier Business Tier

EIS Tier

Client Tier

EJB Container

Connector

Enterprise

Information

Services

EJB

Standalone

Client

Web Container

JSP

Servlet

J2EE Server

Machine Client

Machine

Database Server

Machine

13

J2EE Architecture (1/2)

J2EE Component and Container

Source: Sun Microsystems, Inc., J2EE Specification v1.3

14

J2EE Architecture (2/2)

• J2EE consists of three major parts:

Components

Hold presentation and business logic

Containers

Provide context for components

Connectors

Provide access to legacy enterprise systems

15

J2EE Components

• Application clients

• Applets

• Web components

– Servelets, Java Server Pages (JSP)

Portlet (see JSR168)

• Business components

– Enterprise Java Beans (EJB)

16

J2EE Component

Applet Component

• An applet is a program written in the JavaTM programming language that can be included in an

HTML page, much in the same way an image is included. When you use a Java technologyenabled browser to view a page that contains an applet, the applet's code is transferred to your system and executed by the browser's Java Virtual

Machine (JVM).

• An applet is a small program that is intended not to be run on its own, but rather to be embedded inside another application.

17

Applet pro vs. con

• Applets : Java code that runs inside browser

• Advantages:

– Extends functionality on the client side

– More complicated GUIs than w/ HTML or JavaScript

– Computation can be off-loaded from server

– Users don’t have to build, install, and configure

• Disadvantages:

– Download time

– “Sandbox” limits functionality (unless signed)

– Window management by browser

18

J2EE Component

Web Component

• Servlets

– A servlet is a program that extends the functionality of a Web server. Servlets receive a request from a client, dynamically generate the response (possibly querying databases to fulfill the request), and then send the response containing an HTML or XML document to the client

• JSP

– The JavaServer Pages (JSP) technology provides an extensible way to generate dynamic content for a Web client. A JSP page is a textbased document that describes how to process a request to create a response

19

Java Servlet

Browser

HTTP Request

Servlet Class wasn’t loaded into System

Class Loader

Load Servlet class

Into System

Web

Services

Servlet Class was loaded

Invoker

HTTP Response

Services

20

Java Servlet

• Java Servlet is the bridge for user to use Java solution in Web Server.

• Java Servlet has better performance than

CGI(Common Gateway Interface).

• Java Servlet can use session to replace cookie and enhance security.

• J2EE Server maintains the session for Java

Servlets.

21

JavaServer Pages (JSP)

New JSP Page

JSP was modified

Browser

HTTP Request (.jsp)

Web

Services

HTTP Response

Java

Source

Code

Compiler

Java

Bytecode

Load Servlet class

Into System

Class Loader

JSP isn’t loaded yet.

Invoker jspServices

22

JavaServer Pages (JSP)

• JSP has all features of Servlet.

• JSP is a HTML like document.

• JSP is designed for Web Page Developer.

• JSP will change to Java Servlet source.

• JSP is ran via Servlet mode.

23

JavaServer Pages

Objects

• JSP has 9 objects which developer can use directly without new it.

JSP Object request response pageContext session application out config page exception java class javax.servlet.ServletRequest

javax.servlet.ServletResponse

javax.servlet.jsp. PageContext javax.servlet.http.HttpSession

javax.servlet.ServletContext

javax.servlet.jsp.JspWriter

javax.servlet.ServletConfig

java.lang.Object

java.lang.Throwable

scope request pag page session application page page page page

24

Portlet and Portal

• JSR168

– Java portlet standard

Browser

HTTP

Portal

Server

• WSRP (Web Services for Remote Portlets )

– Remote portlet communication protocol

– Portals aggregate remote portlets

JSR168 Portlet Container

JSR168

Portlet

WSRP

JSR168

Portlet

25

The Reason For JDBC

• Despite almost all databases supporting SQL, database vendors

(Microsoft Access, Oracle etc.) provide proprietary (no standard)

Application Programming Interfaces for sending SQL to the server and receiving results from it!

• Languages such as C/C++ can make use of these proprietary

APIs directly

– High performance

– Can make use of non standard features of the database

– All the database code needs to be rewritten if you change database vendor or product

• JDBC (Java DataBase Connectivity) is a vendor independent

API for accessing relational data from different database vendors in a consistent way

26

CCTM: Course material developed by James King (james.king@londonmet.ac.uk)

JDBC

• JDBC provides an API that hides the vendor specific APIs by

inserting a driver between the Java application and the database API

• JDBC requires a vendor-specific driver

• The driver converts calls from JDBC API to vendor’s API => performance penalty

• The driver does not provide access to vendor specific functionality

• The same Java application can be used with a different vendor’s database by simply switching JDBC driver and changing one line of Java code.

• JDBC 1.0 is included inside JDK 1.1 or higher in a package java.sql

• JDBC 2.0 and 3.0 require updated drivers and an additional package javax.sql

27

CCTM: Course material developed by James King (james.king@londonmet.ac.uk)

Rollback and Commit

• By default connections to the database commit each update as soon as it is completed.

• If you want to make a set of changes and only commit the aggregate result if nothing goes wrong auto commit needs to be switched off connection.setAutoCommit(false)

You can then use

connection.commit() to apply the changes

connection.rollback() to undo changes since the last commit

• You can switch auto commit back on using connection.setAutoCommit(true)

28

CCTM: Course material developed by James King (james.king@londonmet.ac.uk)

J2EE Compoent (1/2)

EJB Component

• Enterprise JavaBean (EJB)

– The Enterprise JavaBeans (EJB) architecture is a server-side technology for developing and deploying components containing the business logic of an enterprise application.

– Enterprise JavaBeans components, termed enterprise beans , are scalable, transactional, and multi-user secure.

• EJB is an architecture for component-based transactional distributed computing.

29

EJB Component (2/2)

• An enterprise bean contains business logic that operates on the enterprise’s data.

• Client access is mediated by a Container.

• There are three kinds of enterprise beans: session beans, entity beans, and messagedriven beans .

30

Enterprise Bean Objects

• Session objects: for a single client, shortlived, …Stateful, Stateless

• Entity objects: object view of data in the database, shared by multiple clients, longlived, …

• Message-driven objects: triggered by a single client message, short-lived, stateless, …

31

Stateful vs. Stateless Session

Beans

• Stateful

– Possess Internal State

– One per client

– Need to handle activation/ passivation

• Stateless

– Do not possess state

– Can be pooled to handle multiple clients

– Do not need to be passivated

32

Entity Beans: CMP vs. BMP

• Container Manager

Persistence

– Container responsible for database accesses/ controls

– Developer focuses on data use

• Bean Managed

Persistence

– Developer must write code to handle database accesses/ controls

– Used for more specialized data mapping strategies

33

Entity Bean Characteristics

• Provides an object view of data in the underlying database

• Shared across multiple users

• Long-lived

• Survives container crash

34

To Implement an Enterprise Bean (1/2)

• Any enterprise bean must define two interfaces and one or two classes

– Remote interface

• defines a bean ’ s external interface

• must extend javax.ejb.EJBObject (which in turn extends java.rmi.Remote)

– Home interface

• The home interface defines a bean ’ s “ life cycle ” methods, eg. create bean, remove bean, find bean, etc.

• must extend javax.ejb.EJBHome which also extends java.rmi.Remote

35

To Implement an EJB (2/2)

• Bean Class

– The java class that actually implements the bean ’ s external interface, e.g. the bean class provides implementations for the bean ’ s “ business methods ”

– An entity bean must implement the javax.ejb.EntityBean interface, while a session bean must implement the (you guessed it) javax.ejb.SessionBean. Both of these interfaces extend javax.ejb.EnterpriseBean

• Primary Key

– The primary key is a very simple class that provides a pointer into a database; Only entity beans need a primary key. This class must implment java.io.Serializable (so the entity bean can automatically be sent to persistent storage)

36

EJB Container

• A container is provided by the Application Server vendor to provide basic services that are required by J2EE specification.

• An EJB programmer places their code here, and is assured a variety of basic services are available

• This means the developer doesn ’ t have to code these services from scratch

• Specification states which services must be supported but not how

37

Basic Services Supplied by the

EJB Container

• Security

• Transaction management

• Remote Client Connectivity

• Life Cycle Management

• Database Connection Pooling

38

More Services provided by container

• The following basic services will be supported by all J2EE compliant products

– RMI/RMI-IIOP

– Resource Pooling

– Thread Control

– Presentation Logic

– Persistence

– Messaging

– And more …

IIOP: Internet Inter-ORB Protocol

ORB: Object Request Broker

39

Can

’ t Do in an EJB

Can

’ t use threads

Can

’ t use the AWT

Can

’ t act as network server

Can

’ t use java.io package

Can

’ t load native libray

Can

’ t use this as an argument or return value

40

EJB Benefits Summary

• Developing distributed applications in Java

– Application developer is spared from following details

• Transaction management

• State management

• Multi-threading

• Connection pooling

• Write once, run anywhere

• Interoperability with other languages

• Compatible with CORBA protocols

41

J2EE Containers (1/2)

Web Containers

• Web Component Containers

– 1. Servlet Containers

• A servlet container provides network services (by which requests and responses are sent), decodes requests, and formats responses. All servlet containers must support HTTP as a protocol for requests and responses, but may also support additional request-response protocols such as HTTPS.

– 2. JSP Containers

• A JSP container provides the same services as a servlet container and an engine that interprets and processes a JSP page into a servlet.

– 3. Web Containers

• A

Web container provides the same services as a JSP container and access to the J2EE service and communication APIs.

42

J2EE Containers (2/2)

EJB Containers

• EJB Container

– Enterprise beans are hosted by an

EJB container . In addition to standard container services, an EJB container provides a range of transaction and persistence services and access to the J2EE service and communication APIs.

43

Tomcat

Tomcat : Java-based web server + servlet container w/ JSP environment

• Execution modes:

Standalone : default mode for Tomcat

Out-of-process add-on : web server plugin opens JVM outside web server; plugin and

JVM communicate using IPC mechanism

(TCP/IP sockets and special protocol)

44

Tomcat and Apache

• Communication mechanism between

Tomcat and Apache: web server adapter” or named as “connector”

• Implemented as shared library (e.g., mod_jserv.so, mod_jk.so)

• Uses/manages TCP connections

• Uses the AJPV12/AJPV13 communication protocol

45

J2EE Connectors

• Contract between container and Enterprise

Information Systems (EIS)

• Proprietary and under the hood

• Implementation is available with J2EE specification version 1.3 / 1.4

46

J2EE Standard Services

• HTTP/HTTPS

• Java Transaction API (JTA)

• Java Database Connection (JDBC)

• Java Message Service (JMS)

• Java Authentication and Authorization Service (JAAS)

• J2EE

Connector Architecture (JCA)

• Others: RMI-IIOP, JavaIDL, JavaMail, JavaBeans

Activation Framework (JAF), Java API for XML Parsing

(JAXP)

IIOP: Internet Inter-ORB Protocol

47

The Solution: J2EE Application Model

• J2EE application model partitions the work needed to implement a multi-tier service into two parts

– the business and presentation logic (implemented by the application developer)

– the standard system services provided by the J2EE platform.

• The developer can rely on the platform to provide the solutions for the hard systems level problems of developing a middle-tier service.

48

J2EE Application Model

Source: Sun Microsystems, Inc., http://java.sun.com/j2ee/overview2.html

49

Benefits of J2EE Application Model

• The J2EE application model provides the benefits of Write Once, Run Anywhere™ portability and scalability for multi-tier applications.

• This standard model minimizes the cost of developer training while providing the enterprise with a broad choice of J2EE servers and development tools.

50

J2EE Platform Roles

• J2EE Product Provider

• Application Component Provider

• Application Assembler

• Deployer

• System Administrator

• Tool Provider

51

The Connector Architecture

• Integration of J2EE servers with Enterprise

Information Systems (EIS)

• EIS vendor-provided resource adaptors

• Resource adaptor-permitting application servers

52

J2EE Connector

• J2EE Connector

– The J2EE

Connector architecture defines a standard architecture for connecting the J2EE platform to heterogeneous EISs. Examples of EISs include ERP, mainframe transaction processing, database systems, and legacy applications not written in the Java programming language. By defining a a set of scalable, secure, and transactional mechanisms, the J2EE

Connector architecture enables the integration of EISs with application servers and enterprise applications.

53

System Level Pluggability

Source: Sun Microsystems, Inc., J2EE Connector Architecture Specification 54

Connector Architecture Overview

Source: Sun Microsystems, Inc., J2EE Connector Architecture Specification 55

Connector Architecture Overview (cont.)

Source: Sun Microsystems, Inc., J2EE Connector Architecture Specification

56

Connector Architecture in B2B Scenario

Source: Sun Microsystems, Inc., J2EE Connector Architecture Specification 57

Client View of an Enterprise Bean

• Home Interface: methods for creating, removing, and finding bean instances

• Remote Interface: methods callable by the client

• Object Identity

• Metadata Interface: mainly for dynamic invocation

• Handle

58

Client View of Session Beans

Source: Sun Microsystems, Inc., Enterprise JavaBeans 2.0

59

Accessing Enterprise Beans from Servlets/JavaServer Pages

Source: Sun Microsystems, Inc., J2EE Specification, v1.3

60

J2EE Deployment

Source: Sun Microsystems, Inc., J2EE Specification, v1.3

61

J2EE Application Life Cycle

Source: Sun Microsystems, Inc., J2EE Connector Architecture Specification 62

Overview of Enterprise Applications Integration (EAI)

Source: P.J. Perrone and V.S.R.R. Chaganti, Building Java Enterprise Systems with J2EE 63

Overview of Enterprise Applications Integration (EAI)

Source: P.J. Perrone and V.S.R.R. Chaganti, Building Java Enterprise Systems with J2EE 64

EAI with XML

Source: P.J. Perrone and V.S.R.R. Chaganti, Building Java Enterprise Systems with J2EE 65

Enterprise Beans of the Example Design

Source: Sun Microsystems, Inc., The J2EE Tutorial

66

J2EE Platform Technologies 1/3

• Servlets and JSP

– Java technology servlets and JavaServer Pages are server components that run in a web server that supports dynamic HTML generation and session management for browser clients.

• EJB

– Enterprise JavaBeans is a server component model that provides protability across application servers and implements automatic services on behalf of the application components.

• JTA

– Java Transaction API provides a transaction demarcation API.

• JTS

– Java transaction Service defines a distributed transaction management service based on the CORBA Object Transaction Service.

67

J2EE Platform Technologies 2/3

• JNDI

– Java Naming and Directory Interface provides access to naming and directory services, such as DNS, LDAP, NDS, and CORBA Naming.

• RMI-IIOP

– Remote Method Invocation(RMI) creates remote interfaces for Java-to-

Java communication. This extension uses the CORBA standard IIOP communication protocol.

• Java IDL

– Java Interface Definition Language creates remote interfaces to support java-to-CORBA communications.

68

J2EE Platform Technologies 3/3

• JDBC

– JDBC database access API provides uniform access to relational databases.

• JMS

– Java Messaging Service supports asynchronous communication using either a reliable queuing or publish/subscribe model.

• JavaMail

– JavaMail provides a protocol-independent framework to build mail and messaging applications.

• JAF

– JavaBeans Activation Framework provides standard services to determine the type of an arbitrary piece of data and activate an appropriate

JavaBeans component to manipulate the data.

69

History of J2EE Technologies

• Distributed Objects

– CORBA, DCOM, etc.

– Three-tier scenario: presentation, business logic, and backend databases

• Hard to “ get right ” without the proper infrastructure

• Server-Side Components

– Focuses on encapsulating “ business rules ” into objects in the middle tier

• Component Transaction Monitors

– Descendant of CORBA ’ s Object Request Broker

• provides discovery, persistence, event notification, transactions, etc. for three-tier or n-tier applications

70

J2EE Platform Services

• Naming Services

– Provide application clients, EJB and Web components with access to a

JNDI naming environment.

• Deployment Services

– Allow components and applications to be customized at the time they are packaged and deployed.

• Transaction Services

– Devide an application into a series of indivisible or atomic units of work.

• Security Services

– Designed to ensure that resources are accessed only by users authorized to use them.

72

J2EE Platform Benefits

• Simplified architecture and development

• Scalability to meet demand variations

• Integration with existing information systems

• Choices of servers, tools, components

• Flexible security model

• The J2EE reduces the cost and complexity of developing these multi-tier services, resulting in services that can be rapidly deployed and easily enhanced as the enterprise responds to competitive pressures

.

73

J2EE Platform

• The J2EE platform is the standard environment for running J2EE applications. The J2EE platform is composed of the following elements:

J2EE deployment specification - a standard that defines a common way of packaging applications for deployment on any

J2EE compatible platform.

– Java technology standards for the J2EE platform - a set of standards that all J2EE platform products must support (JMS ,

JNDI etc)

IETF standards for the J2EE platform - a set of standards defined by the Internet Engineering Task Force that all J2EE platform products must support.(eg XML, HTTP, HTML)

– CORBA standards for the J2EE platform - a set of CORBA standards upon which the J2EE platform bases its middle-tier interoperability.

74

J2EE Application Assembly

• A J2EE application is packaged into one or more standard units for deployment to any J2EE platformcompliant system.

• Each unit contains a functional component or components (enterprise bean, JSP page, servlet, applet, etc.), a standard deployment descriptor that describes its content, and the J2EE declarations which have been specified by the application developer and assembler.

• Once deployed, theses components can then be run.

75

J2EE Reference Implementation

• Its primary role is as an operational definition of the J2EE platform.

• Most importantly, it is used as the standard platform for running the J2EE Compatibility Test

Suite.

• A secondary role for the reference implementation is as a freely available platform for popularizing

Java 2 platform, Enterprise Edition.

76

J2EE Reference Implementation

• Latest version available for download

– Java TM 2 SDK, Enterprise Edition

Version 1.3

– Downloadable at http://java.sun.com/j2ee/

• NOTE :

– This version will require Java 2 SDK, Standard Edition

(J2SE) Version 1.3.1 or higher.

77

Application Servers

• Consists of

– EJB server

– Web server (HTTP)

– Secured web server (HTTPS) …

• J2EE Compliance Test

– Brings vendor neutrality to your applications

– Consists of more than 5000 tests

– Currently 9 application servers have been certified

• BEA WebLogic (BEA)

• iPlanet (Sun + Netscape)

• Websphere (IBM)

• (check out www.javasoft.com/j2ee for latest update)

78

The BEA WebLogic Server

• All Java, clean-room implementation of the J2EE

• Shipping basic APIs since 1997

• One of the most widely-used Application Servers on the market

– Over 12,000 customers

• Associated BEA product: TUXEDO

– Distributed TP Monitor

– Originally developed at Bell Labs in 1984

– Influenced the design of WebLogic

79

Sun ONE Application Server 7

Provides a comprehensive overview of the Sun ONE

Application Server.

Please note - the tour may take up to 1 minute to complete testing your system before starting to load.

• Sun is the first software vendor to deliver a fully J2EE[tm] platform-certified, commercial application server, free of charge, on all leading OS platforms.

• The new Sun ONE Application Server 7 includes the world's fastest, secure http server, and new "Always On" technology.

Sun ONE Application Server 7 80

J2SE Component Links

– Assistive Technologies

– Drag and Drop

– Java Access Bridge

– JavaBeans TM Technology

– Javadoc Tool

– Java Foundation Classes (JFC)/Swing

– Java HotSpot TM Virtual Machine

– Java Platform Debugger Architecture (JPDA)

– Java Plug-in for Windows XP

– Java 2D TM API product page

– Java Web Start

– JDBC TM Technology

– Pluggable Look and Feel

– Remote Method Invocation (RMI)

– Security

81

List of J2ME Technologies

– Personal Profile

– Personal Basis Profile

– Java Card TM Technology

– Java Embedded Server TM Technology

– JavaPhone TM API

– Java Telematics Technology (JTT)

– Java TV TM API

– J2ME Wireless Toolkit

– PersonalJava TM Technology

– Wireless Developer web site

– Connected Limited Device Configuration (CLDC)

– Mobile Information Device Profile (MIDP)

– Connected Device Configuration (CDC)

– Foundation Profile 82

JBoss Application Server

• JBoss is a simply powerful J2EE application server.

– JBoss Application Server is the #1 most widely used Java application server on the market. A J2EE certified platform for developing and deploying enterprise Java applications, Web applications, and Portals,

JBoss Application Server provides the full range of J2EE 1.4 features as well as extended enterprise services including clustering, caching, and persistence.

• EJB3.0

– JBoss Application Server includes support for Enterprise Java Beans (EJB)

3.0 which is designed to dramatically simplify the enterprise Java programming model.

• Service Oriented Architecture

– JBoss AS is founded on a service oriented microkernel architecture with an extremely small in footprint that ensures all services are accessed, managed, and integrated in a unified and consistent manner.

83

Introduction to Apache Ant

• What is Ant?

– Java-based build tool

• Why use Ant?

– Cross-platform

– Java domain smart

– Fast, extensible, integrated

– Alternatives?

• Analogy

– Factory automation

84

Typical Things to Build

85

Designing a Build

• What are you building?

• What does it take to build it?

• How are the steps related?

86

HTML /

Text files

High-level Model

Source Code

Index

Application

(EAR)

87

Examples of Commercially Used AOP Tools

• AspectWerkz

– Supported by BEA

• Spring AOP framework

JBoss AOP

• CME (Concern Manipulation

Environment)

– Supported by IBM

88

Web Tier

Technical Architecture

View - JSP

Struts - SearchForm

Commons Validator

Struts - SearchAction content

Ant build

<index> task

EJB Container

SearchSessionBean

SearchUtil API

Lucene API index

89

AOP

Aspect Oriented Programming

• Which tools are suitable for commercial dev?

– Over a dozen tools are listed on aosd.net

– Early adopters harden new technologies

– How active are the user communities of each? project

AspectJ

AspectWerkz

JBoss AOP

Spring AOP abc aspect#

AspectC++

JAC posts

150..210

each

1..30

list (november’04 posts) aspectj-users at eclipse.org

url eclipse.org/aspectj user at aspectwerkz.codehaus.org

aspectwerkz.codehaus.org aspects/jboss forum jboss.org/products/aop springframework-user abc-users at comlab.ox.ac.uk www.springframework.org abc.comlab.ox.ac.uk aspectsharp-users aspectc-user at aspect.org

jac-users at objectweb.org

aspectsharp.sourceforge.net aspectc.org

jac.objectweb.org

90

AspectJ ide eclipse, jdeveloper, jbuilder, netbeans editor views highlighting, content assist, advice links outline, visualizer, cross references

Aspect

Werkz

JBoss

AOP eclipse advice links advice links,

UI for pointcut creation aspect manager, advised members

Spring

AOP

IDE support, libs, and docs

debugger

other ajdoc, ajbrowser libs docs

++++ plain

Java

++ dynamic deployment

UI, jboss framework integration

++++ ++ spring framework integration

+++ +

91

Building AOP programs

• What ’ s it like to adopt AOP on an existing project?

AspectJ

Aspect

Werkz

JBoss

AOP

Spring

AOP source extended

.java, or .aj

plain .java

, .xml compiler incremental aspectj compile java compile, post processing checking full static checking weaving minor static checking, none of pointcuts compile and load-time, produce bytecode java compile

runtime interception and proxies deployment static deployment hot deployable run plain Java program framework invoked & managed

92

AOP features

• AspectJ and AspectWerkz

– AspectJ 5 will feature support for generics in pointcuts. The

@AspectJ syntax will support the AspectWerkz annotation style

• JBoss AOP

– Static typing for parameters, performance improvements, libraries, and more IDE support features

• Spring AOP

– Performance improvements, interoperability with AspectJ's pointcuts, and packaging of some Spring AOP services as

AspectJ aspects

93

JBoss AOP (1/2)

-

Lack of static checking for pointcuts

-

Advanced IDE features not yet supported

+

Rich set of enterprise aspects libraries are available and integrated with JBoss and JEMS

+

IDE support lowers adoption and reduces need to hand-code XML

+

Support for dynamic deployment of aspects http://jboss.org/products/aop

94

JBoss AOP (2/2)

95

Web services in JBoss Overview: JBoss.net

• Specifies how JBoss server components are exposed as Web service

– Stateless Session Beans

– Web components

– POJO as servlet

96

JBoss Hibernate

Hibernate

IS

EJB 3.0 CMP

CMP is an API and XML mappings

Hibernate is the actual persistence engine

Hibernate caches are being integrated with

JBossCache

Full distributed data with OR backend on one node

97

Hibernate

Part of JBoss full-time

Gavin King and Christian Bauer on board

Persistence for POJOs (JavaBeans)

• Flexible and intuitive mapping

• Support for fine-grained object models

• Powerful, high performance queries

• Dual-Layer Caching Architecture (HDLCA)

• Support for detached objects (no DTOs)

• Transparent Persistence

• Automatic dirty checking

• Transitive Persistence

• Smart fetching and caching

• Smooth migration to EJB3.0

• Consulting and support available as part of JBoss inc

98

Tomcat 5.0.x improvements

• Tomcat’s Remy Maucherat is on JBoss inc staff

• Performance optimizations and reduced garbage collection

• Optional standalone deployer (validation and precompilation of webapps)

• Scalability and reliability enhancements

• Complete server monitoring using JMX

• Improved Taglibs handling, including advanced pooling and tag plugins

• Embedding of Tomcat using JMX

• Enhanced Security Manager support (now allows very restrictive policies)

• Expanded documentation

• Consulting and support available as part of JBoss inc

99

Tomcat standalone or Tomcat inside JBoss ?

• Better JBoss deployer

– Hot deployment

– Deployment of nested archives (EARs, SARs)

– Redeployment

– Automatic undeployment

• Advanced clustering

• Integrated J2EE stack within one VM

– Deployment descriptor

– Optimized local calls

– Integrated security

• AOP in JBoss 4.0 available in Tomcat components and webapps

• Easy to use classloader

• Nukes

100

JBoss IDE

• JBoss IDE is based on Eclipse .

– Series of plugins for Eclipse

• The debugging and monitoring of JBoss servers and the control of their life cycle (start/stop).

• A very comfortable and sophisticated support for XDoclet

– Support completion and generation

– Support for AOP (completion and generation).

• An easy way to configure and deploy the packaging layout of archives

(packed or exploded)

101

What Is JBossCache?

• What is JBossCache?

– A transactional replicated cache for JBoss with and without AOP

(aspect-oriented programming)

• A cache for frequently accessed elements

– Stateful Session Beans, HTTPSession

– Caches are used in a number of places in JBoss

• This one provides a central cache service (MBean interface)

• All access goes through the cache

– Write-through (lazy or eager)

– Reads only access the cache (very fast on cache hits)

– Items not in the cache are loaded (e.g. from database)

– Bounded size; old items are removed by eviction policy

• Local (=non-replicated) and replicated caches

– Replicated caches are the interesting part

102

Feature

• Transactions

– All modifications done within TX, replication at TX commit. No replication on rollback

• Locking

– Access to nodes serialized by locks

– Lock acquisition timeouts used for deadlock prevention

• Replication

– local: in-VM, no replication

– repl-async: replication done on separate thread

– repl-sync: replication done on user's thread, wait for all acks

• All combinations supported

– From local/no-tx/no-locking to repl/tx/locking

– Ex: repl-async/no-locking/TX

103

Nukes on JBoss

• Nukes on JBoss is a port of PHP postnukes

– Scalability problems with Zend engine

– Full port to EJB/J2EE.

– Leverage the vast library of nukes modules

• Most of PN modules are ported

• Core : offers the core functionalities to other modules

– Security, lifecycle management, parameterization

• User : enables user management

• Html : stores files, filesystem is abstracted, stored in DB

• Sections : edit/publish articles

• FORUMS!!!!

104

CMS: ease of update for non-techies

105

Nukes components

106

How to Deploy on JBoss (1/3)

1.

Write your beans and package them in an ejb-jar file.

2.

Write your servlets/JSPs and package them in a war file.

3.

Add a Class-Path attribute to your war files

MANIFEST.MF file to reference your beans package. for detailed information on that see

J2EE Deployment specification.

http://www.jboss.org

http://www.jboss.com

107

How to Deploy in JBoss (2/3)

4. Package your application in an ear file.

An ear file is a jar archive which contains:

• Your jar files

• Your war files

• A deployment descriptor for your application.

This file must be named "application.xml", and must be located in the META-INF directory in the ear archive. This file tells JBoss which modules are EJBs, which ones are web modules, and the context paths for the web-modules.

108

Sample Application.xml file

<?xml version="1.0" encoding="ISO-8859-1"?>

<application> <display-name>My application</display-name>

<module>

<web>

<web-uri>webmodule.war</web-uri> <context root>/servlets</context-root>

</web>

</module>

<module>

<ejb>beans.jar</ejb>

</module>

</application>

109

How to Deploy in JBoss (3/3)

5. Deploy your ear file.

Option 1: Copy your ear file to

JBOSS_HOME/deploy (wow!)

Write once Deploy AnyWhere!!

110

Thank you!

謝謝捧場 http://www.csie.nctu.edu.tw/~tsaiwn/java/

蔡文能

111

112

Download