tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject [CONF] OpenEJB 3.0.x documentation > Application discovery via the classpath
Date Tue, 01 Sep 2009 18:18:00 GMT
    <base href="">
            <link rel="stylesheet" href="/confluence/s/1519/1/1/_/styles/combined.css?spaceKey=OPENEJBx30&amp;forWysiwyg=true"
<body style="background-color: white" bgcolor="white">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
     <h2><a href="">Application
discovery via the classpath</a></h2>
     <h4>Page <b>edited</b> by             <a href="">David
     <div class="notificationGreySide">
         <p>This document details the various ways to get OpenEJB to pickup applications
you'd like deployed while in an embedded mode.</p>

<h1><a name="Applicationdiscoveryviatheclasspath-Emptyejbjar.xmlapproach%28recommended%29"></a>Empty
ejb-jar.xml approach (recommended)</h1>

<p>Simplify the issue of searching for annotated applications by adding an ejb-jar.xml
like this to your app:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader"
style="border-bottom-width: 1px;"><b>"META-INF/ejb-jar.xml</b></div><div
class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;ejb-jar/&gt;</span>

<p>OpenEJB will find the app in the classpath and deploy it along with any annotated
beans it may contain.</p>

<p>The ejb-jar.xml can contain more than just "&lt;ejb-jar/&gt;" as usual.</p>

<p>This is the recommended approach for people using OpenEJB for unit testing as it
allows OpenEJB to find your application in the classpath without the need for you to specify
any path information which tends to complicate builds.</p>

<h1><a name="Applicationdiscoveryviatheclasspath-Including%2FExcludingpaths%28advanced%29"></a>Including/Excluding
paths (advanced)</h1>

<p>If you do not like the idea of having the ejb-jar.xml in your app or an openejb.xml,
we can search the classpath for annotated beans (@Stateless, @Stateful, @MessageDriven) and
load them automatically just as if they contained an ejb-jar.xml.</p>

<p>This form of searching, however, is very expensive as it involves iterating over
every path in the classpath and reading in each class definition contained thereunder and
checking it for annotations.</p>

<p>This approach can only be made faster by helping us trim down or pinpoint the paths
we should search via the <b>openejb.deployments.classpath.include</b> property
which can be specified as a <em>system property</em> or a property passed into
the <em>InitialContext</em>.  </p>

<p>The value of this property is a regular expression and therefore can be absolute
or relative.  For example the path "/Users/dblevins/work/swizzle/swizzle-stream/target/classes"
which contains the class files of an application you wish to test could be included in any
of the following values to the "openejb.deployments.classpath.include" property:</p>

<ul class="alternate" type="square">
	<li>"file:///Users/dblevins/work/swizzle/swizzle-stream/target/classes/"  <em>(an
absolute path)</em></li>
	<li>"file:///Users/dblevins/work/swizzle/.*"                              <em>(relative)</em></li>
       <em>(very relative)</em></li>
       <em>(including several paths)</em></li>

<p>Note the filtering is done on URLs in the classpath, so forward slashes should always
be used even on OSs using backslash ("\").</p>

<p>There is an <b>openejb.deployments.classpath.exclude</b> property if
you wish to work in the opposite direction.  The default values for both properties are as

<p>  openejb.deployments.classpath.include=""  <em>//include nothing</em><br/>
  openejb.deployments.classpath.exclude=".*"  <em>//exclude everything</em></p>

<p>The exclude and the include is applied separately and the results of each are combined
together to create the list of paths OpenEJB will scrape for annotations.</p>

     <div id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;">
            <a href=""
class="grey">Change Notification Preferences</a>

       <a href="">View
       <a href="">View
       <a href=";showCommentArea=true#addcomment">Add

View raw message