Top Description Inners Fields Constructors Methods
org.eclipse.persistence.internal.jpa.deployment

public Class JavaSECMPInitializer

extends JPAInitializer
Class Inheritance
Imports
java.lang.instrument.ClassFileTransformer, .IllegalClassFormatException, .Instrumentation, java.lang.reflect.Constructor, java.net.URL, .URLClassLoader, java.security.AccessController, .PrivilegedActionException, .ProtectionDomain, java.util.Collection, .Enumeration, .HashMap, .Map, jakarta.persistence.PersistenceException, jakarta.persistence.spi.ClassTransformer, .PersistenceUnitInfo, .TransformerException, org.eclipse.persistence.config.PersistenceUnitProperties, org.eclipse.persistence.exceptions.EntityManagerSetupException, org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider, org.eclipse.persistence.internal.security.PrivilegedAccessHelper, .PrivilegedGetConstructorFor, .PrivilegedInvokeConstructor, org.eclipse.persistence.logging.AbstractSessionLog, .SessionLog

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
org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
JavaSECMPInitializer.TempEntityLoader

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 TypeField and Description
public static Instrumentation
private static final Object
protected static JavaSECMPInitializer
protected static boolean
protected static boolean
protected static boolean
Inherited from org.eclipse.persistence.internal.jpa.deployment.JPAInitializer:
initialEmSetupImplsinitializationClassloaderinitializersinitialPuInfosshouldCreateInternalLoader

Constructor Summary

AccessConstructor and Description
protected
JavaSECMPInitializer()

User should not instantiate JavaSECMPInitializer.

protected

Method Summary

Modifier and TypeMethod and Description
public void
checkWeaving(Map<K, V>
The list of properties to check for weaving and update if weaving is not needed
properties
)

Implements abstract org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.checkWeaving.

Check whether weaving is possible and update the properties and variable as appropriate
protected ClassLoader
createTempLoader(Collection<E> col)

Implements abstract org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.createTempLoader.

Create a temporary class loader that can be used to inspect classes and then thrown away.
protected ClassLoader
createTempLoader(Collection<E> col, boolean shouldOverrideLoadClassForCollectionMembers)

Implements abstract org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.createTempLoader.

public static JavaSECMPInitializer
getJavaSECMPInitializer()

Get the singleton entityContainer.

public static JavaSECMPInitializer
public static JavaSECMPInitializer
getJavaSECMPInitializer(ClassLoader classLoader, Map<K, V> m, boolean fromAgent)

public static JavaSECMPInitializer
public static JavaSECMPInitializer
protected static void
initializeFromAgent(Instrumentation instrumentation)

INTERNAL: Should be called only by the agent.

public static void
initializeFromMain(Map<K, V>
- a map containing the set of properties to instantiate with.
m
)

Usually JavaSECMPInitializer is initialized from agent during premain to ensure that the classes to be weaved haven't been loaded before initialization.

public static void
initializeFromMain()

The version of initializeFromMain that passes an empty map.

public static boolean
public static boolean
isInitialized()

Indicates whether initialization has already occurred.

public boolean
protected boolean
public void
registerTransformer(final ClassTransformer transformer, PersistenceUnitInfo persistenceUnitInfo, Map<K, V> properties)

Implements abstract org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.registerTransformer.

Register a transformer.
public static void
setIsInContainer(boolean isInContainer)

public static boolean
usesAgent()

Indicates whether Java agent and globalInstrumentation was used.

Inherited from org.eclipse.persistence.internal.jpa.deployment.JPAInitializer:
callPredeploycreateUniquePersistenceUnitNameextractInitialEmSetupImplfindPersistenceUnitInfofindPersistenceUnitInfoInArchivefindPersistenceUnitInfoInArchivesgetInitializationClassLoaderinitializeinitializeTopLinkLoggingFileinitPersistenceUnitsisPersistenceProviderSupportedloadEntityClasses

Field Detail

globalInstrumentationback to summary
public static Instrumentation globalInstrumentation
initializationLockback to summary
private static final Object initializationLock
initializerback to summary
protected static JavaSECMPInitializer initializer
isInContainerback to summary
protected static boolean isInContainer
isInitializedback to summary
protected static boolean isInitialized
usesAgentback to summary
protected static boolean usesAgent

Constructor Detail

JavaSECMPInitializerback to summary
protected JavaSECMPInitializer()

User should not instantiate JavaSECMPInitializer.

JavaSECMPInitializerback to summary
protected JavaSECMPInitializer(ClassLoader loader)

Method Detail

checkWeavingback to summary
public void checkWeaving(Map<K, V> properties)

Implements abstract org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.checkWeaving.

Check whether weaving is possible and update the properties and variable as appropriate

Parameters
properties:Map<K, V>

The list of properties to check for weaving and update if weaving is not needed

Annotations
@Override
createTempLoaderback to summary
protected ClassLoader createTempLoader(Collection<E> col)

Implements abstract org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.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.

Annotations
@Override
createTempLoaderback to summary
protected ClassLoader createTempLoader(Collection<E> col, boolean shouldOverrideLoadClassForCollectionMembers)

Implements abstract org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.createTempLoader.

Annotations
@Override
getJavaSECMPInitializerback to summary
public static JavaSECMPInitializer getJavaSECMPInitializer()

Get the singleton entityContainer.

getJavaSECMPInitializerback to summary
public static JavaSECMPInitializer getJavaSECMPInitializer(ClassLoader classLoader)
getJavaSECMPInitializerback to summary
public static JavaSECMPInitializer getJavaSECMPInitializer(ClassLoader classLoader, Map<K, V> m, boolean fromAgent)
getJavaSECMPInitializerFromAgentback to summary
public static JavaSECMPInitializer getJavaSECMPInitializerFromAgent()
getJavaSECMPInitializerFromMainback to summary
public static JavaSECMPInitializer getJavaSECMPInitializerFromMain(Map<K, V> m)
initializeFromAgentback to summary
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.

initializeFromMainback to summary
public static void initializeFromMain(Map<K, V> 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:Map<K, V>

- a map containing the set of properties to instantiate with.

initializeFromMainback to summary
public static void initializeFromMain()

The version of initializeFromMain that passes an empty map.

isInContainerback to summary
public static boolean isInContainer()
isInitializedback to summary
public static boolean isInitialized()

Indicates whether initialization has already occurred.

isPersistenceUnitUniquelyDefinedByNameback to summary
public boolean isPersistenceUnitUniquelyDefinedByName()

Overrides org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.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.

Annotations
@Override
keepAllPredeployedPersistenceUnitsback to summary
protected boolean keepAllPredeployedPersistenceUnits()

Overrides org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.keepAllPredeployedPersistenceUnits.

Indicates whether initialPuInfos and initialEmSetupImpls are used.

Annotations
@Override
registerTransformerback to summary
public void registerTransformer(final ClassTransformer transformer, PersistenceUnitInfo persistenceUnitInfo, Map<K, V> properties)

Implements abstract org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.registerTransformer.

Register a transformer. In this case, we use the instrumentation to add a transformer for the JavaSE environment

Annotations
@Override
setIsInContainerback to summary
public static void setIsInContainer(boolean isInContainer)
usesAgentback to summary
public static boolean usesAgent()

Indicates whether Java agent and globalInstrumentation was used.

org.eclipse.persistence.internal.jpa.deployment back to summary

public Class JavaSECMPInitializer.TempEntityLoader

extends URLClassLoader
Class Inheritance

This class loader is provided at initialization time to allow us to temporarily load domain classes so we can examine them for annotations. After they are loaded we will throw this class loader away. Transformers can then be registered on the real class loader to allow weaving to occur. It selectively loads classes based on the list of classnames it is instantiated with. Classes not on that list are allowed to be loaded by the parent.

Field Summary

Modifier and TypeField and Description
pack-priv Collection<E>
pack-priv boolean

Constructor Summary

AccessConstructor and Description
public
TempEntityLoader(URL[] urls, ClassLoader parent, Collection<E> classNames, boolean shouldOverrideLoadClassForCollectionMembers)

public
TempEntityLoader(URL[] urls, ClassLoader parent, Collection<E> classNames)

Method Summary

Modifier and TypeMethod and Description
public Enumeration<URL>
getResources(String
The resource name
name
)

Overrides java.lang.ClassLoader.getResources.

Finds all the resources with the given name.
protected synchronized Class<?>
loadClass(String
The binary name of the class
name
,
boolean
If true then resolve the class
resolve
)

Overrides java.lang.ClassLoader.loadClass.

Loads the class with the specified binary name.
protected boolean
Inherited from java.net.URLClassLoader:
addURLclosedefinePackagefindClassfindResourcefindResourcesgetPermissionsgetResourceAsStreamgetURLsnewInstancenewInstance

Field Detail

classNamesback to summary
pack-priv Collection<E> classNames
shouldOverrideLoadClassForCollectionMembersback to summary
pack-priv boolean shouldOverrideLoadClassForCollectionMembers

Constructor Detail

TempEntityLoaderback to summary
public TempEntityLoader(URL[] urls, ClassLoader parent, Collection<E> classNames, boolean shouldOverrideLoadClassForCollectionMembers)
TempEntityLoaderback to summary
public TempEntityLoader(URL[] urls, ClassLoader parent, Collection<E> classNames)

Method Detail

getResourcesback to summary
public Enumeration<URL> getResources(String name) throws IOException

Overrides java.lang.ClassLoader.getResources.

Doc from java.lang.ClassLoader.getResources.

Finds all the resources with the given name. A resource is some data (images, audio, text, etc) that can be accessed by class code in a way that is independent of the location of the code.

The name of a resource is a /-separated path name that identifies the resource.

Resources in named modules are subject to the encapsulation rules specified by Module.getResourceAsStream. Additionally, and except for the special case where the resource has a name ending with ".class", this method will only find resources in packages of named modules when the package is opened unconditionally (even if the caller of this method is in the same module as the resource).

Parameters
name:String

The resource name

Returns:Enumeration<URL>

An enumeration of URL objects for the resource. If no resources could be found, the enumeration will be empty. Resources for which a URL cannot be constructed, are in a package that is not opened unconditionally, or access to the resource is denied by the security manager, are not returned in the enumeration.

Annotations
@Override
Exceptions
IOException:
If I/O errors occur
loadClassback to summary
protected synchronized Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException

Overrides java.lang.ClassLoader.loadClass.

Doc from java.lang.ClassLoader.loadClass.

Loads the class with the specified binary name. The default implementation of this method searches for classes in the following order:

  1. Invoke findLoadedClass(String) to check if the class has already been loaded.

  2. Invoke the loadClass method on the parent class loader. If the parent is null the class loader built into the virtual machine is used, instead.

  3. Invoke the findClass(String) method to find the class.

If the class was found using the above steps, and the resolve flag is true, this method will then invoke the resolveClass(Class) method on the resulting Class object.

Subclasses of ClassLoader are encouraged to override findClass(String), rather than this method.

Unless overridden, this method synchronizes on the result of getClassLoadingLock method during the entire class loading process.

Parameters
name:String

The binary name of the class

resolve:boolean

If true then resolve the class

Returns:Class<?>

The resulting Class object

Annotations
@Override
Exceptions
ClassNotFoundException:
If the class could not be found
shouldOverrideLoadClassback to summary
protected boolean shouldOverrideLoadClass(String name)