# HG changeset patch # User Jaroslav Tulach # Date 1213430031 -7200 # Node ID 30a0c70c6579d3a865f4c54c1cdd8fb01b5481f4 # Parent 06f2e2a3d986f846188801c3c4017cfac108fb85 AServerInfo projectized, except the final advice to create the "clonning factory" diff -r 06f2e2a3d986 -r 30a0c70c6579 samples/aserverinfo/build.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/samples/aserverinfo/build.xml Sat Jun 14 09:53:51 2008 +0200 @@ -0,0 +1,69 @@ + + + + + + Builds, tests, and runs the project aserverinfo. + + + diff -r 06f2e2a3d986 -r 30a0c70c6579 samples/aserverinfo/nbproject/build-impl.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/samples/aserverinfo/nbproject/build-impl.xml Sat Jun 14 09:53:51 2008 +0200 @@ -0,0 +1,627 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + + + + + + java -cp "${run.classpath.with.dist.jar}" ${main.class} + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + diff -r 06f2e2a3d986 -r 30a0c70c6579 samples/aserverinfo/nbproject/genfiles.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/samples/aserverinfo/nbproject/genfiles.properties Sat Jun 14 09:53:51 2008 +0200 @@ -0,0 +1,8 @@ +build.xml.data.CRC32=c82747ea +build.xml.script.CRC32=68215f8a +build.xml.stylesheet.CRC32=be360661 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=c82747ea +nbproject/build-impl.xml.script.CRC32=b22c6fb6 +nbproject/build-impl.xml.stylesheet.CRC32=f1d9da08 diff -r 06f2e2a3d986 -r 30a0c70c6579 samples/aserverinfo/nbproject/project.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/samples/aserverinfo/nbproject/project.properties Sat Jun 14 09:53:51 2008 +0200 @@ -0,0 +1,65 @@ +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +debug.classpath=\ + ${run.classpath} +debug.test.classpath=\ + ${run.test.classpath} +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/aserverinfo.jar +dist.javadoc.dir=${dist.dir}/javadoc +excludes= +file.reference.junit-4.4.jar=../libs/dist/junit-4.4.jar +file.reference.org-netbeans-insane.jar=../libs/dist/org-netbeans-insane.jar +file.reference.org-netbeans-modules-nbjunit.jar=../libs/dist/org-netbeans-modules-nbjunit.jar +file.reference.org-openide-util.jar=../libs/dist/org-openide-util.jar +includes=** +jar.compress=false +javac.classpath=\ + ${file.reference.org-openide-util.jar} +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.source=1.5 +javac.target=1.5 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir}:\ + ${libs.junit.classpath}:\ + ${libs.junit_4.classpath}:\ + ${file.reference.org-netbeans-modules-nbjunit.jar}:\ + ${file.reference.org-netbeans-insane.jar}:\ + ${file.reference.junit-4.4.jar} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +meta.inf.dir=${src.dir}/META-INF +platform.active=default_platform +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project +# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value +# or test-sys-prop.name=value to set system properties for unit tests): +run.jvmargs= +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff -r 06f2e2a3d986 -r 30a0c70c6579 samples/aserverinfo/nbproject/project.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/samples/aserverinfo/nbproject/project.xml Sat Jun 14 09:53:51 2008 +0200 @@ -0,0 +1,16 @@ + + + org.netbeans.modules.java.j2seproject + + + aserverinfo + 1.6.5 + + + + + + + + + diff -r 06f2e2a3d986 -r 30a0c70c6579 samples/aserverinfo/src/org/apidesign/aserverinfo/AServerInfo.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/samples/aserverinfo/src/org/apidesign/aserverinfo/AServerInfo.java Sat Jun 14 09:53:51 2008 +0200 @@ -0,0 +1,140 @@ +package org.apidesign.aserverinfo; + +import java.net.URL; +import java.util.concurrent.Callable; +import org.openide.util.Exceptions; +import org.openide.util.Lookup; + +public final class AServerInfo { + private final Callable name; + private final Callable url; + private final Callable reset; + private final Callable shutdown; + + public AServerInfo(Callable name, Callable url, Callable reset, Callable s) { + this.name = name; + this.url = url; + this.reset = reset; + this.shutdown = s; + } + + public String getName() { + return call(name, "noname"); + } + + public URL getURL() { + return call(url, null); + } + + public void reset() throws Exception { + reset.call(); + } + + public void shutdown() throws Exception { + shutdown.call(); + } + + + + private static T call(Callable name, T defValue) { + try { + return name.call(); + } catch (Exception ex) { + return defValue; + } + } + + // BEGIN: aserverinfo.create + public interface NameProvider { + public String getName(); + } + public interface URLProvider { + public URL getURL(); + } + public interface ResetHandler { + public void reset(); + } + + public static AServerInfo create(final Lookup interfaces) + // END: aserverinfo.create + { + Callable nameP = new Callable() { + public String call() throws Exception { + NameProvider p = interfaces.lookup(NameProvider.class); + return p == null ? "noname" : p.getName(); + } + }; + Callable urlP = new Callable() { + public URL call() throws Exception { + URLProvider p = interfaces.lookup(URLProvider.class); + return p == null ? null : p.getURL(); + } + }; + Callable resetP = new Callable() { + public Void call() throws Exception { + ResetHandler h = interfaces.lookup(ResetHandler.class); + if (h != null) { + h.reset(); + } + return null; + } + }; + + return new AServerInfo(nameP, urlP, resetP, null); + } + + // BEGIN: aserverinfo.regularcreate + public static AServerInfo create(NameProvider nameProvider, URLProvider urlProvider, ResetHandler reset) + // END: aserverinfo.regularcreate + { + return create(nameProvider, urlProvider, reset, null); + } + + // BEGIN: aserverinfo.regularcreate.withshutdown + /** @since 2.0 */ + public interface ShutdownHandler { + public void shutdown(); + } + + /** @since 2.0 */ + public static AServerInfo create(NameProvider nameProvider, URLProvider urlProvider, ResetHandler reset, ShutdownHandler shutdown) + // END: aserverinfo.regularcreate.withshutdown + { + final NameProvider np = nameProvider; + final URLProvider up = urlProvider; + final ResetHandler h = reset; + final ShutdownHandler s = shutdown; + + Callable nameP = new Callable() { + public String call() throws Exception { + return np == null ? "noname" : np.getName(); + } + }; + Callable urlP = new Callable() { + public URL call() throws Exception { + return up == null ? null : up.getURL(); + } + }; + Callable resetP = new Callable() { + public Void call() throws Exception { + if (h != null) { + h.reset(); + } + return null; + } + }; + Callable shutP = new Callable() { + public Void call() throws Exception { + if (s != null) { + s.shutdown(); + } + return null; + } + }; + + return new AServerInfo(nameP, urlP, resetP, shutP); + } + + + +}