pulse - the web application framework Get pulse at SourceForge.net. Fast, secure and Free Open Source software downloads Ohloh project report for pulse-java

org.torweg.pulse.invocation.lifecycle
Class Lifecycle

java.lang.Object
  extended by org.torweg.pulse.invocation.lifecycle.Lifecycle

public final class Lifecycle
extends java.lang.Object

initialises all bundles and manages the life-cycle of reloadable components.

The Lifecycle singleton initialises all bundles of the pulse container and the config pool. If the container is configured for reloading the Lifecycle singleton watches registered resources for changes and restarts the affected sub-systems on demand.

Moreover it globally initialises the HibernateDataSource, all Bundles and their resources as well as the ContentRegistry and Sitemap.

The Lifecycle sets up a global JAXB context, registers the IP2CountryProvider and sets up the MailQueue as well as the VirtualFileSystem.

Version:
$Revision: 1932 $
Author:
Thomas Weber, Christian Schatt
See Also:
PoorMansCache, Bundle, HibernateDataSource, ContentRegistry

Method Summary
protected static java.util.Collection<java.util.Locale> convertLocaleList(java.util.Collection<Locale> collection, boolean onlyActive)
          converts the given list of org.torweg.pulse.service.request.Locale to a list of java.util.Locale.
static java.util.Collection<java.util.Locale> getActiveLocales()
          returns a list of all active {@link Locale}s.
static AttributeFactory getAttributeFactory()
          returns the AttributeFactory.
static java.io.File getBasePath()
          returns the containers root directory.
static Bundle getBundle(java.lang.String name)
          get the Bundle with the specified name.
static java.util.Collection<Bundle> getBundles()
           
protected  java.util.concurrent.ConcurrentHashMap<java.lang.String,Bundle> getBundlesDirectly()
          used by LifecycleHibernateTasks.
protected  java.io.File getBundlesRootDir()
           
static ICaptchaAdapter<?> getCaptchaAdapter()
          Returns the (configured) ICaptchaAdapter.
protected  java.util.Set<Component> getComponentsDirectly()
          used by some Lifecycle tasks.
static int getDefaultPort()
          returns the port to be used for standard HTTP connections.
static org.apache.fop.apps.FopFactory getFopFactory()
          Returns the Lifecycles' (configured) FopFactory -instance.
static IGeoLocationProvider getGeoLocationProvider()
          returns the IGeoLocationProvider.
static HibernateDataSource getHibernateDataSource()
          Returns the HibernateDataSource.
protected  HibernateDataSourceImpl getHibernateDatasourceDirectly()
          used by LifecycleHibernateTasks.
static Lifecycle getInstance()
          Deprecated. 
static javax.xml.bind.JAXBContext getJAXBContext()
           
static com.sun.jersey.api.json.JSONJAXBContext getJSONJAXBContext()
           
static java.util.Collection<java.util.Locale> getKnownLocales()
          returns a list of all known {@link Locale}s.
protected  java.util.Collection<Locale> getLocalesDirectly()
          used by some Lifecycle tasks.
static MailQueue getMailQueue()
          returns the MailQueue.
protected  MailQueue getMailQueueDirectly()
          used by LifecycleMailQueueTasks.
protected  ServletConfig getPulseConfiguration()
          gives internal access to the pulse configuration.
protected  java.io.File getPulseRootDir()
          used by some Lifecycle tasks.
static java.util.Random getRandom()
          returns the default random source which usually is a SecureRandom .
static byte[] getSaltedHash(byte[] src)
          creates a salted SHA-512 hash of the given byte array.
static int getSecurePort()
          returns the port to be used for secure (HTTPS) connections.
static java.lang.String getVersioningPrefix()
          returns the versioning prefix (see: VersionRewriteFilter).
static Action.Security getWeakestCommandSecurityLevel()
          returns the weakest security level Action.Security to be honoured, if TLS is available.
static boolean isTransportLayerSecurityAvailable()
          indicates whether pulse is configured to use TLS.
protected  void setAttributeFactoryDirectly(AttributeFactory factory)
          sets the initialised AttributeFactory during startup.
protected  void setHibernateDataSourceDirectly(HibernateDataSourceImpl ds)
          used by LifecycleHibernateTasks to inject the data source.
protected  void setJAXBContext(javax.xml.bind.JAXBContext ctx)
          sets the JAXBContext.
protected  void setJSONJAXBContext(com.sun.jersey.api.json.JSONJAXBContext context)
          sets the JSONJAXBContext.
protected  void setMailQueueDirectly(MailQueue mc)
          used by LifecycleMailQueueTasks to inject the mail queue.
static void shutdown()
          shuts the Lifecycle singleton down.
static void startup(java.io.File pulseWebapp)
          initialises the Lifecyle singleton.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getAttributeFactory

public static AttributeFactory getAttributeFactory()
returns the AttributeFactory.

Returns:
the AttributeFactory

getBundles

public static java.util.Collection<Bundle> getBundles()
Returns:
the bundles of the pulse container

getBundle

public static Bundle getBundle(java.lang.String name)
get the Bundle with the specified name.

Parameters:
name - the name of the bundle
Returns:
the Bundle or null, if no such Bundle exists.

getBasePath

public static java.io.File getBasePath()
returns the containers root directory.

Returns:
the containers root directory

getHibernateDataSource

public static HibernateDataSource getHibernateDataSource()
Returns the HibernateDataSource.

Returns:
the HibernateDataSource

getGeoLocationProvider

public static IGeoLocationProvider getGeoLocationProvider()
returns the IGeoLocationProvider.

Returns:
the IGeoLocationProvider

getCaptchaAdapter

public static ICaptchaAdapter<?> getCaptchaAdapter()
Returns the (configured) ICaptchaAdapter.

Returns:
the captcha-adapter

getFopFactory

public static org.apache.fop.apps.FopFactory getFopFactory()
Returns the Lifecycles' (configured) FopFactory -instance.

Returns:
the Lifecycles' FopFactory-instance

getJAXBContext

public static javax.xml.bind.JAXBContext getJAXBContext()
Returns:
the global JAXBContext
See Also:
JAXBContext

getJSONJAXBContext

public static com.sun.jersey.api.json.JSONJAXBContext getJSONJAXBContext()
Returns:
a JSONJAXBContext#newInstance(String) with a JSON mapping of JSONConfiguration#Notation#MAPPED

getKnownLocales

public static java.util.Collection<java.util.Locale> getKnownLocales()
returns a list of all known {@link Locale}s.

Returns:
a list of all known {@link Locale}s
See Also:
getActiveLocales()

getActiveLocales

public static java.util.Collection<java.util.Locale> getActiveLocales()
returns a list of all active {@link Locale}s.

Returns:
a list of all active {@link Locale}s
See Also:
getKnownLocales()

getMailQueue

public static MailQueue getMailQueue()
returns the MailQueue.

Returns:
the MailQueue

isTransportLayerSecurityAvailable

public static boolean isTransportLayerSecurityAvailable()
indicates whether pulse is configured to use TLS.

Returns:
true, if TLS is available

getWeakestCommandSecurityLevel

public static Action.Security getWeakestCommandSecurityLevel()
returns the weakest security level Action.Security to be honoured, if TLS is available.

Returns:
the weakest security level to be honoured
See Also:
isTransportLayerSecurityAvailable()

getDefaultPort

public static int getDefaultPort()
returns the port to be used for standard HTTP connections.

Returns:
the port to be used for standard HTTP connections

getSecurePort

public static int getSecurePort()
returns the port to be used for secure (HTTPS) connections.

Returns:
the port to be used for secure (HTTPS) connections

getVersioningPrefix

public static java.lang.String getVersioningPrefix()
returns the versioning prefix (see: VersionRewriteFilter).

Returns:
the versioning prefix

getRandom

public static java.util.Random getRandom()
returns the default random source which usually is a SecureRandom .

Returns:
the default random source

getSaltedHash

public static byte[] getSaltedHash(byte[] src)
creates a salted SHA-512 hash of the given byte array.

Parameters:
src - the source byte array to be hashed
Returns:
a salted SHA-512 hash of the given byte array

startup

public static void startup(java.io.File pulseWebapp)
initialises the Lifecyle singleton.

Parameters:
pulseWebapp - the root directory of the pulse webapp

getInstance

@Deprecated
public static Lifecycle getInstance()
Deprecated. 

Returns:
the Lifecycle singleton

shutdown

public static void shutdown()
shuts the Lifecycle singleton down.


getPulseRootDir

protected java.io.File getPulseRootDir()
used by some Lifecycle tasks.

Returns:
the root directory

getLocalesDirectly

protected java.util.Collection<Locale> getLocalesDirectly()
used by some Lifecycle tasks.

Returns:
the locales

getComponentsDirectly

protected java.util.Set<Component> getComponentsDirectly()
used by some Lifecycle tasks.

Returns:
the components

getBundlesDirectly

protected java.util.concurrent.ConcurrentHashMap<java.lang.String,Bundle> getBundlesDirectly()
used by LifecycleHibernateTasks.

Returns:
the bundles

getHibernateDatasourceDirectly

protected HibernateDataSourceImpl getHibernateDatasourceDirectly()
used by LifecycleHibernateTasks.

Returns:
the data source

setHibernateDataSourceDirectly

protected void setHibernateDataSourceDirectly(HibernateDataSourceImpl ds)
used by LifecycleHibernateTasks to inject the data source.

Parameters:
ds - the data source

getMailQueueDirectly

protected MailQueue getMailQueueDirectly()
used by LifecycleMailQueueTasks.

Returns:
the mail queue

setMailQueueDirectly

protected void setMailQueueDirectly(MailQueue mc)
used by LifecycleMailQueueTasks to inject the mail queue.

Parameters:
mc - the mail queue

getPulseConfiguration

protected ServletConfig getPulseConfiguration()
gives internal access to the pulse configuration.

Returns:
the pulse configuration

setJAXBContext

protected void setJAXBContext(javax.xml.bind.JAXBContext ctx)
sets the JAXBContext.

Parameters:
ctx - the JAXBContext to set.

setJSONJAXBContext

protected void setJSONJAXBContext(com.sun.jersey.api.json.JSONJAXBContext context)
sets the JSONJAXBContext.

Parameters:
context - the JSONJAXBContext to be set

setAttributeFactoryDirectly

protected void setAttributeFactoryDirectly(AttributeFactory factory)
sets the initialised AttributeFactory during startup.

Parameters:
factory - the factory to be set

convertLocaleList

protected static java.util.Collection<java.util.Locale> convertLocaleList(java.util.Collection<Locale> collection,
                                                                          boolean onlyActive)
converts the given list of org.torweg.pulse.service.request.Locale to a list of java.util.Locale.

Parameters:
collection - the list to be converted
onlyActive - flag indicating whether to return only active locales
Returns:
the converted list
See Also:
Locale

getBundlesRootDir

protected java.io.File getBundlesRootDir()
Returns:
Returns the root-directory for the bundles. (for WatchDog)