From cc7a12f74a9ce4555d5abd8989dfab43290fb41c Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 24 Feb 2012 16:28:27 -0500 Subject: [PATCH] Java dependencies update As of Java 6, XML Stax parsing is natively supported. This change removes the external Stax dependencies and updates how the JSON libs are fetched (in deps.sh), which now come from github. Signed-off-by: Bill Erickson Signed-off-by: Dan Scott --- src/java/deps.sh | 37 ++++++++++++--------------- src/java/org/opensrf/net/xmpp/XMPPReader.java | 5 +--- src/java/org/opensrf/util/XMLFlattener.java | 5 +--- 3 files changed, 19 insertions(+), 28 deletions(-) diff --git a/src/java/deps.sh b/src/java/deps.sh index 0d7a7bf..c6302ca 100755 --- a/src/java/deps.sh +++ b/src/java/deps.sh @@ -2,31 +2,22 @@ # Utility script for fetching the OpenSRF Java dependencies # ---------------------------------------------------------------- -. deps.inc -STAX=stax-api-1.0.1.jar -WSTX=wstx-lgpl-3.2.1.jar -MEMCACHE=java_memcached-release_1.5.1.jar -JSON=json.zip +MEMCACHE=java_memcached-release_2.0.1.jar +MEMCACHE_URL=http://img.whalin.com/memcached/jdk6/standard/$MEMCACHE +JSON_URL=https://github.com/douglascrockford/JSON-java/zipball/master JSON_ZIP=json.zip - -STAX_URL=http://woodstox.codehaus.org/$STAX -WSTX_URL=http://woodstox.codehaus.org/3.2.1/$WSTX -MEMCACHE_URL=http://img.whalin.com/memcached/jdk5/standard/$MEMCACHE -JSON_URL=http://www.json.org/java/$JSON - -JAVAC="javac -J-Xmx256m" -JAVA="java -Xmx256m" +JSON_JAR=json.jar mkdir -p deps -if [ ! -f deps/$STAX ]; then wget $STAX_URL -O deps/$STAX; fi -if [ ! -f deps/$WSTX ]; then wget $WSTX_URL -O deps/$WSTX; fi if [ ! -f deps/$MEMCACHE ]; then wget $MEMCACHE_URL -O deps/$MEMCACHE; fi -if [ ! -f deps/$JSON ]; then - mkdir -p deps +if [ ! -f deps/$JSON_JAR ]; then cd deps - wget "$JSON_URL" - unzip $JSON && $JAVAC org/json/*.java; - jar cf json.jar org + wget "$JSON_URL" -O $JSON_ZIP + unzip $JSON_ZIP + mkdir -p org/json/ + cp douglascrockford*/*.java org/json/ + javac org/json/*.java + jar cf $JSON_JAR org/json/*.class fi @@ -38,3 +29,9 @@ else echo "example: INSTALLDIR=/path/to/java $0" echo "" fi + +echo "" +echo "To compile OpenSRF java:" +echo "" +echo "CLASSPATH=deps/$MEMCACHE:deps/$JSON_JAR javac org/opensrf/*.java org/opensrf/net/xmpp/*.java org/opensrf/util/*.java org/opensrf/test/*.java" +echo "" diff --git a/src/java/org/opensrf/net/xmpp/XMPPReader.java b/src/java/org/opensrf/net/xmpp/XMPPReader.java index dcaf8bd..406298a 100644 --- a/src/java/org/opensrf/net/xmpp/XMPPReader.java +++ b/src/java/org/opensrf/net/xmpp/XMPPReader.java @@ -9,8 +9,6 @@ import java.util.concurrent.ConcurrentLinkedQueue; import java.util.Date; import org.opensrf.util.Logger; -import com.ctc.wstx.stax.WstxInputFactory; - /** * Slim XMPP Stream reader. This reader only understands enough XMPP * to handle logins and recv messages. It's implemented as a StAX parser. @@ -162,8 +160,7 @@ public class XMPPReader implements Runnable { try { - //XMLInputFactory factory = XMLInputFactory.newInstance(); - XMLInputFactory factory = new com.ctc.wstx.stax.WstxInputFactory(); + XMLInputFactory factory = XMLInputFactory.newInstance(); /** disable as many unused features as possible to speed up the parsing */ factory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, Boolean.FALSE); diff --git a/src/java/org/opensrf/util/XMLFlattener.java b/src/java/org/opensrf/util/XMLFlattener.java index 5a8561d..7abefe0 100644 --- a/src/java/org/opensrf/util/XMLFlattener.java +++ b/src/java/org/opensrf/util/XMLFlattener.java @@ -12,8 +12,6 @@ import java.io.InputStream; import org.opensrf.util.JSONWriter; import org.opensrf.util.JSONReader; -import com.ctc.wstx.stax.WstxInputFactory; - /** * Flattens an XML file into a properties map. Values are stored as JSON strings or arrays. * An array is created if more than one value resides at the same key. @@ -57,8 +55,7 @@ public class XMLFlattener { */ public Map read() throws javax.xml.stream.XMLStreamException { - //XMLInputFactory factory = XMLInputFactory.newInstance(); - XMLInputFactory factory = new com.ctc.wstx.stax.WstxInputFactory(); + XMLInputFactory factory = XMLInputFactory.newInstance(); /** disable as many unused features as possible to speed up the parsing */ factory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, Boolean.TRUE); -- 2.11.0