| Title: HomeBaseDiscussion |
| {note:title=THIS PAGE IS ARCHIVED FOR THE MOMENT AND WILL BE REMOVED LATER. |
| } |
| <a name="HomeBaseDiscussion-Lifein0.9.2"></a> |
| # Life in 0.9.2 |
| |
| Some background on how a 0.9.2 installation behaves. |
| |
| <a name="HomeBaseDiscussion-Basiclayout"></a> |
| ## Basic layout |
| |
| Basically, openejb.base is the source for 100% of all configuration |
| information and third party config files (log4j, castor, instantdb, |
| whatever). This includes finding where the, possibly many, <Deployment> |
| entries in the openejb.conf point. The openejb.home is where the code |
| loading OpenEJB will look for all the OpenEJB libraries. Usually |
| openejb.base is not explicitly set and defaults to the value of |
| openejb.home, so many people are used to only dealing with openejb.home. |
| |
| The point of having and openejb.base and openejb.home was basically to |
| allow several independently configured instances of OpenEJB running on a |
| system (perhaps embedded in Swing apps, in Tomcat, running as a standalone |
| Server, or even in Groovy as Mr. Strachan did!) but without the need to |
| copy all the OpenEJB system libraries everywhere. |
| |
| *openejb.home* |
| * can be set explicitly via a system property. |
| * if not set it default's to user.dir, which is the current working |
| directory. |
| See [source code](http://cvs.openejb.org/viewrep/openejb/openejb-sfnet/src/main/org/openejb/util/FileUtils.java?r=1.7.4.3#l58) |
| |
| *openejb.base* |
| * can be set explicitly via a system property. |
| * If not set it default's to openejb.home. |
| See [source code](http://cvs.openejb.org/viewrep/openejb/openejb-sfnet/src/main/org/openejb/util/FileUtils.java?r=1.7.4.3#l59) |
| |
| *openejb.configuration* |
| * can be set to explicitly point to the file containing your |
| configuration. |
| * If set to a relative path, we first look in user.dir/your-conf-file, |
| then in openejb.base/your-conf-file |
| * If not set we check in openejb.base/conf/openejb.conf |
| * If no conf file is found, we create one in |
| openejb.base/conf/openejb.conf |
| See [source code](http://cvs.openejb.org/viewrep/openejb/openejb-sfnet/src/facilities/org/openejb/alt/config/ConfigUtils.java?r=1.21.2.1#l269) |
| |
| |
| *relative paths in openejb.conf* |
| * Deployment entries are resolved relative to openejb.base. [source code](http://cvs.openejb.org/viewrep/openejb/openejb-sfnet/src/facilities/org/openejb/alt/config/ConfigurationFactory.java?r=1.22.2.1#l969) |
| * Containers (such as the Castor CMP Container) use openejb.base to |
| resolve their own config files. Kind of an [ugly hack| |
| http://cvs.openejb.org/viewrep/openejb/openejb-sfnet/src/facilities/org/openejb/alt/containers/castor_cmp11/CastorCMP11_EntityContainer.java?r=1.16.2.6#l404] |
| to get Castor JDO to load the database.xml and all other files from the |
| right place, but it works. |
| * Resource adapters that are embedded usually have config files of their |
| own and are also loaded from the openeb.base. See [code](http://cvs.openejb.org/viewrep/openejb/openejb-sfnet/src/facilities/org/openejb/resource/jdbc/JdbcManagedConnectionFactory.java?r=1.7#l71) |
| . Again that could be done better. |
| |
| Note: Both Containers and Resources are what OpenEJB thinks of as [Services](http://cvs.openejb.org/viewrep/openejb/openejb-sfnet/src/main/org/openejb/spi/Service.java?r=1.2#l47) |
| which have an init method. In hindsight, both hacks to the JDBC Resouces |
| Adapter and Castor CMP Container could be removed if we simply guaranteed |
| that a Service's init method is called "relative" to the openejb.base dir. |
| |
| *log files* |
| * The log4.configuration file is resolved relative to openejb.base. See [code](http://cvs.openejb.org/viewrep/openejb/openejb-sfnet/src/main/org/openejb/util/Logger.java?r=1.11.4.3#l1601) |
| * The properties in the config file that point to files are also resolved |
| relative to openejb.base. See [code](http://cvs.openejb.org/viewrep/openejb/openejb-sfnet/src/main/org/openejb/util/Logger.java?r=1.11.4.3#l1632) |
| |
| *OpenEJB libraries* |
| * The jars in the [lib and dist](http://cvs.openejb.org/viewrep/openejb/openejb-sfnet/src/server/org/openejb/server/Main.java?r=1.3) |
| directories under openejb.home are [added to the classpath|http://cvs.openejb.org/viewrep/openejb/openejb-sfnet/src/main/org/openejb/util/ClasspathUtils.java?r=1.5.2.1#l95] |
| . |
| |
| <a name="HomeBaseDiscussion-Summary"></a> |
| ## Summary |
| |
| A summary of the above in a different notation: |
| |
| |
| openejb.home = user.dir (can be set explicitly) |
| openejb.base = openejb.home (can be set explicitly) |
| openejb.conf = openejb.base/conf/openejb.conf (can be set explicitly) |
| logging.conf = openejb.base/conf/logging.conf (can be set explicitly) |
| deployments = paths listed in openejb.conf (relative paths resolved from |
| openejb.base) |
| Classpath includes openejb.home/lib and openejb.home/dist |
| |
| |
| <a name="HomeBaseDiscussion-Examplelayout"></a> |
| ## Example layout |
| |
| In this one the openejb.home and openejb.base are set, everything else is |
| defaulted. The openejb.conf file as been updated to point to the ejb jars |
| by name (abc-ejbs.jar and xyz-ejbs.jar). |
| |
| An example layout: |
| |
| /usr/local/openejb (openejb.home) |
| /usr/local/openejb/lib (in classpath) |
| /usr/local/openejb/dist (in classpath) |
| /home/jsmith/foo_app (openejb.base) |
| /home/jsmith/foo_app/conf/openejb.conf |
| /home/jsmith/foo_app/conf/logging.conf |
| /home/jsmith/foo_app/abc-ejbs.jar (Deployment entry in openejb.conf) |
| /home/jsmith/foo_app/xyz-ejbs.jar (Deployment entry in openejb.conf) |
| /home/jsmith/foo_app/logs/ |
| |
| |
| |
| <a name="HomeBaseDiscussion-AnotherExamplelayout"></a> |
| ## Another Example layout |
| |
| In this example openejb.home and openejb.base are setup as well as the |
| explicit paths for the openejb and log4j configuration files. |
| |
| An example layout: |
| |
| /usr/local/openejb (openejb.home) |
| /usr/local/openejb/lib (in classpath) |
| /usr/local/openejb/dist (in classpath) |
| /home/jsmith/foo_app (openejb.base) |
| /home/jsmith/foo_app/openejb.xml (openejb.configuration) |
| /home/jsmith/foo_app/abc-ejbs.jar (Deployment entry in openejb.xml) |
| /home/jsmith/foo_app/xyz-ejbs.jar (Deployment entry in openejb.xml) |
| /home/jsmith/foo_app/log4j.conf (log4j.configuration) |
| /home/jsmith/foo_app/mylogs/ (logging dir as defined in log4j.conf) |
| |
| |
| <a name="HomeBaseDiscussion-PossibleandniceTomcatsetup."></a> |
| ## Possible and nice Tomcat setup. |
| |
| Set openejb.base to be the same as catalina.home, then OpenEJB and Tomcat |
| will share the same conf and logs directories. |
| |
| <a name="HomeBaseDiscussion-CurrentOpenEJB1.0layout"></a> |
| # Current OpenEJB 1.0 layout |
| |
| In the current 1.0 code, user.dir and openejb.home and openejb.base are |
| essentially aggregated together to create a larger layout for a single |
| running OpenEJB instance. See [code](http://cvs.openejb.org/viewrep/openejb/openejb1/modules/core/src/java/org/openejb/util/FileUtils.java?r=1.4#l267) |
| |
| *openejb.home* |
| * can be set explicitly via a system property. |
| * if not set it default's to user.dir, which is the current working |
| directory. |
| Same as 0.9.2 |
| |
| *openejb.base* |
| * can be set explicitly via a system property. |
| * If not set it default's to openejb.home. |
| Same as 0.9.2 |
| |
| *openejb.configuration* |
| * can be set to explicitly point to the file containing your |
| configuration. |
| * If set to a relative path, we first look in user.dir/your-conf-file, |
| then in openejb.base/your-conf-file, openejb.home/your-conf-file. |
| * If not set we check in openejb.base/conf/openejb.conf, then |
| openejb.home/conf/openejb.conf |
| * If no conf file is found, we create one in |
| openejb.base/conf/openejb.conf |
| |
| *relative paths in openejb.conf* |
| * Deployment entries are resolved relative to openejb.base, then |
| openejb.home. [source code](http://cvs.openejb.org/viewrep/openejb/openejb1/modules/core/src/java/org/openejb/alt/config/ConfigurationFactory.java?r=1.6#l1120) |
| * Containers (such as the Castor CMP Container) use openejb.base to |
| resolve their own config files. (Same as 0.9.2) |
| * Resource adapters are loaded from the openeb.home, not openejb.base as |
| in 0.9.2. See [code](http://cvs.openejb.org/viewrep/openejb/openejb1/modules/core/src/java/org/openejb/resource/jdbc/JdbcManagedConnectionFactory.java?r=1.5#l147) |
| . |
| |
| *log files* |
| * The log4.configuration file is resolved relative to openejb.base, then |
| openejb.home. |
| * Each property in the config file that point to files are also first |
| resolved relative to openejb.base then openejb.home. See [code](http://cvs.openejb.org/viewrep/openejb/openejb1/modules/core/src/java/org/openejb/util/Logger.java?r=1.6) |
| |
| *OpenEJB libraries* |
| * The jars in the directories under openejb.home are added to the |
| classloader. |
| |
| |
| <a name="HomeBaseDiscussion-Example"></a> |
| ## Example |
| |
| An interesting note on this is that the openejb.home is only checked when |
| the file or directory is not found in the openejb.base. So say you had the |
| following entries in your openejb.conf. |
| |
| |
| <Deployment dir="beans" /> |
| <Deployment jar="foobar.jar" /> |
| |
| |
| Then say you have an openejb.home with the following files and directories: |
| |
| |
| /usr/local/openejb (openejb.home) |
| /usr/local/openejb/dist/(multiple jars) |
| /usr/local/openejb/lib/(multiple jars) |
| /usr/local/openejb/conf/openejb.conf |
| /usr/local/openejb/beans/widget.jar |
| /usr/local/openejb/beans/dohickey.jar |
| /usr/local/openejb/beans/gizmo.jar |
| /usr/local/openejb/logs/ (default logging dir) |
| |
| |
| And an openejb.base with the following files and directories: |
| |
| |
| /home/jsmith/foo_app (openejb.base) |
| /home/jsmith/foo_app/conf/openejb.conf (used for this app) |
| /home/jsmith/foo_app/foobar.jar |
| /home/jsmith/foo_app/log4j.conf (log4j.configuration) |
| /home/jsmith/foo_app/logs/ (logging dir as defined in log4j.conf) |
| |
| |
| In this setup you will end up using your own conf file, your own logging |
| file and logs directory. You will get the ejbs from foobar.jar located in |
| your openejb.base and the ejbs from the widget.jar, dohickey.jar, and |
| gizmo.jar files in openejb.home/beans. |
| |
| Let's say that later on you decide you don't like having the foobar.jar |
| listed in your conf file and decide to create a beans dir in your |
| openejb.base and put it there. When you start up your openejb instance it |
| will no longer contain the ejbs from the widget.jar, dohickey.jar, and |
| gizmo.jar files. They are in the openejb.home and the openejb.home is only |
| checked when the file or directory is not found in the openejb.base. By |
| adding a beans directory to your openejb.base you also implicitly removed |
| all the ejbs from openejb.home/beans. |
| |
| By adding to your base you are potentially removing parts of your |
| configuration at the same time. |
| {note} |