java/j2ee
TRANSCRIPT
![Page 1: Java/J2EE](https://reader033.vdocuments.mx/reader033/viewer/2022052911/559e04b21a28ab2f6a8b48a6/html5/thumbnails/1.jpg)
Enterprise Applications & Java/J2EE Technologies
Dr. Douglas C. Schmidt [email protected]
http://www.dre.vanderbilt.edu/~schmidt/
Professor of EECS Vanderbilt University Nashville, Tennessee
![Page 2: Java/J2EE](https://reader033.vdocuments.mx/reader033/viewer/2022052911/559e04b21a28ab2f6a8b48a6/html5/thumbnails/2.jpg)
Tutorial on J2EE Douglas C. Schmidt
2
Agenda• What makes an application “Enterprise”?• Java/J2EE to develop Enterprise Applications• EJB Specification• JBoss Application Server + AOP• What is an Architect’s role?
![Page 3: Java/J2EE](https://reader033.vdocuments.mx/reader033/viewer/2022052911/559e04b21a28ab2f6a8b48a6/html5/thumbnails/3.jpg)
Tutorial on J2EE Douglas C. Schmidt
3
Enterprise Architectures• They all have well thought out solutions to the “-ilities” of
software development.
![Page 4: Java/J2EE](https://reader033.vdocuments.mx/reader033/viewer/2022052911/559e04b21a28ab2f6a8b48a6/html5/thumbnails/4.jpg)
Tutorial on J2EE Douglas C. Schmidt
4
Enterprise = “-ilities”• Availability• Dependability• Distributability• Maintainability• Reusability• Reliability• Scalability• Recoverability• Etc…
![Page 5: Java/J2EE](https://reader033.vdocuments.mx/reader033/viewer/2022052911/559e04b21a28ab2f6a8b48a6/html5/thumbnails/5.jpg)
Tutorial on J2EE Douglas C. Schmidt
5
Availability
• The accessibility of a system resource in a timely manner; for example, the measurement of a system's uptime.
![Page 6: Java/J2EE](https://reader033.vdocuments.mx/reader033/viewer/2022052911/559e04b21a28ab2f6a8b48a6/html5/thumbnails/6.jpg)
Tutorial on J2EE Douglas C. Schmidt
6
Dependability• "[..] the trustworthiness of a computing system which allows
reliance to be justifiably placed on the service it delivers [..]" – IFIP WG10.4 on DEPENDABLE COMPUTING AND FAULT TOLERANCE
![Page 7: Java/J2EE](https://reader033.vdocuments.mx/reader033/viewer/2022052911/559e04b21a28ab2f6a8b48a6/html5/thumbnails/7.jpg)
Tutorial on J2EE Douglas C. Schmidt
7
Distributability• Involve Multiple
Environments/Servers• Can span across geographical
locations• Hand held devices to
Multiprocessor Servers
![Page 8: Java/J2EE](https://reader033.vdocuments.mx/reader033/viewer/2022052911/559e04b21a28ab2f6a8b48a6/html5/thumbnails/8.jpg)
Tutorial on J2EE Douglas C. Schmidt
8
Maintainability• “You are developing tomorrow’s legacy code”• To keep up or carry on; continue.• To keep in a condition of good repair or efficiency.
– What makes a system maintainable?
![Page 9: Java/J2EE](https://reader033.vdocuments.mx/reader033/viewer/2022052911/559e04b21a28ab2f6a8b48a6/html5/thumbnails/9.jpg)
Tutorial on J2EE Douglas C. Schmidt
9
Reusability• To use again, especially after salvaging or special treatment
or processing. • Reduces duplicate code / “Copy & Paste”• Easier to maintain • Faster to develop
![Page 10: Java/J2EE](https://reader033.vdocuments.mx/reader033/viewer/2022052911/559e04b21a28ab2f6a8b48a6/html5/thumbnails/10.jpg)
Tutorial on J2EE Douglas C. Schmidt
10
Reliability• The trustworthiness to do what the system is expected or
designed to do. • Available 24-7-365• Performs within acceptable thresholds
![Page 11: Java/J2EE](https://reader033.vdocuments.mx/reader033/viewer/2022052911/559e04b21a28ab2f6a8b48a6/html5/thumbnails/11.jpg)
Tutorial on J2EE Douglas C. Schmidt
11
Scalability• “Refers to how much a system can be expanded. The term
by itself implies a positive capability. For example, "the device is known for its scalability" means that it can be made to serve a larger number of users without breaking down or requiring major changes in procedure.”
– Computer Desktop Encyclopedia
![Page 12: Java/J2EE](https://reader033.vdocuments.mx/reader033/viewer/2022052911/559e04b21a28ab2f6a8b48a6/html5/thumbnails/12.jpg)
Tutorial on J2EE Douglas C. Schmidt
12
Recoverability• Single point of failure• Clustered servers• Emergency backup plans• Disaster backup plans
![Page 13: Java/J2EE](https://reader033.vdocuments.mx/reader033/viewer/2022052911/559e04b21a28ab2f6a8b48a6/html5/thumbnails/13.jpg)
Questions / Comments?
![Page 14: Java/J2EE](https://reader033.vdocuments.mx/reader033/viewer/2022052911/559e04b21a28ab2f6a8b48a6/html5/thumbnails/14.jpg)
Tutorial on J2EE Douglas C. Schmidt
14
Java/J2EE to develop Enterprise Applications• EE = Enterprise Edition• Specifications and Standards• Enabled Vendors to build Application Servers• Focus on Business Logic, not on infrastructure• Removed some complexities, introduced others
![Page 15: Java/J2EE](https://reader033.vdocuments.mx/reader033/viewer/2022052911/559e04b21a28ab2f6a8b48a6/html5/thumbnails/15.jpg)
Tutorial on J2EE Douglas C. Schmidt
15
Standards & Specifications
• EJB• JSP• JAXP• JMS• JNDI• JMX
• Servlets• JDBC• JTA• JCA• RMI• JNI
Some but not all…
![Page 16: Java/J2EE](https://reader033.vdocuments.mx/reader033/viewer/2022052911/559e04b21a28ab2f6a8b48a6/html5/thumbnails/16.jpg)
Tutorial on J2EE Douglas C. Schmidt
16
J2EE Architecture
![Page 17: Java/J2EE](https://reader033.vdocuments.mx/reader033/viewer/2022052911/559e04b21a28ab2f6a8b48a6/html5/thumbnails/17.jpg)
Tutorial on J2EE Douglas C. Schmidt
17
Containers“Containers provide the runtime support for J2EE application components. Containers provide a federated view of the underlying J2EE APIs to the application components. J2EE application components never interact directly with other J2EE application components. They use the protocols and methods of the container for interacting with each other and with platform services. Interposing a container between the application components and the J2EE services allows the container to transparently inject the services defined by the components’ deployment descriptors, such as declarative transaction management, security checks, resource pooling, and state management.”
-J2EE Specification v1.4
![Page 18: Java/J2EE](https://reader033.vdocuments.mx/reader033/viewer/2022052911/559e04b21a28ab2f6a8b48a6/html5/thumbnails/18.jpg)
Tutorial on J2EE Douglas C. Schmidt
18
EJB Specification• Session, Entity, and Message Driven Beans• Instance Lifecycle• Declarative Transaction Management• Security• Threading/Locking• Remote/Local Invocation
![Page 19: Java/J2EE](https://reader033.vdocuments.mx/reader033/viewer/2022052911/559e04b21a28ab2f6a8b48a6/html5/thumbnails/19.jpg)
Tutorial on J2EE Douglas C. Schmidt
19
Session Beans• Executes on behalf of a single client.• Can be transaction-aware.• Updates shared data in an underlying database.• Does not represent directly shared data in the database, although it may
access and update such data.• Is relatively short-lived.• Is removed when the EJB container crashes. The client has to re-
establish a new session object to continue computation.• Can be either Stateful or Stateless.
![Page 20: Java/J2EE](https://reader033.vdocuments.mx/reader033/viewer/2022052911/559e04b21a28ab2f6a8b48a6/html5/thumbnails/20.jpg)
Tutorial on J2EE Douglas C. Schmidt
20
When to use Session Beans• Session Façade pattern• Front end a web service• Manage transactions, threading, pooling, etc.• Expose a remote interface
![Page 21: Java/J2EE](https://reader033.vdocuments.mx/reader033/viewer/2022052911/559e04b21a28ab2f6a8b48a6/html5/thumbnails/21.jpg)
Tutorial on J2EE Douglas C. Schmidt
21
Entity Beans• Provides an object view of data in the database.• Allows shared access from multiple users.• Can be long-lived (lives as long as the data in the database).• The entity, its primary key, and its remote reference survive
the crash of the EJB container.
![Page 22: Java/J2EE](https://reader033.vdocuments.mx/reader033/viewer/2022052911/559e04b21a28ab2f6a8b48a6/html5/thumbnails/22.jpg)
Tutorial on J2EE Douglas C. Schmidt
22
When to use Entity Beans• Services that have a small limited object model.• Object model needs to perform CrUD operations.• No complex joins are needed to retrieve data.• No need to walk complex object graphs.
![Page 23: Java/J2EE](https://reader033.vdocuments.mx/reader033/viewer/2022052911/559e04b21a28ab2f6a8b48a6/html5/thumbnails/23.jpg)
Tutorial on J2EE Douglas C. Schmidt
23
Message Driven Beans• Executes upon receipt of a single client message (JMS).• Is asynchronously invoked.• Can be transaction-aware.• May update shared data in an underlying database.• Does not represent directly shared data in the database, although it may access
and update such data.• Is relatively short-lived.• Is stateless.• Is removed when the EJB container crashes. The container has to re-establish a
new message-driven object to continue computation.
![Page 24: Java/J2EE](https://reader033.vdocuments.mx/reader033/viewer/2022052911/559e04b21a28ab2f6a8b48a6/html5/thumbnails/24.jpg)
Tutorial on J2EE Douglas C. Schmidt
24
When to use MDB• Distributed systems• JMS• Asynchronous calls• Manage Transactions, threading, pooling, etc.
![Page 25: Java/J2EE](https://reader033.vdocuments.mx/reader033/viewer/2022052911/559e04b21a28ab2f6a8b48a6/html5/thumbnails/25.jpg)
Tutorial on J2EE Douglas C. Schmidt
25
Bean Lifecycle
![Page 26: Java/J2EE](https://reader033.vdocuments.mx/reader033/viewer/2022052911/559e04b21a28ab2f6a8b48a6/html5/thumbnails/26.jpg)
Tutorial on J2EE Douglas C. Schmidt
26
Declarative Transactions• Declare the transaction level through configuration of a bean.• Container manages these transactions for you.• Valid transaction Values:
– Not Supported– Required– Supports
– Requires New– Mandatory– Never
![Page 27: Java/J2EE](https://reader033.vdocuments.mx/reader033/viewer/2022052911/559e04b21a28ab2f6a8b48a6/html5/thumbnails/27.jpg)
Tutorial on J2EE Douglas C. Schmidt
27
Application Servers• Implement the specification for EJB containers.• Provide environment which allows developers to focus on
business logic.
![Page 28: Java/J2EE](https://reader033.vdocuments.mx/reader033/viewer/2022052911/559e04b21a28ab2f6a8b48a6/html5/thumbnails/28.jpg)
Tutorial on J2EE Douglas C. Schmidt
28
JBoss Application Server• J2EE application server – open source• www.jboss.org• EJB Container and more• Implements Specification through “Interceptors” – AOP-like
![Page 29: Java/J2EE](https://reader033.vdocuments.mx/reader033/viewer/2022052911/559e04b21a28ab2f6a8b48a6/html5/thumbnails/29.jpg)
Tutorial on J2EE Douglas C. Schmidt
29
AOP – Aspect Oriented Programming“Aspect-Oriented Programming (AOP) complements OO programming by allowing the developer to dynamically modify the static OO model to create a system that can grow to meet new requirements. Just as objects in the real world can change their states during their lifecycles, an application can adopt new characteristics as it develops.”
-Graham O’Regan
![Page 30: Java/J2EE](https://reader033.vdocuments.mx/reader033/viewer/2022052911/559e04b21a28ab2f6a8b48a6/html5/thumbnails/30.jpg)
Tutorial on J2EE Douglas C. Schmidt
30
JBoss EJB Interceptor Stack
Clie
nt P
roxy
Log
Inte
rcep
tor
Sec
urity
In
terc
epto
rTr
ansa
ctio
n In
terc
epto
rB
ean
Cre
atio
n In
terc
epto
rLo
ck
Inte
rcep
tor
Bean Impl
![Page 31: Java/J2EE](https://reader033.vdocuments.mx/reader033/viewer/2022052911/559e04b21a28ab2f6a8b48a6/html5/thumbnails/31.jpg)
Tutorial on J2EE Douglas C. Schmidt
31
Implementing Declarative Transactions using Interceptors
• Not Supported• Required• Supports• Requires New• Mandatory• Never
![Page 32: Java/J2EE](https://reader033.vdocuments.mx/reader033/viewer/2022052911/559e04b21a28ab2f6a8b48a6/html5/thumbnails/32.jpg)
Tutorial on J2EE Douglas C. Schmidt
32
Not SupportedC
lient
Pro
xy
Log
Inte
rcep
tor
Sec
urity
In
terc
epto
rT
rans
actio
n In
terc
epto
rB
ean
Cre
atio
n In
terc
epto
rLo
ck
Inte
rcep
tor
Bean Impl
Clie
nt P
roxy
Log
Inte
rcep
tor
Sec
urity
In
terc
epto
rT
rans
actio
n In
terc
epto
rB
ean
Cre
atio
n In
terc
epto
rLo
ck
Inte
rcep
tor
Bean Impl
![Page 33: Java/J2EE](https://reader033.vdocuments.mx/reader033/viewer/2022052911/559e04b21a28ab2f6a8b48a6/html5/thumbnails/33.jpg)
Tutorial on J2EE Douglas C. Schmidt
33
RequiredC
lient
Pro
xy
Log
Inte
rcep
tor
Sec
urity
In
terc
epto
rT
rans
actio
n In
terc
epto
rB
ean
Cre
atio
n In
terc
epto
rLo
ck
Inte
rcep
tor
Bean Impl
Clie
nt P
roxy
Log
Inte
rcep
tor
Sec
urity
In
terc
epto
rT
rans
actio
n In
terc
epto
rB
ean
Cre
atio
n In
terc
epto
rLo
ck
Inte
rcep
tor
Bean Impl
![Page 34: Java/J2EE](https://reader033.vdocuments.mx/reader033/viewer/2022052911/559e04b21a28ab2f6a8b48a6/html5/thumbnails/34.jpg)
Tutorial on J2EE Douglas C. Schmidt
34
SupportsC
lient
Pro
xy
Log
Inte
rcep
tor
Sec
urity
In
terc
epto
rT
rans
actio
n In
terc
epto
rB
ean
Cre
atio
n In
terc
epto
rLo
ck
Inte
rcep
tor
Bean Impl
Clie
nt P
roxy
Log
Inte
rcep
tor
Sec
urity
In
terc
epto
rT
rans
actio
n In
terc
epto
rB
ean
Cre
atio
n In
terc
epto
rLo
ck
Inte
rcep
tor
Bean Impl
![Page 35: Java/J2EE](https://reader033.vdocuments.mx/reader033/viewer/2022052911/559e04b21a28ab2f6a8b48a6/html5/thumbnails/35.jpg)
Tutorial on J2EE Douglas C. Schmidt
35
Requires NewC
lient
Pro
xy
Log
Inte
rcep
tor
Sec
urity
In
terc
epto
rT
rans
actio
n In
terc
epto
rB
ean
Cre
atio
n In
terc
epto
rLo
ck
Inte
rcep
tor
Bean Impl
Clie
nt P
roxy
Log
Inte
rcep
tor
Sec
urity
In
terc
epto
rT
rans
actio
n In
terc
epto
rB
ean
Cre
atio
n In
terc
epto
rLo
ck
Inte
rcep
tor
Bean Impl
![Page 36: Java/J2EE](https://reader033.vdocuments.mx/reader033/viewer/2022052911/559e04b21a28ab2f6a8b48a6/html5/thumbnails/36.jpg)
Tutorial on J2EE Douglas C. Schmidt
36
MandatoryC
lient
Pro
xy
Log
Inte
rcep
tor
Sec
urity
In
terc
epto
rT
rans
actio
n In
terc
epto
rB
ean
Cre
atio
n In
terc
epto
rLo
ck
Inte
rcep
tor
Bean Impl
Clie
nt P
roxy
Log
Inte
rcep
tor
Sec
urity
In
terc
epto
rT
rans
actio
n In
terc
epto
rB
ean
Cre
atio
n In
terc
epto
rLo
ck
Inte
rcep
tor
Bean ImplException!
![Page 37: Java/J2EE](https://reader033.vdocuments.mx/reader033/viewer/2022052911/559e04b21a28ab2f6a8b48a6/html5/thumbnails/37.jpg)
Tutorial on J2EE Douglas C. Schmidt
37
NeverC
lient
Pro
xy
Log
Inte
rcep
tor
Sec
urity
In
terc
epto
rT
rans
actio
n In
terc
epto
rB
ean
Cre
atio
n In
terc
epto
rLo
ck
Inte
rcep
tor
Bean Impl
Clie
nt P
roxy
Log
Inte
rcep
tor
Sec
urity
In
terc
epto
rT
rans
actio
n In
terc
epto
rB
ean
Cre
atio
n In
terc
epto
rLo
ck
Inte
rcep
tor
Bean Impl
Exception!
![Page 38: Java/J2EE](https://reader033.vdocuments.mx/reader033/viewer/2022052911/559e04b21a28ab2f6a8b48a6/html5/thumbnails/38.jpg)
Tutorial on J2EE Douglas C. Schmidt
38
Custom Interceptors• AOP – Aspect Oriented Programming• Logging• Timing • Metrics• Any business logic that should be applied widely
![Page 39: Java/J2EE](https://reader033.vdocuments.mx/reader033/viewer/2022052911/559e04b21a28ab2f6a8b48a6/html5/thumbnails/39.jpg)
Tutorial on J2EE Douglas C. Schmidt
39
Developers Focus on Business Logic
WAR WAR WAR EAR EAR EAR