I've put together a how-to on running the same J2EE application, but with
each instance using a different data source, using Orion. It would be nice
if there was a simpler way to do this (particularly in associating data
sources with applications, which causes the bulk of the work).
If the orionsupport.com folks are listening, you have my permission to add
this to your site (just be sure to give credit where due).
Kurt in Atlanta
Title: Running Multiple Application Instances with Orion
Running Multiple Application Instances with Orion
Kurt Hoyt ([EMAIL PROTECTED])
This document assumes you know how to create an EJB .jar file, a web
application's .war file, and a J2EE application's .ear file. All this document
does is describe the changes you need to make in order to run multiple instances
of the same application within the same instance of Orion (one JVM running
on one computer), with each instance using its own data source.
The data-sources.xml file
Create the data source entry in Orions config/data-sources.xml file. Here are the two
data sources I created, one for SQL Server and one for Oracle:
data-source
class="com.evermind.sql.DriverManagerDataSource"
name="SQLServer"
schema="database-schemas/ms-sql.xml"
location="jdbc/SQLServerCoreDS"
xa-location="jdbc/xa/SQLServerXADS"
ejb-location="jdbc/SQLServerDS"
connection-driver="com.inet.tds.TdsDriver"
username="orion"
password="orion"
url="jdbc:inetdae7:SQLServerHost:1433?database=orion"
inactivity-timeout="30"
/
data-source
class="com.evermind.sql.DriverManagerDataSource"
name="Oracle"
schema="database-schemas/oracle.xml"
location="jdbc/OracleCoreDS"
xa-location="jdbc/xa/OracleXADS"
ejb-location=jdbc/OracleDS"
connection-driver="oracle.jdbc.driver.OracleDriver"
username="orion"
password="orion"
url="jdbc:oracle:thin:@OracleHost:1521:orionora"
inactivity-timeout="30"
/
Notice that the ejb-locations are different between the two
data sources. Each data source will need a unique ejb-location (and the other
locations). Notice the naming convention: jdbc/some-nameDS for the
ejb-location, jdbc/some-nameCoreDS for the location, and
jdbc/xa/some-nameXADS for the xa-location (xa = transactional). There
is also a pooled-location that can be used if the data source needs to be
accessed from outside the EJB server (like inside a JSP).
Its the ejb-location that youll need for the orion-ejb-jar.xml file. There will be
a 1:1 relationship between each application instance and its data source.
The orion-ejb-jar.xml file
Once you have a data source set up, you have to tell Orion to use that data source
for the tables it creates for the entity beans in the EJB jar file (which Ill
call myapp-ejb.jar for discussion purposes). You do that by editing the
orion/orion-ejb-jar.xml file that youll put inside the myapp-ejb.jar file.
This means that you will have a different myapp-ejb.jar file for each
application instance, with the only difference being the contents of the
orion-ejb-jar.xml file.
For each entity bean, you tell Orion which data source from the
config/data-sources.xml file to use:
entity-deployment name="Customer" table="Customer" data-source="jdbc/OracleDS"
.
.
.
/entity-deployment
This is the skeleton for the Oracle version of the Content
entity bean deployment. The entity-deployment tag sits inside the
enterprise-beans tag inside the orion-ejb-jar tag inside the
orion-ejb-jar.xml file. Notice the data-source attribute in the
entity-deployment tag. Thats how the connection is made. The
data-source attribute must be set for each entity bean, so each entity bean
must represented with an entity-deployment tag inside the file. For SQL
Server, the same skeleton looks like this:
entity-deployment name="Customer" table="Customer" data-source="jdbc/SQLServerDS"
.
.
.
/entity-deployment
You can see how each version uses a different data source.
I saved the Oracle version in a file called oracle-orion-ejb-jar.xml and the SQL
Server version in a file called sqlserver-orion-ejb-jar.xml. It should be
simple to create some kind of database-neutral skeletons that could be run
through some filter program that would assign the data source for you.
Build the myapp-ejb.jar file
To build the myapp-ejb.jar file, you need to have this directory structure
somewhere:
mypackage/*.class (the EJB remote, home and bean classes)
META-INF/ejb-jar.xml
orion/orion-ejb-jar.xml
Once you have that structure, you can use the jar program to create the EJB jar file:
jar cvf myapp-ejb.j