2024: Domino Containers - The Next Step. News from the Domino Container commu...
2000: Making IT Happen with J2EE
1. 1
Making it Happen with
J2EE
Russell Castagnaro
Chief Mentor
4Charity.com
russell@4charity.com
Introduction
zPresenter
yRussell Castagnaro
yChief Mentor
x4Charity.com
xSyncTank Solutions, Inc
yrussell@4charity.com
yExperience
Introduction
z4Charity.com
yApplication Service Provider for the Non-
Profit industry
yPure Java development
yHttp://www.4charity.com
yLocations:
x San Francisco,CA
x Honolulu, HI
yWe’re Hiring…
2. 2
Presentation Goals
zBrief overview of the J2EE API
zDiscuss various application architectures
zExplain when each API should be used
zMost examples use BEA’s Weblogic Server
What is the J2EE?
zJava2 Enterprise Edition
zA set of Eleven Application Programming
Interfaces (API) that provide a standard
way to solve common issues.
zDelivers on the promise of Standards-
based heterogeneous applications
development.
The J2EE API’s
zDatabase Connectivity (JDBC)
zRemote Method Protocol (RMP/ RMI)
zNaming and Directory Interface (JNDI)
zServlets and Server Pages (JSP)
zMessaging (JMS)
zTransaction Services (JTS/ JTA)
3. 3
The J2EE API’s
zCORBA Communication (IIOP/ CORBA)
zMail (Mail and JAF)
zEnterprise Beans (EJB)
zExtensible Markup Language (XML / XSL)
The J2EE API’s
Java Database
Connectivity
zThe first of the J2EE API’s.
zProvides a standard set of interfaces to
access any compliant data source.
zImproved upon ODBC standard.
zSQL 92 compliant.
4. 4
Remote Method Protocol
Remote Method Interface
zCommunication protocol between Java
objects on separate Virtual Machines
(JVM).
zEnables distributed communications with
no knowledge of networking or sockets.
zMakes remote objects seem local.
zUses Java Serialization to send objects
across a network.
Java Naming & Directory
Interface
zSimple interface that allows for resource
discovery and binding.
zA way to ‘look up’ an object locally or
remotely.
zA way to enter objects into a directory of
objects.
zOther interfaces leverage JNDI (i.e.
LDAP).
Java Servlets
zJava access to network (HTTP) requests
and responses.
zIntegration with a Web Server via a
Servlet Engine.
zImproved performance over CGI.
z70% of successful Java projects are
Servlet-based!
5. 5
Java Sever Pages
zBuilds on the Servlet API.
zProvides a “pure” presentation-layer
templating mechanism.
zAllows HTML coders to write HTML, not
the Java Programmers.
Java Messaging Service
zAsynchronous messaging between de-
coupled components.
zDefines the Message Oriented
Middleware interface for Java
applications.
zSupports:
yGuaranteed Message Delivery
yPoint-to-point messaging
yPublish/ Subscript messaging
Java Transaction Services
z JTS uses the Java Transaction Architecture
(JTA) to monitor and access all transactions
that take place in a given system.
z Implements the OMG Object Transaction
Service (OTS) definition.
z Defines the interfaces between :
yTransaction Manager
yApplication
yApplication Server
yResource (Database Management System)
6. 6
CORBA / IIOP
zInternet Inter-Orb Protocol is the
standard protocol from accessing CORBA
resources.
zCORBA resources may be COBOL, C,
C++, etc.
zRMI over IIOP is supported in Java 2!
Java Mail & Activation
zProvides non-networking specific access
to internet mail services.
zIncludes implementation that can access
SMTP, POP, and IMAP servers.
zMime type support for various data-types
Enterprise Java Beans
zCross platform Java-based component
architecture
zProvides for portability across server
vendors
zWell defined interfaces between client,
server component, server and resources
zHandles data persistence and transaction
integrity
7. 7
Extensible Markup Language
z Self-describing, pure data representation
z Compatible with heterogeneous systems
z Method of configuration of most systems
z Can be used within most of the core API
z Transformations via Extensible Stylesheet
Language Transformation (XSLT)
The J2EE
zYou may remain completely within the
realm of J2EE and provide enterprise
solutions.
zOccasionally the Java Native Interface is
needed to access other systems.
J2EE Construction
zI will use a construction metaphor for
using the J2EE
8. 8
Enterprise Mortar:
JDBC, JNDI and RMI
zJDBC Connects your databases to Java.
yUse Connections, Statements, Result Sets,
etc..
yCall Stored Procedures, etc..
zJNDI locates distributed components.
zRMI allows distributed objects to
communicate as if they were local.
Enterprise Bricks:
EJB, JMS, JTS
zEJB encapsulates business logic, insulates
you from the persistence layer, provides
fault tolerance and fail-over
zJMS provides GMD in Queues or Topics
zJTS allows you to control transaction
isolation level for better data management
Enterprise support beams:
Servlets
zServlets
yProvide the application structure.
yDictate how to navigate inside the
application.
yAre strong, but not pretty.
9. 9
The Enterprise Exterior: JSP
zJSP’s are responsible for the user
experience
zHides the internal structure from clients
zAllows less experienced developers or
web content producers to focus on
presentation
How do the new API’s Help?
zInterfaces* that provide maximum
flexibility.
zThey provide several contracts:
yDeveloper - Component
yContainer -Component
yServer - Container
zYou can avoid deployment specifics in
client code.
Companies Really Are Using
J2EE
zCompanies that use Java:
yMost use JDBC and Servlets
yMany use JNDI/ RMI or IIOP
yBigger players are using EJB, JMS and XML
zCompanies that do not use Java:
yMany are using XML, COM, or CORBA
10. 10
Common Acceptance Path
zUse Servlets (performance, speed of
deployment, ease of development)
zUse JDBC (robust, simple, easy to deploy)
zUse RMI/JNDI (distributed applications)
zUse JNI (integration with other software)
zUse EJB and JMS (high availability,
performance, abstraction)
Now what?
zYou already knew all of that…
zMaybe:
yYour CTO declared that all future
development should be EJB’s!
yYour client decided to listen to some Gartner
Group/ Forrester/ Giga Group advice.
yYou want to develop distributed, scalable
applications in Java.
Avoiding Success With J2EE
zUse one API exclusively, ALL THE TIME.
zUse EJB’s, particularly Entity Beans
excessively.
zCreate ‘Monolithic’ Distributed
applications.
zIgnore other reasonable advice.
13. 13
Report Overkill-us
z Do not use Entity classes to access read-only
data
z Compare the number of sql statements
ySelect name,ssn,salary from emp
ySelect name,ssn,salary from emp where id=1
ySelect name,ssn,salary from emp where id=2
ySelect name,ssn,salary from emp where id=3
y…
z Consider the RMI communication time.
z Contemplate the App Server overhead.
Some Successful Strategies
z Use coarse-grained entities where possible
z Use Interfaces from the start of development
z Use JSP to encapsulate the presentation layer
z Do not put business logic in your JSP’s
z Use Bean Managed Persistence or OR Mapping
tools
z You still need code reviews!
Use coarse-grained Entities
zJDBC is your friend!
zContainer Managed Persistence is not
always appropriate.
zDo not let the Database structure dictate
your object architecture.
14. 14
Use Remote Interfaces from
the beginning
zDefine your interfaces very early in the
construction phase
zCreate stub implementations
zThis allows the presentation layer
development to continue without waiting
for the server side components
Use Interfaces with EJB
EJB Data Access
z There are many ways that you can access your
data via EJB
yUsing a Session
x SQL in the Session or DD
x Data Access Objects
yUsing an Entity
x Container Managed Persistence
x Bean Managed Persistence
• SQL embedded in the Entity or DD
• Data Access Objects
• O/R Mapping Tool
15. 15
EJB Data Access
zUsing a Session with SQL Embedded
yVery straightforward
yEasy to Configure
ySomewhat Flexible
yMay be difficult to maintain
yHard to reuse
Session With SQL Embedded
public AddressData getBusinessAddress() throws RemoteException {
AddressData address = new AddressData();
try {
Connection c = null; PreparedStatement s = null; ResultSet rs = null;
try {
c = getConnection(); s = c.createStatement();
String query = getEnvironmentValue("ADDRESS_SQL");
s.prepareStatement(query); s.setString(id); rs = s.executeQuery();
while (rs.next()){
address.setStreet(rs.getString("ADDRESS"));
address.setCity(rs.getString("CITY"));
address.setState(rs.getString("STATE")); address.setZip(rs.getString("ZIP"));
address.setCountryCode(rs.getString(“COUNTRY_CD");
} //while
} catch (SQLException e){ e.printStackTrace(); } finally {
if ( s != null ) s.close(); if ( rs != null ) rs.close();
if ( c != null) c.close();
} //catch
} catch (SQLException e){}
return address;
}
EJB Data Access
zUsing a Session with a Data Access Object
yModular
yReusable
yDifficult to expand to complex relationships
yTransactions, data-integrity must be
maintained manually
16. 16
Session With DAO
public AddressData getBusinessAddress() throws RemoteException,
BeanDNEException
{
AddressDataBean address = new AddressDataBean(ein);
return address.getAddressData();
}
Other Points
zThe same follows for Entities
zUse a Cookie Cutter Approach
ySpecify your interfaces early
yWrite a tool or use an IDE that will create the
skeleton code for you
yImplement only what you need
zAssign a person to take on the role of
deployment specialist (its not fun)
Using the J2EE
zUse the appropriate technology
zDon’t throw away all of the design
principles you have learned
zJust say no to ‘distributed monolithic’
applications
17. 17
Finally
z Thanks for attending
z Live in Hawaii or Bay Area? Do you like this
stuff? Email your resume to us!
z Source Code Available
yhttp://www.synctank.com/javacon
yrussell@4charity.com
z Check for EJBWiz to be released as open source
soon
z Aloha