1 Reply Latest reply on Jun 15, 2009 9:22 PM by Brian Stansberry

    How to make field-granularity-session-cache the default http

    Ben Schofield Novice

      Working with JBoss AS 5.1, I would like to use the field-granularity-session-cache as the server's default http session cache. Is there a way to make JBoss default to this cache?

      Also, reading the JBoss AS5 Clustering guide it says that in order to use field replication you have to annotate your classes with "@org.jboss.cache.aop.AopMarker" and precompile the code with aopc. Does this still hold true with JBoss AS 5.1? I would like for classes stored in session to remain portable between application server if possible..

        • 1. Re: How to make field-granularity-session-cache the default
          Brian Stansberry Master

          The default clustering behavior in AS 5 can be controlled via the server/XXX/deployers/jbossweb.deployer/META-INF/war-deployers-jboss-beans.xml file.

           <bean name="WebAppClusteringDefaultsDeployer"
           <!-- Default session cache config used by distributable webapps -->
           <property name="cacheName">standard-session-cache</property>
           <!-- Default session cache config used by FIELD granularity distributable webapps -->
           <property name="fieldGranularityCacheName">field-granularity-session-cache</property>
           <property name="replicationGranularity">SESSION</property>

          Change replicationGranularity to FIELD and you'll get FIELD by default, unless you configure something else in the app's jboss-web.xml.

          If you want field-granularity-session-cache to be used by default even if you use SESSION or ATTRIBUTE granularity, change the value of the "cacheName" property. Although I'd recommend adding your own cache config or tweaking standard-session-cache to match what you want. Solely because using a config named "field-granularity-..." for non-field-granularity will confuse someone some day. :)

          I haven't revamped the FIELD granularity section of the guide yet. :(

          The AS now uses the standard POJO Cache annotation instead of @AopMarker. It is @org.jboss.cache.pojo.annotation.Replicable.

          Re: using aopc, you can also use load time weaving. See http://www.jboss.org/jbossaop/docs/2.0.0.GA/docs/aspect-framework/reference/en/html/running.html#d0e4254 for some discussion of weaving options. There are a couple details in there that are a bit off from AS 5.1 but it's useful.

          Here's a quick summary of what I did to get load-time weaving for a FIELD granularity web app:

          1) Edit server/all/conf/bootstrap/aop.xml's AspectManager bean:

          <property name="enableLoadtimeWeaving">true</property>
          <property name="include">com.bar., com.bar.</property>
          <property name="exclude">org.</property>

          The first is self-evident. :) The second is where you list the packages you for sure want AOP to look at for load-time weaving. The third is packages for sure *not* to look at. By default that was "org.jboss." but when I experimented I got complaints about some stuff in org.richfaces in the admin-console.war, so I changed it to just "org."

          2) Copy the pluggable-instrumentor.jar to the bin/ dir from server/all/deployers/jboss-aop-jboss5.deployer

          3) Edit run.conf and add

          JAVA_OPTS="$JAVA_OPTS -javaagent:pluggable-instrumentor.jar"