org.spicefactory.pimento.config
Class PimentoConfig

java.lang.Object
  extended by org.spicefactory.pimento.config.PimentoConfig
All Implemented Interfaces:
ConfigurationProcessor, BeanPostProcessor

public class PimentoConfig
extends Object
implements ConfigurationProcessor, BeanPostProcessor

The core configuration class for Pimento. Usually an instance of this class will be created at application startup. When configured with Spring this class acts as a Spring BeanPostProcessor, that detects all classes annotated with @PimentoInterceptor, and also acts as a Cinnamon ConfigurationProcessor, that registers all internal ClassMappings needed by Pimento.

Author:
Jens Halm

Constructor Summary
PimentoConfig()
          Creates a new instance.
 
Method Summary
 CinnamonConfig getCinnamonConfig()
          Returns the Cinnamon configuration that this Pimento configuration uses internally.
 JpaPersistenceAdapter getJpaPersistenceAdapter()
          The JpaPersistenceAdapter instance for this configuration.
 Metamodel getMetamodel()
          Returns the entity metamodel for this configuration.
 void init(Map<String,String> initMap, Map<String,Object> applicationMap)
          Initializes the ConfigurationProcessor.
 boolean isExecuteUpdatePermitted()
          Checks whether the Query.executeUpdate operation is allowed for clients.
 void postProcess(CinnamonConfig config)
          Method called after the usual configuration logic (XML file parsing, Spring context analyzing) was applied to the given CinnamonConfig instance.
 Object postProcessAfterInitialization(Object bean, String beanName)
           
 Object postProcessBeforeInitialization(Object bean, String beanName)
           
 void preProcess(CinnamonConfig config)
          Method called before the usual configuration logic (XML file parsing, Spring context analyzing) will be applied to the given CinnamonConfig instance.
 void setExecuteUpdatePermitted(boolean permitted)
          Sets whether the Query.executeUpdate operation is allowed for clients.
 void setPersistenceAdapters(Set<PersistenceAdapter> adapters)
          Sets the persistence adapters to use.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PimentoConfig

public PimentoConfig()
Creates a new instance.

Method Detail

getCinnamonConfig

public CinnamonConfig getCinnamonConfig()
Returns the Cinnamon configuration that this Pimento configuration uses internally.

Returns:
the Cinnamon configuration that this Pimento configuration uses internally

setPersistenceAdapters

public void setPersistenceAdapters(Set<PersistenceAdapter> adapters)
Sets the persistence adapters to use.

Parameters:
adapters - the persistence adapters to use

getJpaPersistenceAdapter

public JpaPersistenceAdapter getJpaPersistenceAdapter()
The JpaPersistenceAdapter instance for this configuration. In rare cases where Pimento is used without JPA this method will return null.

Returns:
the JpaPersistenceAdapter instance for this configuration

setExecuteUpdatePermitted

public void setExecuteUpdatePermitted(boolean permitted)
Sets whether the Query.executeUpdate operation is allowed for clients. Since it is very dangerous to expose this method to public clients it is disabled by default. You should only enable it for testing purposes or internal applications.

Parameters:
permitted - whether the executeUpdate operation is permitted for clients

isExecuteUpdatePermitted

public boolean isExecuteUpdatePermitted()
Checks whether the Query.executeUpdate operation is allowed for clients. Since it is very dangerous to expose this method to public clients it is disabled by default. You should only enable it for testing purposes or internal applications.

Returns:
true if the executeUpdate operation is permitted for clients

init

public void init(Map<String,String> initMap,
                 Map<String,Object> applicationMap)
Description copied from interface: ConfigurationProcessor
Initializes the ConfigurationProcessor. Will be called once for each instance before any other method will be invoked.

Specified by:
init in interface ConfigurationProcessor
Parameters:
initMap - the initialisation parameters (taken from ServletConfig in a web application)
applicationMap - the application attributes (taken from ServletContext in a web application)

preProcess

public void preProcess(CinnamonConfig config)
Description copied from interface: ConfigurationProcessor
Method called before the usual configuration logic (XML file parsing, Spring context analyzing) will be applied to the given CinnamonConfig instance.

Specified by:
preProcess in interface ConfigurationProcessor
Parameters:
config - the CinnamonConfig instance under construction

postProcess

public void postProcess(CinnamonConfig config)
Description copied from interface: ConfigurationProcessor
Method called after the usual configuration logic (XML file parsing, Spring context analyzing) was applied to the given CinnamonConfig instance.

Specified by:
postProcess in interface ConfigurationProcessor
Parameters:
config - the CinnamonConfig instance under construction

getMetamodel

public Metamodel getMetamodel()
Returns the entity metamodel for this configuration.

Returns:
the entity metamodel for this configuration

postProcessBeforeInitialization

public Object postProcessBeforeInitialization(Object bean,
                                              String beanName)
                                       throws BeansException
Specified by:
postProcessBeforeInitialization in interface BeanPostProcessor
Throws:
BeansException

postProcessAfterInitialization

public Object postProcessAfterInitialization(Object bean,
                                             String beanName)
                                      throws BeansException
Specified by:
postProcessAfterInitialization in interface BeanPostProcessor
Throws:
BeansException