4 Replies Latest reply on Feb 8, 2006 4:05 PM by anupama

    Tree Cache AOP

    anupama

      Hi Guys,

      I Know I posted many posts but i need quick guidance, please help me. After going through some docs I found out that Jboss Tree Cache AOP can work as satndalone process, as MBean in JBoss etc. There are so many examples I found for standalone process but none for MBean in JBoss, for my application I have customized scripts so need to include JBoss Tree Cache AOP in those, I need to configure JBoss Tree Cache AOP for clustering. Let me explain requirement I need to save some start up data which is Read Only in JBoss Cache for that I have chosen JBoss Tree Cache AOP because of limitations counterpart has, and also AOP is kind of technology my project wants to adapt in near future. I had been through docs for this from long time, didn't find good ones Looking for one which have concrete example of JBoss Cache in JBoss, so guys please direct me asap, I reaally need reply soon.

      Thanks alot,
      Anu

        • 1. Re: Tree Cache AOP
          brian.stansberry

          Basic steps:

          1) Create a -service.xml file (say "mycacheaop-service.xml") to configure your cache. http://docs.jboss.com/jbcache/1.2.4/TreeCache/html/ and http://docs.jboss.com/jbcache/1.2.4/TreeCacheAop/html/ have lots of details on this that I'm not going to go into. Note section 6.1 of the TreeCacheAop doc on what you need to do to make your MBean use TreeCacheAop.

          2) "mycacheaop-service.xml" goes in the /server/all/deploy directory, or you can package it in an ear or sar bundled with your client code. You can find docs online on how to package a service in an ear.

          3) Chapter 12 of the TreeCache doc describes how to access your cache from client code inside JBoss. If you want your client code to work in an envrironment where the cache may not be an bmean, I recommend you use the JNDI approach -- look up the cache in JNDI. The docs give an example mbean config for binding the cache in JNDI; you can add something like that to the bottom of your "mycacheaop-service.xml". Note that the example is written for TreeCache; where you see "TreeCacheMBean" you need to use "TreeCacheAopMBean", both in the mbean config and in your client code.

          • 2. Re: Tree Cache AOP
            anupama

            Hi,

            Thanks for your response.
            I have a question for you, JBoss Cache is like temp storage so that means data will be lost once server was restarted, is that correct.

            Thanks alot,
            Anu

            • 3. Re: Tree Cache AOP
              brian.stansberry

              Yes, unless:

              1) You use a CacheLoader.
              2) You have more than one server, so the cache data is replicated, and you always keep at least one server alive.

              Use of a cache loader is covered in the docs. If you want to get help on a forum, you need to show more evidence that you've read and absorbed the docs.

              • 4. Re: Tree Cache AOP
                anupama

                Hi Guys,

                I finally make CacheAOP to work as MBean in JBoss 4.0, my jboss-aop.xml aspectized configuration file is

                1. jboss-aop.xml

                <?xml version="1.0" encoding="UTF-8"?>
                <aop>
                 <!-- This is declaration file for annotation. We are using JDK1.4 now,
                 so an annotationc pre-compiler is needed for JBossAop.
                 See build.xml target annoc for details.
                 Idea is user will then need only to annotate like:
                 @@org.jboss.cache.aop.AopMarker
                 in his POJO. There will be no need of jboss-aop.xml from user's side.
                 Only extra step is annotation compiling. And in JDK1.5, this step
                 will not be needed since the implicit annotation support.
                
                 For example, see either Address or Person.
                 -->
                
                 <!-- If a POJO has AopMarker annotation, it will be asepctized. -->
                 <prepare expr="field(* @org.jboss.cache.aop.AopMarker->*)" />
                
                 <!--
                 Supports inheritance and polymorphism. It can either be a concrete class
                 or an interface. All sub-classes or interface implementors will be instrumeneted.
                 -->
                 <prepare expr="field(* $instanceof{@org.jboss.cache.aop.InstanceOfAopMarker}->*)" />
                </aop>
                



                My question is what would be preferred way to do conf file, can I stick with this or doing customized config is prefferable.

                2. At client I need to use aspectized classes(classes for which AOPC is done), if I run without using any aop specific jars I got
                java.lang.NoClassDefFoundError: org/jboss/aop/joinpoint/FieldWriteInvocation
                 at java.lang.ClassLoader.defineClass0(Native Method)
                 at java.lang.ClassLoader.defineClass(ClassLoader.java:537)
                 at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
                 at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
                 at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
                 at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
                 at java.security.AccessController.doPrivileged(Native Method)
                 at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
                 at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
                 at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
                 at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
                 at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
                 at com.wdpro.commerce.wdw.be.client.delegate.WDWIBCAppDelegate.getAnswer(WDWIBCAppDelegate.java:206)
                 at TestCache.main(TestCache.java:10)
                Exception in thread "main"
                


                Is there any subset of jars I need to include for client classpath if client wants to use aspectized classes(Cached classes), if so is this set would be constants so I can deliver to client only first time.

                3. I tried to use "/usr/template/hotel/" as FQN but it didn't take it took "/usr/template/", is there any restrictions around FQN patterns

                4. Right now I am looking TreeCacheAOP using MBeanProxy instead of JNDI name, thoough I defined JNDI name for Tree Cache AOP I am't able to use it.
                part of tree-aop-service.xml
                
                
                 <mbean
                 code="org.jboss.invocation.jrmp.server.JRMPProxyFactory"
                 name="mydomain:service=proxyFactory,type=jrmp,target=factory">
                 <attribute
                 name="InvokerName">jboss:service=invoker,type=jrmp</attribute>
                 <attribute
                 name="TargetName">jboss.cache:service=TreeCacheAop</attribute>
                 <attribute name="JndiName">MyCache</attribute> <attribute
                 name="InvokeTargetMethod">true</attribute> <attribute
                 name="ExportedInterface">org.jboss.cache.aop.TreeCacheAopMBean</attribute>
                 <attribute name="ClientInterceptors"> <iterceptors>
                 <interceptor>org.jboss.proxy.ClientMethodInterceptor</interceptor>
                 <interceptor>org.jboss.proxy.SecurityInterceptor</interceptor>
                 <interceptor>org.jboss.invocation.InvokerInterceptor</interceptor>
                 </iterceptors> </attribute>
                 <depends>jboss:service=invoker,type=jrmp</depends>
                 <depends>jboss.cache:service=TreeCacheAop</depends>
                </mbean>
                
                


                Context ctx= new Context();
                TreeCacheAop sam = ctz.lookup("MyCache");

                it's finding JNDI but throwing class cast exception.

                What would be procedure to do look up for Tree Cache AOP MBean via JNDI.