Ejip.Net requires the use of DataSources for connecting to databases it hosts.  This allows Ejip.Net to manage connections for each customer and make sure they are not overallocated leading to less resources for other customers!  Also, these connection pooling in Ejip.Net is automatically created for each hosting customer, so you do not have to worry about URLs, usernames, passwords, etc.  You just deploy, and go!  This however, does require users of non-standard J2EE DataSources (e.g, Aligo's connection pooling) to perhaps jumps through a hoop or two to deploy their code to Ejip.Net.  Below is a guide that must be followed to connect your Aligo application to an Ejip.Net database, IF YOU USE ALIGO's CONNECTION POOLING ONLY.  If you use EJBs, or regular J2EE DataSources in your application, you are OK and just need to modify the JNDI name of your DataSource lookup.

NOTE: It is recommended that you have two sets of aligo.xml, and web.xml files.  One for your local development environment and one that is modified for deployment settings in Ejip.Net.

Steps
------------------------
1. Copy the directory /aligoconf from the RestaurantGuide you downloaded from Ejip.Net directly under the project folder.

ex: userapps/yourproject/aligoconf

In the aligoconf/lib directory are 2 jars that contain 3 classes: EjipDBConnectionManager, EjipDBConnector, and EjipDBAccessor.  These files will replace the Aligo classes of the same name to ensure connections to the Ejip.Net database are made correctly.  Details are below...  For development, you use local-ejip-dbplugin.jar and once everything works locally, you rebuild with ejip-dbplugin.jar for deployment to Ejip.Net.

2. In your Aligo project's build.xml, add the aligoconf/lib/ejip-dbplugin.jar to the build.xml's <compile> target:


	<javac srcdir="src" destdir="${dist.classes}"> 
        <classpath>         
          
           <pathelement path="${classpath.path}" /> 
           <pathelement location="${m1.jars}/m1.jar"/> 
	   <pathelement location="${m1.jars}/m1framework.jar"/> 
	   <pathelement location="${m1.jars}/xmlrpc.jar"/> 
           <pathelement location="${m1.jars}/xalan.jar"/> 
           <pathelement location="${m1.jars}/xerces.jar"/> 
           <pathelement location="${m1.jars}/servlet.jar"/>

           <!-- Addition for compiling classes for Ejip.Net platform -->
	   <pathelement location="aligoconf/lib/${ejip.dbplugin.jar}" />	   
        </classpath>
      	</javac>

3. Modify the build.properties file to include another property.  The property should be called "ejip.dbplugin.jar"

Add the following:
ejip.dbplugin.jar=local-ejip-dbplugin.jar OR ejip-dbplugin.jar

FOR DEVELOPMENT USE: 		local-ejip-dbplugin.jar
FOR DEPLOYMENT TO EJIP USE: 	ejip-dbplugin.jar


3. In your Aligo project's build.xml, add aligoconf/lib/${ejip.dbplugin.jar} to the <war> target as well:

	<war warfile="tojar/yourprojectname.war" webxml="properties/web.xml">
		<lib dir="${m1.jars}">  
			<include name="m1framework.jar" />
            	 	<include name="pminternallib.jar" />           
        	</lib> 
		<lib dir="tojar"> 
             		<include name="yourprojectname.jar" /> 
        	</lib>    

		<!-- Added to ensure Ejip.Net database connections used correctly -->  
		<lib dir="aligoconf/lib/"> 
             		<include name="${ejip.dbplugin.jar}" /> 
        	</lib>
		<!-- End Ejip.Net addition -->
	
             	<fileset dir="wartemp" /> 
      	</war>

4. In the Ejip.Net Console's Deploy section.  Goto the LIB tab and upload the same /aligoconf/lib/ejip-dbplugin.jar.  At this point (when deploying to Ejip.Net), ejip-dbplugin.jar is in two places, your War's WEB-INF/lib and the standard CLASSPATH /lib.  It must be in both.  Trust me.

5. When developing an Aligo application for deployment to Ejip.Net, you should inherit your DBAccessor classes (e.g, AligoDBAccessor) from net.ejip.aligo.db.EjipDBAccessor.  Also, when developing an Aligo application for deployment to Ejip.Net, you should inherit your DBConnector classes (e.g, AligoDBConnector) from net.ejip.aligo.db.Ejip.DBConnector.

NOTE: Everything will still work fine in development as long as you have the build.properties property ejip.dbplugin.jar=local-ejip-dbplugin.jar!

First, modify the superclass of your AligoConnector to be net.ejip.aligo.db.EjipDBConnector.

Example: 
public class AligoConnector extends net.ejip.aligo.db.EjipDBConnector 

Next, modify the AligoAccessor class to instantiate an EjipDBConnectionManager class rather than working with the AligoDBConnectionManager.  To do this is easy!  3 things to do. You add 1 import statement, and 1 attribute, and change the superclass of your AligoAccessor class:

a. Add Import to AligoAccessor

//Ejip.Net required classes for DB connection management
import net.ejip.aligo.db.*;

b. Add attribute of type EjipDBConnectionManager and initialize it to your AligoConnector classname.

// Ejip.Net required modification.  This overrides the dbPool attribute in the 
// com.aligo.db.DBAccessor ancestor, yet prevents any further code changes in
// this class.  Replace "com.xyz.wireless.data.AligoConnector" with the name of your AligoConnector class.
private EjipDBConnectionManager dbPool = new EjipDBConnectionManager("com.xyz.wireless.data.AligoConnector");

c. Modify the superclass of your AligoAccessor class to net.ejip.aligo.db.EjipDBAccessor

// example change to superclass below:
public class AligoAccessor extends EjipDBAccessor

6. Last, you must make two modifications to aligo.xml to take out database registration information.  There are two things to do:

a. First, remove the <Module> tags of any DBAccessor subclasses you might have.

<Extensions>
	<!-- NO Database DBAccessor module for Ejip.Net -->
	REMOVE THIS --> <Module>com.xyz.wireless.data.AligoAccessor</Module>
	<Module>com.aligo.profile.UAQueryModule</Module>
	<Module>com.aligo.xslt.XSLTModule</Module>
</Extensions> 

b. Second, remove the <Database> element (and everything in it) from you aligo.xml configuration file.

REMOVE THIS --> <Database>...</Database>

If these elements are left in aligo.xml, the M-1 Server will try to configure a database connection, which you do not want since you need to use the Ejip.Net connection pooling.


7. You are ready to work with Ejip.Net's J2EE connection pooling!

