可嵌入 EJB 容器配置属性
将以下配置属性用于可嵌入企业 JavaBeans (EJB) 容器。
属性 | 类型 | 缺省值 | 描述 |
---|---|---|---|
com.ibm.websphere.ejbcontainer.cacheSize | java.lang.Long | 2 053 | EJB 高速缓存的存储区数量。 |
com.ibm.websphere.ejbcontainer.cacheSweepInterval | java.lang.Long | 3 000 | EJB 高速缓存扫描的时间间隔,用以确定是否移除条目。 |
com.ibm.websphere.ejbcontainer.inactivePoolCleanupInterval | java.lang.Long | 30 000 | 清除不活动的池之前,清除线程的等待时间(以毫秒计)。 |
com.ibm.websphere.ejbcontainer.passivationDir | java.lang.String | <TempDir> | 钝化有状态 Bean 的目录。用户必须具有对指定目录的读和写访问权。 |
com.ibm.websphere.embeddable.configFileName | java.lang.String | <CurrentWorkingDirectory> /embeddable.properties | 包含可嵌入 EJB 容器属性的属性文件的文件名。处理此文件时,每个属性都将传递到新创建的 EJB 容器,就如同这些属性是以编程方式传递。配置文件中的任何属性将由编程方式传递的属性覆盖。 注意: 还可以在命令行中将此属性指定为系统属性。
|
下表包含数据源的配置属性。每个属性都特定于个别数据源,该数据源允许您使用不同设置来配置多个数据源。将 <data_source_id> 替换为标识要配置的数据源的唯一术语。根据每个数据源的需要,列出部分属性。
属性 | 类型 | 描述 |
---|---|---|
DataSource.<data_source_id>.name | java.lang.String | 必需。Java™ 命名和目录接口 (JNDI) 字符串,由容器用于在可嵌入容器的全局名称空间中绑定此数据源。 此字符串必须与应用程序中使用的 JNDI 查找字符串相匹配。 |
DataSource<data_source_id>.className | java.lang.String | 必需。数据源类的 Java 类名。对于测试,如果 app_server_root/derby/lib/derby.jar 位于 Java 虚拟机类路径上,那么可以使用 Apache Derby。Apache Derby 的受支持数据源类为 org.apache.derby.jdbc.EmbeddedConnectionPoolDataSource 和 org.apache.derby.jdbc.EmbeddedXADataSource。 |
DataSource.<data_source_id>.connectionSharing | java.lang.String | 有关共享连接的策略。有效值为 MatchOriginalRequest(缺省值)、MatchCurrentState 或 None。MatchOriginalRequest 意味着,如果连接请求与现有连接的原始请求设置相匹配,那么连接请求可能共享。MatchCurrentState 意味着,如果连接请求与现有连接的当前设置相匹配,那么连接请求可能共享。None 意味着,多个连接请求未共享相同连接。 |
DataSource.<data_source_id>.databaseName | java.lang.String | 此数据源连接到的数据库的名称。 |
DataSource.<data_source_id>.isolationLevel | java.lang.Integer | 此数据源中连接的事务隔离级别。如果未指定,那么缺省值是由 JDBC 驱动程序或数据库提供。 有效值为 1(表示未落实读)、2(表示已落实读)、4(表示可重复读)或 8(表示序列化)。 这些值来自 java.sql.Connection 中的常量,并且可以更改。 |
DataSource.<data_source_id>.maxIdleTime | java.lang.Integer | 连接池可以在多少秒之后关闭未使用的连接。 |
DataSource.<data_source_id>.maxPoolSize | java.lang.Integer | 为此数据源创建的最大连接数。在使用此数目的并发连接之后,将阻止用于从此数据源获取连接的将来请求,直至一个或多个正在使用的连接已返回到池中。 |
DataSource.<data_source_id>.maxStatements | java.lang.Integer | 由连接池高速缓存的语句的最大数量。此值除以 maxPoolSize 值以确定可以为池中每个连接高速缓存的语句数量。值 0 将禁用语句高速缓存。 |
DataSource.<data_source_id>.minPoolSize | java.lang.Integer | 要在此数据源的连接池中保留的最大连接数。如果未在使用任何连接,那么连接池必须废弃连接,直至池大小达到此设置。此设置必须为非负数。 |
DataSource.<data_source_id>.password | java.lang.String | 访问数据库时给定用户的密码。与先前属性相同的是,如果数据库未启用安全性或者如果在创建连接时以编程方式提供了用户名和密码,那么可以省略此属性。 |
DataSource.<data_source_id>.transactional | java.lang.Boolean | 此数据源是否必须列在 Java 事务 API (JTA) 事务中。 有效值为 true(缺省值)或 false。 |
DataSource.<data_source_id>.user | java.lang.String | 用于访问数据库的用户名。如果数据库未启用安全性或者如果在创建连接时以编程方式提供了用户名和密码,那么可以省略此属性。 |
DataSource.<data_source_id>.<vendor_property_name _or_connection_pool_property_name> | java.lang.String | 您还可以配置其他属性:
|
DataSource.<data_source_id>.xaRecoveryPassword | java.lang.String | 仅适用于 XA 数据源。用于 XA 恢复的密码。 |
DataSource.<data_source_id>.xaRecoveryUser | java.lang.String | 仅适用于 XA 数据源。某些数据库需要具有特殊特权(用于 XA 恢复)的用户。使用此属性来指定用于 XA 恢复的用户名,而不是使用缺省用户。 |
使用以下属性来配置两个数据源。
DataSource.ds1.name=env/jdbc/ds1
DataSource.ds1.className=org.apache.derby.jdbc.EmbeddedConnectionPoolDataSource
DataSource.ds1.transactional=true
DataSource.ds1.createDatabase=create
DataSource.ds1.databaseName=jtest1
DataSource.ds1.user=dbuser1
DataSource.ds1.password=dbpwd1
DataSource.ds1.maxPoolSize=5
DataSource.ds2.name=env/jdbc/ds2
DataSource.ds2.className=org.apache.derby.jdbc.EmbeddedXADataSource
DataSource.ds2.connectionSharing=MatchOriginalRequest
DataSource.ds2.createDatabase=create
DataSource.ds2.databaseName=jtest2
DataSource.ds2.user=dbuser2
DataSource.ds2.password=dbpwd2
DataSource.ds2.maxPoolSize=10
DataSource.ds2.minPoolSize=1
DataSource.ds3.name=env/jdbc/ds3
DataSource.ds3.className=com.ibm.db2.jcc.DB2XADataSource
DataSource.ds3.driverType=4
DataSource.ds3.databaseName=DB2COPY1
DataSource.ds3.serverName=mydb2.test.ibm.com
DataSource.ds3.portName=50000
DataSource.ds3.user=dbuser1
DataSource.ds3.password=dbpwd1
第一个数据源 ds1 在名称空间中以名称 env/jdbc/ds1 来绑定,并且最多为 Apache Derby 数据库的五个连接提供连接池。 第二个数据源 ds2 在 env/jdbc/ds2 的名称空间中提供,并且为 Apache Derby 数据库提供符合 XA 的连接池。
- 将 <app> 替换为应用程序名称。
缺省情况下,应用程序名称为空字符串。但是,在调用 createEJBContainer 时,可以使用 EJBContainer.APP_NAME 属性来指定应用程序名称。
- 将 <module> 替换为模块名称。
模块名称或者在 ejb-jar.xml 中指定为 <module-name>(是不带“.jar”后缀的 JAR 文件名称),或者是包含该模块的目录的名称。
- 将 <ejb> 替换为 EJB 的名称。
EJB 的名称在 ejb-jar.xml 中指定为 <ejb-name>,或者在使用注释时使用 name 元素指定;例如,@Stateless(name="TestBean")。如果 EJB 注释中未指定名称,那么将使用简单类名;例如,TestBean 表示类 com.ibm.test.TestBean。
- 将 <interceptor> 替换为拦截器类的名称。
- 将 <ref> 替换为资源引用、EJB 引用或环境条目的名称。
引用可以在 ejb-jar.xml 中指定;例如,<res-ref-name>jdbc/mydsref</res-ref-name>,或 <ejb-ref-name>java:module/env/myejbref</ejb-ref-name>。或者,可以使用注释来指定引用;例如 @Resource(name="jdbc/mydsref") 或 @EJB(name="java:module/env/myenvref")。
如果启动可嵌入容器时未指定应用程序名称,那么必须省略 <app>。但是,您必须使用 # 定界符。例如,Bean.#<module>#<bean>.ResourceRef.BindingName。
属性 | 类型 | 描述 |
---|---|---|
Bean.<app>#<module>#<ejb>.ResourceRef.BindingName.<ref> 或 Interceptor.<app>#<module>#<interceptor>.ResourceRef.BindingName.<ref> | java.lang.String | 当查找或插入资源引用时要使用的 JNDI 字符串。此字符串必须是已配置数据源的 JNDI 名称。 |
Bean.<app>#<module>#<ejb>.EJBRef.BindingName.<ref-name> 或 Interceptor.<app>#<module>#<interceptor>.EJBRef.BindingName.<ref> | java.lang.String | 当查找或插入 EJB 引用时要使用的 JNDI 字符串。此字符串必须是可嵌入 EJB 容器中 EJB 的 java:global、java:app 或 java:module JNDI 字符串。 |
Bean.<app>#<module>#<ejb>.EnvEntry.Value.<ref-name> 或 Interceptor.<app>#<module>#<interceptor>.EnvEntry.Value.<ref> | java.lang.String | 当查找或插入环境条目时要使用的值。此属性覆盖 env-entry-value 指定的值。 此值必须对环境条目的类型有效。 |
Bean.<app>#<module>#<ejb>.EnvEntry.BindingName.<ref> 或 Interceptor.<app>#<module>#<interceptor>.EnvEntry.BindingName.<ref> | java.lang.String | 当查找或插入环境条目时要使用的 JNDI 字符串。此字符串必须是同一可嵌入 EJB 容器中其他环境条目的 java:global、java:app 或 java:module JNDI 字符串。 |
Bean.<app>#<module>#<ejb>.DataSource.BindingName.<ref> 或 Interceptor.<app>#<module>#<interceptor>.DataSource.BindingName.<ref> | java.lang.String | 当查找或插入数据源时要使用的 JNDI 字符串。此字符串必须是已配置数据源的 JNDI 名称,或者是同一可嵌入 EJB 容器中其他数据源的 java:global、java:app 或 java:module JNDI 字符串。应用程序开发者应使用资源引用,而非直接查找数据源。如果对应用程序编写代码以直接查找数据源,那么您可以使用此属性来覆盖应用程序中包含的数据源定义。请参阅信息中心以获取有关数据源定义的更多信息。 |
使用以下属性来为具有两个引用的 EJB 和具有环境条目的拦截器配置绑定。
Bean.#TestModule#TestBean.ResourceRef.BindingName.jdbc/dsref=env/jdbc/ds1
Bean.#TestModule#TestBean.EJBRef.BindingName.ejb/Cart=java:global/CartModule/CartBean
Interceptor.#TestModule#com.ibm.example.LoggerInterceptor.EnvEntry.Value.logFile=/tmp/output.log

Bean.#TestModule#TestBean.DataSource.BindingName.java\:module/env/TestDataSource=jdbc/MyDataSource
gotchaProperty | Type | Default value | Description |
---|---|---|---|
com.ibm.websphere.securityEnabled | java.lang.String | false | Determines whether security roles are checked. Valid values are false (default) or true. If true, then security roles are checked; if false, then security roles are not checked. |
role.<role_name> | java.lang.String | Maps an EJB role to one or more users. The <role_name> is a role assigned to a method, either through the annotation @RolesAllowed or through the deployment descriptor <method-permission>. The value is a string of comma-delimited user names, for example “bob, mary, john”. The users in the list are allowed to run methods that require the <role_name>. | |
role.runAs.<role_name> | java.lang.String | Maps one EJB role to one user. The <role_name> is a role assigned to a bean or method, either through the annotation @RunAs or through the deployment descriptor <run-as>. The value is a single user name. The user name is used for any authorization that is required by the bean while it is running. | |
user.invocation | java.lang.String | Defines the user that might be used for authorization when the bean is invoked. The value is a single user name. The container checks that this user is mapped to a role that is allowed to run any executed method. |
The following table contains configuration properties for the Local Transaction Containment (LTC) behavior. For an explanation of LTC, read about local transaction containment. Each property is specific to a bean.
If an application name is not specified when launching the embeddable container, the <application_name> must be omitted. However, you must use the # delimiter. For example, Bean.#<module_name>#<bean_name>LocalTransaction.Resolver.
Property | Type | Default value | Description |
---|---|---|---|
Bean.<application_name>#<module_name>#<bean_name>.LocalTransaction.Resolver | java.lang.String | Application | Determines the entity that is responsible for local transaction resolution. Valid values are Application (default) or ContainerAtBoundary. |
Bean.<application_name>#<module_name>#<bean_name>.LocalTransaction.UnresolvedAction | java.lang.String | Rollback | Determines the action taken for unresolved local transactions. Valid values are Rollback (default) or Commit. |
The following table contains configuration properties for XA behavior.
Property | Type | Default value | Description |
---|---|---|---|
com.ibm.websphere.tx.acceptHeuristicHazard | java.lang.String | false | Specifies whether last participant support is enabled for all modules. The default value is false. |
com.ibm.websphere.tx.auditRecovery | java.lang.String | true | Specifies whether recovery processing outputs audit messages, which indicate XA resource and XID processing during recovery. When no audit recovery is specified, only a single recovery message is output along with the number of transactions that are recovered, unless an error occurs. |
com.ibm.websphere.tx.clientInactivityTimeout | java.lang.String | 0 | Specifies the maximum duration, in seconds, between transactional requests. Any period of client inactivity that exceeds this timeout value results in the transaction being rolled back. The default setting, 0, means that no limit exists. |
com.ibm.websphere.tx.enableLoggingForHeuristicReporting | java.lang.String | false | This property enables logging for heuristic reporting. If last participant support is enabled, reporting of heuristic outcomes that might occur when the server becomes unavailable requires additional information to be written to the transaction log. If enabled, one additional log write is completed for any transaction that involves both one-phase and two-phase commit resources. No additional records are written for transactions that do not involve a one-phase commit resource. |
com.ibm.websphere.tx.heuristicRetryLimit | java.lang.String | 0 | Specifies the number of times that the transaction service retries a completion signal such as commit or rollback. Retries occur after a transient exception from a resource manager. The default value, 0, indicates no limit to the number of retries. |
com.ibm.websphere.tx.heuristicRetryWait | java.lang.String | 0 | Specifies the number of seconds that the transaction service waits before retrying a completion signal, such as commit or rollback, after a transient exception from a resource manager. |
com.ibm.websphere.tx.LPSHeuristicCompletion | java.lang.String | ROLLBACK (case insensitive) |
The heuristic completion action to be taken by the transaction service in a transaction with last participant support when the outcome of the one-phase commit resource is unknown. The values ROLLBACK or COMMIT cause the two-phase commit resources to be completed accordingly. The setting, MANUAL, means that the transaction service takes no action and leave the two-phase commit resources in-doubt. The default value is ROLLBACK. |
com.ibm.websphere.tx.maximumTransactionTimeout | java.lang.String | 300 | Specifies, in seconds, the upper limit of the transaction timeout value. This timeout value constrains the upper limit of all other transaction timeout values. |
com.ibm.websphere.tx.totalTranLifetimeTimeout | java.lang.String | 120 | Specifies the default maximum time, in seconds, allowed for a transaction before the transaction service initiates timeout. Any transaction that does not begin completion processing before this timeout occurs is rolled back. |
com.ibm.websphere.tx.tranLogDirectory | java.lang.String | profiles\server name\tranlog | Specifies the name of a directory for this server where the transaction service stores log files for recovery. |
com.ibm.websphere.tx.tranLogSize | java.lang.String | 1024 | Specifies the size, in kilobytes, of transaction log files. The minimum file size is 64KB. The default value sets the file size to 1MB. |