Using EGit to quickly create an Adapter Module’s EJB & EAR project
Creating an Adapter Module for PI takes a bit of an effort as we have to create the EJB and EAR projects in NWDS and set up all the necessary build paths and deployment descriptor files.
As I start to use EGit/Git to manage my NWDS projects, I’ve come to find different ways it can enhance my workflows. One such area is in setting up template EJB & EAR projects for custom adapter module. There is already other approaches like the blog below is using templates for adapter module projects.
Simple Steps to build an Adapter Module using EJB,EAR template
The benefit of using EGit is that the projects will be automatically version-managed by Git once the template is cloned into NWDS.
Below are the steps on how to quickly set up an adapter module project using template content from GitHub.
The steps below are based on NWDS 7.31. EGit needs to be installed and configured first as detailed in Installation and Initial Configuration sections of the following blog.
Using EGit for Java source code management in NWDS
Step 1 – Clone Git repository from GitHub to NWDS
Go to the Git repository via the link below, and select Copy to clipboard.
engswee/pi-module-template · GitHub
In NWDS, switch to Git perspective – Window > Open Perspective > Other > Git Repository Exploring
Click the Clone Git Repository button
A window will pop up with pre-populated value of the GitHub URL details. Accept the default value and click Next.
It will load the GitHub branch details. Click Next again.
Finally, it will prompt for a destination of the local Git repository. Browse to the appropriate folder and select Finish.
The contents will be downloaded from GitHub to the local Git repository. The screenshot below shows the new (arbitrarily named) Git repository new-module.
Step 2 – Import EJB and EAR projects
The contents in the Git repository already consists of the template EJB and EAR projects for a custom adapter module. This content will need to be imported into NWDS’s project explorer.
Right click on the Git repository and select Import Projects.
Select Import existing projects and click Next.
Select both EJB and EAR projects and click Finish.
After import has completed. Switch to the Java EE perspective and both the EJB and EAR projects will be listed in the Project Explorer.
Step 3 – Refactor project contents
Now just refactor the project contents according to the development naming conventions and requirements.
Rename EAR project.
Update provider name in application-j2ee-engine.xml in EAR project.
Rename EJB project.
Rename package in EJB project.
Rename EJB 3.0 Session Bean.
Rename ejb-j2ee-engine.xml deployment descriptor. Ensure that this matches the name of the session bean above.
Rename ejb-jar.xml deployment descriptor. Ensure that the name and package path matches above changes.
Step 4 – Commit initial content to Git (Optional)
Once all the changes have been done, optionally commit an initial version to the Git repository.
With this, the EJB and EAR projects are now ready for further development according to project requirements.
With this simple and easy steps, we can quickly establish a new custom adapter module project and dive right into the design and development details. We no longer need to remember the details of setting up the project configuration correctly, which can be quite repetitive (which I also find hard to remember at times with so many screens involved).
Once the Git repository is cloned, with just a few refactoring steps, the project is ready for development. Additionally, it benefits from already being tracked by Git.
Can this also work for componets build using the development infrastructure locally.
I haven't tried that myself. Maybe you can give it a try and let us know how it goes?
Nice blog on the deployment... I saw it from a forum post and it gives good direction on all the steps for those that have not done it before. Even a nice refresher for someone that doesn't want to thumb through the 40-45 page guides that are available elsewhere.
Thanks for the comment. Yeah, for someone who is quite absent-minded as I am, I had to keep on referring to the bulky guides each time I wanted to build a module. Now I can get it up and running in a jiffy 🙂