Module org.eclipse.persistence.jpa
Class JavaSECMPInitializer
java.lang.Object
org.eclipse.persistence.internal.jpa.deployment.JPAInitializer
org.eclipse.persistence.internal.jpa.deployment.JavaSECMPInitializer
INTERNAL:
JavaSECMPInitializer is used to bootstrap the deployment of EntityBeans in EJB 3.0
when deployed in a non-managed setting
It is called internally by our Provider
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
This class loader is provided at initialization time to allow us to temporarily load domain classes so we can examine them for annotations. -
Field Summary
Modifier and TypeFieldDescriptionstatic Instrumentation
protected static JavaSECMPInitializer
protected static boolean
protected static boolean
protected static boolean
Fields inherited from class org.eclipse.persistence.internal.jpa.deployment.JPAInitializer
initialEmSetupImpls, initializationClassloader, initializers, initialPuInfos, shouldCreateInternalLoader
-
Constructor Summary
ModifierConstructorDescriptionprotected
User should not instantiate JavaSECMPInitializer.protected
JavaSECMPInitializer
(ClassLoader loader) -
Method Summary
Modifier and TypeMethodDescriptionvoid
checkWeaving
(Map properties) Check whether weaving is possible and update the properties and variable as appropriateprotected ClassLoader
Create a temporary class loader that can be used to inspect classes and then thrown away.protected ClassLoader
createTempLoader
(Collection col, boolean shouldOverrideLoadClassForCollectionMembers) static JavaSECMPInitializer
Get the singleton entityContainer.static JavaSECMPInitializer
getJavaSECMPInitializer
(ClassLoader classLoader) static JavaSECMPInitializer
getJavaSECMPInitializer
(ClassLoader classLoader, Map m, boolean fromAgent) static JavaSECMPInitializer
static JavaSECMPInitializer
protected static void
initializeFromAgent
(Instrumentation instrumentation) INTERNAL: Should be called only by the agent.static void
The version of initializeFromMain that passes an empty map.static void
Usually JavaSECMPInitializer is initialized from agent during premain to ensure that the classes to be weaved haven't been loaded before initialization.static boolean
static boolean
Indicates whether initialization has already occurred.boolean
Indicates whether puName uniquely defines the persistence unit.protected boolean
Indicates whether initialPuInfos and initialEmSetupImpls are used.void
registerTransformer
(ClassTransformer transformer, PersistenceUnitInfo persistenceUnitInfo, Map properties) Register a transformer.static void
setIsInContainer
(boolean isInContainer) static boolean
Indicates whether Java agent and globalInstrumentation was used.Methods inherited from class org.eclipse.persistence.internal.jpa.deployment.JPAInitializer
callPredeploy, createUniquePersistenceUnitName, extractInitialEmSetupImpl, findPersistenceUnitInfo, findPersistenceUnitInfoInArchive, findPersistenceUnitInfoInArchives, getInitializationClassLoader, initialize, initializeTopLinkLoggingFile, initPersistenceUnits, isPersistenceProviderSupported, loadEntityClasses
-
Field Details
-
globalInstrumentation
-
usesAgent
protected static boolean usesAgent -
isInContainer
protected static boolean isInContainer -
isInitialized
protected static boolean isInitialized -
initializer
-
-
Constructor Details
-
JavaSECMPInitializer
protected JavaSECMPInitializer()User should not instantiate JavaSECMPInitializer. -
JavaSECMPInitializer
-
-
Method Details
-
isInContainer
public static boolean isInContainer() -
setIsInContainer
public static void setIsInContainer(boolean isInContainer) -
getJavaSECMPInitializer
Get the singleton entityContainer. -
getJavaSECMPInitializer
-
getJavaSECMPInitializerFromAgent
-
getJavaSECMPInitializerFromMain
-
getJavaSECMPInitializer
public static JavaSECMPInitializer getJavaSECMPInitializer(ClassLoader classLoader, Map m, boolean fromAgent) -
checkWeaving
Check whether weaving is possible and update the properties and variable as appropriate- Specified by:
checkWeaving
in classJPAInitializer
- Parameters:
properties
- The list of properties to check for weaving and update if weaving is not needed
-
createTempLoader
Create a temporary class loader that can be used to inspect classes and then thrown away. This allows classes to be introspected prior to loading them with application's main class loader enabling weaving.- Specified by:
createTempLoader
in classJPAInitializer
-
createTempLoader
protected ClassLoader createTempLoader(Collection col, boolean shouldOverrideLoadClassForCollectionMembers) - Specified by:
createTempLoader
in classJPAInitializer
-
initializeFromAgent
INTERNAL: Should be called only by the agent. (when weaving classes) If succeeded return true, false otherwise.- Throws:
Exception
-
initializeFromMain
Usually JavaSECMPInitializer is initialized from agent during premain to ensure that the classes to be weaved haven't been loaded before initialization. However, in this case initialization can't be debugged. In order to be able to debug initialization specify in java options -javaagent with parameter "main": (note: a separate eclipselink-agent.jar is no longer required) -javaagent:c:\trunk\eclipselink.jar=main that causes instrumentation to be cached during premain and postpones initialization until main. With initialization done in main (during the first createEntityManagerFactory call) there's a danger of the classes to be weaved being already loaded. In that situation initializeFromMain should be called before any classes are loaded. The sure-to-work method would be to create a new runnable class with a main method consisting of just two lines: calling initializeFromMain followed by reflective call to the main method of the original runnable class. The same could be achieved by calling PersistenceProvider.createEntityManagerFactory method instead of JavaSECMPInitializer.initializeFromMain method, however initializeFromMain might be more convenient because it doesn't require a persistence unit name. The method doesn't do anything if JavaSECMPInitializer has been already initialized.- Parameters:
m
- - a map containing the set of properties to instantiate with.
-
initializeFromMain
public static void initializeFromMain()The version of initializeFromMain that passes an empty map. -
registerTransformer
public void registerTransformer(ClassTransformer transformer, PersistenceUnitInfo persistenceUnitInfo, Map properties) Register a transformer. In this case, we use the instrumentation to add a transformer for the JavaSE environment- Specified by:
registerTransformer
in classJPAInitializer
-
isPersistenceUnitUniquelyDefinedByName
public boolean isPersistenceUnitUniquelyDefinedByName()Indicates whether puName uniquely defines the persistence unit. usesAgent means that it is a stand alone SE case. Otherwise it could be an application server case where different persistence units may have the same name: that could happen if they are loaded by different classloaders; the common case is the same persistence unit jar deployed in several applications.- Overrides:
isPersistenceUnitUniquelyDefinedByName
in classJPAInitializer
-
isInitialized
public static boolean isInitialized()Indicates whether initialization has already occurred. -
usesAgent
public static boolean usesAgent()Indicates whether Java agent and globalInstrumentation was used. -
keepAllPredeployedPersistenceUnits
protected boolean keepAllPredeployedPersistenceUnits()Indicates whether initialPuInfos and initialEmSetupImpls are used.- Overrides:
keepAllPredeployedPersistenceUnits
in classJPAInitializer
-