Module org.eclipse.persistence.jpa
Class JavaSECMPInitializer
- java.lang.Object
-
- org.eclipse.persistence.internal.jpa.deployment.JPAInitializer
-
- org.eclipse.persistence.internal.jpa.deployment.JavaSECMPInitializer
-
public class JavaSECMPInitializer extends JPAInitializer
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:
EntityManagerFactoryProvider
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classJavaSECMPInitializer.TempEntityLoaderThis class loader is provided at initialization time to allow us to temporarily load domain classes so we can examine them for annotations.
-
Field Summary
Fields Modifier and Type Field Description static InstrumentationglobalInstrumentationprotected static JavaSECMPInitializerinitializerprotected static booleanisInContainerprotected static booleanisInitializedprotected static booleanusesAgent-
Fields inherited from class org.eclipse.persistence.internal.jpa.deployment.JPAInitializer
initialEmSetupImpls, initializationClassloader, initializers, initialPuInfos, shouldCreateInternalLoader
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedJavaSECMPInitializer()User should not instantiate JavaSECMPInitializer.protectedJavaSECMPInitializer(ClassLoader loader)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckWeaving(Map properties)Check whether weaving is possible and update the properties and variable as appropriateprotected ClassLoadercreateTempLoader(Collection col)Create a temporary class loader that can be used to inspect classes and then thrown away.protected ClassLoadercreateTempLoader(Collection col, boolean shouldOverrideLoadClassForCollectionMembers)static JavaSECMPInitializergetJavaSECMPInitializer()Get the singleton entityContainer.static JavaSECMPInitializergetJavaSECMPInitializer(ClassLoader classLoader)static JavaSECMPInitializergetJavaSECMPInitializer(ClassLoader classLoader, Map m, boolean fromAgent)static JavaSECMPInitializergetJavaSECMPInitializerFromAgent()static JavaSECMPInitializergetJavaSECMPInitializerFromMain(Map m)protected static voidinitializeFromAgent(Instrumentation instrumentation)INTERNAL: Should be called only by the agent.static voidinitializeFromMain()The version of initializeFromMain that passes an empty map.static voidinitializeFromMain(Map m)Usually JavaSECMPInitializer is initialized from agent during premain to ensure that the classes to be weaved haven't been loaded before initialization.static booleanisInContainer()static booleanisInitialized()Indicates whether initialization has already occurred.booleanisPersistenceUnitUniquelyDefinedByName()Indicates whether puName uniquely defines the persistence unit.protected booleankeepAllPredeployedPersistenceUnits()Indicates whether initialPuInfos and initialEmSetupImpls are used.voidregisterTransformer(jakarta.persistence.spi.ClassTransformer transformer, jakarta.persistence.spi.PersistenceUnitInfo persistenceUnitInfo, Map properties)Register a transformer.static voidsetIsInContainer(boolean isInContainer)static booleanusesAgent()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 Detail
-
globalInstrumentation
public static Instrumentation globalInstrumentation
-
usesAgent
protected static boolean usesAgent
-
isInContainer
protected static boolean isInContainer
-
isInitialized
protected static boolean isInitialized
-
initializer
protected static JavaSECMPInitializer initializer
-
-
Constructor Detail
-
JavaSECMPInitializer
protected JavaSECMPInitializer()
User should not instantiate JavaSECMPInitializer.
-
JavaSECMPInitializer
protected JavaSECMPInitializer(ClassLoader loader)
-
-
Method Detail
-
isInContainer
public static boolean isInContainer()
-
setIsInContainer
public static void setIsInContainer(boolean isInContainer)
-
getJavaSECMPInitializer
public static JavaSECMPInitializer getJavaSECMPInitializer()
Get the singleton entityContainer.
-
getJavaSECMPInitializer
public static JavaSECMPInitializer getJavaSECMPInitializer(ClassLoader classLoader)
-
getJavaSECMPInitializerFromAgent
public static JavaSECMPInitializer getJavaSECMPInitializerFromAgent()
-
getJavaSECMPInitializerFromMain
public static JavaSECMPInitializer getJavaSECMPInitializerFromMain(Map m)
-
getJavaSECMPInitializer
public static JavaSECMPInitializer getJavaSECMPInitializer(ClassLoader classLoader, Map m, boolean fromAgent)
-
checkWeaving
public void checkWeaving(Map properties)
Check whether weaving is possible and update the properties and variable as appropriate- Specified by:
checkWeavingin classJPAInitializer- Parameters:
properties- The list of properties to check for weaving and update if weaving is not needed
-
createTempLoader
protected ClassLoader createTempLoader(Collection col)
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:
createTempLoaderin classJPAInitializer
-
createTempLoader
protected ClassLoader createTempLoader(Collection col, boolean shouldOverrideLoadClassForCollectionMembers)
- Specified by:
createTempLoaderin classJPAInitializer
-
initializeFromAgent
protected static void initializeFromAgent(Instrumentation instrumentation) throws Exception
INTERNAL: Should be called only by the agent. (when weaving classes) If succeeded return true, false otherwise.- Throws:
Exception
-
initializeFromMain
public static void initializeFromMain(Map m)
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(jakarta.persistence.spi.ClassTransformer transformer, jakarta.persistence.spi.PersistenceUnitInfo persistenceUnitInfo, Map properties)Register a transformer. In this case, we use the instrumentation to add a transformer for the JavaSE environment- Specified by:
registerTransformerin 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:
isPersistenceUnitUniquelyDefinedByNamein 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:
keepAllPredeployedPersistenceUnitsin classJPAInitializer
-
-