简体   繁体   English

GlassFish 4(EJB3)-无状态bean生命周期

[英]GlassFish 4 (EJB3) - stateless bean lifecycle

According to official documentation there are two states of stateless EJB: doesnt-exists and ready. 根据官方文档 ,无状态EJB有两种状态:不存在和就绪。 But that's all it says about lifecycle. 但这就是生命周期的全部内容。

I use glassfish 4 and I need to know exactly 我使用glassfish 4,我需要确切知道

  1. when stateless EJB instance is created - at moment when domain started or when I inject my EJB to some point or? 创建无状态EJB实例时-在域启动时或在某个时候注入EJB时还是?
  2. when non used stateless EJB is destroyed - at moment when domain stopped or after some idle time or? 当未使用的无状态EJB被销毁时-当域停止时或经过一些空闲时间后还是?

Please, help me. 请帮我。

I think it's necessary to read the following glassfish settings from http://docs.oracle.com/cd/E18930_01/html/821-2431/abeea.html : 我认为有必要从http://docs.oracle.com/cd/E18930_01/html/821-2431/abeea.html阅读以下glassfish设置:

The EJB pool settings are: EJB池设置为:

Initial and Minimum Pool Size: the initial and minimum number of beans maintained in the pool. 初始和最小池大小:池中维护的Bean的初始和最小数目。 Valid values are from 0 to MAX_INTEGER, and the default value is 8. The corresponding EJB deployment descriptor attribute is steady-pool-size. 有效值为0到MAX_INTEGER,默认值为8。相应的EJB部署描述符属性为稳定池大小。

Set this property to a number greater than zero for a moderately loaded system. 对于中等负载的系统,将此属性设置为大于零的数字。 Having a value greater than zero ensures that there is always a pooled instance to process an incoming request. 值大于零可确保始终有一个池化实例来处理传入请求。

Maximum Pool Size: the maximum number of connections that can be created to satisfy client requests. 最大池大小:可以创建以满足客户端请求的最大连接数。 Valid values are from zero to MAX_INTEGER., and the default is 32. A value of zero means that the size of the pool is unbounded. 有效值为0到MAX_INTEGER。,默认值为32。零值表示池的大小是无界的。 The potential implication is that the JVM heap will be filled with objects in the pool. 潜在的含义是,JVM堆将在池中填充对象。 The corresponding EJB deployment descriptor attribute is max-pool-size. 相应的EJB部署描述符属性为max-pool-size。

Set this property to be representative of the anticipated high load of the system. 将此属性设置为代表系统预期的高负载。 An very large pool wastes memory and can slow down the system. 很大的池会浪费内存,并会降低系统速度。 A very small pool is also inefficient due to contention. 由于争用,非常小的池也效率很低。

Pool Resize Quantity: the number of beans to be created or deleted when the cache is being serviced by the server. 池调整大小数量:服务器为缓存提供服务时要创建或删除的Bean数。 Valid values are from zero to MAX_INTEGER and default is 16. The corresponding EJB deployment descriptor attribute is resize-quantity. 有效值为0到MAX_INTEGER,默认值为16。相应的EJB部署描述符属性为resize-quantity。

Be sure to re-calibrate the pool resize quantity when you change the maximum pool size, to maintain an equilibrium. 更改最大池大小时,请确保重新校准池调整大小数量,以保持平衡。 Generally, a larger maximum pool size should have a larger pool resize quantity. 通常,较大的最大池大小应具有较大的池调整大小数量。

Pool Idle Timeout: the maximum time that a stateless session bean, entity bean, or message-driven bean is allowed to be idle in the pool. 池空闲超时:允许无状态会话Bean,实体Bean或消息驱动的Bean在池中空闲的最长时间。 After this time, the bean is destroyed if the bean in case is a stateless session bean or a message driver bean. 在此时间之后,如果该bean是无状态会话bean或消息驱动程序bean,则该bean被销毁。 This is a hint to server. 这是对服务器的提示。 The default value is 600 seconds. 默认值为600秒。 The corresponding EJB deployment descriptor attribute is pool-idle-timeout-in-seconds. 对应的EJB部署描述符属性为秒池空闲超时。

If there are more beans in the pool than the maximum pool size, the pool drains back to initial and minimum pool size, in steps of pool resize quantity at an interval specified by the pool idle timeout. 如果池中的bean超过最大池大小,则池将以池空闲超时指定的时间间隔以池调整大小数量的步骤退回到初始和最小池大小。 If the resize quantity is too small and the idle timeout large, you will not see the pool draining back to steady size quickly enough. 如果调整大小数量太小而空闲超时很大,您将看不到池足够快地流回稳定大小。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM