Title: J2EE for Smalltalkers
1J2EE for Smalltalkers
- Alan Knight
- Cincom Systems of Canada
- knight_at_acm.org
2Who am I
- Carleton University
- The Object People, 1992-2000
- Chief Architect for TOPLink
- Led TOPLink for BEA WebLogic integration
- Sun Expert Group for EJB 2.0
3My Background/Biases
- Databases (relational)
- Web stuff
- Weak on mainframes, message queueing
- J2EE
- Worked very extensively with EJB and JDBC,
especially entity beans - Implemented ST version of Servlets/JSP
- Once read a white paper on Connectors
4Outline
- Definitions
- Quick overview of the simple parts
- Servlets/JSP in more detail
- EJB in depth
- For each
- description, motivation, Smalltalk equivalents
5J2EE Goals
- World domination
- Easier distributed (i.e. web) apps
- web for VB programmers (PowerBuilder of the Web)
- Transparent distribution, transactions, security,
connection management - Provide Portable Java-Centric APIs for standard
services
6Why do I need to know about it?
- Know what youre missing
- Know what you need to coexist with
- Know what youre up against
- Hold your own in the battle of the acronyms
- All those dot-coms cant be wrong
7Battle of the AcronymsWe want to build our
architecture around browser-based Java clients
talking to a scalable cluster of JTS-enabled BMP
entity EJBs
8Wrong Responses
- Um, yeah, but Smalltalk is, like, good.
9Right Response
- Have we actually measured the gain from
clustering vs. the RPC overhead on fine-grained
entity EJBs. That also implies transaction
control at the client or else many fine-grained
JTS transactions. Since were standardized on
Oracle, the only reason we need the JTS overhead
is in fact because of the cluster. Plus the
development overhead is going to frustrate any
attempts at an XP process, or even unit-testing
without major turnaround times. Do we have
estimates on the impact of deployment costs on
the development cycle?
10Whats in J2EE
- J2EE
- JDBC (database)
- Transaction Service
- JMS (messaging)
- JNDI (naming service)
- Connectors (legacy adaptors)
- Servlets
- Java Server Pages
- EJB (Enterprise JavaBeans)
- Related Technologies
- CORBA
- RMI over IIOP
- Java bindings
- Transaction Service
- XML
- Most configuration files
11Whats in J2EE (condensed)
- Big pile of stuff
- Only a few of them really interesting
- Lets quickly review basics and Smalltalk
equivalents
12JDBC
- Database Drivers
- Standard, interoperable drivers
- Not really standard, but no worse than others
- Most vendors supply drivers
- Smalltalk equivalent
- Vendor database drivers
- But, not as many, not as up to date
- ODBC, but platform-limited, performance and
features may vary
13Transaction Service
- JTS Identical to CORBA Transaction Service
- Distributed transactions
- Two-phase commit (some of them)
- Smalltalk equivalent
- CORBA transaction service
14JMS
- Messaging Service
- Guaranteed delivery and ordering
- Transactional (with some issues)
- Smalltalk equivalent
- Bindings to proprietary APIs, e.g. MQSeries
- No portable API
15JNDI
- Java Naming and Directory Service
- Maps to multiple different services
- LDAP by far the most important
- Smalltalk equivalent
- CORBA naming
- bindings to LDAP, DNS, or others
16Connectors
- New mechanism for standard interfaces to outside
systesm - transactions
- connections and pooling
- security
- Resources map Java concepts onto outside systems
- Not many exist yet
17The Easy Stuff (quiz)
- JDBC
- JTS
- JMS
- JNDI
- Connectors
18Interesting Stuff
- Fundamentally, J2EE is
- Servlets/JSP
- EJB
- supporting technologies
19Servlet Features
- CGI overhead not required
- Very simple and lightweight
- Full flexibility and control for programmers
- Automates header parsing etc.
- But, awkward, pages must be built by programmers
20Smalltalk Equivalents
- VisualWorks 5i.4 (Web Toolkit)
- Whitecap (VW Apache Jserv)
- Wiki
- Swazoo/AIDA
- Commanche
- Servlets are like commands, not like objects that
know how to render themselves.
21JSP
- Templated approach
- HTML containing code
- lt aPerson name gt
- Compiled into servlets at run-time
- Various conveniences inserted automatically
- Answer to Microsoft ASP (with add-ons)
22JSP Smalltalk Equivalents
- VisualWorks 5i.4 Web Toolkit
- Tsunami (custom tags only)
- Various templating schemes
- Squeak SSP (but html in browser)
- VisualAge VisualWave file templating
- WikiWorks
- Others?
23JSP Servlets
- Together make up a reasonable web presentation
layer if used well. - Servlets for input processing
- JSPs for presentation
24EJB
- Enterprise Java Beans
- Very large and complex topic
- Not well understood
- In flux (1.1 widely implemented, 2.0 still quite
new) - Strongly-hyped
- Fractal (the superficial complexity conceals the
underlying complexity)
25About EJB
- History
- Server-Side component model
- Attempt at a Java answer to MTS
- Objectives
- Server-side component model
- Portable beans
- Easy for typical developers
- Scalability
- Automatic distributed transactions
26EJB Basics
- Beans server-side, remote, RMI semantics
- No relation to JavaBeans
- Roles author, deployer, user
- Several types
- Session services (instances not shared)
- Entity domain objects (instances are shared)
- Very web-focused
27Session Bean Types
- Stateless
- only lives for the duration of one method call
- very scalable
- like MTS, Tuxedo, CICS (sort of)
- Stateful
- Explicitly created and destroyed
- Maintain transient state
28Entity Beans
- Shared
- identity provided by primary key class
- Persistent (relational assumed)
- Container-Managed Persistence (CMP)
- Bean-Managed Persistence (BMP)
29Beans are Distributed Objects
- RMI Semantics
- Non-beans always passed by value
- Beans always passed by reference
- Users never see the bean
- EJBObject acts as a stand-in
- Related beans can see either the remote or local
(but only one - no polymorphism)
30Conceptual View
31Generated Classes
EJB and Domain
RMI
Account
bean-developer defined domain class
AccountBeanEOImpl_Stub
bean developer definedremote interface,
container generated remote implementation
AccountPK
AccountBeanEOImpl_Skel
bean-developer defined serializable primary key
AccountHome
AccountBeanHomeImpl_Stub
AccountBeanHomeImpl_Skel
bean developer definedhome interface, container
generated home implementation
server-generated RMI stubs and skeletons
32Deployment
- Adds remote wrappers, generates all the
additional classes - Declaratively specify
- transactions (participates, requires, requires
new, none) - security (who can invoke this method)
- lots and lots and lots of other stuff
- typically multiple deployment descriptors, much
larger than the bean class.
33EJB Issues
34EJB Issues
- Overall Complexity (current spec 500 pgs)
- 18 pages on Assignment Relationships
- Component Models
- Development Process
- Threading and Concurrency
- Performance and Scalability
- Usage Patterns
- Persistence
35Component Models
- Widget-like
- java beans, visualage parts, COM
- stand alone, re-use in many contexts
- strong author/user distinction
- coupling via events
- no visible inheritance/polymorphism only to the
general widget interface - reflection-based exensibility, visual
manipulation - e.g. widgets
36Component Models (contd)
- Service-like
- session beans, COM/MTS
- stand alone, re-use in many contexts
- strong author/user distinction
- very little coupling
- no visible inheritance/polymorphism only to the
general component interface - reflection based or no extensibility
- e.g. legacy system wrapper, complex i/o library
37Components vs.Domain Objects
- Domain Objects
- strong relationships with complex interactions
- difficult to re-use despite decades of research
- weak author/user distinction
- heavy use of inheritance and polymorphism
- e.g. most business objects
38Component Semantics
- No inheritance
- Entity relationships
- undefined in ejb 1.0
- strongly specified in ejb 2.0
- container-maintained
- specified in the deployment descriptor
- remote or local
- heavyweight (sometimes very)
39Development Process
- Concerns
- Very heavy on code generation
- Beans cannot run outside container
- Turnaround time for changes
- Testability
- Debuggability
40Development Process (contd)
- Suggests
- fine-grained (non-bean) business objects
- test and run outside of container
- very thin session bean wrappers
- no entity beans
- advantage vs. direct business objects?
41Development and Deployment
- Deployment is very complex
- especially in ejb 2.0, more complex than
development - CASE tools required
- targets component assembly
- up-front design/build re-usable components
- later application assembly phase
42Threads
- No need to worry about threads, transactions, or
security - Thread Isolation
- at most one call to a bean instance at a time
- Therefore only two concurrency options
- pessimistic in-memory locking
- per-user copies of the bean
43Threading and copies
- One call at a time
- distributed calls, no distinct process stack, so
loopback calls are prohibited (recursion,
double dispatch, etc.) - Beans can be marked re-entrant, but thisi s
strongly discouraged - Pessimistic locking bottlenecks too easily
- Per-user copies use a lot of space
- must copy even on read
44Persistence
- Session beans
- serializable for timeout/clustering purposes
- database persistence left to the user
- Entity beans
- Bean-Managed Persistence
- Container-Managed Persistence
- A wide variety of issues
- Actively hostile to OODBs
45Performance and Scalability
- Scalability usually costs performance
- e.g. stateless components
- Scalability-related features
- distributed transactions (100x normal)
- all calls distributed
- instance pooling passivation
- maximum numbers of instances
- thread pooling
- database connection pooling
46Clustering
- Scalability to multiple servers
- global locking issues for entity beans
- server cross-communication issues
- can force transactions to be distributed
- complicates some issues (e.g. write order)
47Overall Usage
- Entity beans essentially unusable
- performance
- development
- 2.0 probably worse than 1.0
- semantics
- Sesssion beans as thin layer quite workable
- Typically Servlet/JSP-gtSession Bean -gt domain
objects - Doesnt add a lot vs. Servlet-gtdomain objects
48EJB Smalltalk Equivalents
- None
- Declarative transactions, security interesting
- Automated failover for sessions interesting
49J2EE in Smalltalk Terms
- Depends on view of component assembly
- Servlets, Server Pages useful
- EJB for domain not useful
- Session beans -gt some extra infrastructure
- Supporting technologies portable LDAP useful
50Battle of the Acronyms RevisitedWe want to
build our architecture around browser-based Java
clients talking to a scalable cluster of
JTS-enabled BMP EJBs
51Right Response
- Have we actually measured the gain from
clustering vs. the RPC overhead on fine-grained
entity EJBs. That also implies transaction
control at the client or else many fine-grained
JTS transactions. Since were standardized on
Oracle, the only reason we need the JTS overhead
is in fact because of the cluster. Plus the
development overhead is going to frustrate any
attempts at an XP process, or even unit-testing
without major turnaround times. Do we have
estimates on the impact of deployment costs on
the development cycle?
52The End
53Extra Slides
54Homes and Finders
- Used to create, destroy and lookup beans
- Registered with JNDI
- Finders
- Entity Bean Queries
- Defined as methods on the home interface
- Static
- EJB 1.0 no definition
- EJB 2.0 EJBQL query language
55Persistence
- Strong assumption of relational
- actively hostile to OODBs
- Sessions beans not shared or persistent
- may use persistent domain objects or entity beans
- Entity Beans
- BMP
- CMP
56Bean-managed
- complete control, but only per-bean
- conventional wisdom prefers
- inefficient on read-many
- no control over write order
- assumes write-through/no sequence numbers
- impose a lot of limits on what a good framework
can do
57CMP 1.0
- Very limited
- only simple types
- one bean per table
- relationships undefined
- vendor-specific enhancements available
- queries undefined
- no control over caching or locking
58CMP 2.0
- invents new query language
- no dynamic querying
- no intetgration with cache, locking
- adds local beans with relationships
- breaks normal programming language semantics
- assumption of write-through
59Primary Keys
- Entity beans have Primary Key classes
- For simple keys, can be primitives
- For composite keys, a class whose inst vars
mirror the key inst vars of the bean
60Activate/Passivate
- Maximum number of instances at a time
- Surplus or not recently used instances are
passivated - serialize or equivalent to persistent storage
- re-use memory
612.0 notes
- Relationships can be local now
- local not polymorphic with remote
- permissions not checked
- so beans can be essentially local objects. Where
does the cmp intercept come in? - the code-generation crap is in there
- may or may not have local interfaces
- there are dependent values
- is the relationship fixup in there? yes
- Dependent objects always serialized. Always
- removing an object must remove it from all
relationships - they still have to track any attempt to send a
message to a removed object - 10.3.4.1 implies 2 refs to 1 object but 10.3.6
sounds like must still null out. Looks to me like
must null out ONLY if its the same kind of
relationship in another instance. - What does relationship type mean? (ejb-relation
and ejb-relationship-role) - ah. Only affect 1-1 and 1-many. Theyre literally
enforced. See 10.3.71