eclenhancer command

The entity enhancer tool for Java™ Persistence API (JPA) applications inserts bytecode into an entity class file that supports the JPA provider to manage the state of an entity. Use this command-line tool to enhance entities under the Java™ Persistence API (JPA) 2.1 specification provider, EclipseLink, for WebSphere® Application Server.

JPA with the application server requires that all entity classes be enhanced if you want to manage their state. In a container-managed environment, automated enhancement is provided by the containers. In a Java SE environment, though, no containers manage persistence and you might use this command frequently before packaging application files for testing. After you create the JPA entities, you can run the eclenhancer tool to inject bytecode into the entities before you package the Java archive (JAR) file into the enterprise archive (EAR) file for the application.

Syntax

Before you run the command, you must have a persistence.xml file in the class path, or specify its location in the -persistenceinfo argument. Issue the command from the bin subdirectory of the profile_root directory.

The command syntax is as follows:

[AIX][HP-UX][Linux][Solaris][z/OS]
eclenhancer.sh [arguments] <source> <target>
[Windows]
eclenhancer.bat [arguments] <source> <target>

Parameters

The enhancer accepts the standard set of command-line arguments defined by the configuration framework along with the following required arguments:
  • classpath <path>: Specifies the location of the Java source files to weave: either a directory or a JAR file. If the persistence.xml file is not in this location, you must use the -persistenceinfo attribute to specify the location of the persistence.xml.
If the directory does not match the enhanced class package, the package structure is created beneath the directory. By default, the enhancer overwrites the original .class file.
  • <source>: Specifies the location of the Java source files to weave: either a directory or a JAR file. If the persistence.xml file is not in this location, you must specify the location of the persistence.xml using the -persistenceinfo attribute.
  • <target>: Specifies the output location: either a directory or a JAR file.

Usage

To use the eclenhancer tool, you need to define entities to the JPA specifications, and you must compile the entities. You can run the eclenhancer tool against the entities before you package them into a JAR file. If the entities are already packaged, you can extract the entity class files, run the enhancer, and re-create the JAR file.

To enhance your entities:
  • Verify that your entities are in the class path. Add them if they are not in the class path.
  • Run the eclenhancer command. It is found in profile_root/bin directory.
Messages and errors are logged to the administrative console as specified in the log settings. After you start the eclenhancer command, your files are enhanced.

Examples

To enhance entities that are located in a JAR:

[AIX][HP-UX][Linux][Solaris][z/OS]
$ cd build
/home/user/myproject/build $ ${profile_root}/bin/eclenhancer.sh -persistenceinfo
/home/user/myproject/build/myjar-containing-persistencexml.jar -classpath 
/classpath1;/classpath2 /home/user/myproject/build/myjar-source.jar 
/home/user/myproject/build/myjar-target.jar
[Windows]
C:\myproject\build>%profile_root%\bin\eclenhancer.bat -persistenceinfo c:\myjar-
containing-persistencexml.jar -classpath c:\classpath1;c:\classpath2 c:\myjar-
source.jar c:\myjar-target.jar

Icon that indicates the type of topic Reference topic



Timestamp icon Last updated: March 5, 2017 17:24
File name: rejb_eclenhancer.html