<commit_before>h1. Javassist Maven Plugin

p. <a href="https://travis-ci.org/icon-Systemhaus-GmbH/javassist-maven-plugin"><img src="https://travis-ci.org/icon-Systemhaus-GmbH/javassist-maven-plugin.svg" /></a>

p. A simple Maven plugin that can apply Javassist tranformation on classes after compilation.

h2. How to use it

p. Include the plugin on your @pom.xml@ descriptor:

bc.. 
	<plugin>
		<groupId>com.github.drochetti</groupId>
		<artifactId>javassist-maven-plugin</artifactId>
		<version>1.0.0-SNAPSHOT</version>
		<configuration>
			<includeTestClasses>false</includeTestClasses>
			<transformerClasses>
				<transformerClass>
				    <className>com.domain.ToStringTransformer</className>
				    <properties>
				        <property>
				            <name>append.value</name>
				            <value> and ToStringTransformer</value>
				        </property>
				    </properties>
				</transformerClass>
			</transformerClasses>
		</configuration>
		<executions>
			<execution>
				<phase>process-classes</phase>
				<goals>
					<goal>javassist</goal>
				</goals>
			</execution>
		</executions>
	</plugin>

p. You must implement Class transformers, here's one simple example (at least, not a "logger" one).

bc.. 
/**
 * Silly transformer, used to hack the toString method.
 */
public class ToStringTransformer extends ClassTransformer {

    private static final String = APPEND_VALUE_PROPERTY_KEY = "append.value"; 

    private String appendValue;

	/**
	 * We'll only transform subtypes of MyInterface.
	 */
	@Override
	protected boolean filter(CtClass candidateClass) throws Exception {
		CtClass myInterface = ClassPool.getDefault().get(MyInterface.class.getName());
		return !candidateClass.equals(myInterface) && candidateClass.subtypeOf(myInterface);
	}

	/**
	 * Hack the toString() method.
	 */
	@Override
	protected void applyTransformations(CtClass classToTransform) throws Exception {
		// Actually you must test if it exists, but it's just an example...
		CtMethod toStringMethod = classToTransform.getDeclaredMethod("toString");
		classToTransform.removeMethod(toStringMethod);

		CtMethod hackedToStringMethod = CtNewMethod.make(
				"public String toString() { return \"toString() hacked by Javassist"+(this.appendValue != null ? this.appendValue:"")+"\"; }",
				classToTransform);
		classToTransform.addMethod(hackedToStringMethod);
	}

    /**
     * 
     */
    @Override
    protected void configure(final Properties properties) {
        if( null == properties ) {
            return;
        }
        this.appendValue = properties.getProperty(APPEND_VALUE_PROPERTY_KEY);
    }
}

h2. Known limitations

* Not published on Maven Central or Sonatype OSS repos yet (Critical);
* Don't instrument classes inside .jar files, only classes on your project;
* Lack of unit tests and sample app;
* Further implementations of @com.github.drochetti.javassist.maven.ClassTransformer@ can enable easier interactions with the Javassist API (provide some utilities).

h2. How to contribute?

p. If you think this project is useful for you, them there's a huge chance it's useful to others, so please feel free
to fork, fix it, improve it and test it (the "Known limitations" above is a great way to start).

h2. Documentation

* <a href="https://travis-ci.org/icon-Systemhaus-GmbH/javassist-maven-plugin/site/latest">maven site</a>
* <a href="https://travis-ci.org/icon-Systemhaus-GmbH/javassist-maven-plugin/wiki">wiki</a>
<commit_msg>Links in README.textile correctedwq. Issue #16<commit_after>h1. Javassist Maven Plugin

p. <a href="https://travis-ci.org/icon-Systemhaus-GmbH/javassist-maven-plugin"><img src="https://travis-ci.org/icon-Systemhaus-GmbH/javassist-maven-plugin.svg" /></a>

p. A simple Maven plugin that can apply Javassist tranformation on classes after compilation.

h2. How to use it

p. Include the plugin on your @pom.xml@ descriptor:

bc.. 
	<plugin>
		<groupId>com.github.drochetti</groupId>
		<artifactId>javassist-maven-plugin</artifactId>
		<version>1.0.0-SNAPSHOT</version>
		<configuration>
			<includeTestClasses>false</includeTestClasses>
			<transformerClasses>
				<transformerClass>
				    <className>com.domain.ToStringTransformer</className>
				    <properties>
				        <property>
				            <name>append.value</name>
				            <value> and ToStringTransformer</value>
				        </property>
				    </properties>
				</transformerClass>
			</transformerClasses>
		</configuration>
		<executions>
			<execution>
				<phase>process-classes</phase>
				<goals>
					<goal>javassist</goal>
				</goals>
			</execution>
		</executions>
	</plugin>

p. You must implement Class transformers, here's one simple example (at least, not a "logger" one).

bc.. 
/**
 * Silly transformer, used to hack the toString method.
 */
public class ToStringTransformer extends ClassTransformer {

    private static final String = APPEND_VALUE_PROPERTY_KEY = "append.value"; 

    private String appendValue;

	/**
	 * We'll only transform subtypes of MyInterface.
	 */
	@Override
	protected boolean filter(CtClass candidateClass) throws Exception {
		CtClass myInterface = ClassPool.getDefault().get(MyInterface.class.getName());
		return !candidateClass.equals(myInterface) && candidateClass.subtypeOf(myInterface);
	}

	/**
	 * Hack the toString() method.
	 */
	@Override
	protected void applyTransformations(CtClass classToTransform) throws Exception {
		// Actually you must test if it exists, but it's just an example...
		CtMethod toStringMethod = classToTransform.getDeclaredMethod("toString");
		classToTransform.removeMethod(toStringMethod);

		CtMethod hackedToStringMethod = CtNewMethod.make(
				"public String toString() { return \"toString() hacked by Javassist"+(this.appendValue != null ? this.appendValue:"")+"\"; }",
				classToTransform);
		classToTransform.addMethod(hackedToStringMethod);
	}

    /**
     * 
     */
    @Override
    protected void configure(final Properties properties) {
        if( null == properties ) {
            return;
        }
        this.appendValue = properties.getProperty(APPEND_VALUE_PROPERTY_KEY);
    }
}

h2. Known limitations

* Not published on Maven Central or Sonatype OSS repos yet (Critical);
* Don't instrument classes inside .jar files, only classes on your project;
* Lack of unit tests and sample app;
* Further implementations of @com.github.drochetti.javassist.maven.ClassTransformer@ can enable easier interactions with the Javassist API (provide some utilities).

h2. How to contribute?

p. If you think this project is useful for you, them there's a huge chance it's useful to others, so please feel free
to fork, fix it, improve it and test it (the "Known limitations" above is a great way to start).

h2. Documentation

* <a href="https://icon-Systemhaus-GmbH.github.io/">maven site</a>
* <a href="https://github.com/icon-Systemhaus-GmbH/javassist-maven-plugin/wiki">wiki</a>

{'fraction_non_alphanumeric': 0.11247828604516502, 'fraction_numerical': 0.0026056745801968733, 'mean_word_length': 3.7648275862068967, 'pattern_counts': {'":': 0, '<': 89, '<?xml version=': 0, '>': 89, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6560779', 'n_tokens_mistral': 2276, 'n_tokens_neox': 2023, 'n_words': 561}