# HG changeset patch # User František Kučera # Date 1473541423 -7200 # Node ID 7d86d90e6e0e006b3bc039419ceb123e7dc362e8 # Parent 0684883953ba2a0201667890237c392498feff04 Java version (some old source code) diff -r 0684883953ba -r 7d86d90e6e0e java/parameter-lister/build.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/parameter-lister/build.xml Sat Sep 10 23:03:43 2016 +0200 @@ -0,0 +1,73 @@ + + + + + + + + + + + Builds, tests, and runs the project parameter-lister. + + + diff -r 0684883953ba -r 7d86d90e6e0e java/parameter-lister/config/META-INF/services/info.glogalcode.parameterLister.OutputModuleFactory --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/parameter-lister/config/META-INF/services/info.glogalcode.parameterLister.OutputModuleFactory Sat Sep 10 23:03:43 2016 +0200 @@ -0,0 +1,1 @@ +info.glogalcode.parameterLister.modules.TerminalModuleFactory \ No newline at end of file diff -r 0684883953ba -r 7d86d90e6e0e java/parameter-lister/nbproject/build-impl.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/parameter-lister/nbproject/build-impl.xml Sat Sep 10 23:03:43 2016 +0200 @@ -0,0 +1,1428 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set src.config.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 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + Must select some files in the IDE or set test.includes + + + + + Must select one file in the IDE or set run.class + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + 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 test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 0684883953ba -r 7d86d90e6e0e java/parameter-lister/nbproject/genfiles.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/parameter-lister/nbproject/genfiles.properties Sat Sep 10 23:03:43 2016 +0200 @@ -0,0 +1,8 @@ +build.xml.data.CRC32=3ece69f2 +build.xml.script.CRC32=9b783ee3 +build.xml.stylesheet.CRC32=8064a381@1.75.2.48 +# 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=3ece69f2 +nbproject/build-impl.xml.script.CRC32=1747cb70 +nbproject/build-impl.xml.stylesheet.CRC32=05530350@1.79.1.48 diff -r 0684883953ba -r 7d86d90e6e0e java/parameter-lister/nbproject/project.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/parameter-lister/nbproject/project.properties Sat Sep 10 23:03:43 2016 +0200 @@ -0,0 +1,76 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=false +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +application.title=parameter-lister +application.vendor=fiki +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 +build.generated.sources.dir=${build.dir}/generated-sources +# 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 +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.test.classpath=\ + ${run.test.classpath} +# Files in build.classes.dir which should be excluded from distribution jar +dist.archive.excludes= +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/parameter-lister.jar +dist.javadoc.dir=${dist.dir}/javadoc +endorsed.classpath= +excludes= +includes=** +jar.compress=false +javac.classpath= +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.processorpath=\ + ${javac.classpath} +javac.source=1.8 +javac.target=1.8 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javac.test.processorpath=\ + ${javac.test.classpath} +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= +main.class=info.glogalcode.parameterLister.CLI +manifest.file=manifest.mf +meta.inf.dir=${src.dir}/META-INF +mkdist.disabled=false +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. +# To set system properties for unit tests define test-sys-prop.name=value: +run.jvmargs= +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +source.encoding=UTF-8 +src.config.dir=config +src.dir=src +test.src.dir=test diff -r 0684883953ba -r 7d86d90e6e0e java/parameter-lister/nbproject/project.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/parameter-lister/nbproject/project.xml Sat Sep 10 23:03:43 2016 +0200 @@ -0,0 +1,16 @@ + + + org.netbeans.modules.java.j2seproject + + + parameter-lister + + + + + + + + + + diff -r 0684883953ba -r 7d86d90e6e0e java/parameter-lister/src/info/glogalcode/parameterLister/CLI.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/parameter-lister/src/info/glogalcode/parameterLister/CLI.java Sat Sep 10 23:03:43 2016 +0200 @@ -0,0 +1,53 @@ +package info.glogalcode.parameterLister; + +import info.glogalcode.parameterLister.modules.TerminalModuleFactory; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.ServiceLoader; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * + * @author Ing. František Kučera (frantovo.cz) + */ +public class CLI { + + public static final String ENV_BASE = "PARAMETER_LISTER"; + public static final String ENV_OUTPUT_MODULE_NAME = ENV_BASE + "_OUTPUT"; + public static final String DEFAULT_MODULE = TerminalModuleFactory.MODULE_NAME; + + public static final int EXIT_SUCCESS = 0; + public static final int EXIT_UNEXPECTED_ERROR = 1; + // 2 is reserved: http://www.tldp.org/LDP/abs/html/exitcodes.html#EXITCODESREF + public static final int EXIT_MODULE_ERROR = 3; + + private static final Logger log = Logger.getLogger(CLI.class.getName()); + + public static void main(String[] args) { + + try { + ServiceLoader modulesLoader = ServiceLoader.load(OutputModuleFactory.class); + final Map modules = new HashMap<>(); + modulesLoader.forEach(f -> modules.put(f.getName(), f)); + + String moduleName = System.getenv(ENV_OUTPUT_MODULE_NAME); + OutputModuleFactory moduleFactory = modules.getOrDefault(moduleName, modules.get(DEFAULT_MODULE)); + OutputModule module = moduleFactory.createModule(); + + try { + module.process(System.out, Arrays.asList(args)); + } catch (OutputModuleException e) { + log.log(Level.SEVERE, "Error while processing output with module " + module.getClass().getName(), e); + System.exit(EXIT_MODULE_ERROR); + } + } catch (Exception e) { + log.log(Level.SEVERE, "Unexpected exception, probably bug.", e); + System.exit(EXIT_UNEXPECTED_ERROR); + + } + System.exit(EXIT_SUCCESS); + } + +} diff -r 0684883953ba -r 7d86d90e6e0e java/parameter-lister/src/info/glogalcode/parameterLister/OutputModule.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/parameter-lister/src/info/glogalcode/parameterLister/OutputModule.java Sat Sep 10 23:03:43 2016 +0200 @@ -0,0 +1,14 @@ +package info.glogalcode.parameterLister; + +import java.io.OutputStream; +import java.util.List; + +/** + * + * @author Ing. František Kučera (frantovo.cz) + */ +public interface OutputModule { + + void process(OutputStream output, List parameters) throws OutputModuleException; + +} diff -r 0684883953ba -r 7d86d90e6e0e java/parameter-lister/src/info/glogalcode/parameterLister/OutputModuleException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/parameter-lister/src/info/glogalcode/parameterLister/OutputModuleException.java Sat Sep 10 23:03:43 2016 +0200 @@ -0,0 +1,24 @@ +package info.glogalcode.parameterLister; + +/** + * + * @author Ing. František Kučera (frantovo.cz) + */ +public class OutputModuleException extends ParameterListerException { + + public OutputModuleException() { + } + + public OutputModuleException(String message) { + super(message); + } + + public OutputModuleException(Throwable cause) { + super(cause); + } + + public OutputModuleException(String message, Throwable cause) { + super(message, cause); + } + +} diff -r 0684883953ba -r 7d86d90e6e0e java/parameter-lister/src/info/glogalcode/parameterLister/OutputModuleFactory.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/parameter-lister/src/info/glogalcode/parameterLister/OutputModuleFactory.java Sat Sep 10 23:03:43 2016 +0200 @@ -0,0 +1,13 @@ +package info.glogalcode.parameterLister; + +/** + * + * @author Ing. František Kučera (frantovo.cz) + */ +public interface OutputModuleFactory { + + public OutputModule createModule() throws OutputModuleFactoryException; + + public String getName(); + +} diff -r 0684883953ba -r 7d86d90e6e0e java/parameter-lister/src/info/glogalcode/parameterLister/OutputModuleFactoryException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/parameter-lister/src/info/glogalcode/parameterLister/OutputModuleFactoryException.java Sat Sep 10 23:03:43 2016 +0200 @@ -0,0 +1,24 @@ +package info.glogalcode.parameterLister; + +/** + * + * @author Ing. František Kučera (frantovo.cz) + */ +public class OutputModuleFactoryException extends ParameterListerException { + + public OutputModuleFactoryException() { + } + + public OutputModuleFactoryException(String message) { + super(message); + } + + public OutputModuleFactoryException(Throwable cause) { + super(cause); + } + + public OutputModuleFactoryException(String message, Throwable cause) { + super(message, cause); + } + +} diff -r 0684883953ba -r 7d86d90e6e0e java/parameter-lister/src/info/glogalcode/parameterLister/ParameterListerException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/parameter-lister/src/info/glogalcode/parameterLister/ParameterListerException.java Sat Sep 10 23:03:43 2016 +0200 @@ -0,0 +1,24 @@ +package info.glogalcode.parameterLister; + +/** + * + * @author Ing. František Kučera (frantovo.cz) + */ +public class ParameterListerException extends Exception { + + public ParameterListerException() { + } + + public ParameterListerException(String message) { + super(message); + } + + public ParameterListerException(Throwable cause) { + super(cause); + } + + public ParameterListerException(String message, Throwable cause) { + super(message, cause); + } + +} diff -r 0684883953ba -r 7d86d90e6e0e java/parameter-lister/src/info/glogalcode/parameterLister/modules/AbstractModuleFactory.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/parameter-lister/src/info/glogalcode/parameterLister/modules/AbstractModuleFactory.java Sat Sep 10 23:03:43 2016 +0200 @@ -0,0 +1,35 @@ +package info.glogalcode.parameterLister.modules; + +import info.glogalcode.parameterLister.OutputModule; +import info.glogalcode.parameterLister.OutputModuleFactory; +import info.glogalcode.parameterLister.OutputModuleFactoryException; + +/** + * + * @author Ing. František Kučera (frantovo.cz) + */ +public abstract class AbstractModuleFactory implements OutputModuleFactory { + + private final Class clazz; + private final String name; + + public AbstractModuleFactory(String name, Class clazz) { + this.clazz = clazz; + this.name = name; + } + + @Override + public String getName() { + return name; + } + + @Override + public OutputModule createModule() throws OutputModuleFactoryException { + try { + return clazz.newInstance(); + } catch (IllegalAccessException | InstantiationException e) { + throw new OutputModuleFactoryException("Error while creating instance of class " + clazz + " for module " + name, e); + } + } + +} diff -r 0684883953ba -r 7d86d90e6e0e java/parameter-lister/src/info/glogalcode/parameterLister/modules/TerminalModule.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/parameter-lister/src/info/glogalcode/parameterLister/modules/TerminalModule.java Sat Sep 10 23:03:43 2016 +0200 @@ -0,0 +1,25 @@ +package info.glogalcode.parameterLister.modules; + +import info.glogalcode.parameterLister.OutputModule; +import info.glogalcode.parameterLister.OutputModuleException; +import java.io.OutputStream; +import java.io.PrintWriter; +import java.util.List; + +/** + * + * @author Ing. František Kučera (frantovo.cz) + */ +public class TerminalModule implements OutputModule { + + @Override + public void process(OutputStream output, List parameters) throws OutputModuleException { + try (PrintWriter out = new PrintWriter(output)) { + for (String parameter : parameters) { + out.println(parameter); + out.flush(); + } + } + } + +} diff -r 0684883953ba -r 7d86d90e6e0e java/parameter-lister/src/info/glogalcode/parameterLister/modules/TerminalModuleFactory.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/parameter-lister/src/info/glogalcode/parameterLister/modules/TerminalModuleFactory.java Sat Sep 10 23:03:43 2016 +0200 @@ -0,0 +1,15 @@ +package info.glogalcode.parameterLister.modules; + +/** + * + * @author Ing. František Kučera (frantovo.cz) + */ +public class TerminalModuleFactory extends AbstractModuleFactory { + + public static final String MODULE_NAME = "terminal"; + + public TerminalModuleFactory() { + super(MODULE_NAME, TerminalModule.class); + } + +}