tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] OpenEJB 3.0.x documentation > Application discovery via the classpath
Date Fri, 11 Sep 2009 21:38:00 GMT
<html>
<head>
    <base href="http://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1519/1/1/_/styles/combined.css?spaceKey=OPENEJBx30&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background-color: white" bgcolor="white">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
     <h2><a href="http://cwiki.apache.org/confluence/display/OPENEJBx30/Application+discovery+via+the+classpath">Application
discovery via the classpath</a></h2>
     <h4>Page <b>edited</b> by             <a href="http://cwiki.apache.org/confluence/display/~dblevins">David
Blevins</a>
    </h4>
     
          <br/>
     <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>
</pre>
</div></div>

<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>
	<li>".&#42;swizzle-stream.&#42;"                                          
       <em>(very relative)</em></li>
	<li>".&#42;(swizzle-stream|swizzle-jira|acme-rocket-app).&#42;"           
       <em>(including several paths)</em></li>
</ul>


<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
follows:</p>

<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>

<p><b>Note</b> by default these settings will only affect which jars OpenEJB
will scan for annotated components when no descriptor is found.  If you would like to use
these settings to also filter out jars to do contain descriptors, set the <b>openejb.deployments.classpath.filter.descriptors</b>
property to <em>true</em>.  The default is <em>false</em>.</p>

     </div>
     <div id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;">
            <a href="http://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
       </div>

       <a href="http://cwiki.apache.org/confluence/display/OPENEJBx30/Application+discovery+via+the+classpath">View
Online</a>
       |
       <a href="http://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=64860&revisedVersion=4&originalVersion=3">View
Change</a>
              |
       <a href="http://cwiki.apache.org/confluence/display/OPENEJBx30/Application+discovery+via+the+classpath?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message