net.databinder.hib
Class DataApplication

java.lang.Object
  extended by org.apache.wicket.Application
      extended by org.apache.wicket.protocol.http.WebApplication
          extended by net.databinder.DataApplicationBase
              extended by net.databinder.hib.DataApplication
All Implemented Interfaces:
HibernateApplication
Direct Known Subclasses:
AuthDataApplication

public abstract class DataApplication
extends DataApplicationBase
implements HibernateApplication

Optional Databinder base Application class for configuration and session management. Supports multiple session factories with key objects.

Author:
Nathan Hamblen

Nested Class Summary
static class DataApplication.BmarkDataBrowser
          Bookmarkable subclass of DataBrowser page.
 
Field Summary
 
Fields inherited from class org.apache.wicket.Application
CONFIGURATION, CONTEXTPATH, DEPLOYMENT, DEVELOPMENT
 
Constructor Summary
DataApplication()
           
 
Method Summary
 void buildHibernateSessionFactory(java.lang.Object key)
          Called by init to create Hibernate session factory and load a configuration.
 void buildHibernateSessionFactory(java.lang.Object key, org.hibernate.cfg.AnnotationConfiguration config)
          Builds and a session factory with the given configuration.
protected  void configureHibernate(org.hibernate.cfg.AnnotationConfiguration config)
          Configures the default session factory; override to add annotated classes but don't forget to call this super-implementation if you want its defaults.
protected  void configureHibernate(org.hibernate.cfg.AnnotationConfiguration config, java.lang.Object key)
          Configures the session factory associated with the key.
protected  void configureHibernateEssentials(org.hibernate.cfg.AnnotationConfiguration config)
          For Hibernate settings that should not normally be overriden by client applications.
protected  void dataInit()
          Initializes a default Hibernate session factory and mounts a page for the data browser.
 org.hibernate.SessionFactory getHibernateSessionFactory(java.lang.Object key)
          Supply the session factory for the given key.
protected  boolean isDataBrowserAllowed()
          Returns true if development mode is enabled.
protected  void mountDataBrowser()
          Mounts Data Diver to /dbrowse.
 org.apache.wicket.RequestCycle newRequestCycle(org.apache.wicket.Request request, org.apache.wicket.Response response)
           
protected  void setHibernateSessionFactory(java.lang.Object key, org.hibernate.SessionFactory sf)
           
 
Methods inherited from class net.databinder.DataApplicationBase
internalInit, isCookielessSupported, isDevelopment, newConverterLocator, newWebResponse, setCookielessSupported
 
Methods inherited from class org.apache.wicket.protocol.http.WebApplication
getApplicationKey, getConfigurationType, getDefaultRequestCycleFactory, getInitParameter, getRequestCycleProcessor, getResourceFinder, getServletContext, getSessionAttributePrefix, getWicketFilter, init, internalDestroy, logEventTarget, logResponseTarget, mount, mount, mountBookmarkablePage, mountBookmarkablePage, mountSharedResource, newAjaxRequestTarget, newRequestCycleProcessor, newSession, newSession, newSession, newSessionStore, newWebRequest, outputDevelopmentModeWarning, sessionDestroyed, setApplicationKey, setWicketFilter, unmount
 
Methods inherited from class org.apache.wicket.Application
addComponentInstantiationListener, addComponentOnAfterRenderListener, addComponentOnBeforeRenderListener, addRenderHeadListener, configure, destroy, exists, get, get, getApplicationKeys, getApplicationSettings, getConverterLocator, getDebugSettings, getExceptionSettings, getFrameworkSettings, getHomePage, getMarkupCache, getMarkupSettings, getMetaData, getName, getPageSettings, getRequestCycleFactory, getRequestCycleSettings, getRequestLogger, getRequestLoggerSettings, getResourceSettings, getSecuritySettings, getSessionFactory, getSessionSettings, getSessionStore, getSharedResources, initializeComponents, newRequestCycle, newRequestLogger, notifyRenderHeadListener, onDestroy, removeComponentInstantiationListener, removeComponentOnAfterRenderListener, removeComponentOnBeforeRenderListener, removeRenderHeadListener, set, setMetaData, unset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataApplication

public DataApplication()
Method Detail

dataInit

protected void dataInit()
Initializes a default Hibernate session factory and mounts a page for the data browser. This is called automatically during start-up. Applications with one session factory will not normally need to override this method; see related methods to override specific tasks.

Specified by:
dataInit in class DataApplicationBase
See Also:
aoe, mountDataBrowser()

mountDataBrowser

protected void mountDataBrowser()
Mounts Data Diver to /dbrowse. Override to mount elsewhere, or not mount at all. This method is only called if isDataBrowserAllowed() returns true in init().


buildHibernateSessionFactory

public void buildHibernateSessionFactory(java.lang.Object key)
Called by init to create Hibernate session factory and load a configuration. Passes an empty new AnnotationConfiguration to buildHibernateSessionFactory(key, config) by default. Override if creating a configuration externally.

Parameters:
key - session factory key; the default key is null

buildHibernateSessionFactory

public final void buildHibernateSessionFactory(java.lang.Object key,
                                               org.hibernate.cfg.AnnotationConfiguration config)
Builds and a session factory with the given configuration. Passes config through configureHibernate methods.

Parameters:
key - session factory key; the default key is null
config - annotation conifuration
See Also:
configureHibernateEssentials(AnnotationConfiguration), configureHibernate(AnnotationConfiguration, Object)

configureHibernate

protected void configureHibernate(org.hibernate.cfg.AnnotationConfiguration config,
                                  java.lang.Object key)
Configures the session factory associated with the key. The default implementation calls the configureHibernate(config) method and ignores the key. For applications with multiple session factories, override this method to perform key-specific configuration here instead.

Parameters:
config - configuration to update
key - object, or null for the default factory

configureHibernateEssentials

protected void configureHibernateEssentials(org.hibernate.cfg.AnnotationConfiguration config)
For Hibernate settings that should not normally be overriden by client applications. Specifically, this method sets Hibernate for a ManagedSessionContext, the session lookup method used by DataRequestCycle.

Parameters:
config - Hibernate configuration

configureHibernate

protected void configureHibernate(org.hibernate.cfg.AnnotationConfiguration config)
Configures the default session factory; override to add annotated classes but don't forget to call this super-implementation if you want its defaults. When running in development the session factory is set for hbm2ddl auto-updating to create and add columns to tables as required. For deployment it is configured for C3P0 connection pooling.

Parameters:
config - used to build Hibernate session factory

getHibernateSessionFactory

public org.hibernate.SessionFactory getHibernateSessionFactory(java.lang.Object key)
Description copied from interface: HibernateApplication
Supply the session factory for the given key. Applications needing only one session factory may return it without inspecting the key parameter.

Specified by:
getHibernateSessionFactory in interface HibernateApplication
Parameters:
key - object, or null for the default factory
Returns:
the retained session factory

setHibernateSessionFactory

protected void setHibernateSessionFactory(java.lang.Object key,
                                          org.hibernate.SessionFactory sf)
Parameters:
key - object, or null for the default factory
sf - session factory to retain

newRequestCycle

public org.apache.wicket.RequestCycle newRequestCycle(org.apache.wicket.Request request,
                                                      org.apache.wicket.Response response)
Overrides:
newRequestCycle in class DataApplicationBase
Returns:
a DataRequestCycle
See Also:
DataRequestCycle

isDataBrowserAllowed

protected boolean isDataBrowserAllowed()
Returns true if development mode is enabled. Override for other behavior.

Returns:
true if the Data Browser page should be enabled


Copyright © 2005-2008 Nathan Hamblen. All Rights Reserved.