Finished review of "are abstract classes useful?", up to line 1600
authorJaroslav Tulach <jtulach@netbeans.org>
Sat, 14 Jun 2008 09:53:37 +0200
changeset 76ee4e8d38093e
parent 75 aa07c59612ac
child 77 22c1953e372c
Finished review of "are abstract classes useful?", up to line 1600
samples/forjoe/build.xml
samples/forjoe/nbproject/project.xml
samples/forjoe/src-api1.0/api/InterfaceThatJustJoeCanImplement.java
samples/forjoe/src-impl/impl/joe/JoesImpl.java
samples/forjoe/src-impl/impl/joe/Main.java
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/samples/forjoe/build.xml	Sat Jun 14 09:53:37 2008 +0200
     1.3 @@ -0,0 +1,47 @@
     1.4 +<?xml version="1.0" encoding="UTF-8"?>
     1.5 +<project name="forjoe" default="run" basedir=".">
     1.6 +    <target name="clean">
     1.7 +        <delete dir="build"/>
     1.8 +    </target>
     1.9 +    
    1.10 +    <target name="build">
    1.11 +        <antcall target="-build-one">
    1.12 +            <param name="version" value="api1.0"/>
    1.13 +        </antcall>
    1.14 +        <echo level="info" message="Compiling the Implementation. This should succeed."/>
    1.15 +        <antcall target="-build-one">
    1.16 +            <param name="version" value="impl"/>
    1.17 +            <param name="cp" location="build/api1.0/classes"/>
    1.18 +        </antcall>
    1.19 +    </target>
    1.20 +    
    1.21 +    <target name="run" depends="build">
    1.22 +        <echo level="info" message="Instantiating and running Joe's implementation. This should succeed."/>
    1.23 +        <antcall target="-run-one">
    1.24 +            <param name="version" value="api1.0"/>
    1.25 +        </antcall>
    1.26 +    </target>
    1.27 +
    1.28 +    
    1.29 +    <!-- support methods -->
    1.30 +    
    1.31 +    <target name="-run-one">
    1.32 +        <fail message="You need to specify API version number" unless="version"/>
    1.33 +        <java classpath="build/${version}/classes:build/impl/classes" classname="impl.joe.Main"
    1.34 +            failonerror="true"
    1.35 +        />
    1.36 +    </target>
    1.37 +    
    1.38 +    <target name="-build-one">
    1.39 +        <fail message="You need to specify version number" unless="version"/>
    1.40 +        
    1.41 +        <mkdir dir="build/${version}/classes"/>
    1.42 +        <property name="cp" value=""/>
    1.43 +        <javac 
    1.44 +            srcdir="src-${version}" 
    1.45 +            destdir="build/${version}/classes" 
    1.46 +            source="1.5" target="1.5"
    1.47 +            classpath="${cp}"
    1.48 +        />
    1.49 +    </target>
    1.50 +</project>
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/samples/forjoe/nbproject/project.xml	Sat Jun 14 09:53:37 2008 +0200
     2.3 @@ -0,0 +1,81 @@
     2.4 +<?xml version="1.0" encoding="UTF-8"?>
     2.5 +<project xmlns="http://www.netbeans.org/ns/project/1" xmlns:ns4="null">
     2.6 +    <type>org.netbeans.modules.ant.freeform</type>
     2.7 +    <configuration>
     2.8 +        <general-data xmlns="http://www.netbeans.org/ns/freeform-project/1">
     2.9 +            <name>forjoe</name>
    2.10 +        </general-data>
    2.11 +        <general-data xmlns="http://www.netbeans.org/ns/freeform-project/2">
    2.12 +            <!-- Do not use Project Properties customizer when editing this file manually. -->
    2.13 +            <name>forjoe</name>
    2.14 +            <properties/>
    2.15 +            <folders>
    2.16 +                <source-folder>
    2.17 +                    <label>forjoe</label>
    2.18 +                    <location>.</location>
    2.19 +                    <encoding>UTF-8</encoding>
    2.20 +                </source-folder>
    2.21 +                <source-folder>
    2.22 +                    <label>src-api1.0</label>
    2.23 +                    <type>java</type>
    2.24 +                    <location>src-api1.0</location>
    2.25 +                    <encoding>UTF-8</encoding>
    2.26 +                </source-folder>
    2.27 +                <source-folder>
    2.28 +                    <label>impl</label>
    2.29 +                    <type>java</type>
    2.30 +                    <location>src-impl</location>
    2.31 +                    <encoding>UTF-8</encoding>
    2.32 +                </source-folder>
    2.33 +            </folders>
    2.34 +            <ide-actions>
    2.35 +                <action name="build">
    2.36 +                    <target>build</target>
    2.37 +                </action>
    2.38 +                <action name="clean">
    2.39 +                    <target>clean</target>
    2.40 +                </action>
    2.41 +                <action name="run">
    2.42 +                    <target>run</target>
    2.43 +                </action>
    2.44 +                <action name="rebuild">
    2.45 +                    <target>clean</target>
    2.46 +                    <target>build</target>
    2.47 +                </action>
    2.48 +            </ide-actions>
    2.49 +            <view>
    2.50 +                <items>
    2.51 +                    <source-folder style="packages">
    2.52 +                        <label>src-api1.0</label>
    2.53 +                        <location>src-api1.0</location>
    2.54 +                    </source-folder>
    2.55 +                    <source-folder style="packages">
    2.56 +                        <label>impl</label>
    2.57 +                        <location>src-impl</location>
    2.58 +                    </source-folder>
    2.59 +                    <source-file>
    2.60 +                        <location>build.xml</location>
    2.61 +                    </source-file>
    2.62 +                </items>
    2.63 +                <context-menu>
    2.64 +                    <ide-action name="build"/>
    2.65 +                    <ide-action name="rebuild"/>
    2.66 +                    <ide-action name="clean"/>
    2.67 +                    <ide-action name="run"/>
    2.68 +                </context-menu>
    2.69 +            </view>
    2.70 +            <subprojects/>
    2.71 +        </general-data>
    2.72 +        <java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/1">
    2.73 +            <compilation-unit>
    2.74 +                <package-root>src-api1.0</package-root>
    2.75 +                <source-level>1.5</source-level>
    2.76 +            </compilation-unit>
    2.77 +            <compilation-unit>
    2.78 +                <package-root>src-impl</package-root>
    2.79 +                <classpath mode="compile">src-api1.0</classpath>
    2.80 +                <source-level>1.5</source-level>
    2.81 +            </compilation-unit>
    2.82 +        </java-data>
    2.83 +    </configuration>
    2.84 +</project>
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/samples/forjoe/src-api1.0/api/InterfaceThatJustJoeCanImplement.java	Sat Jun 14 09:53:37 2008 +0200
     3.3 @@ -0,0 +1,13 @@
     3.4 +package api;
     3.5 +
     3.6 +// BEGIN: forjoe.InterfaceThatJustJoeCanImplement
     3.7 +public abstract class InterfaceThatJustJoeCanImplement {
     3.8 +    protected InterfaceThatJustJoeCanImplement() {
     3.9 +        if (!"impl.joe.JoesImpl".equals(getClass().getName())) {
    3.10 +            throw new IllegalStateException("Sorry, you are not allowed to implement this class");
    3.11 +        }
    3.12 +    }
    3.13 +    
    3.14 +    public abstract void everyoneCallThisJoeWillHandleTheRequest();
    3.15 +}
    3.16 +// END: forjoe.InterfaceThatJustJoeCanImplement
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/samples/forjoe/src-impl/impl/joe/JoesImpl.java	Sat Jun 14 09:53:37 2008 +0200
     4.3 @@ -0,0 +1,9 @@
     4.4 +package impl.joe;
     4.5 +
     4.6 +import api.InterfaceThatJustJoeCanImplement;
     4.7 +
     4.8 +public class JoesImpl extends InterfaceThatJustJoeCanImplement {
     4.9 +    @Override
    4.10 +    public void everyoneCallThisJoeWillHandleTheRequest() {
    4.11 +    }
    4.12 +}
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/samples/forjoe/src-impl/impl/joe/Main.java	Sat Jun 14 09:53:37 2008 +0200
     5.3 @@ -0,0 +1,12 @@
     5.4 +
     5.5 +package impl.joe;
     5.6 +
     5.7 +import api.InterfaceThatJustJoeCanImplement;
     5.8 +
     5.9 +public class Main {
    5.10 +    public static void main(String[] args) throws Exception {
    5.11 +        InterfaceThatJustJoeCanImplement i = new JoesImpl();
    5.12 +        
    5.13 +        i.everyoneCallThisJoeWillHandleTheRequest();
    5.14 +    }
    5.15 +}