[jboss-cvs] JBossCache/examples/PojoCache/passivation ...
Ben Wang
bwang at jboss.com
Mon Nov 6 23:26:52 EST 2006
User: bwang
Date: 06/11/06 23:26:52
Added: examples/PojoCache/passivation build.properties
readme.txt PojoCacheTasks.xml build.sh build.bat
build.xml
Log:
passivation example.
Revision Changes Path
1.1 date: 2006/11/07 04:26:51; author: bwang; state: Exp;JBossCache/examples/PojoCache/passivation/build.properties
Index: build.properties
===================================================================
# set up environment
#
#
# Below should be transparent to you.
#
# basedir is a project attribute
#
# create directory structure
#
source=${basedir}/src
output=${basedir}/output
build=${output}/classes
cache_home=${basedir}/../../..
cache_lib=${cache_home}/lib
#Directory for Junit test result. Subdirectory html contains the result in html format.
reports=${output}/reports
1.1 date: 2006/11/07 04:26:51; author: bwang; state: Exp;JBossCache/examples/PojoCache/passivation/readme.txt
Index: readme.txt
===================================================================
This is an example that illustrates using PojoCache to replicate
over a cluster state information about students and the courses they take.
In addition, the underlying passivation will automatically provide
node passivation transparently when properly configured. We use
pojocache-passivation-service.xml.
Note that you will need to use JDK50 to run this example!
We will use JDK50 POJO Cache annotation for illustration where
the necessary domain model classes have been annotated with
@org.jboss.cache.pojo.annotation.PojoCacheable and
@@org.jboss.cache.pojo.annotation.InstanceOfPojoCacheable annotations.
You can run either using loadtime mode ("run.aop.example"), meaning there is
no need for pre-compilation once you have annotated your POJOs, or using
compilation mode ("run.aopc.example") where another Ant target "aopc" has
been invoked first.
The example involves 4 domain model classes, Person, Student, Address
and Course. Student is a subclass of Person. A Person has an Address, while
a Student can be registered for 0 or more Courses.
The class test.examples.StudentMaintTest:
1. Creates two PojoCache instances.
2. Creates two Student instances, assigns them an Address and a Course, and then
puts them in the cache.
3. Changes various state fields related to the Students and Courses, and
generates output to stdout to show that the state changes are reflected in the
other node in the cache.
The java source files for the example can be found in the src directory.
Note that we have used jboss.aop.path to locate pojocache-aop.xml file.
You can run the example through Ant.
1. Run "build.bat compile" to do a standard Java compilation.
2. Run "build.bat run.aop.example" (or run.aopc.example) to run the example.
The run.aopc.example Ant target depends on "aopc", so calling it will cause
"compile" and "aopc" to run as well.
1.1 date: 2006/11/07 04:26:51; author: bwang; state: Exp;JBossCache/examples/PojoCache/passivation/PojoCacheTasks.xml
Index: PojoCacheTasks.xml
===================================================================
<?xml version="1.0"?>
<project name="PojoCache tasks">
<!--
Tasks definition for JDK50 aopc. In addition to annotate your POJO with JDK-14 style
annotation, you will also need to define the "source" and "build" directory. It will byte-code
instrumented your POJOs and update them under build directory. You can verify this by doing
a listing there to confirm creation of new (and additional) classes.
To use this, you can use Ant import to import it into you regular build.xml (see the example
build.xml here). You will need to pass in the following properties: user.build, where you
output classes is located, and finally user.classpath is the path element that you java
class is using.
-->
<!-- Assuming we are at tools directory -->
<property name="cache_home" value="${cache_home}"/>
<property name="cache_lib" value="${cache_home}/lib"/>
<property name="cache_resources" value="${cache_home}/resources"/>
<!-- set local properties for this build -->
<path id="pojocache.lib.classpath">
<fileset dir="${cache_lib}">
<include name="jboss-common.jar"/>
<include name="concurrent.jar"/>
<include name="javassist.jar"/>
<include name="trove.jar"/>
<include name="jboss-cache.jar"/>
<include name="jboss-aop-jdk50.jar"/>
</fileset>
</path>
<path id="jboss.aop.classpath">
<fileset dir="${cache_lib}">
<include name="jboss-aop-jdk50.jar"/>
</fileset>
</path>
<!-- pre-compile directory with aopc -->
<target name="aopc" depends="compile" description="Precompile aop test classes">
<taskdef name="aopc" classname="org.jboss.aop.ant.AopC" classpathref="pojocache.lib.classpath"/>
<!-- If you have some problem on aopc, turn verbose true to debug -->
<aopc compilerclasspathref="pojocache.lib.classpath" verbose="false">
<src path="${user.build}"/>
<aoppath path="${cache_resources}/pojocache-aop.xml"/>
<classpath refid="user.classpath"/>
</aopc>
</target>
</project>
1.1 date: 2006/11/07 04:26:51; author: bwang; state: Exp;JBossCache/examples/PojoCache/passivation/build.sh
Index: build.sh
===================================================================
#!/bin/sh
CACHE_HOME=`dirname $0`
ANT_HOME=$CACHE_HOME/../../../ant-dist
#CLASSPATH=$ANT_HOME/lib/ant.jar:$ANT_HOME/lib/optional.jar:$ANT_HOME/lib/junit.jar:$JAVA_HOME/lib/tools.jar
# OS specific support (must be 'true' or 'false').
#cygwin=false;
#case "`uname`" in
# CYGWIN*)
# cygwin=true
# ;;
#esac
#if [ $cygwin = "true" ]; then
# Note that JAVA_HOME evn needs to be set under cygwin explictly,
# /cygdrive/e:/j2sdkxxx, for this to work correctly. Otherwise,
# javac can't be located correctly.
# CP=`cygpath -wp $CLASSPATH`
#else
# CP=$CLASSPATH
#fi
#java -cp $CP org.apache.tools.ant.Main "$@"
$ANT_HOME/bin/ant "$@"
1.1 date: 2006/11/07 04:26:51; author: bwang; state: Exp;JBossCache/examples/PojoCache/passivation/build.bat
Index: build.bat
===================================================================
@echo off
set ANT_HOME=..\..\..\ant-dist
REM java -cp %ANT_HOME%/lib/ant.jar;%ANT_HOME%/lib/optional.jar;%ANT_HOME%/lib/junit.jar;%JAVA_HOME%/lib/tools.jar org.apache.tools.ant.Main %1 %2 %3 %4 %5
%ANT_HOME%\bin\ant %1 %2 %3 %4 %5
1.1 date: 2006/11/07 04:26:51; author: bwang; state: Exp;JBossCache/examples/PojoCache/passivation/build.xml
Index: build.xml
===================================================================
<?xml version="1.0"?>
<project name="aop examples JDK50 annotated" default="help">
<property name="build.sysclasspath" value="ignore"/>
<!-- 3 minutes -->
<property name="junit.timeout" value="180000"/>
<!-- We read in some properties here -->
<property file="./build.properties"/>
<!-- This is your own directories -->
<property name="output" value="${basedir}/output"/>
<property name="source" value="${basedir}/src"/>
<property name="build" value="${basedir}/build"/>
<property name="cache_home" value="${cache_home}"/>
<path id="lib.classpath">
<fileset dir="${cache_lib}">
<include name="**/*.jar"/>
</fileset>
</path>
<!-- Need to define these before importing PojoCacheTasks.xml -->
<!-- You define your own classpath here -->
<path id="user.classpath">
<pathelement path="${build}"/>
<path refid="lib.classpath"/>
</path>
<property name="user.build" value="${build}"/>
<property name="user.source" value="${source}"/>
<!-- This is import for the aopc and annoc -->
<import file="PojoCacheTasks.xml"/>
<target name="help" description="help page">
<echo message="build.sh <command> where command is:"/>
<echo message=" compile -- compile the examples code"/>
<echo message=" clobber -- clean up the whole directory"/>
<echo message=" run.aopc.example -- run aop examples with annoc and aopc pre-compiler"/>
</target>
<!-- set up directory -->
<target name="init" description="Prepare to build.">
<!-- Create the time stamp -->
<tstamp/>
<!-- Create the build directory structure used by compile and copy the deployment descriptors into it-->
<mkdir dir="${build}"/>
<mkdir dir="${reports}"/>
</target>
<target name="clean" description="Clean up compiled classes">
<delete dir="${output}"/>
</target>
<target name="clobber" depends="clean"/>
<!-- compile directory -->
<target name="compile" depends="init" description="Build unit testing class">
<javac srcdir="${source}"
destdir="${build}"
includes="**/**"
debug="true"
deprecation="true">
<classpath>
<path refid="lib.classpath"/>
</classpath>
</javac>
<copy todir="${output}/etc">
<fileset dir="${cache_home}/etc">
<include name="**/*"/>
</fileset>
</copy>
</target>
<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_home}/resources/pojocache-aop.xml"/>
<jvmarg value="-javaagent:${cache_lib}/jboss-aop-jdk50.jar"/>
<classpath refid="lib.classpath"/>
<classpath path="${output}/etc"/>
<classpath path="${build}"/>
</java>
</target>
<target name="run.aopc.example" depends="compile, aopc" description="run standalone server replicator.">
<java classname="test.examples.StudentMaintTest" fork="yes">
<classpath refid="lib.classpath"/>
<classpath path="${build}"/>
<classpath path="${output}/etc"/>
</java>
</target>
<target name="run.aop.demo" depends="compile" description="run tree cache demo.">
<java classname="org.jboss.cache.aop.TreeCacheView" fork="yes">
<jvmarg value="-Xmx128M"/>
<classpath refid="lib.classpath"/>
<sysproperty key="log4j.configuration" value="file:${output}/etc/log4j.xml"/>
<classpath path="${output}/etc"/>
<classpath path="${build}"/>
</java>
</target>
</project>
More information about the jboss-cvs-commits
mailing list