Javelin: the JDJ 'World Class Award' winning, leader in visual, model driven Java development since 1996!
try it FREE for 15 days and realize the benefits and efficiencies of managing a POJO based domain model via live class diagrams instead of a plethura of text files.
exPOJO: feedback, contributions, questions, suggestions:
|expose your POJOs!|
Version 2.0.1 just released!
exPOJO is a framework that allows you to 'expose your POJOs' via the Exposed Domain Model pattern. The key classes in the framework are described on this page. The tutorial takes you step by step through the process of the exPOJOnization of your application.
The ModelExposer class defines the central, per session or per thread or per application, 'model exposing' object that makes available the service and repository objects that your application requires (see below for more details on services and repositories). It is not necessary to override this class in your applications. In a J2SE or J2EE environment an instance of the ModelExposer class is automatically instantiated for you during the creation of a user session via the exPOJO servlet filter. At the start of each request the session's ModelExposer is automatically associated with the current thread and thus available via the static method ModelExposer.get(). After processing each request the ModelExposer is detached from the thread. Virtually all persistence facilities required by your application are automatically encapsulated within the ModelExposer object and its services and repositories.
There you go - dependency injection to enable your favorite persistence technology was never so easy - and all without a brain sapping sea of XML declaration files or code uglifying annotations.
The superclass for all repository classes. Override this to define your own repository class(es). These will be added to the ModelExposer and thus accessible from anywhere.
The superclass for all service classes. Override this to define your own service class(es). These will be added to the ModelExposer and thus accessible from anywhere.
While exPOJO can be used for web apps and non web apps alike two web app specific classes are provided to make building J2SE/J2EE/Servlet contain web applications a breeze.
ExpojoServletContextListener is responsible for establishing your web app environment at start up. As the name suggests it implements ServletContextListener and is called during application startup and shutdown by the servlet container according to one simple setting added to your WEB-INF/web.xml file. Typically this class will be responsible for creating any objects that need to be constructed the very first time your application is run.
ExpojoServletFilter is the 'hook' by which every HTTP request thread is automatically 'wrapped' in the context of a ModelExposer associated with the current session. The ModelExposer is automatically attached to the thread servicing the HTTP request upon receiving the request and automatically detached from the thread on returning from servicing the request. In other words the ModelExposer is reused for all requests associated with the same session supporting a "Open Persistence Manager In View" (JDO) and "Open Session In View" (Hibernate) persistence strategy.
an available constructing ModelExposer objects as required. Your application must contain a class that extends *ModelExposerFactory and overrides the addComponents method. This method is called whenever a new ModelExposer is instantiated and it is responsible for adding any required repository and service components to the ModelExposer that are required by your application.
You must also override the createPersistenceProviderFactory method to create the persistence provider factory appropriate to your persistence engine - see below.
The PersistenceProvider superclass abstracts the behaviour of persistence providers to provide a generic interface to persistence functionality regardless of the persistence technology used (JDO, Hibernate or in the future perhaps JPA). Specialized PersistenceProvider derived classes implement the persistence of vendor specific persistence provider classes: a Session in Hibernate Session and a PersistenceManager in JDO. A ModelExposer holds a reference to its own PersistenceProvider that it obtains from the PersistenceProviderFactory at initialization. Model objects rarely need to access the PersistenceProvider directly but Repository classes need it to perform persistence technology specific queries. Service classes will require access to it on rare occasions.
You don't normally need to derive from or instantiate a PersistenceProvider. Its use is mainly transparent.
The PersistenceProviderFactory class has been overridden in the exPOJO framework to implement factories that create PersistenceProviders for the various technologies. You will rarely need to change these. You will, however, need to instantiate the appropriate factory by overriding ExpojoServletContextListener.createPersistenceProviderFactory.
exPOJO currently has working factories for:
exPOJO can easily be enhanced to support other persistence technologies as they evolve.