org.specrunner.hibernate
Class PluginConfiguration

java.lang.Object
  extended by org.specrunner.parameters.core.ParameterHolder
      extended by org.specrunner.plugins.core.AbstractPlugin
          extended by org.specrunner.plugins.core.AbstractPluginNamed
              extended by org.specrunner.plugins.core.AbstractPluginScoped
                  extended by org.specrunner.plugins.core.AbstractPluginValue
                      extended by org.specrunner.hibernate.AbstractPluginFactory
                          extended by org.specrunner.hibernate.PluginConfiguration
All Implemented Interfaces:
IParameterHolder, IActionType, IParalelPlugin, IPlugin, ISleepPlugin, ITestPlugin, ITimedPlugin, IWaitPlugin

public class PluginConfiguration
extends AbstractPluginFactory

Creates/recovers a configuration instance and add it to the global context. It can be done by using two strategies:

To make configuration thread safe for in memory databases like Hypersonic the URL connection can be changed for example to 'jdbc:hsqldb:mem:phonebook'. To allow this behavior set threadsafe='true', or set the feature FEATURE_THREADSAFE to 'true'.

Author:
Thiago Santos

Field Summary
static String FEATURE_FACTORY
          Feature to set configuration factory class.
static String FEATURE_METHOD
          Feature to set method factory name.
static String FEATURE_TYPE
          Feature to set configuration provider class name.
static String SESSION_CONFIGURATION
          Default configuration name.
 
Fields inherited from class org.specrunner.hibernate.AbstractPluginFactory
factory, method, type
 
Fields inherited from class org.specrunner.plugins.core.AbstractPlugin
FEATURE_CONDITION, FEATURE_NORMALIZED, FEATURE_SLEEP, FEATURE_THREADSAFE, FEATURE_TIMEOUT, FEATURE_WAIT
 
Constructor Summary
PluginConfiguration()
           
 
Method Summary
protected  void changeUrl(IContext context, org.hibernate.cfg.Configuration cfg)
          Change URL if thread safe is true.
 ENext doStart(IContext context, IResultSet result)
           
static org.hibernate.cfg.Configuration getConfiguration(IContext context, String name)
          Gets the configuration object bound to the environment with a given name.
 void initialize(IContext context)
           
 
Methods inherited from class org.specrunner.hibernate.AbstractPluginFactory
getActionType, getFactory, getMethod, getType, setFactory, setMethod, setType
 
Methods inherited from class org.specrunner.plugins.core.AbstractPluginValue
getValue, getValue, isEval, setEval, setValue
 
Methods inherited from class org.specrunner.plugins.core.AbstractPluginScoped
getScope, saveGlobal, saveLocal, saveStrict, setScope
 
Methods inherited from class org.specrunner.plugins.core.AbstractPluginNamed
getName, setName
 
Methods inherited from class org.specrunner.plugins.core.AbstractPlugin
copy, doEnd, getCondition, getConditionModel, getNormalized, getNormalized, getParent, getSleep, getSleepModel, getThreadsafe, getTimeout, getTimeoutModel, getWait, getWaitModel, setCondition, setConditionModel, setNormalized, setParent, setSleep, setSleepModel, setThreadsafe, setTimeout, setTimeoutModel, setWait, setWaitModel, toString
 
Methods inherited from class org.specrunner.parameters.core.ParameterHolder
getParameters, setParameters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.specrunner.parameters.IParameterHolder
getParameters, setParameters
 

Field Detail

SESSION_CONFIGURATION

public static final String SESSION_CONFIGURATION
Default configuration name.

See Also:
Constant Field Values

FEATURE_TYPE

public static final String FEATURE_TYPE
Feature to set configuration provider class name.


FEATURE_FACTORY

public static final String FEATURE_FACTORY
Feature to set configuration factory class.


FEATURE_METHOD

public static final String FEATURE_METHOD
Feature to set method factory name.

Constructor Detail

PluginConfiguration

public PluginConfiguration()
Method Detail

initialize

public void initialize(IContext context)
                throws PluginException
Specified by:
initialize in interface IPlugin
Overrides:
initialize in class AbstractPlugin
Throws:
PluginException

doStart

public ENext doStart(IContext context,
                     IResultSet result)
              throws PluginException
Specified by:
doStart in interface IPlugin
Overrides:
doStart in class AbstractPlugin
Throws:
PluginException

changeUrl

protected void changeUrl(IContext context,
                         org.hibernate.cfg.Configuration cfg)
Change URL if thread safe is true.

Parameters:
context - The context.
cfg - The configuration.

getConfiguration

public static org.hibernate.cfg.Configuration getConfiguration(IContext context,
                                                               String name)
                                                        throws PluginException
Gets the configuration object bound to the environment with a given name.

Parameters:
context - The context.
name - The presumed name of configuration.
Returns:
The configuration with the given name, if exists, otherwise the configuration with default name, if exists, or null.
Throws:
PluginException - On configuration lookup error.


Copyright © 2014. All rights reserved.