com.ikokoon.serenity
Class Transformer

java.lang.Object
  extended by com.ikokoon.serenity.Transformer
All Implemented Interfaces:
IConstants, java.lang.instrument.ClassFileTransformer

public class Transformer
extends java.lang.Object
implements java.lang.instrument.ClassFileTransformer, IConstants

This class is the entry point for the Serenity code coverage/complexity/dependency/profiling functionality. This class is called by the JVM on startup. The agent then has first access to the byte code for all classes that are loaded. During this loading the byte code can be enhanced.

Since:
12.07.09
Version:
01.00
Author:
Michael Couck

Field Summary
 
Fields inherited from interface com.ikokoon.serenity.IConstants
CLEAN_CLASSES, COMPLEXITY, COVERAGE, DATABASE_FILE_JPA, DATABASE_FILE_ODB, DATABASE_FILE_RAM, DEPENDENCY, EXCLUDED_PACKAGES_PROPERTY, INCLUDED_ADAPTERS_PROPERTY, INCLUDED_JARS_PROPERTY, INCLUDED_PACKAGES_PROPERTY, JAVA_CLASS_PATH, LOG_4_J_PROPERTIES, PROFILING, SEPARATOR, SERENITY_DIRECTORY, SERENITY_PERSISTENCE_UNIT, SERENITY_SOURCE, SUREFIRE_TEST_CLASS_PATH, WRITE_CLASSES
 
Constructor Summary
Transformer()
           
 
Method Summary
static void premain(java.lang.String args, java.lang.instrument.Instrumentation instrumentation)
          This method is called by the JVM at startup.
protected static void printSystemProperties()
           
protected static void removeShutdownHook()
           
 byte[] transform(java.lang.ClassLoader loader, java.lang.String className, java.lang.Class<?> classBeingRedefined, java.security.ProtectionDomain protectionDomain, byte[] classBytes)
          This method transforms the classes that are specified.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Transformer

public Transformer()
Method Detail

premain

public static void premain(java.lang.String args,
                           java.lang.instrument.Instrumentation instrumentation)
This method is called by the JVM at startup. This method will only be called if the command line for starting the JVM has the following on it: -javaagent:serenity/serenity.jar. This instruction tells the JVM that there is an agent that must be used. In the META-INF directory of the jar specified there must be a MANIFEST.MF file. In this file the instructions must be something like the following: Manifest-Version: 1.0
Boot-Class-Path: asm-3.1.jar and so on..., in the case that the required libraries are not on the classpath, which they should be
Premain-Class: com.ikokoon.serenity.Transformer Another line in the manifest can start an agent after the JVM has been started, but not for all JVMs. So not very useful. These instructions tell the JVM to call this method when loading class files.

Parameters:
args - a set of arguments that the JVM will call the method with
instrumentation - the instrumentation implementation of the JVM

removeShutdownHook

protected static void removeShutdownHook()

printSystemProperties

protected static void printSystemProperties()

transform

public byte[] transform(java.lang.ClassLoader loader,
                        java.lang.String className,
                        java.lang.Class<?> classBeingRedefined,
                        java.security.ProtectionDomain protectionDomain,
                        byte[] classBytes)
                 throws java.lang.instrument.IllegalClassFormatException
This method transforms the classes that are specified.

Specified by:
transform in interface java.lang.instrument.ClassFileTransformer
Throws:
java.lang.instrument.IllegalClassFormatException


Copyright © 2010. All Rights Reserved.