How to import an existing module into existing project

From IHE Wiki
Jump to navigation Jump to search

This section explains, with few steps, how to import an existing module into existing project (Web application).


Steps are detailed below.



Step1 - Check out our existing module from the Forge

You need to check the module out from the Forge. If you are not able to do that, please read section Code control.

When you did it successfully, add this module into your working set (Eclipse), to show inside your application. More details are described in section "Define your Working sets" inside this wiki page .


Step2 - Declare the module in your existing application

Inside the application.xml file (for EAR configuration)

For the application, you need to declare the new module you added. This step will add the module in the EAR application.


To do that, please open the file :


<your_workspace>/<existing-application-name>-ear/earContent/META-INF/application.xml

And add lines, to declare the module you added.

  • If the module is an EJB module, here are the lines add :

  <module>
      <ejb>YOUR_EJB_MODULE_TO_ADD-ejb.jar</ejb>
  </module>
		


  • If the module is a WEB module, here are the lines add :

  <module>
    <web>
      <web-uri>YOUR_WEB_MODULE_TO_ADD-ui.war</web-uri>
      <context-root>/YOUR_CONTEXT_YOU_WANT_TO_REACH_THIS_MODULE</context-root>
    </web>
  </module>
		

/!\ Note : The value you will give to <context-root> will be the way to access to your web module. For example, if your <context-root> is /ProductRegistry , then you will access to this module, going to http://localhost:8080/ProductRegistry


You can see an example of application.xml clicking on that page .



Inside the build.xml file (for building and deployment)

For building and deployment, you have now to update the build.xml file, used by ant.


To do that, please open the file :


<your_workspace>/<existing-application-name>-ear/build.xml

And add a line, to declare the module you added in the application in the building and deploying processes.

Here is the following line to add :


		<ant dir="YOUR_MODULE_TO_ADD" 		target="${target}" inheritAll="false"/>
		

You need to insert it inside the delegate target, the one used for multi-projects building.

/!\ Important note : Please respect the order inside this file :

  • First position is declared the persistence module.
  • Second position are declared the EJB modules.
  • Third position is (are) declared the UI module(s).
  • Last position is declared the EAR module.

For example :

 

    	<!-- Ant target :   delegate -->
	<target name="delegate" description="Build everything">
		
		<property name="target" value="all" />

		<ant dir="SampleGazelle-persistence" 	target="${target}" inheritAll="false"/>
		<ant dir="SampleCommon-ejb" 		target="${target}" inheritAll="false"/>
		<ant dir="SampleTF-ejb" 		target="${target}" inheritAll="false"/>
		<ant dir="YOUR_MODULE_TO_ADD (if EJB)"	target="${target}" inheritAll="false"/>
		<ant dir="SampleGazelle-ui" 		target="${target}" inheritAll="false"/>
		<ant dir="YOUR_MODULE_TO_ADD (if UI)"	target="${target}" inheritAll="false"/>
		<ant dir="SampleGazelle-ear" 		target="${target}" inheritAll="false"/>

	</target>


Inside the read-me.txt file (for documentation)

For documentation, please declare the module you added inside the read-me.txt file inside the EAR project. This file helps developers to understand the application and installation. And if you plug a module to an existing application, then Gazelle developers will need to know that they will have to check it out, to work in this application.


To do that, please open the file :


<your_workspace>/<existing-application-name>-ear/read-me.txt

Add a line, describing the module you added in the application.

For example :

 

     - SampleTF-ejb : This module contains an example of codes from the Technical Framework. Generate a JAR file ready to be loaded in our application.

Inside the persistence.xml file (for mapping with the database), if this is an EJB module and if it contains entities (objects mapped with the database)

If the module you want to add is an EJB module and if it contains entities (objects mapped with the database), then you need to declare it in the Persistence Layer.


To do that, go inside the file :


<your_workspace>/<existing-application-name>-persistence/ejbModule/META-INF/persistence.xml


And add a line :

 

     <jar-file>../<your_existing_module_to_add>-ejb.jar</jar-file>


You can see an example clicking on that page .



Step3 - Check your module is succesfully installed in the application

Deploy your project in JBoss Application Server. For that step, open a console, and from the <your_workspace>/<existing-application-name>-ear directory, launch the ant commands in a console :

  • ant help
  • then follow instructions explaining how execute the targets clean, then all


/!\ Note : When these steps are done, don't forget to take a look to the JBoss deployment logs inside your console. You should see none error.


You can now check that application works with your module :

  • If you added an EJB3 module with entities, check that the tables of your entities have been created in your application database.
  • If you added an EJB3 module with just Java classes/business layer, check that your code is well-called by the application.
  • If you added a Web module with entities, check that the module is reachable from the context path.



Back to the Gazelle Developers Guide homepage.