public abstract class

AbstractInstrumenter

extends Object
implements Instrumenter
java.lang.Object
   ↳ org.hibernate.bytecode.buildtime.AbstractInstrumenter
Known Direct Subclasses

Class Overview

Provides the basic templating of how instrumentation should occur.

Summary

Nested Classes
class AbstractInstrumenter.CustomFieldFilter Allows control over what exacctly to transform. 
Fields
protected final Logger logger
protected final Instrumenter.Options options
Public Constructors
AbstractInstrumenter(Logger logger, Instrumenter.Options options)
Creates the basic instrumentation strategy.
Public Methods
void execute(Set files)
The main instrumentation entry point.
Protected Methods
final boolean checkMagic(File file, long magic)
abstract ClassDescriptor getClassDescriptor(byte[] byecode)
Given the bytecode of a java class, retrieve the descriptor for that class.
abstract ClassTransformer getClassTransformer(ClassDescriptor descriptor, Set classNames)
Create class transformer for the class.
final boolean isClassFile(File file)
Does this file represent a compiled class?
final boolean isJarFile(File file)
Does this file represent a zip file of some format?
void processClassFile(File file, Set classNames)
Process a class file.
void processFile(File file, Set classNames)
Actually process the file by applying instrumentation transformations to any classes it contains.
void processJarFile(File file, Set classNames)
Process an archive file.
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.hibernate.bytecode.buildtime.Instrumenter

Fields

protected final Logger logger

protected final Instrumenter.Options options

Public Constructors

public AbstractInstrumenter (Logger logger, Instrumenter.Options options)

Creates the basic instrumentation strategy.

Parameters
logger The bridge to the environment's logging system.
options User-supplied options.

Public Methods

public void execute (Set files)

The main instrumentation entry point. Given a set of files, perform instrumentation on each discovered class file.

Parameters
files The files.

Protected Methods

protected final boolean checkMagic (File file, long magic)

Throws
IOException

protected abstract ClassDescriptor getClassDescriptor (byte[] byecode)

Given the bytecode of a java class, retrieve the descriptor for that class.

Parameters
byecode The class bytecode.
Returns
  • The class's descriptor
Throws
Exception Indicates problems access the bytecode.

protected abstract ClassTransformer getClassTransformer (ClassDescriptor descriptor, Set classNames)

Create class transformer for the class.

Parameters
descriptor The descriptor of the class to be instrumented.
classNames The names of all classes to be instrumented; the "pipeline" if you will.
Returns
  • The transformer for the given class; may return null to indicate that transformation should be skipped (ala already instrumented).

protected final boolean isClassFile (File file)

Does this file represent a compiled class?

Parameters
file The file to check.
Returns
  • True if the file is a class; false otherwise.
Throws
IOException Indicates problem access the file.

protected final boolean isJarFile (File file)

Does this file represent a zip file of some format?

Parameters
file The file to check.
Returns
  • True if the file is n archive; false otherwise.
Throws
IOException Indicates problem access the file.

protected void processClassFile (File file, Set classNames)

Process a class file. Delegated to from processFile(File, Set) in the case of a class file.

Parameters
file The class file to process.
classNames The 'pipeline' of classes to be processed. Only actually populated when the user specifies to perform Options#performExtendedInstrumentation() extended instrumentation.
Throws
Exception Indicates an issue either access files or applying the transformations.

protected void processFile (File file, Set classNames)

Actually process the file by applying instrumentation transformations to any classes it contains.

Again, just like with #collectClassNames this method can handle both class and archive files.

Parameters
file The file to process.
classNames The 'pipeline' of classes to be processed. Only actually populated when the user specifies to perform Options#performExtendedInstrumentation() extended instrumentation.
Throws
Exception Indicates an issue either access files or applying the transformations.

protected void processJarFile (File file, Set classNames)

Process an archive file. Delegated to from processFile(File, Set) in the case of an archive file.

Parameters
file The archive file to process.
classNames The 'pipeline' of classes to be processed. Only actually populated when the user specifies to perform Options#performExtendedInstrumentation() extended instrumentation.
Throws
Exception Indicates an issue either access files or applying the transformations.