| |
| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
| <HTML> |
| <HEAD> |
| <!-- $PAGETITLE --> |
| <TITLE>OpenEJB - General Configuration</TITLE> |
| <LINK href="http://openejb.apache.org/all.css" rel="stylesheet" type="text/css"> |
| <!--[if IE]><link rel="stylesheet" type="text/css" media="screen, projection" href="openejb.apache.org/ie.css"><![endif]--> |
| |
| <LINK rel="SHORTCUT ICON" href="http://openejb.apache.org/images/favicon.ico"> |
| <SCRIPT language="JavaScript" src="http://cwiki.apache.org/confluence/pages/viewpage.action?spaceKey=OPENEJB&title=functions.js" type="text/javascript"></SCRIPT> |
| <META http-equiv="Content-Type" content="text/html;charset=UTF-8"> |
| </HEAD> |
| <BODY> |
| |
| <!-- Delay the loading of the external javascript file needed for labels (as it takes too long to load and visibly holds loading of the page body) --> |
| <!-- To do this without javascript errors over undefined functions, we need to declare stubs here (that are overrided later by the proper implementations) --> |
| <SCRIPT language="JavaScript" type="text/javascript"> |
| function doAddLabel(hideTextfieldAfterAddParam) |
| { |
| // stub |
| } |
| |
| function onAddLabel() |
| { |
| // stub |
| } |
| |
| function showLabelsInput() |
| { |
| // stub |
| } |
| </SCRIPT> |
| |
| <A name="top"></A> |
| <TABLE class="frameTable" cellpadding="0" cellspacing="0" border="0"> |
| <TR class="Row1"> |
| <TD class="Col1"><IMG alt="" src="http://openejb.apache.org/images/dotTrans.gif"></TD> |
| <TD class="Col2"><IMG alt="" src="http://openejb.apache.org/images/dotTrans.gif"></TD> |
| <TD class="Col3"><IMG alt="" src="http://openejb.apache.org/images/dotTrans.gif"></TD> |
| <TD class="Col4"><IMG alt="" src="http://openejb.apache.org/images/dotTrans.gif"></TD> |
| <TD class="Col5"><IMG alt="" src="http://openejb.apache.org/images/dotTrans.gif"></TD> |
| </TR> |
| <TR class="Row2"> |
| <TD class="Col1"><IMG alt="" src="http://openejb.apache.org/images/dotTrans.gif"></TD> |
| <TD class="Col2"> </TD> |
| <TD class="Col3" id="breadcrumbs"> |
| <!-- $TOP_NAV_BAR --> |
| |
| |
| |
| |
| |
| <A href="../OPENEJB/index.html" title="Index">Home</A> | <A href="../OPENEJB/download.html" title="Download">Download</A> | <A href="../OPENEJB/mailing-lists.html" title="Mailing Lists">Lists</A> | <A href="http://issues.apache.org/jira/browse/OPENEJB" rel="nofollow">Issues</A> |
| </TD> |
| <TD class="Col4"><IMG alt="" src="http://openejb.apache.org/images/dotTrans.gif"></TD> |
| <TD class="Col5"> </TD> |
| </TR> |
| <TR class="Row3"> |
| <TD class="Col1"><IMG alt="" class="Row3Img" id="thinLine" src="http://openejb.apache.org/images/line_sm.gif"></TD> |
| <TD class="Col2"><IMG alt="" class="Row3Img" src="http://openejb.apache.org/images/dotTrans.gif"></TD> |
| <TD class="Col3"><IMG alt="" class="Row3Img" src="http://openejb.apache.org/images/dotTrans.gif"></TD> |
| <TD class="Col4"><IMG alt="" src="http://openejb.apache.org/images/dotTrans.gif"></TD> |
| <TD class="Col5"><IMG alt="" class="Row3Img" src="http://openejb.apache.org/images/dotTrans.gif"></TD> |
| </TR> |
| <TR class="Row4"> |
| <TD class="Col1"> |
| <SPAN id="Navigation"> |
| |
| |
| |
| |
| |
| |
| <H3><A name="Navigation-Overview"></A>Overview</H3> |
| |
| <UL class="alternate" type="square"> |
| <LI><A href="../OPENEJB/index.html" title="Index">Home</A></LI> |
| <LI><A href="../OPENEJB/news.html" title="News">News</A></LI> |
| <LI><A href="../OPENEJB/faq.html" title="FAQ">FAQ</A></LI> |
| <LI><A href="../OPENEJB/download.html" title="Download">Download</A></LI> |
| <LI><A href="index.html" title="Index">Documentation</A></LI> |
| <LI><A href="../OPENEJB/examples.html" title="Examples">Examples</A></LI> |
| <LI><A href="../OPENEJB/mailing-lists.html" title="Mailing Lists">Mailing Lists</A></LI> |
| <LI><A href="../OPENEJB/source-code.html" title="Source Code">Source Code</A></LI> |
| <LI><A href="http://blogs.apache.org/openejb" rel="nofollow">Project Blog</A></LI> |
| </UL> |
| |
| |
| <H3><A name="Navigation-Configuration"></A>Configuration</H3> |
| |
| <UL class="alternate" type="square"> |
| <LI><A href="../OPENEJB/configuration.html" title="Configuration">General</A></LI> |
| <LI><A href="deployments.html" title="Deployments">Deployments</A></LI> |
| <LI><A href="../OPENEJB/containers.html" title="Containers">Containers</A></LI> |
| </UL> |
| |
| |
| <H3><A name="Navigation-Servers"></A>Servers</H3> |
| |
| <UL class="alternate" type="square"> |
| <LI><A href="../OPENEJB/local-server.html" title="Local Server">Local</A></LI> |
| <LI><A href="../OPENEJB/remote-server.html" title="Remote Server">Remote</A></LI> |
| </UL> |
| |
| |
| <H3><A name="Navigation-Integrations"></A>Integrations</H3> |
| |
| <UL class="alternate" type="square"> |
| <LI><A href="../OPENEJB/tomcat.html" title="Tomcat">Tomcat</A></LI> |
| <LI><A href="../OPENEJB/geronimo.html" title="Geronimo">Geronimo</A></LI> |
| <LI><A href="../OPENEJB/webobjects.html" title="WebObjects">WebObjects</A></LI> |
| </UL> |
| |
| |
| <H3><A name="Navigation-Community"></A>Community</H3> |
| |
| <UL class="alternate" type="square"> |
| <LI><A href="../OPENEJB/team.html" title="Team">Team</A></LI> |
| <LI><A href="../OPENEJB/articles.html" title="Articles">Articles</A></LI> |
| <LI><A href="irc://irc.freenode.net/#openejb" rel="nofollow">IRC</A></LI> |
| </UL> |
| |
| |
| <H3><A name="Navigation-RelatedProjects"></A>Related Projects</H3> |
| |
| <UL class="alternate" type="square"> |
| <LI><A href="http://activemq.apache.org/" rel="nofollow">ActiveMQ</A></LI> |
| <LI><A href="http://openjpa.apache.org/" rel="nofollow">OpenJPA</A></LI> |
| <LI><A href="http://cxf.apache.org/" rel="nofollow">CXF</A></LI> |
| </UL> |
| |
| |
| <H3><A name="Navigation-Index"></A>Index</H3> |
| <UL class="alternate" type="square"> |
| <LI><A href="../OPENEJB/space-index.html" title="Space Index">Site Index</A></LI> |
| <LI><A href="space-index.html" title="Space Index">Doc Index</A></LI> |
| </UL> |
| |
| <H3> |
| <A name="Navigation-Feeds"></A> |
| Feeds |
| </H3> |
| |
| <UL class="feeds"> |
| <LI> |
| <A href="http://cwiki.apache.org/confluence/spaces/rss.action?key=OPENEJB&newPages=false"> |
| <IMG src="http://openejb.apache.org/images/rss.gif"></A> |
| <A class="feedsText" href="http://cwiki.apache.org/confluence/spaces/rss.action?key=OPENEJB&newPages=false">Site</A> |
| </LI> |
| |
| <LI><A href="http://cwiki.apache.org/confluence/spaces/blogrss.action?key=OPENEJB"> |
| <IMG src="http://openejb.apache.org/images/rss.gif"></A> |
| <A class="feedsText" href="http://cwiki.apache.org/confluence/spaces/blogrss.action?key=OPENEJB">News</A> |
| </LI> |
| </UL> |
| </SPAN> |
| </TD> |
| <TD class="Col2"> </TD> |
| <TD class="Col3"> |
| <TABLE id="PageHeader" border="0" width="100%"> |
| <TR> |
| <TD> |
| <A href="http://openejb.apache.org/"> |
| <IMG hspace="0" src="http://openejb.apache.org/images/logo_openejb.gif" vspace="0"> |
| </A> |
| </TD> |
| <TD align="right"> |
| <A href="http://www.apache.org/"> |
| <IMG src="http://www.apache.org/images/asf-logo.gif" width="258" height="66"> |
| </A> |
| </TD> |
| </TR> |
| <TR> |
| <TD id="page_title"> |
| <!-- $TITLE --> |
| General Configuration |
| </TD> |
| |
| <TD align="right"> |
| <BR><BR> |
| <!-- Google CSE Search Box Begins --> |
| <FORM id="searchbox_010475492895890475512:_t4iqjrgx90" action="http://www.google.com/cse"> |
| <INPUT type="hidden" name="cx" value="010475492895890475512:_t4iqjrgx90"> |
| <INPUT type="hidden" name="cof" value="FORID:0"> |
| <INPUT name="q" type="text" size="25"> |
| <INPUT type="submit" name="sa" value="Search"> |
| </FORM> |
| <SCRIPT type="text/javascript" src="http://www.google.com/coop/cse/brand?form=searchbox_010475492895890475512:_t4iqjrgx90"></SCRIPT> |
| <!-- Google CSE Search Box Ends --> |
| |
| </TD> |
| </TR> |
| </TABLE> |
| <P> |
| <!-- $BODY --> |
| <DIV id="PageContent"> |
| <H1><A name="GeneralConfiguration-Defaults%2COverridesandOrder"></A>Defaults, Overrides and Order</H1> |
| |
| <P>When booting up OpenEJB for testing via the LocalInitialContextFactory there is quite a bit of flexibility to how things are configured.</P> |
| |
| <P>OpenEJB will function fine with no configuration at all and will happily create things as needed and select defaults for everything. So in a real sense configuration is all about overriding those defaults. There are several places to put your overrides and an a specific order how they are applied. Here they are in order of preference; 1 = highest, 5 = lowest.</P> |
| |
| <OL> |
| <LI>InitialContext properties</LI> |
| <LI>jndi.properties from the classpath</LI> |
| <LI>System properties</LI> |
| <LI>openejb.xml declarations/properties</LI> |
| <LI>service-jar.xml declarations/properties (internal concept, no need to worry about it)</LI> |
| </OL> |
| |
| |
| <P>It opens up some interesting possibilities in how you configure your environment. You could do 100% of your configuration in your test case via InitialContext propertes, or you could do say 80% in a jndi.properties file or openejb.xml file and 20% in your test case via InitialContext properties. You can put 100% of your configuration in a jndi.properties or openejb.xml file and override them via InitialContext properties.</P> |
| |
| <P>You can manage the properties how you wish and there is no need for redundant definitions if you do not want them.</P> |
| |
| <H1><A name="GeneralConfiguration-Whatisconfigurable%3F"></A>What is configurable?</H1> |
| |
| <P>Everything you can configure via an openejb.xml (minus the <Deployment> element) can be configured/overridden via properties. See <A href="configuring-containers-in-tests.html" title="Configuring Containers in Tests">Configuring Containers in Tests</A> and <A href="configuring-datasources-in-tests.html" title="Configuring DataSources in Tests">Configuring DataSources in Tests</A>.</P> |
| |
| <P>Everything in your logging.properties can be configured/overridden via properties. See <A href="configuring-logging-in-tests.html" title="Configuring Logging in Tests">Configuring Logging in Tests</A>.</P> |
| |
| <P>The properties of persistence units declared in a persistence.xml can be configured/overridden via properties. See <A href="configuring-persistenceunits-in-tests.html" title="Configuring PersistenceUnits in Tests">Configuring PersistenceUnits in Tests</A>.</P> |
| |
| <P>OpenEJB has many flags that can also be set as properties. See <A href="http://cwiki.apache.org/confluence/pages/createpage.action?spaceKey=OPENEJBx30&title=OpenEJB%20Properties&linkCreation=true&fromPageId=2851487" class="createlink">OpenEJB Properties</A> for details on those.</P> |
| |
| <H1><A name="GeneralConfiguration-ExampleofusingInitialContextproperties"></A>Example of using InitialContext properties</H1> |
| |
| <DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent"> |
| <PRE class="code-java"> |
| Properties p = <SPAN class="code-keyword">new</SPAN> Properties(); |
| |
| <SPAN class="code-comment">// set the initial context factory |
| </SPAN>p.put(<SPAN class="code-quote">"java.naming.factory.initial "</SPAN>, <SPAN class="code-quote">" org.apache.openejb.client.LocalInitialContextFactory"</SPAN>); |
| |
| <SPAN class="code-comment">// change some logging |
| </SPAN>p.put(<SPAN class="code-quote">"log4j.category.OpenEJB.options "</SPAN>, <SPAN class="code-quote">" debug"</SPAN>); |
| p.put(<SPAN class="code-quote">"log4j.category.OpenEJB.startup "</SPAN>, <SPAN class="code-quote">" debug"</SPAN>); |
| p.put(<SPAN class="code-quote">"log4j.category.OpenEJB.startup.config "</SPAN>, <SPAN class="code-quote">" debug"</SPAN>); |
| |
| <SPAN class="code-comment">// create some resources |
| </SPAN>p.put(<SPAN class="code-quote">"movieDatabase = <SPAN class="code-keyword">new</SPAN>:<SPAN class="code-comment">//Resource?type"</SPAN>, <SPAN class="code-quote">"DataSource"</SPAN>); |
| </SPAN>p.put(<SPAN class="code-quote">"movieDatabase.JdbcDriver "</SPAN>, <SPAN class="code-quote">" org.hsqldb.jdbcDriver"</SPAN>); |
| p.put(<SPAN class="code-quote">"movieDatabase.JdbcUrl "</SPAN>, <SPAN class="code-quote">" jdbc:hsqldb:mem:moviedb"</SPAN>); |
| |
| <SPAN class="code-comment">// override properties on your <SPAN class="code-quote">"movie-unit"</SPAN> persistence unit |
| </SPAN>p.put(<SPAN class="code-quote">"movie-unit.hibernate.dialect "</SPAN>, <SPAN class="code-quote">" org.hibernate.dialect.HSQLDialect"</SPAN>); |
| |
| <SPAN class="code-comment">// set some openejb flags |
| </SPAN>p.put(<SPAN class="code-quote">"openejb.jndiname.format "</SPAN>, <SPAN class="code-quote">" {ejbName}/{interfaceClass}"</SPAN>); |
| p.put(<SPAN class="code-quote">"openejb.descriptors.output "</SPAN>, <SPAN class="code-quote">" <SPAN class="code-keyword">true</SPAN>"</SPAN>); |
| p.put(<SPAN class="code-quote">"openejb.validation.output.level "</SPAN>, <SPAN class="code-quote">" verbose"</SPAN>); |
| |
| InitialContext initialContext = <SPAN class="code-keyword">new</SPAN> InitialContext(p); |
| </PRE> |
| </DIV></DIV> |
| |
| <H1><A name="GeneralConfiguration-Exampleofusingjndi.properties"></A>Example of using jndi.properties</H1> |
| |
| <P>Here's an example of the same properties being specified via a jndi.properties file. This file just needs to be placed in the classpath, not in a subdirectory of a path in the classpath such as META-INF, but at the root of any of the paths in the classpath.</P> |
| |
| <DIV class="code panel" style="border-width: 1px;"><DIV class="codeHeader panelHeader" style="border-bottom-width: 1px;"><B>jndi.properties</B></DIV><DIV class="codeContent panelContent"> |
| <PRE class="code-java"> |
| # set the initial context factory |
| java.naming.factory.initial = org.apache.openejb.client.LocalInitialContextFactory |
| |
| # change some logging |
| log4j.category.OpenEJB.options = debug |
| log4j.category.OpenEJB.startup = debug |
| log4j.category.OpenEJB.startup.config = debug |
| |
| # create some resources |
| movieDatabase = <SPAN class="code-keyword">new</SPAN>:<SPAN class="code-comment">//Resource?type=DataSource |
| </SPAN>movieDatabase.JdbcDriver = org.hsqldb.jdbcDriver |
| movieDatabase.JdbcUrl = jdbc:hsqldb:mem:moviedb |
| |
| # override properties on your <SPAN class="code-quote">"movie-unit"</SPAN> persistence unit |
| movie-unit.hibernate.dialect = org.hibernate.dialect.HSQLDialect |
| |
| # set some openejb flags |
| openejb.jndiname.format = {ejbName}/{interfaceClass} |
| openejb.descriptors.output = <SPAN class="code-keyword">true</SPAN> |
| openejb.validation.output.level = verbose |
| </PRE> |
| </DIV></DIV> |
| |
| <P>Then OpenEJB can be booted via the InitialContext as normal. Properties can still be used to override any of the above properties:</P> |
| |
| <DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent"> |
| <PRE class="code-java"> |
| Properties p = <SPAN class="code-keyword">new</SPAN> Properties(); |
| |
| p.put(<SPAN class="code-quote">"openejb.validation.output.level "</SPAN>, <SPAN class="code-quote">" medium"</SPAN>); |
| |
| InitialContext initialContext = <SPAN class="code-keyword">new</SPAN> InitialContext(p); |
| </PRE> |
| </DIV></DIV> |
| </DIV> |
| </P> |
| </TD> |
| <TD class="Col4"><IMG src="http://openejb.apache.org/images/dotTrans.gif"></TD> |
| <TD class="Col5"> |
| |
| |
| </TD> |
| </TR> |
| <TR class="Row5"> |
| <TD class="Col1"> </TD> |
| <TD class="Col2"> </TD> |
| <TD class="Col3"> |
| <BR> |
| <BR> |
| <IMG width="100%" height="1" src="http://openejb.apache.org/images/line_light.gif"> |
| <TABLE width="100%"> |
| <TR> |
| <TD> |
| <SPAN class="bodyGrey"> |
| <SMALL> |
| <NOTICE><!-- $FOOTER --> |
| Apache OpenEJB is an project of The Apache Software Foundation (ASF) - <A href="http://openejb.apache.org/privacy-policy.html">Website Privacy Policy</A> - |
| </NOTICE> |
| <BR> |
| Site Powered by |
| <A href="http://atlassian.com/">Atlassian</A> |
| <A href="http://atlassian.com/confluence/">Confluence</A> |
| . |
| </SMALL> |
| </SPAN> |
| </TD> |
| <TD align="right"> |
| <A style="color:#999;font-size:small;font-weight:normal;" href="http://cwiki.apache.org/confluence/pages/editpage.action?spaceKey=OPENEJBx30&title=General%20Configuration">[ edit ]</A> |
| </TD> |
| </TR> |
| </TABLE> |
| <BR> |
| </TD> |
| <TD class="Col4"><IMG src="http://openejb.apache.org/images/dotTrans.gif"></TD> |
| <TD class="Col5"> </TD> |
| </TR> |
| </TABLE> |
| |
| <!-- Needed for composition plugin --> |
| <!-- delay the loading of large javascript files to the end so that they don't interfere with the loading of page content --> |
| <SPAN style="display: none"> |
| <SCRIPT type="text/javascript" language="JavaScript" src="http://cwiki.apache.org/confluence/labels-javascript"></SCRIPT> |
| |
| </SPAN> |
| |
| <SCRIPT type="text/javascript"> |
| var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); |
| document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); |
| </SCRIPT> |
| <SCRIPT type="text/javascript"> |
| var pageTracker = _gat._getTracker("UA-2717626-1"); |
| pageTracker._initData(); |
| pageTracker._trackPageview(); |
| </SCRIPT> |
| </BODY> |
| </HTML> |
| |