[jboss-user] [JBossCache] - Re: Configuration problems For PojoCache under JBoss AS
Naxo
do-not-reply at jboss.com
Wed Jan 31 14:09:05 EST 2007
Hello again,
I really don?t know how to aspectize the objects I want to cache. As I said in my first post, all the examples that I have found are standalone. I want to use it in the Jboss AS, so I am having problems to understand exactly what to do. Please remember that I am newbie in Jboss and JbossCache. I have read all the documentation, and examples and I am quite lost right now, so I hope you can help me.
According to the documentation, there are two steps needed to instrument or aspectize the POJOs via JBossAop:
1. Prepare POJO. Via annotation or xml declaration. For annotation either JDK 1.4 or JDK 5.0.
2. Instrumentation. Instrument the POJO either at compile-time or load-time. Compile-time => use the so-called aop pro-compiler to do bytecode manipulation. Load-time => you need either a special system class loader or in JDK 5.0 you use the javaagent option.
I want to use JDK 5.0 via annotation and also I want to use the load-time mode (I don?t want to do any pre-compilation at all). I think that this way is easy for a beginner like me in JbossCache. No xml files, no pre-compilation? just annotation
I am using JBossCache 1.4.1. GA under Jboss 4.0.5. GA (EJB3).
-- POJO declaration --
For the first step, I am using two classes from example directory (JBossCache-1.4.1.GA\examples\PojoCache\annotated50), Person.java and Address.java. So this is the POJO declaration:
| package stpd.component.sensors.reads;
|
| /**
| * @author Ben Wang
| */
| @org.jboss.cache.aop.annotation.InstanceOfPojoCacheable
| public class Person {
| protected String name;
| protected Address address;
|
| ...
|
| package stpd.component.sensors.reads;
|
| /**
| * @author Ben Wang
| */
| @org.jboss.cache.aop.annotation.PojoCacheable
| public class Address {
| protected String city;
| protected int zip;
| protected String street;
|
| ...
|
-- Instrumentation ?
For the second step I am using file \META-INF\jboss-aop.xml:
| <?xml version="1.0" encoding="UTF-8"?>
|
| <!--
| This is the meta file to declare user's POJO as "aspectized" under
| JBossCacheAop. User will need this file when:
| 1. Run off-line precompier, aopc, to generate the "aspectized" class
| 2. Run on-line with a special aop class loader.
| -->
| <aop>
| <prepare expr="field(* @org.jboss.cache.aop.annotation.PojoCacheable->*)" />
| <prepare expr="field(* $instanceof{@org.jboss.cache.aop.annotation.InstanceOfPojoCacheable}->*)" />
| </aop>
|
There is an example called ?annotated50? that uses JDK50 POJO Cache annotation and that can be run in load-time mode. It uses ant to build and run the example. This is how you run the example in Load-time mode:
| <target name="run.loadtime.example" depends="compile" description="run standalone server replicator.">
| <java classname="test.examples.StudentMaintTest" fork="yes">
| <jvmarg value="-Djboss.aop.path=${cache_resources}/jboss-aop.xml"/>
| <jvmarg value="-javaagent:${cache_lib-50}/jboss-aop-jdk50.jar"/>
| <classpath refid="lib.classpath"/>
| <classpath path="${output}/etc"/>
| <classpath path="${build}"/>
| </java>
| </target>
|
I am not using ant to build my project, and I don?t know how to use javaagent option for JDK 5.0.
Sorry and thank you agian.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4008946#4008946
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4008946
More information about the jboss-user
mailing list