📄 ch07s16.html
字号:
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Container configuration</title><link rel="stylesheet" href="styles.css" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/styles.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets Vimages/callouts/"><link rel="home" href="index.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/index.html" title="JBoss 3.0 Documentation"><link rel="up" href="ch07.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch07.html" title="Chapter 7. Advanced container configuration : use of jboss.xml"><link rel="previous" href="ch07s13.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch07s13.html" title="Declaring an EJB reference"><link rel="next" href="ch07s22.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch07s22.html" title="Web container configuration : use of jboss-web.xml"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><table border="0" cellpadding="0" cellspacing="0" height="65"><tr height="65"><td rowspan="2"><img src="jboss.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/jboss.gif" border="0"></td><td rowspan="2" background="gbar.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/gbar.gif" width="100%" align="right" valign="top"><a href="index.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/index.html"><img src="doc.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/doc.gif" border="0"></a><a href="ch07.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch07.html"><img src="toc.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/toc.gif" border="0"></a><a href="ch07s13.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch07s13.html"><img src="prev.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/prev.gif" border="0"></a><a href="ch07s22.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch07s22.html"><img src="next.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/next.gif" border="0"></a></td></tr><tr></tr></table><div class="section"><a name="d0e2700"></a><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="d0e2700"></a>Container configuration</h2></div></div><p>When you deploy an application, JBoss creates a container for each of your
beans. This container will be used
only for this particular bean. It must be configured according to the type of
the bean (CMP Entity Bean, Stateful
Session Bean, etc.). Different standard configurations are stored in the
standardjboss.xml file. You may provide
additional custom configurations in the jboss.xml file for your application.</p><div class="section"><a name="d0e2705"></a><div class="titlepage"><div><h3 class="title"><a name="d0e2705"></a>Standard Configurations</h3></div></div><p>JBoss currently provides a standard configuration for each type of bean. These
configurations are stored in the
standardjboss.xml file. There are currently 8 standard configurations. If you
don't provide anything else (as we
advise you to do, at least at the beginning), JBoss will automatically choose
the right standard configuration for
your container. The available configurations are the following: <div class="itemizedlist"><ul><li><p><a name="d0e2711"></a>Standard CMP EntityBean</p></li><li><p><a name="d0e2714"></a>Standard BMP EntityBean </p></li><li><p><a name="d0e2717"></a>Standard Stateless SessionBean </p></li><li><p><a name="d0e2720"></a>Standard Stateful SessionBean </p></li><li><p><a name="d0e2723"></a>Standard Message Driven Bean</p></li><li><p><a name="d0e2726"></a>jdk1.2.2 CMP EntityBean </p></li><li><p><a name="d0e2729"></a>jdk1.2.2 BMP EntityBean </p></li><li><p><a name="d0e2732"></a>jdk1.2.2 Stateless SessionBean </p></li><li><p><a name="d0e2735"></a>jdk1.2.2 Stateful SessionBean </p></li></ul></div>
</p><p>The first five ones are to be used in all cases. The four last
ones are deprecated and will disappear in the future.</p><p>They were used if you run JBoss with a jdk1.2.2 JVM as explain below. From now the VM version
is detected and using the five first configurations is the rule.</p></div><div class="section"><a name="d0e2743"></a><div class="titlepage"><div><h3 class="title"><a name="d0e2743"></a>[Deprecated]How do I configure my bean for jdk1.2.2 clients ?</h3></div></div><p>If you run JBoss on a jdk1.3 JVM, but your clients use jdk1.2.2, the standard
configuration won't work (the protocols
are not backward compatible). In this case, you have to force JBoss to use the
corresponding jdk1.2.2 configuration.
You do that by providing a jboss.xml file. This file must be in the META-INF
directory of your jar file, along with
ejb-jar.xml. In the section for your bean, simply add a <configuration-name> tag. Your xml files will look like
this (note that the <ejb-name> tags in the 2 xml files must match)
ejb-jar.xml:
</p><pre class="programlisting">
<ejb-jar>
<enterprise-beans>
<session>
<ejb-name>Bean A</ejb-name>
<home>AHome</home>
<remote>A</remote>
<ejb-class>ABean</ejb-class>
<session-type>Stateful</session-type>
<transaction-type>Container</transaction-type>
</ejb-ref>
</session>
</enterprise-beans>
</ejb-jar>
</pre><p>jboss.xml: </p><pre class="programlisting">
<jboss>
<enterprise-beans>
<session>
<ejb-name>Bean A</ejb-name>
<configuration-name>jdk1.2.2 Stateful SessionBean<configuration-name>
</session>
<enterprise-beans>
</jboss>
</pre></div><div class="section"><a name="d0e2754"></a><div class="titlepage"><div><h3 class="title"><a name="d0e2754"></a>Custom configurations</h3></div></div><p>You may want to provide your own advanced configuration. For example, you may
want to increase the size of your pool,
or use a different instance cache. To do this, you must define your
configuration in jboss.xml in the <container-configurations> tag. Then you have to use your new
configuration in the bean section of your jboss.xml file.
For example, if you want to log calls to your bean, your file will look like
this :
</p><pre class="programlisting">
<jboss>
<enterprise-beans>
<session>
<ejb-name>Bean A</ejb-name>
<configuration-name>Logging Configuration<configuration-name>
</session>
<enterprise-beans>
...
<container-configurations>
<container-configuration>
<container-name>Logging Configuration</container-name>
<call-logging>true</call-logging>
<container-invoker>org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker</container-invoker>
<container-interceptors>
<interceptor>org.jboss.ejb.plugins.LogInterceptor</interceptor>
<!-- CMT -->
<interceptor transaction="Container">org.jboss.ejb.plugins.TxInterceptorCMT</interceptor>
<interceptor transaction="Container" metricsEnabled="true">org.jboss.ejb.plugins.MetricsInterceptor</interceptor>
<interceptor transaction="Container">org.jboss.ejb.plugins.StatefulSessionInstanceInterceptor</interceptor>
<!-- BMT -->
<interceptor transaction="Bean">org.jboss.ejb.plugins.StatefulSessionInstanceInterceptor</interceptor>
<interceptor transaction="Bean">org.jboss.ejb.plugins.TxInterceptorBMT</interceptor>
<interceptor transaction="Bean" metricsEnabled="true">org.jboss.ejb.plugins.MetricsInterceptor</interceptor>
<interceptor>org.jboss.ejb.plugins.SecurityInterceptor</interceptor>
</container-interceptors>
<instance-cache>org.jboss.ejb.plugins.StatefulSessionInstanceCache</instance-cache>
<persistence-manager>org.jboss.ejb.plugins.StatefulSessionFilePersistenceManager</persistence-manager>
<transaction-manager>org.jboss.tm.TxManager</transaction-manager>
<container-invoker-conf>
<RMIObjectPort>4444</RMIObjectPort>
<Optimized>False</Optimized>
</container-invoker-conf>
<container-cache-conf>
<cache-policy>org.jboss.ejb.plugins.LRUEnterpriseContextCachePolicy</cache-policy>
<cache-policy-conf>
<min-capacity>1</min-capacity>
<max-capacity>1</max-capacity>
<overager-period>300</overager-period>
<max-bean-age>600</max-bean-age>
<resizer-period>400</resizer-period>
<max-cache-miss-period>60</max-cache-miss-period>
<min-cache-miss-period>1</min-cache-miss-period>
<cache-load-factor>0.75</cache-load-factor>
</cache-policy-conf>
</container-cache-conf>
</container-configuration>
</container-configurations>
...
</jboss>
</pre></div><div class="section"><a name="d0e2761"></a><div class="titlepage"><div><h3 class="title"><a name="d0e2761"></a>Content of a container configuration</h3></div></div><p>These are the different things you can customize in a <container-configuration> tag in jboss.xml. See the jboss.xml DTD
for
more details:
</p><div class="itemizedlist"><ul><li><p><a name="d0e2767"></a><call-logging> this tag must have a boolean value: true
or false. It tells the container if calls to this bean must be
logged or not. It is set to false in standard configurations.
</p></li><li><p><a name="d0e2770"></a><container-invoker> the container invoker is the entry point to the container. Currently, only the RMI/JRMP container invoker is available.
</p></li><li><p><a name="d0e2773"></a><container-interceptors> the stack of JBoss interceptors for this bean. You can add your custom interceptor here (for expert use only)
</p></li><li><p><a name="d0e2776"></a><instance-pool> the instance pool is a set (a "pool") of
free (ie not currently associated to a context) instances of the
bean. When an instance of the bean is no longer used, it is thrown back to the
pool. This is not used for Stateful Session
Beans, since the instances are not reusable.
</p></li><li><p><a name="d0e2779"></a><instance-cache> the cache contains the instances of a
bean which are currently associated to a context. If it grows too
big, the cache may decide to passivate some of the instances. This is not used
for Stateless Session Beans, since these
are directly reusable after a call.
</p></li><li><p><a name="d0e2782"></a><persistence-manager> the persistence manager is in
charge of storing permanent information in the instance of a bean.
For BMP Entities, it will merely transmit orders to the bean; for Stateful
Sessions and CMP Entities, it has to save the
state of the bean. This is not used for Stateless Session Beans, since they
don't have a state to save.
</p></li><li><p><a name="d0e2785"></a><container-invoker-conf> configuration of the container invoker.
</p><p> There are several elements which can nest within
container-invoker-conf, one of which is <Optimized>. This
controls the behavior of bean method calls within the Java VM in which
jboss is running. If the value of Optimized is "false" then the
container will behave per the EJB spec and all objects passed into and
out of bean remote methods will be marshalled over RMI regardless of
whether the client is running remotely or in the same VM as jboss.</p><p> If the value of Optimized is "true" then objects passed between
bean methods and clients in the jboss java VM will be passed by
reference rather than by value. This is <span class="emphasis"><i>much</i></span>
more efficient (and can result in substantial performance
improvements) but can result in unexpected behavior. For example, if
a bean has a member object and returns that object from a get() method
then the EJB-specified behavior is to make a copy of that object which
is returned over RMI to the caller. Therefore if the caller modifies
the returned object in any way she will modify the copy of the object.
If Optimized is "true" then the caller will modify the original object
per se, rather than a copy.</p><p>Another element is <RMIObjectPort>, it defines the port on which JBoss runs its RMI Server. It has to
be changed when running multiple instances of JBoss on the same server.</p><p>The other elements are specific to Message Driven Beans and are explained in <a href="ch08s20.html#mdb.config.advanced" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch08s20.html#mdb.config.advanced" title="Advanced MDB configuration">the section called “Advanced MDB configuration”</a></p></li><li><p><a name="d0e2800"></a><container-cache-conf> configuration of the cache. See below for more details.
</p></li><li><p><a name="d0e2803"></a><role-mapping-manager>, <security-domain>, <authentication-module> : security options.
See <a href="ch13s78.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch13s78.html" title="JAAS Based Security in JBoss">the section called “JAAS Based Security in JBoss”</a>.</p></li><li><p><a name="d0e2808"></a><container-pool-conf> configuration of the pool. Mainly,
the minimum and maximum size of the pool.
</p></li><li><p><a name="d0e2811"></a>
<commit-option> must be A, B, C, D (from JBoss 2.4). </p><p>
Option A: The container caches the beans state between transactions.
This options assumes that the bean/container is the only one accessing
the persistent data. Therefore the container synchronizes the
memory state from the persistent storage only (via ejbLoad) when
absolutely neccessary (when the state isn't cached yet), that is
before the first business method executes on a found bean or after
the bean is passivated and reactivated to serve another business
method. This behaviour is regardless of wether the business method
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -