Instrumentation

First step in using the SVO library is to instrument the Value Objects. This is currently done by an ant task called SmartTask, we don't provide a solution to do runtime modification yet. Performing the modification on compiletime has the advantage of leaving out all classloader problems that might occur on runtime.

The main changes carried out are (refer to the implementation section for a detailed description):

To let ant know that you want to use the additional bytecode modificating task you need to insert

	<taskdef name="smartify"
	classname="org.bsf.smartValueObject.tools.SmartTask"
	classpathref="svo.classpath" />

somewhere in your build.xml file. "svo.classpath" is a reference to a classpath containing bsf-SVO-client.jar, javassist.jar and the directory where the VOs to be modified reside (Javassist, a bytecode modification library, currently loads the classes with a classloader, this will change in a future version).

Use this task right after the compilation process, like:

	<target name="smartify" depends="clean, compile">
		<smartify>
			<fileset dir="${build.dir}/test">
				<include name="**/*VO.class"/>
			</fileset>
		</smartify>
	</target>

This would process all compiled classes ending in VO using the default instrumentor. The instrumentor is the class in charge of doing the actual byte code modifiations. Currently there are two instrumentors, one implemented with Javassist (the default) and the other with ASM.

You specify the instrumentor to use with the "instrumentor" - attribute of SmartTask:

	<smartify instrumentor="org.bsf.smartValueObject.tools.ASMInstrumentor">
	...
	</smartify>

This would choose the bytecode modifier based on Objectweb's ASM library. Its main advantage compared to the Javassist-specific implementation is the small size of the asm jar-file (25K).

After the successful instrumentation the original class gets overwritten with the modified version.

Have a look at the examples-dir for a short demonstration.


back index next