Welcome Guest  |  Register  |  Login
Login Name Password
  Search  
  Index  | Recent Threads  | Unanswered Threads  | Who's Online  | Help


Quick Go »

No member browsing this thread
Thread Status: Active
Total posts in this thread: 2
[ Jump to Last Post ]
Post new Thread
Author
Previous Thread This topic has been viewed 3952 times and has 1 reply Next Thread
Male chrisco
Expert
Member's Avatar

Australia
Joined: Nov 24, 2005
Post Count: 706
Status: Offline
Reply to this Post  Reply with Quote 
exPOJO supports exposed model pattern via JPOX

I've just released an open source, light weight, low jar dependency but nonetheless very useful framework for implementing the "Open PersistenceManager in View" and "Exposed Domain Model" patterns discussed in Chris Richardson's excellent books: "POJOs in ACTION".

A brief description follows or you can go to the site at http://expojo.com

There's nothing quite like an exposed model!
We're not talking about a super model wardrobe malfunction here. We talking about something even more sexy than that - a fully exposed domain object model!

exPOJO encapsulates most of what you need to create a ModelExposer that provides access to the service and repository classes that expose your POJO based model. The excellent transparent persistence provided by JPOX means that your POJOs can remain pure POJOs. Using the 'exposed domain model' pattern the need for separate DAOs to be developed, tested and maintained evapourates, slashing development and testing times and improving runtime performance.

The exPOJO framework provides persistence engine specific implementations of persistence via an abstracted PersistenceProvider class. Your POJOs are accessed and modified via service and repository classes that are responsible for all interactions with the database, keeping your POJOs nice a pure.

Currently exPOJO supports JDO (JPOX & Kodo) and Mock PersistenceProviderS. When appropriate a JPA PersistenceProvider could be implemented with little effort.

Testing using the MockPersistenceProvider

Because the service and repository classes interface to the generic persistence provider interface the PersistenceProviders are completely interchangeable: you can do most of your development and testing using a MockPersistenceProvider which allows testing of your model object's operation without the overhead of writing to a database and creating/updating a schema. When you are sure your domain model object and the business logic they implement are correct you can plug in the JdoPersistenceProvider and start testing your application with a real datastore.

Open PersistenceManager in View
In J2EE environment the popular persistence strategy is to hold a PM open per user session or view. This enables the objects in the PM cache to be kept around longer instead of throwing them away after each request has been serviced.

Open PersistenceManager in View is great but how do your objects access the PM without storing a direct reference and without using the outlawed singleton? The classic dependency injection problem. The exPOJO ModelExposer class makes itself available when a servlet request is in progess by association with the thread.

A couple of lines of code in your service method is all that is required to provide an association between your objects and the PM they are associated with. This is dependecny injection without the overhead or learning curve or jar dependency issues of complex frameworks like swing and others.

All that is required is to hook into your servlet's service method, which you probably already do with the following code:

public void service(ServletRequest req, ServletResponse res)
{
// obtain model exposer from session
....

// associate this thread with the model exposer
modelExposer.attachThread();

// Handle the HTTP request
super.service(req, res);

// dissassociate this thread from the model exposer
modelExposer.detachThread();
}

Within the context of the UI code executing to service the HTTP request you can simply user ModelExposer.get() to obtain a reference to the appropriate modelExposer - which in turn can provide references to service and repository objects. Repository objects provide methods that return a single domain object or a collection of objects matching a query criteria. Once you have an object you can navigate using the normal '.' operator and JPOX will lazy fetch related objects on demand.
----------------------------------------
Chris Colman
http://visualclassworks.com
Javelin: Visual modeling & coding with automatic JDO 2/DataNucleus meta data generation.
http://expojo.com
expojo: Simple dependency injection and exposed POJO domain model pattern
[Jan 16, 2007 1:06:14 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Male chrisco
Expert
Member's Avatar

Australia
Joined: Nov 24, 2005
Post Count: 706
Status: Offline
Reply to this Post  Reply with Quote 
exPOJO supports "exposed POJO model pattern" via JPOX


A brief description follows or you can go to the site at http://expojo.com


Version 1.3 of exPOJO has recently been released with much improved, automatic dependency injection. Simply set up the ExpojoServletFilter and your application objects have easy access to the ModelExposer and thus all the repositories and services you associate with that ModelExposer.

With version 1.3 you no longer need to extend ModelExposer to use exPOJO. You merely add your repositories and services via a single overridden method of your servlet context listener and voila: no beans, no XML bean configuration, no waiting till runtime to detect errors in your 'plumbing'. Your persistence infrastructure is configured with just a couple of lines of Java code.

exPOJO 1.3's use of the new ExpojoServletFilter means that you no longer need to add any code to your extended UI framework's servlet to facilitate dependency injection so exPOJO can now work 'right out of the box' with any UI framework.

If you want to take advantage of the transparent persistence of POJOs provided by excellent ORMs like JPOX then you should seriously consider a 15 minute test drive of exPOJO and the exposed POJO model pattern. exPOJO is a light weight, bean free, XML free, dependency injection framework that has an extremely small footprint and simple learning curve.

exPOJO also provides a persistence engine abstraction layer so that you can easily change your persistence engine without rewriting your application. It's perfect for those wanting to compare how their app performs under a variety of different persistence engines: for example your boss may want you to use a slower reflection/proxy based ORM like Hibernate for no good technical reason but you understand the performance benefits offered by a byte code enhancement based ORM like JPOX and want to compare how your app performs under both engines. exPOJO is your perfect, light weight wrapper to achieve that goal. Instead of locking your app into a Hibernate only solution you leave it open to be powered by any transparent persistence engine - those available now and those that become available in the future.

It could change the way you look at web app development forever and massively increase your productivity over heavy weight alternatives like EJB, Spring, Bean and DTOs or combinations thereof.
----------------------------------------
Chris Colman
http://visualclassworks.com
Javelin: Visual modeling & coding with automatic JDO 2/DataNucleus meta data generation.
http://expojo.com
expojo: Simple dependency injection and exposed POJO domain model pattern
[Sep 27, 2007 7:42:58 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
[ Jump to Last Post ]
Show Printable Version of Thread  Post new Thread