blob: 00ec43efc45b11458fad7fa4f69256142be788a9 [file] [log] [blame]
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>4.&nbsp;Configuration Properties</title><base href="display"><link rel="stylesheet" type="text/css" href="css/docbook.css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.76.1"><link rel="home" href="manual.html" title="Apache OpenJPA 2.2 User's Guide"><link rel="up" href="ref_guide_slice.html" title="Chapter&nbsp;13.&nbsp; Slice: Distributed Persistence"><link rel="prev" href="slice_configuration.html" title="3.&nbsp;Usage"><link rel="next" href="ref_guide_integration.html" title="Chapter&nbsp;14.&nbsp; Third Party Integration"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">4.&nbsp;Configuration Properties</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="slice_configuration.html">Prev</a>&nbsp;</td><th width="60%" align="center">Chapter&nbsp;13.&nbsp;
Slice: Distributed Persistence
</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="ref_guide_integration.html">Next</a></td></tr></table><hr></div><div class="section" title="4.&nbsp;Configuration Properties"><div class="titlepage"><div><div><h2 class="title" style="clear: both" id="d5e16863">4.&nbsp;Configuration Properties</h2></div></div></div><div class="toc"><dl><dt><span class="section"><a href="ch29s04.html#d5e16868">4.1. Global Properties</a></span></dt><dd><dl><dt><span class="section"><a href="ch29s04.html#d5e16870">4.1.1. openjpa.slice.DistributionPolicy</a></span></dt><dt><span class="section"><a href="ch29s04.html#d5e16876">4.1.2. openjpa.slice.Lenient</a></span></dt><dt><span class="section"><a href="ch29s04.html#d5e16883">4.1.3. openjpa.slice.Master</a></span></dt><dt><span class="section"><a href="ch29s04.html#d5e16891">4.1.4. openjpa.slice.Names</a></span></dt><dt><span class="section"><a href="ch29s04.html#d5e16899">4.1.5. openjpa.slice.ThreadingPolicy</a></span></dt><dt><span class="section"><a href="ch29s04.html#d5e16925">4.1.6. openjpa.slice.TransactionPolicy</a></span></dt></dl></dd><dt><span class="section"><a href="ch29s04.html#d5e16943">4.2. Per-Slice Properties</a></span></dt></dl></div>
<p>
The properties to configure Slice can be classified in two broad groups.
The <span class="emphasis"><em>global</em></span> properties apply to all the slices, for example,
the thread pool used to execute the queries in parallel or the transaction
manager used to coordinate transaction across multiple slices.
The <span class="emphasis"><em>per-slice</em></span> properties apply to individual slice, for example,
the JDBC connection URL of a slice.
</p>
<div class="section" title="4.1.&nbsp;Global Properties"><div class="titlepage"><div><div><h3 class="title" id="d5e16868">4.1.&nbsp;Global Properties</h3></div></div></div><div class="toc"><dl><dt><span class="section"><a href="ch29s04.html#d5e16870">4.1.1. openjpa.slice.DistributionPolicy</a></span></dt><dt><span class="section"><a href="ch29s04.html#d5e16876">4.1.2. openjpa.slice.Lenient</a></span></dt><dt><span class="section"><a href="ch29s04.html#d5e16883">4.1.3. openjpa.slice.Master</a></span></dt><dt><span class="section"><a href="ch29s04.html#d5e16891">4.1.4. openjpa.slice.Names</a></span></dt><dt><span class="section"><a href="ch29s04.html#d5e16899">4.1.5. openjpa.slice.ThreadingPolicy</a></span></dt><dt><span class="section"><a href="ch29s04.html#d5e16925">4.1.6. openjpa.slice.TransactionPolicy</a></span></dt></dl></div>
<div class="section" title="4.1.1.&nbsp;openjpa.slice.DistributionPolicy"><div class="titlepage"><div><div><h4 class="title" id="d5e16870">4.1.1.&nbsp;openjpa.slice.DistributionPolicy</h4></div></div></div>
<p>
This <span class="emphasis"><em>mandatory</em></span> plug-in property determines how newly
persistent instances are distributed across individual slices.
The value of this property is a fully-qualified class name that implements
<a class="ulink" href="../javadoc/org/apache/openjpa/slice/DistributionPolicy.html" target="_top">
<code class="classname">org.apache.openjpa.slice.DistributionPolicy</code>
</a> interface.
</p>
</div>
<div class="section" title="4.1.2.&nbsp;openjpa.slice.Lenient"><div class="titlepage"><div><div><h4 class="title" id="d5e16876">4.1.2.&nbsp;openjpa.slice.Lenient</h4></div></div></div>
<p>
This boolean plug-in property controls the behavior when one or more slice
can not be connected or unavailable for some other reasons.
If <code class="classname">true</code>, the unreachable slices are ignored. If
<code class="classname">false</code> then any unreachable slice will raise an exception
during startup.
</p>
<p>
By default this value is set to <code class="classname">false</code> i.e. all configured
slices must be available.
</p>
</div>
<div class="section" title="4.1.3.&nbsp;openjpa.slice.Master"><div class="titlepage"><div><div><h4 class="title" id="d5e16883">4.1.3.&nbsp;openjpa.slice.Master</h4></div></div></div>
<p>
The user application often directs OpenJPA to generate primary keys
for persistence instances automatically or from a specific database
sequence. For such primary key value generation strategy where
a database instance is required, Slice uses a designated slice
referred to as <span class="emphasis"><em>master</em></span> slice.
</p>
<p>
The master slice can be specified explicitly via
<code class="classname">openjpa.slice.Master</code> property and whose value is one
of the configured slice names. If this property is not explicitly
specified then, by default, the master slice is the first slice
in the list of configured slice names.
</p>
<p>
</p><div class="warning" title="Warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3>
Currently, there is no provision to use sequence from
multiple slices.
</div><p>
</p>
</div>
<div class="section" title="4.1.4.&nbsp;openjpa.slice.Names"><div class="titlepage"><div><div><h4 class="title" id="d5e16891">4.1.4.&nbsp;openjpa.slice.Names</h4></div></div></div>
<p>
This plug-in property can be used to register the logical slice names.
The value of this property is comma-separated list of slice names.
The ordering of the names in this list is
<span class="emphasis"><em>significant</em></span> because
<a class="link" href="slice_configuration.html#distribution_policy" title="3.3.&nbsp;Implement DistributionPolicy interface">DistributionPolicy</a> and
<a class="link" href="slice_configuration.html#replication_policy" title="3.4.&nbsp;Implement ReplicationPolicy interface">ReplicationPolicy</a> receive
the input argument of the slice names in the same order.
</p>
<p>
If logical slice names are not registered explicitly via this property,
then all logical slice names available in the persistence unit are
registered. The ordering of the slice names in this case is alphabetical.
</p>
<p>
If logical slice names are registered explicitly via this property, then
any logical slice that is available in the persistence unit but excluded
from this list is ignored.
</p>
</div>
<div class="section" title="4.1.5.&nbsp;openjpa.slice.ThreadingPolicy"><div class="titlepage"><div><div><h4 class="title" id="d5e16899">4.1.5.&nbsp;openjpa.slice.ThreadingPolicy</h4></div></div></div>
<p>
This plug-in property determines the nature of thread pool being used
for database operations such as query or flush on individual slices.
The value of the property is a
fully-qualified class name that implements
<a class="ulink" href="http://download.oracle.com/javase/6/docs/api/java/util/concurrent/ExecutorService.html" target="_top">
<code class="classname">java.util.concurrent.ExecutorService</code>
</a> interface.
Two pre-defined pools can be chosen via their aliases namely
<code class="classname">fixed</code> or <code class="classname">cached</code>.
</p>
<p>
The pre-defined alias <code class="classname">cached</code> activates a
<a class="ulink" href="http://download.oracle.com/javase/6/docs/api/java/util/concurrent/Executors.html#newCachedThreadPool()" target="_top">cached thread pool</a>.
A cached thread pool creates new threads as needed, but will reuse
previously constructed threads when they are available. This pool
is suitable in scenarios that execute many short-lived asynchronous tasks.
The way Slice uses the thread pool to execute database operations is
akin to such scenario and hence <code class="classname">cached</code> is the default
value for this plug-in property.
</p>
<p>
The <code class="classname">fixed</code> alias activates a
<a class="ulink" href="http://download.oracle.com/javase/6/docs/api/java/util/concurrent/Executors.html#newFixedThreadPool(int)" target="_top">fixed thread pool</a>.
The fixed thread pool can be further parameterized with
<code class="classname">CorePoolSize</code>, <code class="classname">MaximumPoolSize</code>,
<code class="classname">KeepAliveTime</code> and <code class="classname">RejectedExecutionHandler</code>.
The meaning of these parameters are described in
<a class="ulink" href="http://download.oracle.com/javase/6/docs/api/java/util/concurrent/ThreadPoolExecutor.html" target="_top">JavaDoc</a>.
The users can exercise finer control on thread pool behavior via these
parameters.
By default, the core pool size is <code class="classname">10</code>, maximum pool size is
also <code class="classname">10</code>, keep alive time is <code class="classname">60</code> seconds and
rejected execution is
<a class="ulink" href="http://download.oracle.com/javase/6/docs/api/java/util/concurrent/ThreadPoolExecutor.AbortPolicy.html" target="_top">aborted</a>.
</p>
<p>
Both of the pre-defined aliases can be parameterized with a fully-qualified
class name that implements
<a class="ulink" href="http://download.oracle.com/javase/6/docs/api/java/util/concurrent/ThreadFactory.html" target="_top">
<code class="classname">java.util.concurrent.ThreadFactory</code>
</a> interface.
</p>
</div>
<div class="section" title="4.1.6.&nbsp;openjpa.slice.TransactionPolicy"><div class="titlepage"><div><div><h4 class="title" id="d5e16925">4.1.6.&nbsp;openjpa.slice.TransactionPolicy</h4></div></div></div>
<p>
This plug-in property determines the policy for transaction commit
across multiple slices. The value of this property is a fully-qualified
class name that implements
<a class="ulink" href="http://download.oracle.com/javaee/6/api/javax/transaction/TransactionManager.html" target="_top">
<code class="classname">javax.transaction.TransactionManager</code>
</a> interface.
</p>
<p>
Three pre-defined policies can be chosen
by their aliases namely <code class="classname">default</code>,
<code class="classname">xa</code> and <code class="classname">jndi</code>.
</p>
<p>
The <code class="classname">default</code> policy employs
a Transaction Manager that commits or rolls back transaction on individual
slices <span class="emphasis"><em>without</em></span> a two-phase commit protocol.
It does <span class="emphasis"><em>not</em></span>
guarantee atomic nature of transaction across all the slices because if
one or more slice fails to commit, there is no way to rollback the transaction
on other slices that committed successfully.
</p>
<p>
The <code class="classname">xa</code> policy employs a Transaction Manager that that commits
or rolls back transaction on individual
slices using a two-phase commit protocol. The prerequisite to use this scheme
is, of course, that all the slices must be configured to use
XA-compliant JDBC driver.
</p>
<p>
The <code class="classname">jndi</code> policy employs a Transaction Manager by looking up the
JNDI context. The prerequisite to use this transaction
manager is, of course, that all the slices must be configured to use
XA-compliant JDBC driver.
</p><div class="warning" title="Warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3>This JNDI based policy is not available currently.</div><p>
</p>
</div>
</div>
<div class="section" title="4.2.&nbsp;Per-Slice Properties"><div class="titlepage"><div><div><h3 class="title" id="d5e16943">4.2.&nbsp;Per-Slice Properties</h3></div></div></div>
<p>
Any OpenJPA property can be configured for each individual slice. The property name
is of the form <code class="classname">openjpa.slice.[Logical slice name].[OpenJPA Property Name]</code>.
For example, <code class="classname">openjpa.slice.One.ConnectionURL</code> where <code class="classname">One</code>
is the logical slice name and <code class="classname">ConnectionURL</code> is an OpenJPA property
name.
</p>
<p>
If a property is not configured for a specific slice, then the value for
the property equals to the corresponding <code class="classname">openjpa.*</code> property.
</p>
</div>
</div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="slice_configuration.html">Prev</a>&nbsp;</td><td width="20%" align="center"><a accesskey="u" href="ref_guide_slice.html">Up</a></td><td width="40%" align="right">&nbsp;<a accesskey="n" href="ref_guide_integration.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">3.&nbsp;Usage&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="manual.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;Chapter&nbsp;14.&nbsp;
Third Party Integration
</td></tr></table></div></body></html>