Initial version of sample to explain 'code injection'
authorJaroslav Tulach <jtulach@netbeans.org>
Sat, 10 Jan 2009 21:29:22 +0100
changeset 30377b6002451c4
parent 302 fb84830aacc2
child 304 adb083bd81c5
Initial version of sample to explain 'code injection'
samples/codeinjection/build.xml
samples/codeinjection/manifest.mf
samples/codeinjection/nbproject/build-impl.xml
samples/codeinjection/nbproject/genfiles.properties
samples/codeinjection/nbproject/project.properties
samples/codeinjection/nbproject/project.xml
samples/codeinjection/src/org/apidesign/codeinjection/CountDown.java
samples/codeinjection/src/org/apidesign/codeinjection/CountDownImplV1.java
samples/codeinjection/src/org/apidesign/codeinjection/CountDownImplV2.java
samples/codeinjection/src/org/apidesign/codeinjection/spi/CountDownExtender.java
samples/codeinjection/test/org/apidesign/codeinjection/Version10Test.java
samples/codeinjection/test/org/apidesign/codeinjection/Version20Test.java
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/samples/codeinjection/build.xml	Sat Jan 10 21:29:22 2009 +0100
     1.3 @@ -0,0 +1,74 @@
     1.4 +<?xml version="1.0" encoding="UTF-8"?>
     1.5 +<!-- You may freely edit this file. See commented blocks below for -->
     1.6 +<!-- some examples of how to customize the build. -->
     1.7 +<!-- (If you delete it and reopen the project it will be recreated.) -->
     1.8 +<!-- By default, only the Clean and Build commands use this build script. -->
     1.9 +<!-- Commands such as Run, Debug, and Test only use this build script if -->
    1.10 +<!-- the Compile on Save feature is turned off for the project. -->
    1.11 +<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
    1.12 +<!-- in the project's Project Properties dialog box.-->
    1.13 +<project name="codeinjection" default="default" basedir=".">
    1.14 +    <description>Builds, tests, and runs the project codeinjection.</description>
    1.15 +    <import file="nbproject/build-impl.xml"/>
    1.16 +    <!--
    1.17 +
    1.18 +    There exist several targets which are by default empty and which can be 
    1.19 +    used for execution of your tasks. These targets are usually executed 
    1.20 +    before and after some main targets. They are: 
    1.21 +
    1.22 +      -pre-init:                 called before initialization of project properties
    1.23 +      -post-init:                called after initialization of project properties
    1.24 +      -pre-compile:              called before javac compilation
    1.25 +      -post-compile:             called after javac compilation
    1.26 +      -pre-compile-single:       called before javac compilation of single file
    1.27 +      -post-compile-single:      called after javac compilation of single file
    1.28 +      -pre-compile-test:         called before javac compilation of JUnit tests
    1.29 +      -post-compile-test:        called after javac compilation of JUnit tests
    1.30 +      -pre-compile-test-single:  called before javac compilation of single JUnit test
    1.31 +      -post-compile-test-single: called after javac compilation of single JUunit test
    1.32 +      -pre-jar:                  called before JAR building
    1.33 +      -post-jar:                 called after JAR building
    1.34 +      -post-clean:               called after cleaning build products
    1.35 +
    1.36 +    (Targets beginning with '-' are not intended to be called on their own.)
    1.37 +
    1.38 +    Example of inserting an obfuscator after compilation could look like this:
    1.39 +
    1.40 +        <target name="-post-compile">
    1.41 +            <obfuscate>
    1.42 +                <fileset dir="${build.classes.dir}"/>
    1.43 +            </obfuscate>
    1.44 +        </target>
    1.45 +
    1.46 +    For list of available properties check the imported 
    1.47 +    nbproject/build-impl.xml file. 
    1.48 +
    1.49 +
    1.50 +    Another way to customize the build is by overriding existing main targets.
    1.51 +    The targets of interest are: 
    1.52 +
    1.53 +      -init-macrodef-javac:     defines macro for javac compilation
    1.54 +      -init-macrodef-junit:     defines macro for junit execution
    1.55 +      -init-macrodef-debug:     defines macro for class debugging
    1.56 +      -init-macrodef-java:      defines macro for class execution
    1.57 +      -do-jar-with-manifest:    JAR building (if you are using a manifest)
    1.58 +      -do-jar-without-manifest: JAR building (if you are not using a manifest)
    1.59 +      run:                      execution of project 
    1.60 +      -javadoc-build:           Javadoc generation
    1.61 +      test-report:              JUnit report generation
    1.62 +
    1.63 +    An example of overriding the target for project execution could look like this:
    1.64 +
    1.65 +        <target name="run" depends="codeinjection-impl.jar">
    1.66 +            <exec dir="bin" executable="launcher.exe">
    1.67 +                <arg file="${dist.jar}"/>
    1.68 +            </exec>
    1.69 +        </target>
    1.70 +
    1.71 +    Notice that the overridden target depends on the jar target and not only on 
    1.72 +    the compile target as the regular run target does. Again, for a list of available 
    1.73 +    properties which you can use, check the target you are overriding in the
    1.74 +    nbproject/build-impl.xml file. 
    1.75 +
    1.76 +    -->
    1.77 +</project>
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/samples/codeinjection/manifest.mf	Sat Jan 10 21:29:22 2009 +0100
     2.3 @@ -0,0 +1,3 @@
     2.4 +Manifest-Version: 1.0
     2.5 +X-COMMENT: Main-Class will be added automatically by build
     2.6 +
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/samples/codeinjection/nbproject/build-impl.xml	Sat Jan 10 21:29:22 2009 +0100
     3.3 @@ -0,0 +1,655 @@
     3.4 +<?xml version="1.0" encoding="UTF-8"?>
     3.5 +<!--
     3.6 +*** GENERATED FROM project.xml - DO NOT EDIT  ***
     3.7 +***         EDIT ../build.xml INSTEAD         ***
     3.8 +
     3.9 +For the purpose of easier reading the script
    3.10 +is divided into following sections:
    3.11 +
    3.12 +  - initialization
    3.13 +  - compilation
    3.14 +  - jar
    3.15 +  - execution
    3.16 +  - debugging
    3.17 +  - javadoc
    3.18 +  - junit compilation
    3.19 +  - junit execution
    3.20 +  - junit debugging
    3.21 +  - applet
    3.22 +  - cleanup
    3.23 +
    3.24 +        -->
    3.25 +<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="codeinjection-impl">
    3.26 +    <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
    3.27 +    <!-- 
    3.28 +                ======================
    3.29 +                INITIALIZATION SECTION 
    3.30 +                ======================
    3.31 +            -->
    3.32 +    <target name="-pre-init">
    3.33 +        <!-- Empty placeholder for easier customization. -->
    3.34 +        <!-- You can override this target in the ../build.xml file. -->
    3.35 +    </target>
    3.36 +    <target depends="-pre-init" name="-init-private">
    3.37 +        <property file="nbproject/private/config.properties"/>
    3.38 +        <property file="nbproject/private/configs/${config}.properties"/>
    3.39 +        <property file="nbproject/private/private.properties"/>
    3.40 +    </target>
    3.41 +    <target depends="-pre-init,-init-private" name="-init-user">
    3.42 +        <property file="${user.properties.file}"/>
    3.43 +        <!-- The two properties below are usually overridden -->
    3.44 +        <!-- by the active platform. Just a fallback. -->
    3.45 +        <property name="default.javac.source" value="1.4"/>
    3.46 +        <property name="default.javac.target" value="1.4"/>
    3.47 +    </target>
    3.48 +    <target depends="-pre-init,-init-private,-init-user" name="-init-project">
    3.49 +        <property file="nbproject/configs/${config}.properties"/>
    3.50 +        <property file="nbproject/project.properties"/>
    3.51 +    </target>
    3.52 +    <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init">
    3.53 +        <available file="${manifest.file}" property="manifest.available"/>
    3.54 +        <condition property="manifest.available+main.class">
    3.55 +            <and>
    3.56 +                <isset property="manifest.available"/>
    3.57 +                <isset property="main.class"/>
    3.58 +                <not>
    3.59 +                    <equals arg1="${main.class}" arg2="" trim="true"/>
    3.60 +                </not>
    3.61 +            </and>
    3.62 +        </condition>
    3.63 +        <condition property="manifest.available+main.class+mkdist.available">
    3.64 +            <and>
    3.65 +                <istrue value="${manifest.available+main.class}"/>
    3.66 +                <isset property="libs.CopyLibs.classpath"/>
    3.67 +            </and>
    3.68 +        </condition>
    3.69 +        <condition property="have.tests">
    3.70 +            <or>
    3.71 +                <available file="${test.src.dir}"/>
    3.72 +            </or>
    3.73 +        </condition>
    3.74 +        <condition property="have.sources">
    3.75 +            <or>
    3.76 +                <available file="${src.dir}"/>
    3.77 +            </or>
    3.78 +        </condition>
    3.79 +        <condition property="netbeans.home+have.tests">
    3.80 +            <and>
    3.81 +                <isset property="netbeans.home"/>
    3.82 +                <isset property="have.tests"/>
    3.83 +            </and>
    3.84 +        </condition>
    3.85 +        <condition property="no.javadoc.preview">
    3.86 +            <and>
    3.87 +                <isset property="javadoc.preview"/>
    3.88 +                <isfalse value="${javadoc.preview}"/>
    3.89 +            </and>
    3.90 +        </condition>
    3.91 +        <property name="run.jvmargs" value=""/>
    3.92 +        <property name="javac.compilerargs" value=""/>
    3.93 +        <property name="work.dir" value="${basedir}"/>
    3.94 +        <condition property="no.deps">
    3.95 +            <and>
    3.96 +                <istrue value="${no.dependencies}"/>
    3.97 +            </and>
    3.98 +        </condition>
    3.99 +        <property name="javac.debug" value="true"/>
   3.100 +        <property name="javadoc.preview" value="true"/>
   3.101 +        <property name="application.args" value=""/>
   3.102 +        <property name="source.encoding" value="${file.encoding}"/>
   3.103 +        <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
   3.104 +            <and>
   3.105 +                <isset property="javadoc.encoding"/>
   3.106 +                <not>
   3.107 +                    <equals arg1="${javadoc.encoding}" arg2=""/>
   3.108 +                </not>
   3.109 +            </and>
   3.110 +        </condition>
   3.111 +        <property name="javadoc.encoding.used" value="${source.encoding}"/>
   3.112 +        <property name="includes" value="**"/>
   3.113 +        <property name="excludes" value=""/>
   3.114 +        <property name="do.depend" value="false"/>
   3.115 +        <condition property="do.depend.true">
   3.116 +            <istrue value="${do.depend}"/>
   3.117 +        </condition>
   3.118 +        <condition else="" property="javac.compilerargs.jaxws" value="-Djava.endorsed.dirs='${jaxws.endorsed.dir}'">
   3.119 +            <and>
   3.120 +                <isset property="jaxws.endorsed.dir"/>
   3.121 +                <available file="nbproject/jaxws-build.xml"/>
   3.122 +            </and>
   3.123 +        </condition>
   3.124 +    </target>
   3.125 +    <target name="-post-init">
   3.126 +        <!-- Empty placeholder for easier customization. -->
   3.127 +        <!-- You can override this target in the ../build.xml file. -->
   3.128 +    </target>
   3.129 +    <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init" name="-init-check">
   3.130 +        <fail unless="src.dir">Must set src.dir</fail>
   3.131 +        <fail unless="test.src.dir">Must set test.src.dir</fail>
   3.132 +        <fail unless="build.dir">Must set build.dir</fail>
   3.133 +        <fail unless="dist.dir">Must set dist.dir</fail>
   3.134 +        <fail unless="build.classes.dir">Must set build.classes.dir</fail>
   3.135 +        <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
   3.136 +        <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
   3.137 +        <fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
   3.138 +        <fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
   3.139 +        <fail unless="dist.jar">Must set dist.jar</fail>
   3.140 +    </target>
   3.141 +    <target name="-init-macrodef-property">
   3.142 +        <macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
   3.143 +            <attribute name="name"/>
   3.144 +            <attribute name="value"/>
   3.145 +            <sequential>
   3.146 +                <property name="@{name}" value="${@{value}}"/>
   3.147 +            </sequential>
   3.148 +        </macrodef>
   3.149 +    </target>
   3.150 +    <target name="-init-macrodef-javac">
   3.151 +        <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
   3.152 +            <attribute default="${src.dir}" name="srcdir"/>
   3.153 +            <attribute default="${build.classes.dir}" name="destdir"/>
   3.154 +            <attribute default="${javac.classpath}" name="classpath"/>
   3.155 +            <attribute default="${includes}" name="includes"/>
   3.156 +            <attribute default="${excludes}" name="excludes"/>
   3.157 +            <attribute default="${javac.debug}" name="debug"/>
   3.158 +            <attribute default="/does/not/exist" name="sourcepath"/>
   3.159 +            <element name="customize" optional="true"/>
   3.160 +            <sequential>
   3.161 +                <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}">
   3.162 +                    <classpath>
   3.163 +                        <path path="@{classpath}"/>
   3.164 +                    </classpath>
   3.165 +                    <compilerarg line="${javac.compilerargs} ${javac.compilerargs.jaxws}"/>
   3.166 +                    <customize/>
   3.167 +                </javac>
   3.168 +            </sequential>
   3.169 +        </macrodef>
   3.170 +        <macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3">
   3.171 +            <attribute default="${src.dir}" name="srcdir"/>
   3.172 +            <attribute default="${build.classes.dir}" name="destdir"/>
   3.173 +            <attribute default="${javac.classpath}" name="classpath"/>
   3.174 +            <sequential>
   3.175 +                <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
   3.176 +                    <classpath>
   3.177 +                        <path path="@{classpath}"/>
   3.178 +                    </classpath>
   3.179 +                </depend>
   3.180 +            </sequential>
   3.181 +        </macrodef>
   3.182 +        <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/j2se-project/3">
   3.183 +            <attribute default="${build.classes.dir}" name="destdir"/>
   3.184 +            <sequential>
   3.185 +                <fail unless="javac.includes">Must set javac.includes</fail>
   3.186 +                <pathconvert pathsep="," property="javac.includes.binary">
   3.187 +                    <path>
   3.188 +                        <filelist dir="@{destdir}" files="${javac.includes}"/>
   3.189 +                    </path>
   3.190 +                    <globmapper from="*.java" to="*.class"/>
   3.191 +                </pathconvert>
   3.192 +                <delete>
   3.193 +                    <files includes="${javac.includes.binary}"/>
   3.194 +                </delete>
   3.195 +            </sequential>
   3.196 +        </macrodef>
   3.197 +    </target>
   3.198 +    <target name="-init-macrodef-junit">
   3.199 +        <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
   3.200 +            <attribute default="${includes}" name="includes"/>
   3.201 +            <attribute default="${excludes}" name="excludes"/>
   3.202 +            <attribute default="**" name="testincludes"/>
   3.203 +            <sequential>
   3.204 +                <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true">
   3.205 +                    <batchtest todir="${build.test.results.dir}">
   3.206 +                        <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
   3.207 +                            <filename name="@{testincludes}"/>
   3.208 +                        </fileset>
   3.209 +                    </batchtest>
   3.210 +                    <classpath>
   3.211 +                        <path path="${run.test.classpath}"/>
   3.212 +                    </classpath>
   3.213 +                    <syspropertyset>
   3.214 +                        <propertyref prefix="test-sys-prop."/>
   3.215 +                        <mapper from="test-sys-prop.*" to="*" type="glob"/>
   3.216 +                    </syspropertyset>
   3.217 +                    <formatter type="brief" usefile="false"/>
   3.218 +                    <formatter type="xml"/>
   3.219 +                    <jvmarg line="${run.jvmargs}"/>
   3.220 +                </junit>
   3.221 +            </sequential>
   3.222 +        </macrodef>
   3.223 +    </target>
   3.224 +    <target depends="-init-debug-args" name="-init-macrodef-nbjpda">
   3.225 +        <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
   3.226 +            <attribute default="${main.class}" name="name"/>
   3.227 +            <attribute default="${debug.classpath}" name="classpath"/>
   3.228 +            <attribute default="" name="stopclassname"/>
   3.229 +            <sequential>
   3.230 +                <nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="${debug-transport}">
   3.231 +                    <classpath>
   3.232 +                        <path path="@{classpath}"/>
   3.233 +                    </classpath>
   3.234 +                </nbjpdastart>
   3.235 +            </sequential>
   3.236 +        </macrodef>
   3.237 +        <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
   3.238 +            <attribute default="${build.classes.dir}" name="dir"/>
   3.239 +            <sequential>
   3.240 +                <nbjpdareload>
   3.241 +                    <fileset dir="@{dir}" includes="${fix.classes}">
   3.242 +                        <include name="${fix.includes}*.class"/>
   3.243 +                    </fileset>
   3.244 +                </nbjpdareload>
   3.245 +            </sequential>
   3.246 +        </macrodef>
   3.247 +    </target>
   3.248 +    <target name="-init-debug-args">
   3.249 +        <property name="version-output" value="java version &quot;${ant.java.version}"/>
   3.250 +        <condition property="have-jdk-older-than-1.4">
   3.251 +            <or>
   3.252 +                <contains string="${version-output}" substring="java version &quot;1.0"/>
   3.253 +                <contains string="${version-output}" substring="java version &quot;1.1"/>
   3.254 +                <contains string="${version-output}" substring="java version &quot;1.2"/>
   3.255 +                <contains string="${version-output}" substring="java version &quot;1.3"/>
   3.256 +            </or>
   3.257 +        </condition>
   3.258 +        <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
   3.259 +            <istrue value="${have-jdk-older-than-1.4}"/>
   3.260 +        </condition>
   3.261 +        <condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem">
   3.262 +            <os family="windows"/>
   3.263 +        </condition>
   3.264 +        <condition else="${debug-transport-by-os}" property="debug-transport" value="${debug.transport}">
   3.265 +            <isset property="debug.transport"/>
   3.266 +        </condition>
   3.267 +    </target>
   3.268 +    <target depends="-init-debug-args" name="-init-macrodef-debug">
   3.269 +        <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
   3.270 +            <attribute default="${main.class}" name="classname"/>
   3.271 +            <attribute default="${debug.classpath}" name="classpath"/>
   3.272 +            <element name="customize" optional="true"/>
   3.273 +            <sequential>
   3.274 +                <java classname="@{classname}" dir="${work.dir}" fork="true">
   3.275 +                    <jvmarg line="${debug-args-line}"/>
   3.276 +                    <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
   3.277 +                    <jvmarg line="${run.jvmargs}"/>
   3.278 +                    <classpath>
   3.279 +                        <path path="@{classpath}"/>
   3.280 +                    </classpath>
   3.281 +                    <syspropertyset>
   3.282 +                        <propertyref prefix="run-sys-prop."/>
   3.283 +                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
   3.284 +                    </syspropertyset>
   3.285 +                    <customize/>
   3.286 +                </java>
   3.287 +            </sequential>
   3.288 +        </macrodef>
   3.289 +    </target>
   3.290 +    <target name="-init-macrodef-java">
   3.291 +        <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
   3.292 +            <attribute default="${main.class}" name="classname"/>
   3.293 +            <attribute default="${run.classpath}" name="classpath"/>
   3.294 +            <element name="customize" optional="true"/>
   3.295 +            <sequential>
   3.296 +                <java classname="@{classname}" dir="${work.dir}" fork="true">
   3.297 +                    <jvmarg line="${run.jvmargs}"/>
   3.298 +                    <classpath>
   3.299 +                        <path path="@{classpath}"/>
   3.300 +                    </classpath>
   3.301 +                    <syspropertyset>
   3.302 +                        <propertyref prefix="run-sys-prop."/>
   3.303 +                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
   3.304 +                    </syspropertyset>
   3.305 +                    <customize/>
   3.306 +                </java>
   3.307 +            </sequential>
   3.308 +        </macrodef>
   3.309 +    </target>
   3.310 +    <target name="-init-presetdef-jar">
   3.311 +        <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
   3.312 +            <jar compress="${jar.compress}" jarfile="${dist.jar}">
   3.313 +                <j2seproject1:fileset dir="${build.classes.dir}"/>
   3.314 +            </jar>
   3.315 +        </presetdef>
   3.316 +    </target>
   3.317 +    <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-junit,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar" name="init"/>
   3.318 +    <!--
   3.319 +                ===================
   3.320 +                COMPILATION SECTION
   3.321 +                ===================
   3.322 +            -->
   3.323 +    <target depends="init" name="deps-jar" unless="no.deps"/>
   3.324 +    <target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
   3.325 +    <target depends="init" name="-check-automatic-build">
   3.326 +        <available file="${build.classes.dir}/.netbeans_automatic_build" property="netbeans.automatic.build"/>
   3.327 +    </target>
   3.328 +    <target depends="init" if="netbeans.automatic.build" name="-clean-after-automatic-build">
   3.329 +        <antcall target="clean"/>
   3.330 +    </target>
   3.331 +    <target depends="init,deps-jar" name="-pre-pre-compile">
   3.332 +        <mkdir dir="${build.classes.dir}"/>
   3.333 +    </target>
   3.334 +    <target name="-pre-compile">
   3.335 +        <!-- Empty placeholder for easier customization. -->
   3.336 +        <!-- You can override this target in the ../build.xml file. -->
   3.337 +    </target>
   3.338 +    <target if="do.depend.true" name="-compile-depend">
   3.339 +        <j2seproject3:depend/>
   3.340 +    </target>
   3.341 +    <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-compile-depend" if="have.sources" name="-do-compile">
   3.342 +        <j2seproject3:javac/>
   3.343 +        <copy todir="${build.classes.dir}">
   3.344 +            <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
   3.345 +        </copy>
   3.346 +    </target>
   3.347 +    <target name="-post-compile">
   3.348 +        <!-- Empty placeholder for easier customization. -->
   3.349 +        <!-- You can override this target in the ../build.xml file. -->
   3.350 +    </target>
   3.351 +    <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
   3.352 +    <target name="-pre-compile-single">
   3.353 +        <!-- Empty placeholder for easier customization. -->
   3.354 +        <!-- You can override this target in the ../build.xml file. -->
   3.355 +    </target>
   3.356 +    <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
   3.357 +        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
   3.358 +        <j2seproject3:force-recompile/>
   3.359 +        <j2seproject3:javac excludes="" includes="${javac.includes}" sourcepath="${src.dir}"/>
   3.360 +    </target>
   3.361 +    <target name="-post-compile-single">
   3.362 +        <!-- Empty placeholder for easier customization. -->
   3.363 +        <!-- You can override this target in the ../build.xml file. -->
   3.364 +    </target>
   3.365 +    <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
   3.366 +    <!--
   3.367 +                ====================
   3.368 +                JAR BUILDING SECTION
   3.369 +                ====================
   3.370 +            -->
   3.371 +    <target depends="init" name="-pre-pre-jar">
   3.372 +        <dirname file="${dist.jar}" property="dist.jar.dir"/>
   3.373 +        <mkdir dir="${dist.jar.dir}"/>
   3.374 +    </target>
   3.375 +    <target name="-pre-jar">
   3.376 +        <!-- Empty placeholder for easier customization. -->
   3.377 +        <!-- You can override this target in the ../build.xml file. -->
   3.378 +    </target>
   3.379 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" name="-do-jar-without-manifest" unless="manifest.available">
   3.380 +        <j2seproject1:jar/>
   3.381 +    </target>
   3.382 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class">
   3.383 +        <j2seproject1:jar manifest="${manifest.file}"/>
   3.384 +    </target>
   3.385 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class" name="-do-jar-with-mainclass" unless="manifest.available+main.class+mkdist.available">
   3.386 +        <j2seproject1:jar manifest="${manifest.file}">
   3.387 +            <j2seproject1:manifest>
   3.388 +                <j2seproject1:attribute name="Main-Class" value="${main.class}"/>
   3.389 +            </j2seproject1:manifest>
   3.390 +        </j2seproject1:jar>
   3.391 +        <echo>To run this application from the command line without Ant, try:</echo>
   3.392 +        <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
   3.393 +        <property location="${dist.jar}" name="dist.jar.resolved"/>
   3.394 +        <pathconvert property="run.classpath.with.dist.jar">
   3.395 +            <path path="${run.classpath}"/>
   3.396 +            <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
   3.397 +        </pathconvert>
   3.398 +        <echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
   3.399 +    </target>
   3.400 +    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available" name="-do-jar-with-libraries">
   3.401 +        <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
   3.402 +        <pathconvert property="run.classpath.without.build.classes.dir">
   3.403 +            <path path="${run.classpath}"/>
   3.404 +            <map from="${build.classes.dir.resolved}" to=""/>
   3.405 +        </pathconvert>
   3.406 +        <pathconvert pathsep=" " property="jar.classpath">
   3.407 +            <path path="${run.classpath.without.build.classes.dir}"/>
   3.408 +            <chainedmapper>
   3.409 +                <flattenmapper/>
   3.410 +                <globmapper from="*" to="lib/*"/>
   3.411 +            </chainedmapper>
   3.412 +        </pathconvert>
   3.413 +        <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
   3.414 +        <copylibs compress="${jar.compress}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
   3.415 +            <fileset dir="${build.classes.dir}"/>
   3.416 +            <manifest>
   3.417 +                <attribute name="Main-Class" value="${main.class}"/>
   3.418 +                <attribute name="Class-Path" value="${jar.classpath}"/>
   3.419 +            </manifest>
   3.420 +        </copylibs>
   3.421 +        <echo>To run this application from the command line without Ant, try:</echo>
   3.422 +        <property location="${dist.jar}" name="dist.jar.resolved"/>
   3.423 +        <echo>java -jar "${dist.jar.resolved}"</echo>
   3.424 +    </target>
   3.425 +    <target name="-post-jar">
   3.426 +        <!-- Empty placeholder for easier customization. -->
   3.427 +        <!-- You can override this target in the ../build.xml file. -->
   3.428 +    </target>
   3.429 +    <target depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-do-jar-with-libraries,-post-jar" description="Build JAR." name="jar"/>
   3.430 +    <!--
   3.431 +                =================
   3.432 +                EXECUTION SECTION
   3.433 +                =================
   3.434 +            -->
   3.435 +    <target depends="init,compile" description="Run a main class." name="run">
   3.436 +        <j2seproject1:java>
   3.437 +            <customize>
   3.438 +                <arg line="${application.args}"/>
   3.439 +            </customize>
   3.440 +        </j2seproject1:java>
   3.441 +    </target>
   3.442 +    <target name="-do-not-recompile">
   3.443 +        <property name="javac.includes.binary" value=""/>
   3.444 +    </target>
   3.445 +    <target depends="init,-do-not-recompile,compile-single" name="run-single">
   3.446 +        <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
   3.447 +        <j2seproject1:java classname="${run.class}"/>
   3.448 +    </target>
   3.449 +    <target depends="init,-do-not-recompile,compile-test-single" name="run-test-with-main">
   3.450 +        <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
   3.451 +        <j2seproject1:java classname="${run.class}" classpath="${run.test.classpath}"/>
   3.452 +    </target>
   3.453 +    <!--
   3.454 +                =================
   3.455 +                DEBUGGING SECTION
   3.456 +                =================
   3.457 +            -->
   3.458 +    <target depends="init" if="netbeans.home" name="-debug-start-debugger">
   3.459 +        <j2seproject1:nbjpdastart name="${debug.class}"/>
   3.460 +    </target>
   3.461 +    <target depends="init" if="netbeans.home" name="-debug-start-debugger-main-test">
   3.462 +        <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${debug.class}"/>
   3.463 +    </target>
   3.464 +    <target depends="init,compile" name="-debug-start-debuggee">
   3.465 +        <j2seproject3:debug>
   3.466 +            <customize>
   3.467 +                <arg line="${application.args}"/>
   3.468 +            </customize>
   3.469 +        </j2seproject3:debug>
   3.470 +    </target>
   3.471 +    <target depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE." if="netbeans.home" name="debug"/>
   3.472 +    <target depends="init" if="netbeans.home" name="-debug-start-debugger-stepinto">
   3.473 +        <j2seproject1:nbjpdastart stopclassname="${main.class}"/>
   3.474 +    </target>
   3.475 +    <target depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee" if="netbeans.home" name="debug-stepinto"/>
   3.476 +    <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single">
   3.477 +        <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
   3.478 +        <j2seproject3:debug classname="${debug.class}"/>
   3.479 +    </target>
   3.480 +    <target depends="init,-do-not-recompile,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>
   3.481 +    <target depends="init,compile-test-single" if="netbeans.home" name="-debug-start-debuggee-main-test">
   3.482 +        <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
   3.483 +        <j2seproject3:debug classname="${debug.class}" classpath="${debug.test.classpath}"/>
   3.484 +    </target>
   3.485 +    <target depends="init,-do-not-recompile,compile-test-single,-debug-start-debugger-main-test,-debug-start-debuggee-main-test" if="netbeans.home" name="debug-test-with-main"/>
   3.486 +    <target depends="init" name="-pre-debug-fix">
   3.487 +        <fail unless="fix.includes">Must set fix.includes</fail>
   3.488 +        <property name="javac.includes" value="${fix.includes}.java"/>
   3.489 +    </target>
   3.490 +    <target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix">
   3.491 +        <j2seproject1:nbjpdareload/>
   3.492 +    </target>
   3.493 +    <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
   3.494 +    <!--
   3.495 +                ===============
   3.496 +                JAVADOC SECTION
   3.497 +                ===============
   3.498 +            -->
   3.499 +    <target depends="init" name="-javadoc-build">
   3.500 +        <mkdir dir="${dist.javadoc.dir}"/>
   3.501 +        <javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">
   3.502 +            <classpath>
   3.503 +                <path path="${javac.classpath}"/>
   3.504 +            </classpath>
   3.505 +            <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
   3.506 +                <filename name="**/*.java"/>
   3.507 +            </fileset>
   3.508 +        </javadoc>
   3.509 +    </target>
   3.510 +    <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview">
   3.511 +        <nbbrowse file="${dist.javadoc.dir}/index.html"/>
   3.512 +    </target>
   3.513 +    <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
   3.514 +    <!--
   3.515 +                =========================
   3.516 +                JUNIT COMPILATION SECTION
   3.517 +                =========================
   3.518 +            -->
   3.519 +    <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
   3.520 +        <mkdir dir="${build.test.classes.dir}"/>
   3.521 +    </target>
   3.522 +    <target name="-pre-compile-test">
   3.523 +        <!-- Empty placeholder for easier customization. -->
   3.524 +        <!-- You can override this target in the ../build.xml file. -->
   3.525 +    </target>
   3.526 +    <target if="do.depend.true" name="-compile-test-depend">
   3.527 +        <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
   3.528 +    </target>
   3.529 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
   3.530 +        <j2seproject3:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
   3.531 +        <copy todir="${build.test.classes.dir}">
   3.532 +            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
   3.533 +        </copy>
   3.534 +    </target>
   3.535 +    <target name="-post-compile-test">
   3.536 +        <!-- Empty placeholder for easier customization. -->
   3.537 +        <!-- You can override this target in the ../build.xml file. -->
   3.538 +    </target>
   3.539 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/>
   3.540 +    <target name="-pre-compile-test-single">
   3.541 +        <!-- Empty placeholder for easier customization. -->
   3.542 +        <!-- You can override this target in the ../build.xml file. -->
   3.543 +    </target>
   3.544 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
   3.545 +        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
   3.546 +        <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/>
   3.547 +        <j2seproject3:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" excludes="" includes="${javac.includes}" sourcepath="${test.src.dir}" srcdir="${test.src.dir}"/>
   3.548 +        <copy todir="${build.test.classes.dir}">
   3.549 +            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
   3.550 +        </copy>
   3.551 +    </target>
   3.552 +    <target name="-post-compile-test-single">
   3.553 +        <!-- Empty placeholder for easier customization. -->
   3.554 +        <!-- You can override this target in the ../build.xml file. -->
   3.555 +    </target>
   3.556 +    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single" name="compile-test-single"/>
   3.557 +    <!--
   3.558 +                =======================
   3.559 +                JUNIT EXECUTION SECTION
   3.560 +                =======================
   3.561 +            -->
   3.562 +    <target depends="init" if="have.tests" name="-pre-test-run">
   3.563 +        <mkdir dir="${build.test.results.dir}"/>
   3.564 +    </target>
   3.565 +    <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
   3.566 +        <j2seproject3:junit testincludes="**/*Test.java"/>
   3.567 +    </target>
   3.568 +    <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
   3.569 +        <fail if="tests.failed">Some tests failed; see details above.</fail>
   3.570 +    </target>
   3.571 +    <target depends="init" if="have.tests" name="test-report"/>
   3.572 +    <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/>
   3.573 +    <target depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests." name="test"/>
   3.574 +    <target depends="init" if="have.tests" name="-pre-test-run-single">
   3.575 +        <mkdir dir="${build.test.results.dir}"/>
   3.576 +    </target>
   3.577 +    <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
   3.578 +        <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
   3.579 +        <j2seproject3:junit excludes="" includes="${test.includes}"/>
   3.580 +    </target>
   3.581 +    <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
   3.582 +        <fail if="tests.failed">Some tests failed; see details above.</fail>
   3.583 +    </target>
   3.584 +    <target depends="init,-do-not-recompile,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test." name="test-single"/>
   3.585 +    <!--
   3.586 +                =======================
   3.587 +                JUNIT DEBUGGING SECTION
   3.588 +                =======================
   3.589 +            -->
   3.590 +    <target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
   3.591 +        <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
   3.592 +        <property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/>
   3.593 +        <delete file="${test.report.file}"/>
   3.594 +        <mkdir dir="${build.test.results.dir}"/>
   3.595 +        <j2seproject3:debug classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner" classpath="${ant.home}/lib/ant.jar:${ant.home}/lib/ant-junit.jar:${debug.test.classpath}">
   3.596 +            <customize>
   3.597 +                <syspropertyset>
   3.598 +                    <propertyref prefix="test-sys-prop."/>
   3.599 +                    <mapper from="test-sys-prop.*" to="*" type="glob"/>
   3.600 +                </syspropertyset>
   3.601 +                <arg value="${test.class}"/>
   3.602 +                <arg value="showoutput=true"/>
   3.603 +                <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
   3.604 +                <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
   3.605 +            </customize>
   3.606 +        </j2seproject3:debug>
   3.607 +    </target>
   3.608 +    <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
   3.609 +        <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
   3.610 +    </target>
   3.611 +    <target depends="init,-do-not-recompile,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
   3.612 +    <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
   3.613 +        <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
   3.614 +    </target>
   3.615 +    <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
   3.616 +    <!--
   3.617 +                =========================
   3.618 +                APPLET EXECUTION SECTION
   3.619 +                =========================
   3.620 +            -->
   3.621 +    <target depends="init,compile-single" name="run-applet">
   3.622 +        <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
   3.623 +        <j2seproject1:java classname="sun.applet.AppletViewer">
   3.624 +            <customize>
   3.625 +                <arg value="${applet.url}"/>
   3.626 +            </customize>
   3.627 +        </j2seproject1:java>
   3.628 +    </target>
   3.629 +    <!--
   3.630 +                =========================
   3.631 +                APPLET DEBUGGING  SECTION
   3.632 +                =========================
   3.633 +            -->
   3.634 +    <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet">
   3.635 +        <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
   3.636 +        <j2seproject3:debug classname="sun.applet.AppletViewer">
   3.637 +            <customize>
   3.638 +                <arg value="${applet.url}"/>
   3.639 +            </customize>
   3.640 +        </j2seproject3:debug>
   3.641 +    </target>
   3.642 +    <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/>
   3.643 +    <!--
   3.644 +                ===============
   3.645 +                CLEANUP SECTION
   3.646 +                ===============
   3.647 +            -->
   3.648 +    <target depends="init" name="deps-clean" unless="no.deps"/>
   3.649 +    <target depends="init" name="-do-clean">
   3.650 +        <delete dir="${build.dir}"/>
   3.651 +        <delete dir="${dist.dir}"/>
   3.652 +    </target>
   3.653 +    <target name="-post-clean">
   3.654 +        <!-- Empty placeholder for easier customization. -->
   3.655 +        <!-- You can override this target in the ../build.xml file. -->
   3.656 +    </target>
   3.657 +    <target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/>
   3.658 +</project>
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/samples/codeinjection/nbproject/genfiles.properties	Sat Jan 10 21:29:22 2009 +0100
     4.3 @@ -0,0 +1,8 @@
     4.4 +build.xml.data.CRC32=4a8b5abf
     4.5 +build.xml.script.CRC32=83b773e3
     4.6 +build.xml.stylesheet.CRC32=958a1d3e
     4.7 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
     4.8 +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
     4.9 +nbproject/build-impl.xml.data.CRC32=4a8b5abf
    4.10 +nbproject/build-impl.xml.script.CRC32=87b63499
    4.11 +nbproject/build-impl.xml.stylesheet.CRC32=18b47a54
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/samples/codeinjection/nbproject/project.properties	Sat Jan 10 21:29:22 2009 +0100
     5.3 @@ -0,0 +1,65 @@
     5.4 +build.classes.dir=${build.dir}/classes
     5.5 +build.classes.excludes=**/*.java,**/*.form
     5.6 +# This directory is removed when the project is cleaned:
     5.7 +build.dir=build
     5.8 +build.generated.dir=${build.dir}/generated
     5.9 +# Only compile against the classpath explicitly listed here:
    5.10 +build.sysclasspath=ignore
    5.11 +build.test.classes.dir=${build.dir}/test/classes
    5.12 +build.test.results.dir=${build.dir}/test/results
    5.13 +# Uncomment to specify the preferred debugger connection transport:
    5.14 +#debug.transport=dt_socket
    5.15 +debug.classpath=\
    5.16 +    ${run.classpath}
    5.17 +debug.test.classpath=\
    5.18 +    ${run.test.classpath}
    5.19 +# This directory is removed when the project is cleaned:
    5.20 +dist.dir=dist
    5.21 +dist.jar=${dist.dir}/codeinjection.jar
    5.22 +dist.javadoc.dir=${dist.dir}/javadoc
    5.23 +excludes=
    5.24 +file.reference.junit-4.4.jar=../libs/dist/junit-4.4.jar
    5.25 +file.reference.org-netbeans-insane.jar=../libs/dist/org-netbeans-insane.jar
    5.26 +file.reference.org-netbeans-modules-nbjunit.jar=../libs/dist/org-netbeans-modules-nbjunit.jar
    5.27 +includes=**
    5.28 +jar.compress=false
    5.29 +javac.classpath=
    5.30 +# Space-separated list of extra javac options
    5.31 +javac.compilerargs=
    5.32 +javac.deprecation=false
    5.33 +javac.source=1.5
    5.34 +javac.target=1.5
    5.35 +javac.test.classpath=\
    5.36 +    ${javac.classpath}:\
    5.37 +    ${build.classes.dir}:\
    5.38 +    ${file.reference.junit-4.4.jar}:\
    5.39 +    ${file.reference.org-netbeans-insane.jar}:\
    5.40 +    ${file.reference.org-netbeans-modules-nbjunit.jar}
    5.41 +javadoc.additionalparam=
    5.42 +javadoc.author=false
    5.43 +javadoc.encoding=${source.encoding}
    5.44 +javadoc.noindex=false
    5.45 +javadoc.nonavbar=false
    5.46 +javadoc.notree=false
    5.47 +javadoc.private=false
    5.48 +javadoc.splitindex=true
    5.49 +javadoc.use=true
    5.50 +javadoc.version=false
    5.51 +javadoc.windowtitle=
    5.52 +main.class=org.apidesign.codeinjection.Main
    5.53 +manifest.file=manifest.mf
    5.54 +meta.inf.dir=${src.dir}/META-INF
    5.55 +platform.active=default_platform
    5.56 +run.classpath=\
    5.57 +    ${javac.classpath}:\
    5.58 +    ${build.classes.dir}
    5.59 +# Space-separated list of JVM arguments used when running the project
    5.60 +# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
    5.61 +# or test-sys-prop.name=value to set system properties for unit tests):
    5.62 +run.jvmargs=
    5.63 +run.test.classpath=\
    5.64 +    ${javac.test.classpath}:\
    5.65 +    ${build.test.classes.dir}
    5.66 +source.encoding=UTF-8
    5.67 +src.dir=src
    5.68 +test.src.dir=test
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/samples/codeinjection/nbproject/project.xml	Sat Jan 10 21:29:22 2009 +0100
     6.3 @@ -0,0 +1,16 @@
     6.4 +<?xml version="1.0" encoding="UTF-8"?>
     6.5 +<project xmlns="http://www.netbeans.org/ns/project/1">
     6.6 +    <type>org.netbeans.modules.java.j2seproject</type>
     6.7 +    <configuration>
     6.8 +        <data xmlns="http://www.netbeans.org/ns/j2se-project/3">
     6.9 +            <name>codeinjection</name>
    6.10 +            <minimum-ant-version>1.6.5</minimum-ant-version>
    6.11 +            <source-roots>
    6.12 +                <root id="src.dir"/>
    6.13 +            </source-roots>
    6.14 +            <test-roots>
    6.15 +                <root id="test.src.dir"/>
    6.16 +            </test-roots>
    6.17 +        </data>
    6.18 +    </configuration>
    6.19 +</project>
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/samples/codeinjection/src/org/apidesign/codeinjection/CountDown.java	Sat Jan 10 21:29:22 2009 +0100
     7.3 @@ -0,0 +1,27 @@
     7.4 +/*
     7.5 + * To change this template, choose Tools | Templates
     7.6 + * and open the template in the editor.
     7.7 + */
     7.8 +
     7.9 +package org.apidesign.codeinjection;
    7.10 +
    7.11 +/** API class that can counts a count down.
    7.12 + *
    7.13 + * @author Jaroslav Tulach <jtulach@netbeans.org>
    7.14 + * @since 1.0
    7.15 + */
    7.16 +// BEGIN: codeinjection.CountDown
    7.17 +public abstract class CountDown {
    7.18 +    CountDown() {
    7.19 +    }
    7.20 +
    7.21 +    public static CountDown create(int initial) {
    7.22 +        return new CountDownImplV1(initial);
    7.23 +    }
    7.24 +
    7.25 +    /** Decrements the counter */
    7.26 +    public abstract void down();
    7.27 +    /** @return true if the counter is 0 or less */
    7.28 +    public abstract boolean isDown();
    7.29 +}
    7.30 +// END: codeinjection.CountDown
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/samples/codeinjection/src/org/apidesign/codeinjection/CountDownImplV1.java	Sat Jan 10 21:29:22 2009 +0100
     8.3 @@ -0,0 +1,29 @@
     8.4 +/*
     8.5 + * To change this template, choose Tools | Templates
     8.6 + * and open the template in the editor.
     8.7 + */
     8.8 +
     8.9 +package org.apidesign.codeinjection;
    8.10 +
    8.11 +/** The implementation of {@link CountDown} as of version 1.0.
    8.12 + * The {@link #down()} method always decrements by one.
    8.13 + *
    8.14 + * @author Jaroslav Tulach <jtulach@netbeans.org>
    8.15 + * @since 1.0
    8.16 + */
    8.17 +final class CountDownImplV1 extends CountDown {
    8.18 +    CountDownImplV1(int initial) {
    8.19 +        this.cnt = initial;
    8.20 +    }
    8.21 +    
    8.22 +// BEGIN: codeinjection.v1
    8.23 +    private int cnt;
    8.24 +    public void down() {
    8.25 +        cnt--;
    8.26 +    }
    8.27 +
    8.28 +    public boolean isDown() {
    8.29 +        return cnt <= 0;
    8.30 +    }
    8.31 +// END: codeinjection.v1
    8.32 +}
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/samples/codeinjection/src/org/apidesign/codeinjection/CountDownImplV2.java	Sat Jan 10 21:29:22 2009 +0100
     9.3 @@ -0,0 +1,44 @@
     9.4 +/*
     9.5 + * To change this template, choose Tools | Templates
     9.6 + * and open the template in the editor.
     9.7 + */
     9.8 +
     9.9 +package org.apidesign.codeinjection;
    9.10 +
    9.11 +import java.util.Iterator;
    9.12 +import java.util.ServiceLoader;
    9.13 +import org.apidesign.codeinjection.spi.CountDownExtender;
    9.14 +
    9.15 +/** Second version to {@link CountDownImplV1} - imagine someone wants to
    9.16 + * reimplement {@link #down()} method to decrement by two not just by one.
    9.17 + * You do not like that idea at all, but you do not want to prevent such
    9.18 + * behaviour. You just do not want to maintain such bloody code. What can
    9.19 + * you do? You need to allow <b>code injection</b> via the
    9.20 + * {@link CountDownExtender} class!
    9.21 + *
    9.22 + * @author Jaroslav Tulach <jtulach@netbeans.org>
    9.23 + */
    9.24 +final class CountDownImplV2 extends CountDown {
    9.25 +    private int cnt;
    9.26 +
    9.27 +    CountDownImplV2(int initial) {
    9.28 +        this.cnt = initial;
    9.29 +    }
    9.30 +
    9.31 +// BEGIN: codeinjection.v2
    9.32 +    public void down() {
    9.33 +        Iterator<CountDownExtender> it = ServiceLoader.load(CountDownExtender.class).iterator();
    9.34 +        if (it.hasNext()) {
    9.35 +            // injected behaviour
    9.36 +            cnt = it.next().decrement(cnt);
    9.37 +        } else {
    9.38 +            // common behaviour of 1.0 version
    9.39 +            cnt--;
    9.40 +        }
    9.41 +    }
    9.42 +
    9.43 +    public boolean isDown() {
    9.44 +        return cnt <= 0;
    9.45 +    }
    9.46 +// END: codeinjection.v2
    9.47 +}
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/samples/codeinjection/src/org/apidesign/codeinjection/spi/CountDownExtender.java	Sat Jan 10 21:29:22 2009 +0100
    10.3 @@ -0,0 +1,17 @@
    10.4 +package org.apidesign.codeinjection.spi;
    10.5 +
    10.6 +/** Allows to define meaning of "--"
    10.7 + *
    10.8 + * @author Jaroslav Tulach <jtulach@netbeans.org>
    10.9 + * @since 2.0
   10.10 + */
   10.11 +// BEGIN: codeinjection.slot
   10.12 +public interface CountDownExtender {
   10.13 +    /** Allows providers to specify that it means to "decrement" a value.
   10.14 +     *
   10.15 +     * @param value previous value
   10.16 +     * @return result of "--" operation in interpretation of this extender
   10.17 +     */
   10.18 +    public int decrement(int value);
   10.19 +}
   10.20 +// END: codeinjection.slot
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/samples/codeinjection/test/org/apidesign/codeinjection/Version10Test.java	Sat Jan 10 21:29:22 2009 +0100
    11.3 @@ -0,0 +1,34 @@
    11.4 +/*
    11.5 + * To change this template, choose Tools | Templates
    11.6 + * and open the template in the editor.
    11.7 + */
    11.8 +
    11.9 +package org.apidesign.codeinjection;
   11.10 +
   11.11 +import org.junit.Test;
   11.12 +import static org.junit.Assert.*;
   11.13 +
   11.14 +/** Final count down test.
   11.15 + *
   11.16 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   11.17 + */
   11.18 +public class Version10Test {
   11.19 +
   11.20 +    public Version10Test() {
   11.21 +    }
   11.22 +
   11.23 +    /** creates version 1.0 */
   11.24 +    private static CountDown create(int value) {
   11.25 +        return new CountDownImplV1(value);
   11.26 +    }
   11.27 +
   11.28 +    @Test
   11.29 +    public void testDecrementFourTimes() {
   11.30 +        CountDown counter = create(4);
   11.31 +        assertFalse("Not down yet", counter.isDown()); counter.down();
   11.32 +        assertFalse("Not down yet", counter.isDown()); counter.down();
   11.33 +        assertFalse("Not down yet", counter.isDown()); counter.down();
   11.34 +        assertFalse("Not down yet", counter.isDown()); counter.down();
   11.35 +        assertTrue("Down now", counter.isDown());
   11.36 +    }
   11.37 +}
   11.38 \ No newline at end of file
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/samples/codeinjection/test/org/apidesign/codeinjection/Version20Test.java	Sat Jan 10 21:29:22 2009 +0100
    12.3 @@ -0,0 +1,52 @@
    12.4 +/*
    12.5 + * To change this template, choose Tools | Templates
    12.6 + * and open the template in the editor.
    12.7 + */
    12.8 +
    12.9 +package org.apidesign.codeinjection;
   12.10 +
   12.11 +import org.apidesign.codeinjection.spi.CountDownExtender;
   12.12 +import org.junit.Test;
   12.13 +import org.netbeans.junit.MockServices;
   12.14 +import static org.junit.Assert.*;
   12.15 +
   12.16 +/** Final count down test.
   12.17 + *
   12.18 + * @author Jaroslav Tulach <jtulach@netbeans.org>
   12.19 + */
   12.20 +public class Version20Test {
   12.21 +
   12.22 +    public Version20Test() {
   12.23 +    }
   12.24 +
   12.25 +    /** creates version 2.0 */
   12.26 +    private static CountDown create(int value) {
   12.27 +        return new CountDownImplV2(value);
   12.28 +    }
   12.29 +
   12.30 +    @Test
   12.31 +    public void testDecrementFourTimes() {
   12.32 +        MockServices.setServices();
   12.33 +        CountDown counter = create(4);
   12.34 +        assertFalse("Not down yet", counter.isDown()); counter.down();
   12.35 +        assertFalse("Not down yet", counter.isDown()); counter.down();
   12.36 +        assertFalse("Not down yet", counter.isDown()); counter.down();
   12.37 +        assertFalse("Not down yet", counter.isDown()); counter.down();
   12.38 +        assertTrue("Down now", counter.isDown());
   12.39 +    }
   12.40 +
   12.41 +    @Test
   12.42 +    public void testDecrementTwoTimesEnough() {
   12.43 +        MockServices.setServices(DecrementByTwo.class);
   12.44 +        CountDown counter = create(4);
   12.45 +        assertFalse("Not down yet", counter.isDown()); counter.down();
   12.46 +        assertFalse("Not down yet", counter.isDown()); counter.down();
   12.47 +        assertTrue("Two Down is enough", counter.isDown());
   12.48 +    }
   12.49 +
   12.50 +    public static final class DecrementByTwo implements CountDownExtender {
   12.51 +        public int decrement(int value) {
   12.52 +            return value - 2;
   12.53 +        }
   12.54 +    }
   12.55 +}
   12.56 \ No newline at end of file