org.granite.gravity
Class GravityManager

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

public class GravityManager
extends Object

Author:
Franck WOLFF

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, ChannelFactory channelFactory)
          Parse gravity configuration (granite-config.xml), start gravity by using the specified factory and put it in ServletContext.
 
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,
                            ChannelFactory channelFactory)
                     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.
channelFactory - an implementation specific ChannelFactory instance.
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.)

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, ChannelFactory) has never been called).