[jboss-dev-forums] [Design of EJB 3.0] - Cache configurations for EJB3 stateful beans

jaikiran do-not-reply at jboss.com
Thu Jan 29 10:18:20 EST 2009


While updating the reference docs for EJB3, i found this information for JBossAS-4.x related to Stateful bean caching:
anonymous wrote : 
  | Stateful beans are stored in a cache.  This cache is responsible for passivated stateful sessions when the cache becomes too full or a bean is too old.  You may want to set things like the max size of this cache, and when beans should become idle.  Configuration is different depending on whether you are clustered or not.
  | 
  | Non-Clustered:
  |             For non clustered stateful beans, the @org.jboss.annotation.ejb.cache.simple.CacheConfig annotation is
  |             responsible for configuring the cache.
  | Clustered:
  | 
  | 	    For non clustered stateful beans, the @org.jboss.annotation.ejb.cache.tree.CacheConfig annotation is
  |             responsible for configuring the cache.
  | No Passivation:
  | 
  | 	Sometimes it is useful to turn off passivation entirely.  This can be done by plugging in the caching implementation  using the @org.jboss.annotation.ejb.cache.Cache (org.jboss.ejb3.cache.NoPassivationCache.class) annotation.

The annotations have been now moved to a different location. And based on what i see in the definition of org.jboss.ejb3.annotation.CacheConfig:

  | @Retention(RetentionPolicy.RUNTIME)
  | @Target(
  | {ElementType.TYPE})
  | public @interface CacheConfig {
  | 
  |    // Class Members
  | 
  |    public static final String DEFAULT_CLUSTERED_OBJECT_NAME = "jboss.cache:service=EJB3SFSBClusteredCache";
  | 
  |    public static final int DEFAULT_NONCLUSTERED_MAX_SIZE = 100000;
  | 
  |    public static final int DEFAULT_CLUSTERED_MAX_SIZE = 10000;
  | 
  |    public static final long DEFAULT_IDLE_TIMEOUT_SECONDS = 300;
  | 
  |    public static final long DEFAULT_REMOVAL_TIMEOUT_SECONDS = 0;
  | 
  |    public static final boolean DEFAULT_REPL_IS_PASV = true;
  | 
  |    // Instance Members
  | 
  |    String name() default "";
  | 
  |    int maxSize() default CacheConfig.DEFAULT_NONCLUSTERED_MAX_SIZE;
  | 
  |    long idleTimeoutSeconds() default CacheConfig.DEFAULT_IDLE_TIMEOUT_SECONDS;
  | 
  |    boolean replicationIsPassivation() default CacheConfig.DEFAULT_REPL_IS_PASV;
  | 
  |    long removalTimeoutSeconds() default CacheConfig.DEFAULT_REMOVAL_TIMEOUT_SECONDS;
  | }

Am i right in saying:

1) For Non-Clustered: The @org.jboss.ejb3.annotation.CacheConfig is required to be used on the bean as follows:

@Stateful
  | @CacheConfig(maxSize = 1000, idleTimeoutSeconds = 1)
  | public class SimpleStatefulBean implements java.io.Serializable, SimpleStatefulRemote, SimpleStatefulLocal
  | 

2) For Clustered:


@Stateful
  | @CacheConfig(name=CacheConfig.DEFAULT_CLUSTERED_OBJECT_NAME, maxSize = 1000, idleTimeoutSeconds = 1)
  | @Clustered
  | public class SimpleStatefulBean implements java.io.Serializable, SimpleStatefulRemote, SimpleStatefulLocal
  | 

3) For no passivation:

@Stateful
  | @Cache(value="org.jboss.ejb3.cache.NoPassivationCache")
  | public class SimpleStatefulBean implements java.io.Serializable, SimpleStatefulRemote, SimpleStatefulLocal
  | 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4205604#4205604

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4205604



More information about the jboss-dev-forums mailing list