Automated EJB2 To EJB3 Migration: Isha Mittal J.S. Sodhi
Automated EJB2 To EJB3 Migration: Isha Mittal J.S. Sodhi
The artifacts generated by the tool should follow the listed Table name and columns
standards.
Finder methods and queries
EJB3.0 Entity
Entity relationships
o Should list the files that were used to generate the
entity in class level comments. 2.1.2 Identification of Artefacts
o Should contain standard JPA annotations like In this analysis all the artifacts that would be used to
“@Entity”, “@Table”, “@NamedQueries”, aggregate entity attributes was recognized. The following is
“@TransactionAttribute”, “@Column”, “@Id”, the list of such artifacts.
“@SequenceGenerator”, “@GeneratedValue”, and “@Lob” ejb-jar.xml
wherever applicable.
weblogic-cmp-rdbms-jar.xml
o Should list the EJB2.1 deployment descriptor
annotations that are not processed by the tool as “TODO” in weblogic-ejb-jar.xml
class level comments
Local interface corresponding to each entity bean
o Should extend CLBaseEntity<PK Type> and
implement “getCompareables()” and “getPrimaryKey()” Data Transfer Objects corresponding to each entity
methods. bean
o In case of composite primary key, a separate
primary key class should be generated annotated with
“@Embeddable” annotation.
49
International Journal of Computer Applications (0975 – 8887)
Volume 70– No.24, May 2013
Patterns recognized Pattern used to filter jar file that contains DTOs and
local interfaces – “\\D.*-SNAPSHOT.jar$”
o In-case of deployment descriptors each module
contains these xml files in <path>\target\classes\META-INF\
o The corresponding jar file contain the DTOs and The file crawler generates two files after scanning the depths
local interfaces of the entity beans are accessible from of the required directory.
<path>\target\
An xml file (filteredDDPaths.xml) that contains the
2.1.3 Identification of Development absolute paths of the deployment descriptor files for each
Methodologies module.
</module>
<module>
A file (jarPaths.txt) that lists the absolute paths of
<ejb-dd-path>……
the jar files that contain DTOs and local interfaces for each
module. This list would be used to set Java “classpath” and is
a pre-requisite for “Data Transformation”
</project>
50
International Journal of Computer Applications (0975 – 8887)
Volume 70– No.24, May 2013
3.1.2.2 Resources
ejb2-to-ejb3-config.properties – Tool
configuration file
log4j.properties – Tool log4j configuration file
CatalogManager.properties – This file tells the
Figure 3–Data Transformation resolver where to look for catalog files and sets configuration
options.
2.3.1 Meta-data Generation
Xml-catalog.xml – A catalog in XML provides a
This component gathers all the information segregated in mapping from generic addresses to specific local directories
different files for each entity and place it one xml file (entity- on a given machine. A catalog can be used to locate the DTD,
data.xml). XSL transformation would be incorporated to work system entity files, and stylesheet files during processing.
with different xml files and access DTOs present in jar files to
aggregate the data. For each “module” element in ejb-jar_2_0.dtd – DTD used by “ejb-jar.xml”
“filteredDDPaths.xml”, a separate “entity-data.xml” file
would be generated. gcode-constants.xml – This XML file holds
constants that used by XSLT files.
2.3.2 EJB3.0/DAO Code Generation 3.1.3 EJB2 to EJB3
This component uses the meta-data file “entity-data.xml” and
performs an XSL transformation to generate the Java code. 3.1.3.1 Data Artefacts Aggregation
The XSL transformation will generate EJB3.0 entity and it
FileCrawler.java – This component searches a
corresponding DAO objects referencing the generic DAO.
particular directory for certain set of files by making use of
3 IMPLEMENTATION Regular Expression and generates 2 files. The first is an XML
file that contains the absolute paths of the deployment
3.1 Development Modules descriptor files for each module. The second is a text file that
lists the absolute paths of the jar files that contain DTOs and
Eclipse IDE is used for tool development. local interfaces for each module.
3.1.1 3rdParty 3.1.3.2 Data Transformation
Apache Meta-data Generator
o log4j-1.2.16.jar – Application logging o MetadataGenerator.java – This class gathers all
the information segregated in different files for each entity
Saxon-9.1B
and place it one xml file (entity-data-i.xml). XSL
o saxon9-dom.jar – XML document parsing transformation would be incorporated to work with different
xml files and access DTOs present in jar files to aggregate the
o saxon9.jar – XSLT processor data. For each “module” element in “filteredDDPaths.xml”, a
J2EE separate “entity-data-i.xml” file would be generated.
o j2ee-1.4.jar – Required because the tool loads o meta-data-builder.xsl – XSLT file used for meta-
EJB2.1 files (local interfaces) using reflection for scanning data generation
EJB3.0/DAO Code Generator
o CodeGenerator.java – This class uses the meta-
data file “entity-data-i.xml” and performs an XSL
51
International Journal of Computer Applications (0975 – 8887)
Volume 70– No.24, May 2013
3.1.4 Build
3.1.4.1 Ant Build Process
The build process will package the common and EJB2 to Directory/File Description
EJB3 java code in separate jar files. The resources would not
be packaged within the jar file. This would provide flexibility formatter Contains Eclipse IDE
to the user to modify configuration settings without worrying code formatting
about executing the build again. \
preferences file.
ejb2-to-ejb3-tool-build.xml
Tool Base folder for
ejb2-to-ejb3-tool-build.properties
migration tool.
3.2 Execution Process
Lib Contains 3rd party and
The EJB2 to EJB3 migration tool would be executed using a
batch process (ejb2_to_ejb3_tool.bat). The following would
common project jar
be the various stages. files.
Data artefacts aggregation resources Contains
Set java classpath using the jar file paths set in configuration files.
"jarPaths.txt
xslt-files Contains XSL
Data transformation
transformation file.
4 THINGS TO REMEMBER ejb2_to_ejb3_tool.bat Batch file to execute
The following should be considered while integrating the the tool.
generated code.
1. I has been noticed that in the EJB2.1 code, named ejb2-to-ejb3-tool.jar Migration tool jar.
queries use reference to the entity attribute name that do not
match the actual declared variable. Wherever such instances 4.3 Configuration
are encountered, rectify the named query. The tool can be configured by using
2. If a "TODO" related to "The following table column “ejb2_to_ejb3\Utility\resources\ejb2-to-ejb3-
is mapped to an entity field as well as to an entity relationship config.properties” file. It lists different keys that can be set as
attribute" exists; however the related attributes are defined in per project requirements.
separate classes (e.g. Entity and PK class), ignore and remove
this TODO. S. Key Purpose
No
3. After applying fixes for a TODO, it should be
removed from the code. .
4. If an entity exists more than once in the EJB jar, it data.lookup.dir Directory path for
should be distinguished by custom entity name by setting the .path searching the
“name” attribute of “@Entity” annotation.
artifacts.
4.1 Tool 1.
e.g.
4.2 Structure “//ip.address/c$/work
The tool deliverable is in form of a zip archive file “ejb2-to- /flood”
ejb3-migration.zip”. Its structure is as follows.
data.artifacts.di Directory for listing
r.name the filtered artifacts.
2. e.g.
“//ip.address/c$/ejb2_
to_ejb3/artifacts-list-
52
International Journal of Computer Applications (0975 – 8887)
Volume 70– No.24, May 2013
53
International Journal of Computer Applications (0975 – 8887)
Volume 70– No.24, May 2013
code.constants. Location of the xml [2] EJB components Migration Service and Automatic
Deployment – HA
23. file file that holds
constants used in
54
IJCATM : www.ijcaonline.org