Java Enterprise
By Sandeep Desai (http://www.thedesai.net)
Java is a language and a platform. There are
large number of Java, Vendor specific and open source frameworks and APIs for
developing thick applications, web applications and mobile applications
Java based APIs
are JDBC, Servlets, JSP, JSF, EJB and Web
Services. Some of the popular open sources API and frameworks available are
Struts, Spring and Hibernate. Some vendor based frameworks
are Oracle
ADF
Web
Applications can be rich client AJAX
based or HTML based
Ant for building Java Applications
JUnit Java Testing Framework (See my sample)
Eclipse (Open Source IDE for Java UML etc)
Oracle JDeveloper
Apache Tomcat ervlet and JSP Container (pache
Open Source)
Apache Axis (Java Web Services)
Apache Geronimo Application J2EE Server
(Apache Open Source)
JavaRanch Java Community
Java Blueprints
Java Memory Management and Tuning
JDBC
J2EE Architecture
Even if you do client side validation, you
should do server side validation to make sure that invalid data is not entered
by customers
J2EE Patterns
Web Application Frameworks
Struts is a configurable MVC framework
that simplifies the job of developing web applications
Struts is a Model2 Framework
Struts Components
- Action Servlet - provide by Struts, developer does
not need to write one
- Form Beans – JavaBean one for each HTML form, Struts will
call setters and validate()
- Action Objects – implement execute() callback,
validate form and call model components
- Struts-config.xml – map request URLs to Actions, Action
to Form beans and Actions to views
Struts
- Declarative – use XML to configure
application and for validation
- Lifecycle – provide lifecycle
management
- Callback – at key lifecycle events
- Custom Tags
- Data Sources
- Global Exception handling
- Internationalization support – error classes
and custom tags have internationalization support (take resource bundle
strings)
- Plug-ins – Validator framework
initialized as plug-in has init() and destroy() method
Apache Struts
Tutorial
Struts Powerpoint
Presentation
Free
Jakarts Struts Live Book PDF
Java Server Faces is an alternative to
Struts. MyFaces is Apache
implementation of Java Server Faces
Spring is a J2EE framework and aims to
simplify J2EE development
- Lightweight – A non invasive
container that can assemble set of loosely coupled POJOs. This allows
software components to be tested in isolation
- Abstract Transaction Manager – Allows
for pluggable transaction managers, not tied to J2EE environments
- JDBC abstratcion layer – meaningfull
exception hierarchy (no need to extract vendor codes from SQLException)
simplified error handling.
- Integrartes with Toplink, Hibernate,
JDO and iBATIS SQL maps
- AOP functionality – can AOP any
object and add aspects such as declarative transaction management.
Transaction management can be done without EJB or JTA
- A flexible MVC architecture – Can
work with Struts, WebWork or Tapestry and accomodates multiple view
techonlogies like JSP, Velocity, Tiles, iText and POI
You can use all of Spring's functionality
in any J2EE server, and most of it also in non-managed environments. A central
focus of Spring is to allow for reusable business and data access objects that
are not tied to specific J2EE services. Such objects can be reused across J2EE
environments (web or EJB), standalone applications, test environments, etc
without any hassle.
Spring has a layered architecture; all its
functionality builds on lower levels. So you can e.g. use the JavaBeans
configuration management without using the MVC framework or AOP support. But if
you use the web MVC framework or AOP support, you'll find they build on the
configuration framework, so you can apply your knowledge about it immediately.
Spring uses a setter based dependancy injection
pattern (Inversion of Control)
My Spring AOP sample
An
Introduction to AOP Programming with the Spring Framework by Russell Miles
Spring presentation at NEJUG
Pro
Spring by Rob Harrop Jan Machacek
Java
Server Faces
Java Server Faces Tutorial
Java
Aspect Oriented Programming
The
goal is to make the core logic simpler to write and test
AOP
use cases
- Logging,
tracing and auditing
- Security
authentication and authorization
- Rules
engine
- Testing
and Test harness support
- Persistence
and O/R mapping
- Caching,
transparent to application developer
- Transaction
support
- Synchronization
and thread safety
AOP
terms
- Join
point: well defined point in program where AOP functions (advice) can
intercede and affect execution
- Advice:
action taken by the AOP framework at a particular join point. This
functionality implemented by Java method will be called. It will
transparently intercede and be executed . Types of advice are before,
after and around
- Aspect:
collection of one or more advice methods, typically implemented in a
single Java class, an potentially accepting join point context information
as a parameter to those advice methods
- Pointcut:
expression that specifies which join points will be affected by one or
more aspects
- Introductions:
a more intrusive type of intercession that modified the structure/type of your
Java application classes, for example, by implementing a new interface or
adding a new member variable
- Mixin:
refers to adding new class or classes to a pre existing class
- Weaving:
the application/activation of an advice across one or more pointcuts so
that the advice will be executed when the join points are encountered
- Target:
the application object being advised (affected by the aspects) at any
point in time
- Interceptor:
an aspect with only one advice method named "invoke"
AOP
Frameworks
AspectJ
and Spring are the most popular AOP frameworks
AspectJ (1.2)
Aspects and pointcuts are expressed in
AspectJ language. Pre-compiler generates Java code. An .lst file specifies
which Aspects apply to the subsystem. There is no runtime support for turning
Aspects on or off. AJDT Eclipse
plug-in is available
Spring AOP (1.2)
Provides dynamic proxy-based approach to
implementing AOP (using Java Reflection APIs). Target application classes must
implemented interfaces. Uses springconfig.xml for Spring Framework and Spring
AOP configuration. Uses AOP alliance.
Pointcuts and advice are implemented using Spring's IOC (Inversion of control)
framework. IOC is a POJO with a Java Bean setter method. Spring AOP comes with
built in transaction and security support
JBoss AOP 1.1
http://ramnivas.com/
author of AspectJ In Action
Source
Listings
See SCJP notes for Java Fundamentals
Fundamentals.java
demonstrates primitive data types, arrays, controls etc
Objects.java
inheritance, exceptions, inner classes
JavaCollections.java
demonstrates how to create Lists, Sets and Hash Tables (Associative Arrays)
JavaThreads.java
demonstrated how to create and use Threads
Java and JDBC, Oracle
JDBC FAQ
Java 1.5 Basics
Java 1.5 Generics
Java 1.5 Enumerations
Java Basics and Sun
Certified Java Programmer Notes
J2EE
J2EE is a set of API and
services. The services are typically implemented in an Application server. The
API/services for J2EE 1.3 are
- JDBC:
Abstract API for connecting to any database (database vendor has to
provide a JDBC driver)
- JNDI
: Network wide naming service to locate objects in LDAP, JDBC, JMS, EJB
Homes,
- JTA
and JTS: Transaction management API and service
- Servlet
: Implements CGI, creates one thread per session (unlike CGI which runs a
process for each HTTP request) Accepts HTTP requests and sends HTML
replies
- JSP: Allows you to embed Java code in HTML
at runtime the Application Server generates a servlet for the JSP
page. The user can access the
servlet API while writing JSP.
- EJB:
Enterprise Java Beans is used for implementing the business logic layer.
There are three types of beans. Entity Beans, session beans, message
driven beans. EJB consists of a client and a server portion which can be
run on the same or different machine
- RMI-IIOP:
Supports Remote Java method invocation over the IIOP protocol. The
protocol is used for implementing EJB.
- JMS:
Supports messaging using systems such as Oracle AQ (Advanced Queuing).
Support asynchronous messaging system. JMS can work in point to point or
publish/subscribe (used for multiple subscribers)
- JavaMail:
email
- JAF
1.0: JavaBeans Activation Framework used in the JavaMail API. Most
developers do not use this API
- JAXP: Java API for XML Processing supports implementation
independant procession of XML documents through DOM, SAX and XSLT. DOM
tree based API, SAX is event driven API
- JAAS:
Java Authentication and Authorization service is standard API for
authentication and assigning and verifying user privileges new in J2EE 1.3
- JCA:
Java Connector Architecture provides a standard abstract API for
connecting EJBs to Enterprise Information System e.g ERP, CRM and legacy
applications
- SOA: Service Oriented Architecture for created web
services
SOA
(Service Oriented Architecture)
SOA is a standards-based platform that lets you model,
develop, find, and combine services into flexible business processes
- Services - Preferably one
service to one business function
-
Registry - A place to store them so you can find them
easily
-
Process manager - An orchestration
tool so you can plug them together
-
Message bus - A way for them to communicate with
each other
-
Security -
Secure SOA, via WS Security & IDM
-
Monitoring – Useful to have a Real-time Activity
Monitoring & Optimization
Web
services is a set of XML-based technologies (SOAP, UDDI, WSDL) that are the
means by which interoperable application-to-application communication is
carried out on the World Wide Web through a set of standard programmatic
interfaces. Web services are a set of implementation technologies, whereas SOA
is an architectural style or strategy. SOA uses web services
SOAP
Version 1.2 is a lightweight protocol intended for exchanging structured
information in a decentralized, distributed environment. It uses XML
technologies to define an extensible messaging framework providing a message
construct that can be exchanged over a variety of underlying protocols. The
framework has been designed to be independent of any particular programming
model and other implementation specific semantics.
Java Web Services
Java
Web Services Tutorial
Java Blueprints
Catalog
Apache
Web Services
Web
Services Org
Books
Designing
Web Services with the J2EE(TM) 1.4 Platform: JAX-RPC, SOAP, and XML
Technologies