tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] OpenEJB > FAQ
Date Wed, 06 Oct 2010 23:14:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1810/9/1/_/styles/combined.css?spaceKey=OPENEJB&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/OPENEJB/FAQ">FAQ</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~dblevins">David
Blevins</a>
    </h4>
        <br/>
                         <h4>Changes (2)</h4>
                                 
    
<div id="page-diffs">
            <table class="diff" cellpadding="0" cellspacing="0">
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >The short answer is yes.  The basic
approach for all embedding scenarios is to 1) add OpenEJB to your classpath, and 2) construct
your InitialContext using org.apache.openejb.client.LocalInitialContextFactory.  The LocalInitialContextFactory
will boot OpenEJB in your vm and all ejb applications visible in the classpath will be deployed.
See http://openejb.apache.org/embedding-openejb.html for details on how to embed openejb in
your application and IDE.  See [Application discovery via the classpath|OPENEJBx30:Application
discovery via the classpath] for various ways to have your applications discovered.  <br>
<br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">h3.
 Currently I am starting OpenEJB as an embedded service (by performing a lookup of org.apache.openejb.client.LocalInitialContextFactory
in JNDI InitialContext). Is there a way to perform a clean shutdown of this embedded instance?
<br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">If
you don&#39;t mind being tied to some OpenEJB code you could try something like this:
<br>{code} <br>import org.apache.openejb.loader.SystemInstance; <br>import
org.apache.openejb.assembler.classic.Assembler; <br>import org.apache.openejb.assembler.classic.AppInfo;
<br>import org.apache.openejb.OpenEJB; <br> <br>public class Shutdown {
<br>   public static void shutdown() throws Exception { <br>       Assembler assembler
= SystemInstance.get().getComponent(Assembler.class); <br>       for (AppInfo appInfo
: assembler.getDeployedApplications()) { <br>           assembler.destroyApplication(appInfo.jarPath);
<br>       } <br>       OpenEJB.destroy(); <br>   } <br>} <br>{code}
<br> <br></td></tr>
            <tr><td class="diff-unchanged" >h3.  During embedded testing, how
can I externalize all my DataSource configuration?  <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
        </table>
</div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h2><a name="FAQ-%26nbsp%3BGeneral"></a>&nbsp;General</h2>

<p>&nbsp;</p>

<h3><a name="FAQ-WhatspecversiondoesOpenEJBsupport%3F"></a>What spec version
does OpenEJB support?</h3>

<p>OpenEJB supports the Enterprise JavaBeans 3.0 specification and previous versions
2.1, 2.0 and 1.1.</p>

<h3><a name="FAQ-Idon%27tplantouseEJBs%2CsowhywouldIembedOpenEJBintoTomcat."></a>I
don't plan to use EJBs, so why would I embed OpenEJB into Tomcat.</h3>

<p>Adding OpenEJB to Tomcat gives servlets several new Java EE 5 capabilities such as
JPA, JAX-WS, JMS, J2EE Connectors, transactions, and more as well as enhancing the injection
features of Tomcat 6 to now support injection of JavaEE objects like Topics, Queues, EntityManagers,
JMS ConnectionFactories, JavaMail Sessions, as well as simpler data types such as Dates, Classes,
URI, URL, List, Map, Set, Properties, and more.  In the case of Tomcat 5.5 which doesn't support
dependency injection at all, even more is gained.</p>

<h3><a name="FAQ-CanIrunOpenEJBwithaJVMforanyvendor%3F"></a>Can I run OpenEJB
with a JVM for any vendor?</h3>

<p>The Sun, Mac, and IBM vms are regularly tested, however any vm should work.</p>

<h3><a name="FAQ-WhichversionofJavaisrequiredtorunOpenEJB%3F"></a>Which
version of Java is required to run OpenEJB?</h3>

<p>Java versions 5 or 6, aka Java 1.5 or 1.6.</p>

<h3><a name="FAQ-DoIneedApacheMaventoworkwithOpenEJB%3F"></a>Do I need Apache
Maven to work with OpenEJB?</h3>

<p>Definitely not. Most of the examples include both Maven and Ant build files.  OpenEJB
is usable as a plain library, much like an embedded database like Derby, so it is usable in
any application regardless if that application is run via Maven, Ant, Intellij, Eclipse, NetBeans,
JUnit, TestNG, etc.</p>

<h3><a name="FAQ-CanIstartandstopOpenEJBfromanIDE%3FIfyes%2CwhichIDEissupportedbyOpenEJB%3F"></a>Can
I start and stop OpenEJB from an IDE? If yes, which IDE is supported by OpenEJB?</h3>

<p>The short answer is yes.  The basic approach for all embedding scenarios is to 1)
add OpenEJB to your classpath, and 2) construct your InitialContext using org.apache.openejb.client.LocalInitialContextFactory.
 The LocalInitialContextFactory will boot OpenEJB in your vm and all ejb applications visible
in the classpath will be deployed. See <a href="http://openejb.apache.org/embedding-openejb.html"
class="external-link" rel="nofollow">http://openejb.apache.org/embedding-openejb.html</a>
for details on how to embed openejb in your application and IDE.  See <a href="/confluence/display/OPENEJBx30/Application+discovery+via+the+classpath"
title="Application discovery via the classpath">Application discovery via the classpath</a>
for various ways to have your applications discovered. </p>


<h3><a name="FAQ-Duringembeddedtesting%2ChowcanIexternalizeallmyDataSourceconfiguration%3F"></a>During
embedded testing, how can I externalize all my DataSource configuration? </h3>

<p>Create an openejb.xml file in any directory that gets added to your test classpath.
For maven, something that winds up directly under "target/classes/" or "target/test-classes/"
will work just fine.  Then in your test case do this:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
   <span class="code-keyword">protected</span> void setUp() <span class="code-keyword">throws</span>
Exception {
       Properties properties = <span class="code-keyword">new</span> Properties();
       properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,  <span class="code-quote">"org.apache.openejb.client.LocalInitialContextFactory"</span>);

       URL config = <span class="code-keyword">this</span>.getClass().getClassLoader().getResource(<span
class="code-quote">"openejb.xml"</span>);
       properties.setProperty(<span class="code-quote">"openejb.configuration"</span>,
config.toExternalForm());

       initialContext = <span class="code-keyword">new</span> InitialContext(properties);
   }
</pre>
</div></div>
<p>The file itself doesn't have to be called "openejb.xml", you could have a few different
files like that for different testing scenarios each with a name that describes the basic
setup.</p>

<h2><a name="FAQ-ContainerManagedPersistence"></a>Container-Managed Persistence</h2>

<h3><a name="FAQ-WhatenginedoesOpenEJBuseforCMP%3F"></a>What engine does
OpenEJB use for CMP?</h3>

<p>The CMP engine is written as a layer over JPA with OpenJPA doing the persistence
work.</p>

<h3><a name="FAQ-WhatistheformatfortheCMPmappingfiles%3F"></a>What is the
format for the CMP mapping files?</h3>

<p>The standard JPA mapping file and annotations are also used for CMP mappings.</p>

    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/OPENEJB/FAQ">View Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=26471&revisedVersion=23&originalVersion=22">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/OPENEJB/FAQ?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message