com.caucho.amber.manager
Class AmberContainer

java.lang.Object
  extended by com.caucho.amber.manager.AmberContainer
All Implemented Interfaces:
ScanListener, EnvironmentListener

public class AmberContainer
extends java.lang.Object
implements ScanListener, EnvironmentListener

Environment-based container.


Method Summary
 void addDefaultListener(java.lang.String className, ListenerType type)
          Adds a default listener.
 void addEmbeddable(java.lang.String className, EmbeddableType type)
          Adds an embeddable for an introspected class.
 void addEntity(java.lang.String className, EntityType type)
          Adds an entity for an introspected class.
 void addEntityException(java.lang.String className, java.lang.Throwable e)
          Adds an entity for an introspected class.
 void addEntityListener(java.lang.String entityClassName, ListenerType listenerType)
          Adds an entity listener.
 void addException(java.lang.Throwable e)
          Adds an entity for an introspected class.
 void addMappedSuperclass(java.lang.String className, MappedSuperclassType type)
          Adds a mapped superclass for an introspected class.
 void addPersistenceUnit(Path root)
          Adds a persistence root.
 void addPersistenceUnitDefault(ConfigProgram program)
          Adds a persistence-unit default
 void addPersistenceUnitProxy(java.lang.String name, java.util.ArrayList<ConfigProgram> program)
          Adds a persistence-unit default
 void classMatchEvent(EnvironmentClassLoader loader, Path root, java.lang.String className)
          Callback to note the class matches
static AmberContainer create()
          Returns the local container.
static AmberContainer create(java.lang.ClassLoader loader)
          Returns the local container.
 EntityManagerFactory createEntityManagerFactory(PersistenceUnitInfo info)
           
 AmberPersistenceUnit createPersistenceUnit(java.lang.String name)
           
 void environmentBind(EnvironmentClassLoader loader)
          Handles the environment config phase
 void environmentConfigure(EnvironmentClassLoader loader)
          Handles the environment config phase
 void environmentStart(EnvironmentClassLoader loader)
          Handles the case where the environment is starting (after init).
 void environmentStop(EnvironmentClassLoader loader)
          Handles the case where the environment is stopping
 java.lang.Throwable getConfigException()
           
 boolean getCreateDatabaseTables()
          True if database tables should be created automatically.
static AmberContainer getCurrent()
          Returns the local container.
static AmberContainer getCurrent(java.lang.ClassLoader loader)
          Returns the current environment container.
 javax.sql.DataSource getDataSource()
          Gets the primary data source.
 ListenerType getDefaultListener(java.lang.String className)
          Returns the default ListenerType for an introspected class.
 EmbeddableType getEmbeddable(java.lang.String className)
          Returns the EmbeddableType for an introspected class.
 java.lang.ClassLoader getEnhancedLoader()
          Returns the parent loader
 EntityType getEntity(java.lang.String className)
          Returns the EntityType for an introspected class.
 ListenerType getEntityListener(java.lang.String className)
          Returns the entity ListenerType for an introspected class.
 java.util.ArrayList<ListenerType> getEntityListeners(java.lang.String entityClassName)
          Returns the entity listeners for an entity.
 EntityManagerFactory getEntityManagerFactory(java.lang.String name)
           
 EntityManager getExtendedPersistenceContext(java.lang.String name)
           
 AmberGenerator getGenerator()
          Returns the enhancer.
 ListenerType getListener(java.lang.String className)
          Returns the listener for an introspected class.
 MappedSuperclassType getMappedSuperclass(java.lang.String className)
          Returns the MappedSuperclassType for an introspected class.
 java.lang.ClassLoader getParentClassLoader()
          Returns the parent loader
 EntityManager getPersistenceContext(java.lang.String name)
           
static java.lang.String getPersistenceContextJndiPrefix()
          Returns the persistence unit JNDI context.
 AmberPersistenceUnit getPersistenceUnit(java.lang.String name)
           
 java.util.ArrayList<ConfigProgram> getPersistenceUnitDefaultList()
          Returns the persistence-unit default list.
static java.lang.String getPersistenceUnitJndiPrefix()
          Returns the persistence unit JNDI context.
 java.util.ArrayList<ConfigProgram> getProxyProgram(java.lang.String name)
           
 javax.sql.DataSource getReadDataSource()
          Gets the read data source.
 int getScanPriority()
          Since Amber enhances it's priority 0
 java.lang.ClassLoader getTempClassLoader()
          Returns the JClassLoader.
 javax.sql.DataSource getXADataSource()
          Gets the XA data source.
 void init()
           
 void initEntityHomes()
          Initialize the entity homes.
 boolean isRootScannable(Path root, java.lang.String packageRoot)
          Returns true if the root is a valid scannable root.
 boolean isScanMatchAnnotation(CharBuffer annotationName)
          Returns true if the string matches an annotation class.
 java.lang.Class loadTempClass(java.lang.String name)
           
 ScanClass scanClass(Path root, java.lang.String packageRoot, java.lang.String className, int modifiers)
          Returns the state when scanning the class
 void setCreateDatabaseTables(boolean isCreate)
          True if database tables should be created automatically.
 void setDataSource(javax.sql.DataSource dataSource)
          Sets the primary data source.
 void setReadDataSource(javax.sql.DataSource dataSource)
          Sets the read data source.
 void setXADataSource(javax.sql.DataSource dataSource)
          Sets the xa data source.
 void start()
           
 void startPersistenceUnits()
          Adds the URLs for the classpath.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

create

public static AmberContainer create()
Returns the local container.


create

public static AmberContainer create(java.lang.ClassLoader loader)
Returns the local container.


getCurrent

public static AmberContainer getCurrent()
Returns the local container.


getCurrent

public static AmberContainer getCurrent(java.lang.ClassLoader loader)
Returns the current environment container.


setDataSource

public void setDataSource(javax.sql.DataSource dataSource)
Sets the primary data source.


getDataSource

public javax.sql.DataSource getDataSource()
Gets the primary data source.


setReadDataSource

public void setReadDataSource(javax.sql.DataSource dataSource)
Sets the read data source.


getReadDataSource

public javax.sql.DataSource getReadDataSource()
Gets the read data source.


setXADataSource

public void setXADataSource(javax.sql.DataSource dataSource)
Sets the xa data source.


getXADataSource

public javax.sql.DataSource getXADataSource()
Gets the XA data source.


getCreateDatabaseTables

public boolean getCreateDatabaseTables()
True if database tables should be created automatically.


setCreateDatabaseTables

public void setCreateDatabaseTables(boolean isCreate)
True if database tables should be created automatically.


getParentClassLoader

public java.lang.ClassLoader getParentClassLoader()
Returns the parent loader


getEnhancedLoader

public java.lang.ClassLoader getEnhancedLoader()
Returns the parent loader


getGenerator

public AmberGenerator getGenerator()
Returns the enhancer.


getPersistenceUnitJndiPrefix

public static java.lang.String getPersistenceUnitJndiPrefix()
Returns the persistence unit JNDI context.


addPersistenceUnitDefault

public void addPersistenceUnitDefault(ConfigProgram program)
Adds a persistence-unit default


getPersistenceUnitDefaultList

public java.util.ArrayList<ConfigProgram> getPersistenceUnitDefaultList()
Returns the persistence-unit default list.


addPersistenceUnitProxy

public void addPersistenceUnitProxy(java.lang.String name,
                                    java.util.ArrayList<ConfigProgram> program)
Adds a persistence-unit default


getProxyProgram

public java.util.ArrayList<ConfigProgram> getProxyProgram(java.lang.String name)

getPersistenceContextJndiPrefix

public static java.lang.String getPersistenceContextJndiPrefix()
Returns the persistence unit JNDI context.


getTempClassLoader

public java.lang.ClassLoader getTempClassLoader()
Returns the JClassLoader.


loadTempClass

public java.lang.Class loadTempClass(java.lang.String name)
                              throws java.lang.ClassNotFoundException
Throws:
java.lang.ClassNotFoundException

init

public void init()

getEmbeddable

public EmbeddableType getEmbeddable(java.lang.String className)
Returns the EmbeddableType for an introspected class.


getEntity

public EntityType getEntity(java.lang.String className)
Returns the EntityType for an introspected class.


getMappedSuperclass

public MappedSuperclassType getMappedSuperclass(java.lang.String className)
Returns the MappedSuperclassType for an introspected class.


getDefaultListener

public ListenerType getDefaultListener(java.lang.String className)
Returns the default ListenerType for an introspected class.


getEntityListener

public ListenerType getEntityListener(java.lang.String className)
Returns the entity ListenerType for an introspected class.


getListener

public ListenerType getListener(java.lang.String className)
Returns the listener for an introspected class.


getEntityListeners

public java.util.ArrayList<ListenerType> getEntityListeners(java.lang.String entityClassName)
Returns the entity listeners for an entity.


addEntityException

public void addEntityException(java.lang.String className,
                               java.lang.Throwable e)
Adds an entity for an introspected class.


addException

public void addException(java.lang.Throwable e)
Adds an entity for an introspected class.


getConfigException

public java.lang.Throwable getConfigException()

addEmbeddable

public void addEmbeddable(java.lang.String className,
                          EmbeddableType type)
Adds an embeddable for an introspected class.


addEntity

public void addEntity(java.lang.String className,
                      EntityType type)
Adds an entity for an introspected class.


addMappedSuperclass

public void addMappedSuperclass(java.lang.String className,
                                MappedSuperclassType type)
Adds a mapped superclass for an introspected class.


addDefaultListener

public void addDefaultListener(java.lang.String className,
                               ListenerType type)
Adds a default listener.


addEntityListener

public void addEntityListener(java.lang.String entityClassName,
                              ListenerType listenerType)
Adds an entity listener.


initEntityHomes

public void initEntityHomes()
Initialize the entity homes.


createEntityManagerFactory

public EntityManagerFactory createEntityManagerFactory(PersistenceUnitInfo info)

createPersistenceUnit

public AmberPersistenceUnit createPersistenceUnit(java.lang.String name)

start

public void start()

getPersistenceUnit

public AmberPersistenceUnit getPersistenceUnit(java.lang.String name)

getEntityManagerFactory

public EntityManagerFactory getEntityManagerFactory(java.lang.String name)

getPersistenceContext

public EntityManager getPersistenceContext(java.lang.String name)

getExtendedPersistenceContext

public EntityManager getExtendedPersistenceContext(java.lang.String name)

addPersistenceUnit

public void addPersistenceUnit(Path root)
Adds a persistence root.


startPersistenceUnits

public void startPersistenceUnits()
Adds the URLs for the classpath.


getScanPriority

public int getScanPriority()
Since Amber enhances it's priority 0

Specified by:
getScanPriority in interface ScanListener

isRootScannable

public boolean isRootScannable(Path root,
                               java.lang.String packageRoot)
Returns true if the root is a valid scannable root.

Specified by:
isRootScannable in interface ScanListener

scanClass

public ScanClass scanClass(Path root,
                           java.lang.String packageRoot,
                           java.lang.String className,
                           int modifiers)
Description copied from interface: ScanListener
Returns the state when scanning the class

Specified by:
scanClass in interface ScanListener
Parameters:
root - the module/jar's root path
packageRoot - the virtual package root (usually for Testing)
className - the class name
modifiers - the class modifiers
Returns:
the ScanClass object

isScanMatchAnnotation

public boolean isScanMatchAnnotation(CharBuffer annotationName)
Description copied from interface: ScanListener
Returns true if the string matches an annotation class.

Specified by:
isScanMatchAnnotation in interface ScanListener

classMatchEvent

public void classMatchEvent(EnvironmentClassLoader loader,
                            Path root,
                            java.lang.String className)
Callback to note the class matches

Specified by:
classMatchEvent in interface ScanListener

environmentConfigure

public void environmentConfigure(EnvironmentClassLoader loader)
Handles the environment config phase

Specified by:
environmentConfigure in interface EnvironmentListener

environmentBind

public void environmentBind(EnvironmentClassLoader loader)
Handles the environment config phase

Specified by:
environmentBind in interface EnvironmentListener

environmentStart

public void environmentStart(EnvironmentClassLoader loader)
Handles the case where the environment is starting (after init).

Specified by:
environmentStart in interface EnvironmentListener

environmentStop

public void environmentStop(EnvironmentClassLoader loader)
Handles the case where the environment is stopping

Specified by:
environmentStop in interface EnvironmentListener

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object