Java Management Extensions one of the first JSRs and now included in to JDK 5. Monitors health of the system. Alter sys-admin of error conditions. Provides capability of to view and modify runtime parameters.
MBeans are deployed in an MBeanServer and their capabilities are exposed through Connectors. Then tools talk to these connectors to get their information.
JMX is covered by two separate specifications: JSR-3 (MBeans) and JSR-160 (Connectors). BTW, Chris has some good slide-making capabilities - I'll have to get some tips from him for my next preso. For example, he shows an entire class and its methods, then he fades it and zooms in on certain methods and highlights them to explain what they do.
Four types of MBeans: Standard MBeans, Dynamic MBeans, Model MBeans and Open MBeans. More info on these Mbeans can be found at http://docs.sun.com.
Standard MBean: All you need to do create an interface for your class your class name with "MBean" appended to it.
In order to deploy, you need to create and configure an
You can create an MBeanServer using
MBeanServers keep track of MBeans
After creating and configuring an MBeanServer, you simply need to
register your MBean using an Agent. All pretty simple so far, right? Now you have to use a Connector
to expose your MBean to the outside world.
"Connectors are the fly in the ointment." MX4J is an open source project that has good Connectors: i.e. RMIAdaptor and HTTPAdaptor. There's also SNMP Adapters from a number of commercial vendors. In order to solve the current lack of good Connectors we have JSR-160: Distributed Services Specification. This JSR defines one connector: JMXConnector (part of JDK 5).
Chris is now showing us a counter widget deployed as a Swing app and managed using MX4J's web interfaces. Very cool stuff - the ability manipulate runtime parameters. As Chris stated - the real power of JMX will come from the tools. I wonder if there's MBeans available for monitoring webapps - seems like there'd be quite a market for management beans you could just drop in and deploy.
Chris gave a good introduction to JMX, but I don't see myself using it anytime soon. It seems to be something that framework and container developers might use, but not many application developers. Maybe I'm wrong - are you deploying MBeans as part of your web applications? Chris mentioned that Hibernate and Spring have MBeans as part of their distribution - anyone using these? If nothing else, it's great to know that JMX is available if I ever do need to monitor and control applications.
Now Dion's up after a 1/2 hour break with announcements. Dion is talking about JDO 2.0. I think JDO would be a lot more popular if it wasn't for Hibernate. Hibernate seems to have done JDO better and faster.
What is JDO?
- Allows for object persistence
- "I have objects, some need to be persisted"
- "Keep state and behavior together. That is the OO way."
JDO Main Objectives:
- To enable pluggable implemenentations of data stores into application servers
- To provide applicaiton programmers a Java-centric view of persistent information, including enterprise data and locally stored data.
- Transparent Persistence
- OO framework on top of potentially non-OO stores.
- RDBMS (98% of the time)
- TP Monitors
- Integrate with existing technologies
- Java compatible - no need to learn new language
- Usable in managed and non-managed environments
- Define easy semantics for caching objects
- Ability to run in all Java platforms (J2SE, J2EE, J2ME)
When JDO first started, a bad thing happened - the object database guys were heavily involved. JDO 1.0 had 80% of its Expert Group from object database vendors. JDO 2.0 got object guys off the committee and real-world (relational) folks onto it.
JDO 1.0: Most of it is not very new - just a standard way of implementing persistence. Other proprietary tools already accomplish most of what JDO is.
JDO 2.0 Strategic Goals:
- Easy to Use
- natural programming model
- configuration and deployment
- In a Wide Variety of Environments
- J2SE (rich clients)
- application, web servers
JDO 2 Status: First Early Draft Review is out there. Soon there's going to be a Community Review - then things
will start rolling after that.
JDO 2.0 Goals:
- Maintain JDO 1.0 Compatibility (big thing with Sun)
- Standardize Mapping to Relational DB (was vendor extension in 1.0)
- Multi-tier Development Improvements
- Usability Improvement
- Better Object Modelling
- Richer Queries - JDOQL, SQL and Named Queries
- More Vendor Support - try to get Hibernate and Oracle on the bandwagon for political reasons
Dion's take on politics between EJB 3 and JDO 2
- Let's get a standard around transpanent persistence first
- Let's have a standard that can be shared between various groups: J2EE, J2SE, J2ME
- Why have more than one O/R mapping specification?
- Specifications such as EJB could be an umbrella spec for the cross cutting concerns
Why are people even arguing about it? Money. Because companies have invested a lot of time
and money into X technology and therefore they bash the other. This problem might be solved
by an O/R Mapping JSR that both EJB and JDO have to adhere to.
JDBC vs. JDO
|Explicit intrusive code||Fully transparent|
|Manual mapping||Automatic mapping (automatic == create XML file)|
JDO will use all J2EE services inside a container.
Deployment time scalability - database becomes bottleneck as number of users increases. JDO middle tier can relieve this load on the databse. JDO's configuration can be altered at deploy time to handle better scalability through caching.
JDO 2.0 Multi-tier Development - big thing is disconnected objects through attach/detach. Very simple API for detaching and re-attaching objects. Internally there's a version that's used to determine if the object is the same one.
JDO and EJB
As opposed to Entity bean, JDO instances...
- May have subclasses
- May exist outside a container
- Has 1 optional interface to implement
- Accessible as transient objects
And as of JDO 2 (new and improved object modeling!)
- Persistent Abstract Class Support
- map abstract classes to tables
- map properties, fields to columns
- create new implementation instances
- Persistence Interface Support
- map interfaces to tables
- map properties to columns
- more, but I missed them
Some argue that JDO is what Entity Beans should have been!
- JDO is "purer" way to use OO
- Since Entities should be used via local interfaces, why not just do Session Facade -> JDO objects
- CMP in Sun AppServer uses JDO
Some argue that JDO complements Entity Beans because Entity beans can use JDO.
EJB3 is totally moving directorys with regards to Entity Beans, and they are much more like JDO.
EJB3 EntityManager == JDO PersistenceManager == Hibernate Session
JDO and Connector Architecture - JDO is NOT a framework, but plays well with others!
The JDO architecture uses the J2EE Connector architecture for application servers. The JDO PersistenceManager is a caching manager as defined by the J2EE Connector architecture.
A PersistenceManager may define the following Connector components:
Persistence Contract (behind the scenes)
- To achieve transparence, JDO:
- Defines a
- Used too mandate binary compatibility among all vendors (optional in JDO 2)
- Uses tools to make a class persistence capable
- Declares any fields available for persistence storeage
- Defines methods that allow JDO instance management
JDO has a number of callbacks that you can implement: jdoPostLoad(), jdoPreStore(), jdoPreClear(), jdoPreDelete().
In JDO 1: one interface: InstanceCallbacks
In JDO 2: InstanceCallbacks purely extend interfaces: LoadCallback, StoreCallback, etc.
Ways to make classes persistence capable: byte code enhancement, annotations (maybe for JDO 2.1).
JDO Interfaces: PersistenceManagerFactory, PersistenceManager, Transaction (new set/getRollbackOnly() in JDO 2) and JDOHelper (class with static methods, for use by persistence-aware classes), Query, Extent. You'll probably never use an Extent; like "select * from table". Represents all instances of a class or subclasses.
A persistence cabable class is just a POJO - you could use the same class for JDO and/or Hibernate. A default contructor is required in JDO 1, but not in 2.
JDO 2.0 has "use cases" for lazy-loading. This enables you to configure fetching based on certain situations. Sounds pretty cool.
Extent is usually optimized for better performance. If you're selecting all records from a table, you're probably better of using Extent vs. Query in order to avoid OutOfMemory errors.
New in JDO 2: ability to specify query filters in other languages - i.e. SQL or HQL or user-defined. These languages are up to the JDO vendor to implement.
JDO can use stored procedures if you map it in your metadata.
JDO 2.0's Query API looks very rich. It allows you to limit your results to certain properties/columns, as well as set what type of to return.
JDO 2.0 supports obtaining a java.sql.Connection from PersistenceManager. However, this may reduce portability since not all SQL is portable b/w databases.
Overall, I thought this was a great talk by Dion. If you're looking to start working with JDO 2.0, I'd recommend JPOX (also see JPOX with Spring or Tapestry). Unfortunately, their implementation still requires you to "enhance" your classes at build-time, but hopefully they'll have a transparent mechanism for manipulation (i.e. cglib) soon.