Author: bdonlan
Date: 2005-05-21 23:56:37 -0400 (Sat, 21 May 2005)
New Revision: 699
Added:
trunk/clients/Javer2/build.xml
trunk/clients/Javer2/manifest.mf
trunk/clients/Javer2/nbproject/
trunk/clients/Javer2/nbproject/build-impl.xml
trunk/clients/Javer2/nbproject/genfiles.properties
trunk/clients/Javer2/nbproject/project.properties
trunk/clients/Javer2/nbproject/project.xml
trunk/clients/Javer2/src/
trunk/clients/Javer2/src/haver/
trunk/clients/Javer2/src/haver/Callback.java
trunk/clients/Javer2/src/haver/Client.java
trunk/clients/Javer2/src/haver/NonblockingOutputStream.java
trunk/clients/Javer2/src/javer2/
trunk/clients/Javer2/src/javer2/Main.java
trunk/clients/Javer2/test/
Modified:
trunk/clients/Javer2/
Log:
Import initial version of Javer2
Property changes on: trunk/clients/Javer2
___________________________________________________________________
Name: svn:ignore
+ build
dist
.nbintdb
Added: trunk/clients/Javer2/build.xml
===================================================================
--- trunk/clients/Javer2/build.xml 2005-05-22 03:51:20 UTC (rev 698)
+++ trunk/clients/Javer2/build.xml 2005-05-22 03:56:37 UTC (rev 699)
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- You may freely edit this file. See commented blocks below for -->
+<!-- some examples of how to customize the build. -->
+<!-- (If you delete it and reopen the project it will be recreated.) -->
+<project name="Javer2" default="default" basedir=".">
+ <description>Builds, tests, and runs the project Javer2.</description>
+ <import file="nbproject/build-impl.xml"/>
+ <!--
+
+ There exist several targets which are by default empty and which can be
+ used for execution of your tasks. These targets are usually executed
+ before and after some main targets. They are:
+
+ -pre-init: called before initialization of project
properties
+ -post-init: called after initialization of project
properties
+ -pre-compile: called before javac compilation
+ -post-compile: called after javac compilation
+ -pre-compile-single: called before javac compilation of single file
+ -post-compile-single: called after javac compilation of single file
+ -pre-compile-test: called before javac compilation of JUnit tests
+ -post-compile-test: called after javac compilation of JUnit tests
+ -pre-compile-test-single: called before javac compilation of single
JUnit test
+ -post-compile-test-single: called after javac compilation of single
JUunit test
+ -pre-jar: called before JAR building
+ -post-jar: called after JAR building
+ -post-clean: called after cleaning build products
+
+ (Targets beginning with '-' are not intended to be called on their own.)
+
+ Example of inserting an obfuscator after compilation could look like this:
+
+ <target name="-post-compile">
+ <obfuscate>
+ <fileset dir="${build.classes.dir}"/>
+ </obfuscate>
+ </target>
+
+ For list of available properties check the imported
+ nbproject/build-impl.xml file.
+
+
+ Another way to customize the build is by overriding existing main targets.
+ The targets of interest are:
+
+ -init-macrodef-javac: defines macro for javac compilation
+ -init-macrodef-junit: defines macro for junit execution
+ -init-macrodef-debug: defines macro for class debugging
+ -init-macrodef-java: defines macro for class execution
+ -do-jar-with-manifest: JAR building (if you are using a manifest)
+ -do-jar-without-manifest: JAR building (if you are not using a manifest)
+ run: execution of project
+ -javadoc-build: Javadoc generation
+ test-report: JUnit report generation
+
+ An example of overriding the target for project execution could look like
this:
+
+ <target name="run" depends="Javer2-impl.jar">
+ <exec dir="bin" executable="launcher.exe">
+ <arg file="${dist.jar}"/>
+ </exec>
+ </target>
+
+ Notice that the overridden target depends on the jar target and not only
on
+ the compile target as the regular run target does. Again, for a list of
available
+ properties which you can use, check the target you are overriding in the
+ nbproject/build-impl.xml file.
+
+ -->
+</project>
Property changes on: trunk/clients/Javer2/build.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Added: trunk/clients/Javer2/manifest.mf
===================================================================
--- trunk/clients/Javer2/manifest.mf 2005-05-22 03:51:20 UTC (rev 698)
+++ trunk/clients/Javer2/manifest.mf 2005-05-22 03:56:37 UTC (rev 699)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+X-COMMENT: Main-Class will be added automatically by build
+
Property changes on: trunk/clients/Javer2/nbproject
___________________________________________________________________
Name: svn:ignore
+ private
Added: trunk/clients/Javer2/nbproject/build-impl.xml
===================================================================
--- trunk/clients/Javer2/nbproject/build-impl.xml 2005-05-22 03:51:20 UTC
(rev 698)
+++ trunk/clients/Javer2/nbproject/build-impl.xml 2005-05-22 03:56:37 UTC
(rev 699)
@@ -0,0 +1,550 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+*** GENERATED FROM project.xml - DO NOT EDIT ***
+*** EDIT ../build.xml INSTEAD ***
+
+For the purpose of easier reading the script
+is divided into following sections:
+
+ - initialization
+ - compilation
+ - jar
+ - execution
+ - debugging
+ - javadoc
+ - junit compilation
+ - junit execution
+ - junit debugging
+ - applet
+ - cleanup
+
+-->
+<project name="Javer2-impl" default="build" basedir="..">
+ <target name="default" depends="test,jar,javadoc" description="Build and
test whole project."/>
+ <!--
+ ======================
+ INITIALIZATION SECTION
+ ======================
+ -->
+ <target name="-pre-init">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target name="-init-private" depends="-pre-init">
+ <property file="nbproject/private/private.properties"/>
+ </target>
+ <target name="-init-user" depends="-pre-init,-init-private">
+ <property file="${user.properties.file}"/>
+ <!-- The two properties below are usually overridden -->
+ <!-- by the active platform. Just a fallback. -->
+ <property name="default.javac.source" value="1.4"/>
+ <property name="default.javac.target" value="1.4"/>
+ </target>
+ <target name="-init-project" depends="-pre-init,-init-private,-init-user">
+ <property file="nbproject/project.properties"/>
+ </target>
+ <target name="-do-init"
depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property">
+ <j2seproject:property name="platform.home"
value="platforms.${platform.active}.home"
xmlns:j2seproject="http://www.netbeans.org/ns/j2se-project/1"/>
+ <j2seproject:property name="platform.bootcp"
value="platforms.${platform.active}.bootclasspath"
xmlns:j2seproject="http://www.netbeans.org/ns/j2se-project/1"/>
+ <j2seproject:property name="platform.compiler"
value="platforms.${platform.active}.compile"
xmlns:j2seproject="http://www.netbeans.org/ns/j2se-project/1"/>
+ <j2seproject:property name="platform.javac.tmp"
value="platforms.${platform.active}.javac"
xmlns:j2seproject="http://www.netbeans.org/ns/j2se-project/1"/>
+ <condition property="platform.javac"
value="${platform.home}/bin/javac">
+ <equals arg1="${platform.javac.tmp}"
arg2="$${platforms.${platform.active}.javac}"/>
+ </condition>
+ <property name="platform.javac" value="${platform.javac.tmp}"/>
+ <j2seproject:property name="platform.java.tmp"
value="platforms.${platform.active}.java"
xmlns:j2seproject="http://www.netbeans.org/ns/j2se-project/1"/>
+ <condition property="platform.java" value="${platform.home}/bin/java">
+ <equals arg1="${platform.java.tmp}"
arg2="$${platforms.${platform.active}.java}"/>
+ </condition>
+ <property name="platform.java" value="${platform.java.tmp}"/>
+ <condition property="platform.invalid" value="true">
+ <or>
+ <contains string="${platform.javac}"
substring="$${platforms."/>
+ <contains string="${platform.java}" substring="$${platforms."/>
+ </or>
+ </condition>
+ <fail unless="platform.home">Must set platform.home</fail>
+ <fail unless="platform.bootcp">Must set platform.bootcp</fail>
+ <fail unless="platform.java">Must set platform.java</fail>
+ <fail unless="platform.javac">Must set platform.javac</fail>
+ <fail if="platform.invalid">Platform is not correctly set up</fail>
+ <available file="${manifest.file}" property="manifest.available"/>
+ <condition property="manifest.available+main.class">
+ <and>
+ <isset property="manifest.available"/>
+ <isset property="main.class"/>
+ <not>
+ <equals arg1="${main.class}" arg2="" trim="true"/>
+ </not>
+ </and>
+ </condition>
+ <available property="have.tests" file="${test.src.dir}"/>
+ <condition property="netbeans.home+have.tests">
+ <and>
+ <isset property="netbeans.home"/>
+ <isset property="have.tests"/>
+ </and>
+ </condition>
+ <condition property="no.javadoc.preview">
+ <isfalse value="${javadoc.preview}"/>
+ </condition>
+ <property name="run.jvmargs" value=""/>
+ <property name="javac.compilerargs" value=""/>
+ <property name="work.dir" value="${basedir}"/>
+ <condition property="no.deps">
+ <and>
+ <istrue value="${no.dependencies}"/>
+ </and>
+ </condition>
+ </target>
+ <target name="-post-init">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target name="-init-check"
depends="-pre-init,-init-private,-init-user,-init-project,-do-init">
+ <fail unless="src.dir">Must set src.dir</fail>
+ <fail unless="test.src.dir">Must set test.src.dir</fail>
+ <fail unless="build.dir">Must set build.dir</fail>
+ <fail unless="dist.dir">Must set dist.dir</fail>
+ <fail unless="build.classes.dir">Must set build.classes.dir</fail>
+ <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
+ <fail unless="build.test.classes.dir">Must set
build.test.classes.dir</fail>
+ <fail unless="build.test.results.dir">Must set
build.test.results.dir</fail>
+ <fail unless="build.classes.excludes">Must set
build.classes.excludes</fail>
+ <fail unless="dist.jar">Must set dist.jar</fail>
+ </target>
+ <target name="-init-macrodef-property">
+ <macrodef name="property"
uri="http://www.netbeans.org/ns/j2se-project/1">
+ <attribute name="name"/>
+ <attribute name="value"/>
+ <sequential>
+ <property name="@{name}" value="[EMAIL PROTECTED]"/>
+ </sequential>
+ </macrodef>
+ </target>
+ <target name="-init-macrodef-javac">
+ <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/1">
+ <attribute name="srcdir" default="${src.dir}"/>
+ <attribute name="destdir" default="${build.classes.dir}"/>
+ <attribute name="classpath" default="${javac.classpath}"/>
+ <attribute name="debug" default="${javac.debug}"/>
+ <element name="customize" optional="true"/>
+ <sequential>
+ <javac srcdir="@{srcdir}" destdir="@{destdir}"
debug="@{debug}" deprecation="${javac.deprecation}" source="${javac.source}"
target="${javac.target}" fork="yes" executable="${platform.javac}"
includeantruntime="false">
+ <classpath>
+ <path path="@{classpath}"/>
+ </classpath>
+ <compilerarg line="${javac.compilerargs}"/>
+ <customize/>
+ </javac>
+ </sequential>
+ </macrodef>
+ </target>
+ <target name="-init-macrodef-junit">
+ <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/1">
+ <attribute name="includes" default="**/*Test.java"/>
+ <sequential>
+ <junit showoutput="true" fork="true" dir="${basedir}"
failureproperty="tests.failed" errorproperty="tests.failed"
jvm="${platform.java}">
+ <batchtest todir="${build.test.results.dir}">
+ <fileset dir="${test.src.dir}" includes="@{includes}"/>
+ </batchtest>
+ <classpath>
+ <path path="${run.test.classpath}"/>
+ </classpath>
+ <syspropertyset>
+ <propertyref prefix="test-sys-prop."/>
+ <mapper type="glob" from="test-sys-prop.*" to="*"/>
+ </syspropertyset>
+ <formatter type="brief" usefile="false"/>
+ </junit>
+ </sequential>
+ </macrodef>
+ </target>
+ <target name="-init-macrodef-nbjpda">
+ <macrodef name="nbjpdastart"
uri="http://www.netbeans.org/ns/j2se-project/1">
+ <attribute name="name" default="${main.class}"/>
+ <attribute name="classpath" default="${debug.classpath}"/>
+ <attribute name="stopclassname" default=""/>
+ <sequential>
+ <nbjpdastart transport="dt_socket"
addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}">
+ <classpath>
+ <path path="@{classpath}"/>
+ </classpath>
+ <bootclasspath>
+ <path path="${platform.bootcp}"/>
+ </bootclasspath>
+ </nbjpdastart>
+ </sequential>
+ </macrodef>
+ <macrodef name="nbjpdareload"
uri="http://www.netbeans.org/ns/j2se-project/1">
+ <attribute name="dir" default="${build.classes.dir}"/>
+ <sequential>
+ <nbjpdareload>
+ <fileset includes="${fix.includes}*.class" dir="@{dir}"/>
+ </nbjpdareload>
+ </sequential>
+ </macrodef>
+ </target>
+ <target name="-init-macrodef-debug">
+ <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/1">
+ <attribute name="classname" default="${main.class}"/>
+ <attribute name="classpath" default="${debug.classpath}"/>
+ <attribute name="args" default="${application.args}"/>
+ <sequential>
+ <java fork="true" classname="@{classname}" dir="${work.dir}"
jvm="${platform.java}">
+ <jvmarg value="-Xdebug"/>
+ <jvmarg value="-Xnoagent"/>
+ <jvmarg value="-Djava.compiler=none"/>
+ <jvmarg
value="-Xrunjdwp:transport=dt_socket,address=${jpda.address}"/>
+ <jvmarg line="${run.jvmargs}"/>
+ <classpath>
+ <path path="@{classpath}"/>
+ </classpath>
+ <syspropertyset>
+ <propertyref prefix="run-sys-prop."/>
+ <mapper type="glob" from="run-sys-prop.*" to="*"/>
+ </syspropertyset>
+ <arg line="@{args}"/>
+ </java>
+ </sequential>
+ </macrodef>
+ </target>
+ <target name="-init-macrodef-java">
+ <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
+ <attribute name="classname" default="${main.class}"/>
+ <element name="customize" optional="true"/>
+ <sequential>
+ <java fork="true" classname="@{classname}" dir="${work.dir}"
jvm="${platform.java}">
+ <jvmarg line="${run.jvmargs}"/>
+ <classpath>
+ <path path="${run.classpath}"/>
+ </classpath>
+ <syspropertyset>
+ <propertyref prefix="run-sys-prop."/>
+ <mapper type="glob" from="run-sys-prop.*" to="*"/>
+ </syspropertyset>
+ <customize/>
+ </java>
+ </sequential>
+ </macrodef>
+ </target>
+ <target name="-init-presetdef-jar">
+ <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
+ <jar jarfile="${dist.jar}" compress="${jar.compress}">
+ <fileset dir="${build.classes.dir}"
xmlns="http://www.netbeans.org/ns/j2se-project/1"/>
+ </jar>
+ </presetdef>
+ </target>
+ <target name="init"
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"/>
+ <!--
+ ===================
+ COMPILATION SECTION
+ ===================
+ -->
+ <target name="deps-jar" depends="init" unless="no.deps"/>
+ <target name="-pre-pre-compile" depends="init,deps-jar">
+ <mkdir dir="${build.classes.dir}"/>
+ </target>
+ <target name="-pre-compile">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target name="-do-compile"
depends="init,deps-jar,-pre-pre-compile,-pre-compile">
+ <j2seproject:javac
xmlns:j2seproject="http://www.netbeans.org/ns/j2se-project/1"/>
+ <copy todir="${build.classes.dir}">
+ <fileset dir="${src.dir}" excludes="${build.classes.excludes}"/>
+ </copy>
+ </target>
+ <target name="-post-compile">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target name="compile"
depends="init,deps-jar,-pre-pre-compile,-pre-compile,-do-compile,-post-compile"
description="Compile project."/>
+ <target name="-pre-compile-single">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target name="-do-compile-single" depends="init,deps-jar,-pre-pre-compile">
+ <fail unless="javac.includes">Must select some files in the IDE or set
javac.includes</fail>
+ <j2seproject:javac
xmlns:j2seproject="http://www.netbeans.org/ns/j2se-project/1">
+ <customize>
+ <patternset includes="${javac.includes}"/>
+ </customize>
+ </j2seproject:javac>
+ </target>
+ <target name="-post-compile-single">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target name="compile-single"
depends="init,deps-jar,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single"/>
+ <!--
+ ====================
+ JAR BUILDING SECTION
+ ====================
+ -->
+ <target name="-pre-pre-jar" depends="init">
+ <dirname property="dist.jar.dir" file="${dist.jar}"/>
+ <mkdir dir="${dist.jar.dir}"/>
+ </target>
+ <target name="-pre-jar">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target name="-do-jar-without-manifest"
depends="init,compile,-pre-pre-jar,-pre-jar" unless="manifest.available">
+ <j2seproject:jar
xmlns:j2seproject="http://www.netbeans.org/ns/j2se-project/1"/>
+ </target>
+ <target name="-do-jar-with-manifest"
depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available"
unless="manifest.available+main.class">
+ <j2seproject:jar manifest="${manifest.file}"
xmlns:j2seproject="http://www.netbeans.org/ns/j2se-project/1"/>
+ </target>
+ <target name="-do-jar-with-mainclass"
depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class">
+ <j2seproject:jar manifest="${manifest.file}"
xmlns:j2seproject="http://www.netbeans.org/ns/j2se-project/1">
+ <manifest xmlns="http://www.netbeans.org/ns/j2se-project/1">
+ <attribute j2seproject:name="Main-Class"
value="${main.class}"/>
+ </manifest>
+ </j2seproject:jar>
+ </target>
+ <target name="-post-jar">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target name="jar"
depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-post-jar"
description="Build JAR."/>
+ <!--
+ =================
+ EXECUTION SECTION
+ =================
+ -->
+ <target name="run" depends="init,compile" description="Run a main class.">
+ <j2seproject:java
xmlns:j2seproject="http://www.netbeans.org/ns/j2se-project/1">
+ <customize>
+ <arg line="${application.args}"/>
+ </customize>
+ </j2seproject:java>
+ </target>
+ <target name="run-single" depends="init,compile-single">
+ <fail unless="run.class">Must select one file in the IDE or set
run.class</fail>
+ <j2seproject:java classname="${run.class}"
xmlns:j2seproject="http://www.netbeans.org/ns/j2se-project/1"/>
+ </target>
+ <!--
+ =================
+ DEBUGGING SECTION
+ =================
+ -->
+ <target name="-debug-start-debugger" if="netbeans.home" depends="init">
+ <j2seproject:nbjpdastart name="${debug.class}"
xmlns:j2seproject="http://www.netbeans.org/ns/j2se-project/1"/>
+ </target>
+ <target name="-debug-start-debuggee" depends="init,compile">
+ <j2seproject:debug
xmlns:j2seproject="http://www.netbeans.org/ns/j2se-project/1"/>
+ </target>
+ <target name="debug" if="netbeans.home"
depends="init,compile,-debug-start-debugger,-debug-start-debuggee"
description="Debug project in IDE."/>
+ <target name="-debug-start-debugger-stepinto" if="netbeans.home"
depends="init">
+ <j2seproject:nbjpdastart stopclassname="${main.class}"
xmlns:j2seproject="http://www.netbeans.org/ns/j2se-project/1"/>
+ </target>
+ <target name="debug-stepinto" if="netbeans.home"
depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee"/>
+ <target name="-debug-start-debuggee-single" if="netbeans.home"
depends="init,compile-single">
+ <fail unless="debug.class">Must select one file in the IDE or set
debug.class</fail>
+ <j2seproject:debug classname="${debug.class}"
xmlns:j2seproject="http://www.netbeans.org/ns/j2se-project/1"/>
+ </target>
+ <target name="debug-single" if="netbeans.home"
depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-single"/>
+ <target name="-pre-debug-fix" depends="init">
+ <fail unless="fix.includes">Must set fix.includes</fail>
+ <property name="javac.includes" value="${fix.includes}.java"/>
+ </target>
+ <target name="-do-debug-fix" if="netbeans.home"
depends="init,-pre-debug-fix,compile-single">
+ <j2seproject:nbjpdareload
xmlns:j2seproject="http://www.netbeans.org/ns/j2se-project/1"/>
+ </target>
+ <target name="debug-fix" if="netbeans.home"
depends="init,-pre-debug-fix,-do-debug-fix"/>
+ <!--
+ ===============
+ JAVADOC SECTION
+ ===============
+ -->
+ <target name="-javadoc-build" depends="init">
+ <mkdir dir="${dist.javadoc.dir}"/>
+ <j2seproject:property name="platform.javadoc.tmp"
value="platforms.${platform.active}.javadoc"
xmlns:j2seproject="http://www.netbeans.org/ns/j2se-project/1"/>
+ <condition property="platform.javadoc"
value="${platform.home}/bin/javadoc">
+ <equals arg1="${platform.javadoc.tmp}"
arg2="$${platforms.${platform.active}.javadoc}"/>
+ </condition>
+ <property name="platform.javadoc" value="${platform.javadoc.tmp}"/>
+ <condition property="javadoc.notree.opt" value="-notree">
+ <istrue value="${javadoc.notree}"/>
+ </condition>
+ <property name="javadoc.notree.opt" value=""/>
+ <condition property="javadoc.use.opt" value="-use">
+ <istrue value="${javadoc.use}"/>
+ </condition>
+ <property name="javadoc.use.opt" value=""/>
+ <condition property="javadoc.nonavbar.opt" value="-nonavbar">
+ <istrue value="${javadoc.nonavbar}"/>
+ </condition>
+ <property name="javadoc.nonavbar.opt" value=""/>
+ <condition property="javadoc.noindex.opt" value="-noindex">
+ <istrue value="${javadoc.noindex}"/>
+ </condition>
+ <property name="javadoc.noindex.opt" value=""/>
+ <condition property="javadoc.splitindex.opt" value="-splitindex">
+ <istrue value="${javadoc.splitindex}"/>
+ </condition>
+ <property name="javadoc.splitindex.opt" value=""/>
+ <condition property="javadoc.author.opt" value="-author">
+ <istrue value="${javadoc.author}"/>
+ </condition>
+ <property name="javadoc.author.opt" value=""/>
+ <condition property="javadoc.version.opt" value="-version">
+ <istrue value="${javadoc.version}"/>
+ </condition>
+ <property name="javadoc.version.opt" value=""/>
+ <condition property="javadoc.private.opt" value="-private">
+ <istrue value="${javadoc.private}"/>
+ </condition>
+ <property name="javadoc.private.opt" value=""/>
+ <condition property="javadoc.classpath.opt" value="${javac.classpath}">
+ <not>
+ <equals arg1="${javac.classpath}" arg2=""/>
+ </not>
+ </condition>
+ <property name="javadoc.classpath.opt" value=""""/>
+ <apply executable="${platform.javadoc}" failonerror="true"
parallel="true">
+ <arg value="-d"/>
+ <arg file="${dist.javadoc.dir}"/>
+ <arg value="-source"/>
+ <arg value="${javac.source}"/>
+ <arg value="-windowtitle"/>
+ <arg value="${javadoc.windowtitle}"/>
+ <arg line="${javadoc.notree.opt} ${javadoc.use.opt}
${javadoc.nonavbar.opt} ${javadoc.noindex.opt} ${javadoc.splitindex.opt}
${javadoc.author.opt} ${javadoc.version.opt} ${javadoc.private.opt}"/>
+ <arg value="-classpath"/>
+ <arg path="${javadoc.classpath.opt}"/>
+ <arg value="-sourcepath"/>
+ <arg file="${src.dir}"/>
+ <fileset dir="${src.dir}" includes="**/*.java"/>
+ </apply>
+ </target>
+ <target name="-javadoc-browse" if="netbeans.home"
unless="no.javadoc.preview" depends="init,-javadoc-build">
+ <nbbrowse file="${dist.javadoc.dir}/index.html"/>
+ </target>
+ <target name="javadoc" depends="init,-javadoc-build,-javadoc-browse"
description="Build Javadoc."/>
+ <!--
+ =========================
+ JUNIT COMPILATION SECTION
+ =========================
+ -->
+ <target name="-pre-pre-compile-test" if="have.tests"
depends="init,compile">
+ <mkdir dir="${build.test.classes.dir}"/>
+ </target>
+ <target name="-pre-compile-test">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target name="-do-compile-test" if="have.tests"
depends="init,compile,-pre-pre-compile-test,-pre-compile-test">
+ <j2seproject:javac srcdir="${test.src.dir}"
destdir="${build.test.classes.dir}" debug="true"
classpath="${javac.test.classpath}"
xmlns:j2seproject="http://www.netbeans.org/ns/j2se-project/1"/>
+ <copy todir="${build.test.classes.dir}">
+ <fileset dir="${test.src.dir}">
+ <exclude name="**/*.java"/>
+ </fileset>
+ </copy>
+ </target>
+ <target name="-post-compile-test">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target name="compile-test"
depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test"/>
+ <target name="-pre-compile-test-single">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target name="-do-compile-test-single" if="have.tests"
depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single">
+ <fail unless="javac.includes">Must select some files in the IDE or set
javac.includes</fail>
+ <j2seproject:javac srcdir="${test.src.dir}"
destdir="${build.test.classes.dir}" debug="true"
classpath="${javac.test.classpath}"
xmlns:j2seproject="http://www.netbeans.org/ns/j2se-project/1">
+ <customize>
+ <patternset includes="${javac.includes}"/>
+ </customize>
+ </j2seproject:javac>
+ </target>
+ <target name="-post-compile-test-single">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target name="compile-test-single"
depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single"/>
+ <!--
+ =======================
+ JUNIT EXECUTION SECTION
+ =======================
+ -->
+ <target name="-pre-test-run" if="have.tests" depends="init">
+ <mkdir dir="${build.test.results.dir}"/>
+ </target>
+ <target name="-do-test-run" if="have.tests"
depends="init,compile-test,-pre-test-run">
+ <j2seproject:junit
xmlns:j2seproject="http://www.netbeans.org/ns/j2se-project/1"/>
+ </target>
+ <target name="-post-test-run" if="have.tests"
depends="init,compile-test,-pre-test-run,-do-test-run">
+ <fail if="tests.failed">Some tests failed; see details above.</fail>
+ </target>
+ <target name="test-report" if="have.tests" depends="init"/>
+ <target name="-test-browse" if="netbeans.home+have.tests" depends="init"/>
+ <target name="test"
depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse"
description="Run unit tests."/>
+ <target name="-pre-test-run-single" if="have.tests" depends="init">
+ <mkdir dir="${build.test.results.dir}"/>
+ </target>
+ <target name="-do-test-run-single" if="have.tests"
depends="init,compile-test-single,-pre-test-run-single">
+ <fail unless="test.includes">Must select some files in the IDE or set
test.includes</fail>
+ <j2seproject:junit includes="${test.includes}"
xmlns:j2seproject="http://www.netbeans.org/ns/j2se-project/1"/>
+ </target>
+ <target name="-post-test-run-single" if="have.tests"
depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single">
+ <fail if="tests.failed">Some tests failed; see details above.</fail>
+ </target>
+ <target name="test-single"
depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single"
description="Run single unit test."/>
+ <!--
+ =======================
+ JUNIT DEBUGGING SECTION
+ =======================
+ -->
+ <target name="-debug-start-debuggee-test" if="have.tests"
depends="init,compile-test">
+ <fail unless="test.class">Must select one file in the IDE or set
test.class</fail>
+ <j2seproject:debug classname="junit.textui.TestRunner"
classpath="${debug.test.classpath}" args="${test.class}"
xmlns:j2seproject="http://www.netbeans.org/ns/j2se-project/1"/>
+ </target>
+ <target name="-debug-start-debugger-test" if="netbeans.home+have.tests"
depends="init,compile-test">
+ <j2seproject:nbjpdastart name="${test.class}"
classpath="${debug.test.classpath}"
xmlns:j2seproject="http://www.netbeans.org/ns/j2se-project/1"/>
+ </target>
+ <target name="debug-test"
depends="init,compile-test,-debug-start-debugger-test,-debug-start-debuggee-test"/>
+ <target name="-do-debug-fix-test" if="netbeans.home"
depends="init,-pre-debug-fix,compile-test-single">
+ <j2seproject:nbjpdareload dir="${build.test.classes.dir}"
xmlns:j2seproject="http://www.netbeans.org/ns/j2se-project/1"/>
+ </target>
+ <target name="debug-fix-test" if="netbeans.home"
depends="init,-pre-debug-fix,-do-debug-fix-test"/>
+ <!--
+ =========================
+ APPLET EXECUTION SECTION
+ =========================
+ -->
+ <target name="run-applet" depends="init,compile-single">
+ <fail unless="applet.url">Must select one file in the IDE or set
applet.url</fail>
+ <j2seproject:java classname="sun.applet.AppletViewer"
xmlns:j2seproject="http://www.netbeans.org/ns/j2se-project/1">
+ <customize>
+ <arg value="${applet.url}"/>
+ </customize>
+ </j2seproject:java>
+ </target>
+ <!--
+ =========================
+ APPLET DEBUGGING SECTION
+ =========================
+ -->
+ <target name="-debug-start-debuggee-applet" if="netbeans.home"
depends="init,compile-single">
+ <fail unless="applet.url">Must select one file in the IDE or set
applet.url</fail>
+ <j2seproject:debug classname="sun.applet.AppletViewer"
args=""${applet.url}""
xmlns:j2seproject="http://www.netbeans.org/ns/j2se-project/1"/>
+ </target>
+ <target name="debug-applet" if="netbeans.home"
depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet"/>
+ <!--
+ ===============
+ CLEANUP SECTION
+ ===============
+ -->
+ <target name="deps-clean" depends="init" unless="no.deps"/>
+ <target name="-do-clean" depends="init">
+ <delete dir="${build.dir}"/>
+ <delete dir="${dist.dir}"/>
+ </target>
+ <target name="-post-clean">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target name="clean" depends="init,deps-clean,-do-clean,-post-clean"
description="Clean build products."/>
+</project>
Property changes on: trunk/clients/Javer2/nbproject/build-impl.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Added: trunk/clients/Javer2/nbproject/genfiles.properties
===================================================================
--- trunk/clients/Javer2/nbproject/genfiles.properties 2005-05-22 03:51:20 UTC
(rev 698)
+++ trunk/clients/Javer2/nbproject/genfiles.properties 2005-05-22 03:56:37 UTC
(rev 699)
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=a2809796
+build.xml.script.CRC32=b6072d29
+build.xml.stylesheet.CRC32=ba5d3624
+# 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=a2809796
+nbproject/build-impl.xml.script.CRC32=5d0a7dea
+nbproject/build-impl.xml.stylesheet.CRC32=1cf0b40c
Property changes on: trunk/clients/Javer2/nbproject/genfiles.properties
___________________________________________________________________
Name: svn:eol-style
+ native
Added: trunk/clients/Javer2/nbproject/project.properties
===================================================================
--- trunk/clients/Javer2/nbproject/project.properties 2005-05-22 03:51:20 UTC
(rev 698)
+++ trunk/clients/Javer2/nbproject/project.properties 2005-05-22 03:56:37 UTC
(rev 699)
@@ -0,0 +1,53 @@
+application.args=
+build.classes.dir=${build.dir}/classes
+build.classes.excludes=**/*.java,**/*.form
+# This directory is removed when the project is cleaned:
+build.dir=build
+# 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}/Javer2.jar
+dist.javadoc.dir=${dist.dir}/javadoc
+jar.compress=false
+javac.classpath=
+# Space-separated list of extra javac options
+javac.compilerargs=
+javac.deprecation=false
+javac.source=1.4
+javac.target=1.4
+javac.test.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}:\
+ ${libs.junit.classpath}
+javadoc.author=false
+javadoc.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=javer2.Main
+manifest.file=manifest.mf
+platform.active=Java_HotSpot_TM__Client_VM_1.4.2_08-b03
+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}
+src.dir=src
+test.src.dir=test
Property changes on: trunk/clients/Javer2/nbproject/project.properties
___________________________________________________________________
Name: svn:eol-style
+ native
Added: trunk/clients/Javer2/nbproject/project.xml
===================================================================
--- trunk/clients/Javer2/nbproject/project.xml 2005-05-22 03:51:20 UTC (rev
698)
+++ trunk/clients/Javer2/nbproject/project.xml 2005-05-22 03:56:37 UTC (rev
699)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://www.netbeans.org/ns/project/1">
+ <type>org.netbeans.modules.java.j2seproject</type>
+ <configuration>
+ <data xmlns="http://www.netbeans.org/ns/j2se-project/1">
+ <name>Javer2</name>
+ <minimum-ant-version>1.6</minimum-ant-version>
+ <explicit-platform explicit-source-supported="true"/>
+ </data>
+ </configuration>
+</project>
Property changes on: trunk/clients/Javer2/nbproject/project.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Added: trunk/clients/Javer2/src/haver/Callback.java
===================================================================
--- trunk/clients/Javer2/src/haver/Callback.java 2005-05-22 03:51:20 UTC
(rev 698)
+++ trunk/clients/Javer2/src/haver/Callback.java 2005-05-22 03:56:37 UTC
(rev 699)
@@ -0,0 +1,64 @@
+/*
+ * Callback.java
+ *
+ * Created on May 21, 2005, 9:39 PM
+ */
+
+package haver;
+import java.io.IOException;
+
+/**
+ *
+ * @author bdonlan
+ */
+public abstract class Callback {
+ /**
+ * Called when a connection to the server is established but before
handshaking
+ * occurs.
+ * @param source haver.Client instance associated with this event
+ * @throws java.io.IOException
+ */
+ public void onConnect(Client source) throws IOException {}
+ /**
+ * Called when a connection attempt fails.
+ * @param source haver.Client instance associated with this event
+ * @param e IOException which caused the connection failure
+ * @throws java.io.IOException
+ */
+ public void onConnectFailed(Client source, java.io.IOException e) throws
IOException {}
+ /**
+ * Called when an established connection is lost
+ * @param source haver.Client instance associated with this event
+ * @param e Exception associated with the connection loss, or null if
connection loss did
+ * not have an associated exception (e.g., connection broken)
+ * @throws java.io.IOException
+ */
+ public void onDisconnected(Client source, java.io.IOException e) throws
IOException {}
+ /**
+ * Called when a message is received from the server
+ * @param source haver.Client instance associated with this event
+ * @param args Arguments of the message
+ * @throws java.io.IOException
+ */
+ public void onIncomingLine(Client source, String[] args) throws
IOException {}
+ /**
+ * Called when a message is sent to the server
+ * @param source haver.Client instance associated with this event
+ * @param args Arguments of the message
+ * @throws java.io.IOException
+ */
+ public void onOutgoingLine(Client source, String[] args) throws
IOException {}
+ /**
+ * Called when the server requires identification
+ * @param source haver.Client instance associated with this event
+ * @throws java.io.IOException
+ */
+ public void onNeedIdent(Client source) throws IOException {}
+ /**
+ * Called when the name given by the client has been accepted
+ * @param source haver.Client instance associated with this event
+ * @param name Name that was accepted by the server
+ * @throws java.io.IOException
+ */
+ public void onAccept(Client source, String name) throws IOException {}
+}
Property changes on: trunk/clients/Javer2/src/haver/Callback.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: trunk/clients/Javer2/src/haver/Client.java
===================================================================
--- trunk/clients/Javer2/src/haver/Client.java 2005-05-22 03:51:20 UTC (rev
698)
+++ trunk/clients/Javer2/src/haver/Client.java 2005-05-22 03:56:37 UTC (rev
699)
@@ -0,0 +1,408 @@
+/*
+ * Client.java
+ *
+ * Created on May 21, 2005, 8:48 PM
+ */
+
+package haver;
+import java.io.*;
+import java.util.*;
+import java.net.*;
+import java.lang.reflect.*;
+
+/**
+ * A Haver client class
+ * @author bdonlan
+ */
+public class Client {
+
+ Set listening = Collections.synchronizedSet(new java.util.HashSet());
+ Callback dist;
+ Socket theSocket = null;
+ boolean connecting = false;
+ Thread io = null;
+ Client self = this;
+ PrintWriter writer = null;
+ BufferedReader reader = null;
+ NonblockingOutputStream s;
+
+ static final String[] greeting = {"HAVER", "haver.Client/0.00"};
+
+ String host;
+ int port;
+
+ /** Creates a new instance of Client */
+ public Client() {
+ dist = new CallbackDist(listening);
+ }
+
+ /**
+ * Reverses Haver escaping.
+ * @param val String to unescape
+ * @return The unescaped string
+ */
+ protected static final String unescape(String val) {
+ //if (val != null) return val;
+ StringBuffer out = new StringBuffer();
+ int pin = 0;
+ int nextEsc = -1;
+ while (-1 != (nextEsc = val.indexOf("\033", pin))) {
+ out.append(val.substring(0, nextEsc - 1));
+ switch (val.charAt(nextEsc + 1)) {
+ case 'r':
+ out.append('\r');
+ break;
+ case 'n':
+ out.append('\n');
+ break;
+ case 'e':
+ out.append('\033');
+ break;
+ case 't':
+ out.append('\t');
+ break;
+ default:
+ out.append(val.charAt(nextEsc + 1));
+ break;
+ }
+ pin = nextEsc + 2;
+ }
+ out.append(val.substring(pin));
+ return out.toString();
+ }
+
+ /**
+ * Escapes a string according to the Haver protocol
+ * @param val String to escape
+ * @return Escaped string
+ */
+ protected static final String escape(String val) {
+ return val.replaceAll("\033", "\033e")
+ .replaceAll("\n", "\033n")
+ .replaceAll("\r", "\033r")
+ .replaceAll("\t", "\033t");
+ }
+
+ /**
+ * Decodes a raw line from the Haver protocol.
+ * @param inLine Line to decode. May end in '\r\n' but must only be one
line.
+ * @return An array containing the unescaped arguments of the line.
+ */
+ protected static final String[] decodeLine(String inLine) {
+ inLine = inLine.replaceAll("[\n\r]", ""); // We'll assume you only
passed one
+ // line in.
+ String[] args = inLine.split("\t");
+ for (int i = 0; i < args.length; i++) {
+ args[i] = unescape(args[i]);
+ }
+ return args;
+ }
+
+ /**
+ * Encodes a set of arguments for line transmission
+ * @param args Unescaped arguments to encode
+ * @return Escaped and joined line ready for transmission, complete with
ending \r\n
+ */
+ protected static final String encodeLine(String[] args) {
+ StringBuffer out = new StringBuffer();
+ for (int i = 0; i < args.length; i++) {
+ if (i != 0)
+ out.append("\t");
+ out.append(escape(args[i]));
+ }
+ out.append("\r\n");
+ return out.toString();
+ }
+
+ protected class CallbackDist extends Callback {
+ java.util.Set listeners;
+
+ public CallbackDist(Set l) {
+ listeners = l;
+ }
+
+ public void onDisconnected(Client source, IOException e) throws
IOException {
+ try {reader.close();} catch (Throwable t) {}
+ try {writer.close();} catch (Throwable t) {}
+ try {theSocket.close();} catch (Throwable t) {}
+ reader = null;
+ writer = null;
+ theSocket = null;
+ io = null;
+
+ Iterator i = listeners.iterator();
+ while (i.hasNext()) {
+ Callback c = (Callback)i.next();
+ c.onDisconnected(source, e);
+ }
+
+ }
+
+ public void onConnectFailed(Client source, IOException e) throws
IOException {
+ Iterator i = listeners.iterator();
+ while (i.hasNext()) {
+ Callback c = (Callback)i.next();
+ c.onConnectFailed(source, e);
+ }
+ }
+
+ public void onConnect(Client source) throws IOException {
+ Iterator i = listeners.iterator();
+ while (i.hasNext()) {
+ Callback c = (Callback)i.next();
+ c.onConnect(source);
+ }
+ }
+
+ public void onOutgoingLine(Client source, String[] args) throws
IOException {
+ Iterator i = listeners.iterator();
+ while (i.hasNext()) {
+ Callback c = (Callback)i.next();
+ c.onOutgoingLine(source, args);
+ }
+ }
+
+ public void onIncomingLine(Client source, String[] args) throws
IOException {
+ Iterator i = listeners.iterator();
+ while (i.hasNext()) {
+ Callback c = (Callback)i.next();
+ c.onIncomingLine(source, args);
+ }
+ }
+
+ public void onNeedIdent(Client source) throws IOException {
+ Iterator i = listeners.iterator();
+ while (i.hasNext()) {
+ Callback c = (Callback)i.next();
+ c.onNeedIdent(source);
+ }
+ }
+
+ public void onAccept(Client source, String name) throws IOException {
+ Iterator i = listeners.iterator();
+ while (i.hasNext()) {
+ Callback c = (Callback)i.next();
+ c.onAccept(source, name);
+ }
+ }
+
+ }
+
+ protected void gotLine(String[] args) throws IOException {
+ dist.onIncomingLine(this, args);
+ }
+
+ protected void run(String host, int port) {
+ io.setName("haver.Client input thread");
+ try {
+ Socket mySock = new Socket(host, port);
+ theSocket = mySock;
+ } catch (IOException e) {
+ try {
+ io = null;
+ dist.onConnectFailed(this, e);
+ } catch (IOException e2) {}
+ return;
+ }
+ try {
+
+ writer = new PrintWriter
+ (new OutputStreamWriter
+ (s = new NonblockingOutputStream
+ (new BufferedOutputStream
+ (theSocket.getOutputStream()))));
+ s.setAutoFlush(true);
+ reader = new BufferedReader
+ (new InputStreamReader
+ (theSocket.getInputStream()));
+ dist.onConnect(this);
+ ioLoop();
+ } catch (IOException e) {
+ try {
+ dist.onDisconnected(this, e);
+ } catch (IOException e2) {
+ }
+ return;
+ }
+ }
+
+ protected void sendLine(String[] args) throws IOException {
+ if (writer != null) {
+ String l = encodeLine(args);
+ System.out.print("C: " + l);
+ writer.print(l);
+ writer.flush();
+ }
+ }
+
+ protected void ioLoop() throws IOException {
+ // Konnichiha, saaba-san!
+ sendLine(greeting);
+ while (io != null) {
+ String l = reader.readLine();
+ if (l == null) {
+ dist.onDisconnected(this, null);
+ return;
+ }
+ System.out.println("S: " + l);
+ String[] args = decodeLine(l);
+ dist.onIncomingLine(this, args);
+ dispatch(args);
+ }
+ }
+
+ /**
+ * Connect to a given host asynchronously.
+ * @param host Hostname to connect to
+ * @param port Port number to connect to
+ * @throws java.lang.IllegalStateException Thrown if the client is already
connected or connecting.
+ */
+ public synchronized void connect(String host, int port)
+ throws IllegalStateException
+ {
+ if (io != null && io.isAlive()) {
+ throw new IllegalStateException("Already connecting");
+ }
+ theSocket = null;
+ this.host = host;
+ this.port = port;
+ io = new Thread(new Runnable() {
+ public void run() {
+ self.run(self.host, self.port);
+ }
+ });
+ io.start();
+ }
+
+ protected class ConnectMonitor extends Callback {
+ IOException fail = null;
+ boolean done = false;
+ String name;
+
+ public ConnectMonitor(String name) {
+ this.name = name;
+ }
+
+ public void onNeedIdent(Client source) throws IOException {
+ source.ident(name);
+ }
+ public synchronized void onDisconnected(Client source, IOException e) {
+ fail = new IOException("Disconnected unexpectedly");
+ notifyAll();
+ }
+ public synchronized void onConnectFailed(Client source, IOException e)
{
+ fail = e;
+ notifyAll();
+ }
+ public synchronized void onAccept(Client source, String name) {
+ done = true;
+ notifyAll();
+ }
+ }
+
+ /**
+ * Connects to a host synchronously.
+ * @param host Hostname to connect to.
+ * @param port Port to connect to.
+ * @param name Name to use upon connect.
+ * @throws java.io.IOException Thrown if an IO exception occurs at any
point during the connect, or if the
+ * connection is lost.
+ */
+ public void syncConnect(String host, int port, String name) throws
IOException {
+ ConnectMonitor m = new ConnectMonitor(name);
+
+ addNotify(m);
+ connect(host, port);
+
+ synchronized (m) {
+ while (true) {
+ if (m.fail != null) {
+ removeNotify(m);
+ throw m.fail;
+ }
+ if (m.done) {
+ removeNotify(m);
+ return;
+ }
+ try {
+ m.wait();
+ } catch (InterruptedException e) {
+ // XXX: abort?
+ }
+ }
+ }
+ }
+
+ /**
+ * Adds a callback to notify when an event occurs
+ * @param c Callback class to add
+ */
+ public void addNotify(Callback c) {
+ listening.add(c);
+ }
+
+ /**
+ * Removes a callback class from the notify list
+ * @param c Callback to remove
+ */
+ public void removeNotify(Callback c) {
+ listening.remove(c);
+ }
+
+ protected void dispatch(String[] args) throws IOException {
+ String cmd = args[0].toUpperCase();
+ Class me = this.getClass();
+ try {
+ Class[] params = {args.getClass()};
+ Method m = me.getDeclaredMethod("handle_" + cmd, params);
+ Object[] args2 = {args};
+ m.invoke(this, args2);
+ } catch (InvocationTargetException e) {
+ Throwable thingy = e.getTargetException();
+ if (thingy instanceof Error) {
+ throw (Error)thingy;
+ }
+ if (thingy instanceof IOException) {
+ throw (IOException) thingy;
+ }
+ // XXX: need better exception here
+ throw new IOException("Unknown TargetException:\n" +
thingy.toString());
+ }
+ catch (NoSuchMethodException e) {} // unhandled server event
+ catch (IllegalAccessException e) {
+ // eep!
+ e.printStackTrace();
+ }
+ }
+
+ protected void handle_FOO(String[] args) {
+ System.out.println("foo'd by the bar");
+ }
+
+ protected void handle_HAVER(String[] args) throws IOException {
+ dist.onNeedIdent(this);
+ }
+
+ /**
+ * Identify with the given name
+ * @param name Name to identify with
+ * @throws java.io.IOException
+ */
+ public void ident(String name) throws IOException {
+ String[] l = {"IDENT", name};
+ sendLine(l);
+ }
+
+ protected void handle_HELLO(String[] args) throws IOException {
+ dist.onAccept(this, args[1]);
+ }
+
+ protected void handle_PING(String[] args) throws IOException {
+ args[0] = "PONG";
+ sendLine(args);
+ }
+
+ protected void handle_ACCEPT(String[] args) throws IOException {
+ dist.onAccept(this, args[1]);
+ }
+}
Property changes on: trunk/clients/Javer2/src/haver/Client.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: trunk/clients/Javer2/src/haver/NonblockingOutputStream.java
===================================================================
--- trunk/clients/Javer2/src/haver/NonblockingOutputStream.java 2005-05-22
03:51:20 UTC (rev 698)
+++ trunk/clients/Javer2/src/haver/NonblockingOutputStream.java 2005-05-22
03:56:37 UTC (rev 699)
@@ -0,0 +1,202 @@
+/*
+ * NonblockingOutputStream.java
+ *
+ * Created on January 10, 2005, 1:53 PM
+ */
+
+package haver;
+import java.io.*;
+import java.util.*;
+
+/**
+ *
+ * @author bdonlan
+ */
+public class NonblockingOutputStream extends java.io.FilterOutputStream
+ implements Runnable {
+
+ protected Vector preflush, pending;
+ protected long active_len;
+ protected long pending_len;
+ protected long preflush_len;
+ protected boolean flushing, closing, autoflush;
+ protected IOException pending_exception = null;
+ protected Thread th;
+ protected OutputStream out;
+
+ public NonblockingOutputStream(OutputStream out) {
+ super(out);
+ this.out = out;
+ flushing = closing = autoflush = false;
+ preflush = null;
+ pending = new Vector();
+ active_len = pending_len = preflush_len = 0;
+ th = new Thread(this);
+ th.start();
+ }
+
+ public void run() {
+ if (Thread.currentThread() != th)
+ throw new IllegalStateException("run() must be executed from
within " +
+ "NonblockingOutputStream.th");
+ th.setName("NonblockingOutputStream worker thread");
+ try {
+ while (true) {
+ Vector work;
+ boolean flushafter = false;
+ synchronized (th) {
+ active_len = 0;
+ if (flushing) {
+ flushafter = true;
+ flushing = false;
+
+ }
+ work = pending;
+ pending = new Vector();
+ active_len = pending_len;
+ pending_len = 0;
+ if (flushing) {
+ flushafter = true;
+ flushing = false;
+ pending = preflush;
+ pending_len = preflush_len;
+ preflush_len = 0;
+ preflush = null;
+ } else if (active_len == 0) {
+ //System.out.println("active_len == 0, blocking");
+ if (autoflush) {
+ out.flush();
+ }
+ if (closing) {
+ out.close();
+ return;
+ }
+ try {
+ th.wait();
+ } catch (InterruptedException e) {}
+ //System.out.println("done blocking");
+ continue;
+ }
+ }
+ Iterator it;
+ //System.out.println("writing, active_len = " + active_len);
+ it = work.iterator();
+ while (it.hasNext()) {
+ byte[] b = (byte[]) it.next();
+ out.write(b);
+ }
+ if (flushafter)
+ out.flush();
+ }
+ } catch (IOException e) {
+ synchronized(th) {
+ pending_exception = e;
+ }
+ }
+ }
+
+ public void write(byte[] b) throws IOException {
+ if (b.length == 0)
+ return;
+ //System.out.println("write called");
+ synchronized(th) {
+ if (pending_exception != null)
+ throw pending_exception;
+ if (flushing) {
+ preflush.add(b);
+ preflush_len += b.length;
+ } else {
+ pending.add(b);
+ pending_len += b.length;
+ th.notifyAll();
+ }
+ dump();
+ }
+ }
+
+ public void close() throws IOException {
+ synchronized(th) {
+ if (pending_exception != null)
+ throw pending_exception;
+ closing = true;
+ th.notifyAll();
+ dump();
+ }
+ }
+
+ public void flush() throws IOException {
+ synchronized(th) {
+ if (pending_exception != null)
+ throw pending_exception;
+ /* if we'return autoflushing, eventually a buffer will fill
somewhere
+ * and cause a flush, or else autoFlush will kick in. So the manual
+ * flush() is redundant
+ */
+ if (autoflush)
+ return;
+ flushing = true;
+ preflush = new Vector();
+ preflush_len = 0;
+ th.notifyAll();
+ dump();
+ }
+ }
+
+ /**
+ * Getter for property autoFlush.
+ * @return Value of property autoFlush.
+ */
+ public boolean isAutoFlush() {
+ return autoflush;
+ }
+
+ /**
+ * Setter for property autoFlush.
+ * @param autoFlush New value of property autoFlush.
+ */
+ public void setAutoFlush(boolean autoFlush) {
+ synchronized (th) {
+ autoflush = true;
+ th.notify();
+ }
+ }
+
+ protected void dump() {
+ /*
+ System.out.println("=== NonblockingOutputStream status:");
+ synchronized(th) {
+ System.out.println("Flags: flushing="+flushing+"
closing="+closing+" autoflush="+autoflush);
+ System.out.println("Buffer levels: preflush_len=" + preflush_len +
" pending_len="+pending_len);
+ System.out.print("Vector element counts: ");
+ if (preflush == null) {
+ System.out.print("preflush={null}" );
+ } else {
+ System.out.print("preflush=" + preflush.size());
+ }
+ System.out.println("pending=" + pending.size());
+ }
+ System.out.println("Stack trace:");
+ new Exception().printStackTrace();
+ */
+ }
+
+ public void write(int b) throws IOException {
+ byte[] a = new byte[1];
+ a[0] = (byte) b;
+ write(a);
+ }
+
+ public void write(byte[] b, int off, int len) throws IOException {
+ if (len == 0)
+ return;
+ if (len < 0)
+ throw new IllegalArgumentException("len must not be negative");
+ if (off + len > b.length)
+ throw new IllegalArgumentException("off + len > b.length");
+ byte[] buffer = new byte[len];
+ int i;
+ for (i = 0; i < len; i++)
+ buffer[i] = b[off + i];
+ write(buffer);
+ }
+}
Property changes on: trunk/clients/Javer2/src/haver/NonblockingOutputStream.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: trunk/clients/Javer2/src/javer2/Main.java
===================================================================
--- trunk/clients/Javer2/src/javer2/Main.java 2005-05-22 03:51:20 UTC (rev
698)
+++ trunk/clients/Javer2/src/javer2/Main.java 2005-05-22 03:56:37 UTC (rev
699)
@@ -0,0 +1,67 @@
+/*
+ * Main.java
+ *
+ * Created on May 21, 2005, 8:46 PM
+ */
+
+package javer2;
+import haver.*;
+
+/**
+ *
+ * @author bdonlan
+ */
+public class Main extends haver.Callback {
+ Client c;
+
+ /** Creates a new instance of Main */
+ public Main() throws Throwable {
+ c = new Client();
+ c.syncConnect("localhost", 15455, "bd_");
+ c.addNotify(this);
+ System.out.println("out");
+ }
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) throws Throwable {
+ // TODO code application logic here
+ new Main();
+ }
+
+ public String join(String[] parts) {
+ StringBuffer b = new StringBuffer();
+ for (int i = 0; i < parts.length; i++) {
+ b.append('\t');
+ b.append(parts[i]);
+ }
+ return b.toString().substring(1);
+ }
+
+ public void onDisconnected(Client source, java.io.IOException e) throws
java.io.IOException {
+ System.out.println("dc");
+ super.onDisconnected(source, e);
+ }
+
+ public void onConnect(Client source) throws java.io.IOException {
+ System.out.println("connected");
+ super.onConnect(source);
+ }
+
+ public void onOutgoingLine(Client source, String[] args) throws
java.io.IOException {
+ //System.out.println("out:");
+ super.onOutgoingLine(source, args);
+ }
+
+ public void onIncomingLine(Client source, String[] args) throws
java.io.IOException {
+ //System.out.println("in");
+ super.onIncomingLine(source, args);
+ }
+
+ public void onAccept(Client source, String nick) throws
java.io.IOException {
+ System.out.println("Accepted: " + nick);
+ super.onAccept(source, nick);
+ }
+
+}
Property changes on: trunk/clients/Javer2/src/javer2/Main.java
___________________________________________________________________
Name: svn:eol-style
+ native