org.granite.gravity
Class GravityManager

java.lang.Object
  extended by org.granite.gravity.GravityManager

public class GravityManager
extends Object

Author:
Franck WOLFF

Nested Class Summary
static interface GravityManager.GravityServiceConfigurator
           
 
Constructor Summary
GravityManager()
           
 
Method Summary
static Gravity getGravity(ServletContext context)
          Returns a previously started Gravity instance.
static void reconfigure(ServletContext context, GravityConfig gravityConfig)
          Reconfigure gravity with the new supplied configuration (after reloading granite-config.xml).
static Gravity start(ServletConfig servletConfig)
          Parse gravity configuration (granite-config.xml), start gravity by using the specified factory and put it in ServletContext.
static Gravity start(ServletContext context)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GravityManager

public GravityManager()
Method Detail

start

public static Gravity start(ServletConfig servletConfig)
                     throws ServletException
Parse gravity configuration (granite-config.xml), start gravity by using the specified factory and put it in ServletContext. If Gravity is already started, returns the previous instance from the servlet context.

This method is intended to be used in GenericServlet.init(ServletConfig) methods only and synchronizes on the current ServletContext instance.

Parameters:
servletConfig - the servlet config passed in HttpServlet.init(ServletConfig config) method.
Returns:
a newly created and started Gravity instance or previously started one.
Throws:
ServletException - if something goes wrong (GravityFactory not found, Gravity.start() error, etc.)

start

public static Gravity start(ServletContext context)
                     throws ServletException
Throws:
ServletException

reconfigure

public static void reconfigure(ServletContext context,
                               GravityConfig gravityConfig)
Reconfigure gravity with the new supplied configuration (after reloading granite-config.xml).

Only these configuration options are taken into account when reconfiguring Gravity:

Parameters:
context - the ServletContext where the gravity instance is registered.
gravityConfig - the new (reloaded) GravityConfig.

getGravity

public static Gravity getGravity(ServletContext context)
Returns a previously started Gravity instance. This method isn't synchronized and should be used in HttpServlet.doPost(...) methods only.

Parameters:
context - the ServletContext from which to retrieve the Gravity instance.
Returns:
the unique and started Gravity instance (or null if start(ServletConfig) has never been called).