commonjava-developer Mailing List for CommonJava Open Component Project (Page 13)
Brought to you by:
johnqueso
You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(10) |
Feb
(114) |
Mar
(169) |
Apr
(25) |
May
|
Jun
(5) |
Jul
(17) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <joh...@co...> - 2004-02-18 06:19:48
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-config/projects/jboss-config-service/service-client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26148/projects/jboss-config-service/service-client Log Message: Directory /cvsroot/commonjava/commonjava-projects/commonjava-config/projects/jboss-config-service/service-client added to the repository |
From: <joh...@co...> - 2004-02-18 06:19:44
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-config/projects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26148/projects Log Message: Directory /cvsroot/commonjava/commonjava-projects/commonjava-config/projects added to the repository |
From: <joh...@co...> - 2004-02-16 07:18:04
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-caching In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv396 Modified Files: project.xml Log Message: added project description and changed name to Caching. Index: project.xml =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-caching/project.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- project.xml 18 Sep 2003 00:34:01 -0000 1.1 +++ project.xml 16 Feb 2004 07:10:16 -0000 1.2 @@ -3,7 +3,7 @@ <project> <pomVersion>3</pomVersion> <id>commonjava-caching</id> - <name>CommonJava Caching Libraries</name> + <name>Caching</name> <groupId>commonjava</groupId> <currentVersion>2.0</currentVersion> <organization> @@ -13,6 +13,11 @@ <inceptionYear>2002</inceptionYear> <package>org.commonjava.caching</package> + <description> + Entire package centered around an implementation of an aging cache (complete with + proactively waiting grooming thread) which exposes an enhanced map interface to the user. + </description> + <dependencies> <dependency> <groupId>commonjava</groupId> |
From: <joh...@co...> - 2004-02-16 07:11:13
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-codec In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31886 Modified Files: .classpath .project project.xml Log Message: deprecated Base64 and XmlFormatter in favor of the commonjava-util versions. This package is officially on its way to becoming defunct. Abandon ship!!! Index: .classpath =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-codec/.classpath,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- .classpath 15 Dec 2003 01:51:15 -0000 1.3 +++ .classpath 16 Feb 2004 07:03:23 -0000 1.4 @@ -1,20 +1,11 @@ <?xml version="1.0" encoding="UTF-8"?> - <classpath> - <classpathentry kind="src" path="src/java"> - </classpathentry> - <classpathentry kind="var" rootpath="JRE_SRCROOT" path="JRE_LIB" sourcepath="JRE_SRC"> - </classpathentry> - <classpathentry kind="var" path="MAVEN_REPO/commonjava/jars/commonjava-lang-2.0.jar"> - </classpathentry> - <classpathentry kind="var" path="MAVEN_REPO/commonjava/jars/commonjava-io-2.0.jar"> - </classpathentry> - <classpathentry kind="var" path="MAVEN_REPO/commonjava/jars/commonjava-reflection-2.0.jar"> - </classpathentry> - <classpathentry kind="var" path="MAVEN_REPO/commonjava/jars/commonjava-util-2.0.jar"> - </classpathentry> - <classpathentry kind="var" path="MAVEN_REPO/commons-logging/jars/commons-logging-1.0.2.jar"> - </classpathentry> - <classpathentry kind="output" path="target/classes"> - </classpathentry> -</classpath> \ No newline at end of file + <classpathentry kind="src" path="src/java"/> + <classpathentry kind="var" path="JRE_LIB" sourcepath="JRE_SRC"/> + <classpathentry kind="var" path="MAVEN_REPO/commons-logging/jars/commons-logging-1.0.2.jar"/> + <classpathentry kind="src" path="/commonjava-io"/> + <classpathentry kind="src" path="/commonjava-lang"/> + <classpathentry kind="src" path="/commonjava-reflection"/> + <classpathentry kind="src" path="/commonjava-util"/> + <classpathentry kind="output" path="target/classes"/> +</classpath> Index: .project =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-codec/.project,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- .project 18 Sep 2003 00:38:36 -0000 1.1 +++ .project 16 Feb 2004 07:03:23 -0000 1.2 @@ -1,19 +1,22 @@ <?xml version="1.0" encoding="UTF-8"?> - <projectDescription> - <name>commonjava-codec</name> - <comment> + <name>commonjava-codec</name> + <comment> </comment> - <projects> - </projects> - <buildSpec> - <buildCommand> - <name>org.eclipse.jdt.core.javabuilder</name> - <arguments> - </arguments> - </buildCommand> - </buildSpec> - <natures> - <nature>org.eclipse.jdt.core.javanature</nature> - </natures> -</projectDescription> \ No newline at end of file + <projects> + <project>commonjava-io</project> + <project>commonjava-lang</project> + <project>commonjava-reflection</project> + <project>commonjava-util</project> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> Index: project.xml =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-codec/project.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- project.xml 18 Sep 2003 00:38:36 -0000 1.1 +++ project.xml 16 Feb 2004 07:03:23 -0000 1.2 @@ -13,6 +13,13 @@ <inceptionYear>2002</inceptionYear> <package>org.commonjava.codec</package> + <description> + Basically defunct set of en/decoders for XML formatting/parsing regex-based file parsing, + and javabeans formatting. May revive the regex-based file parsing, since this is still a + pretty good idea, but it doesn't quite fit into the common mold with XML parsing. And it + really shouldn't... The rest is definitely on the way out, though. + </description> + <dependencies> <dependency> <groupId>commonjava</groupId> |
From: <joh...@co...> - 2004-02-16 07:11:12
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-codec/src/java/org/commonjava/codec In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31886/src/java/org/commonjava/codec Modified Files: Base64.java Log Message: deprecated Base64 and XmlFormatter in favor of the commonjava-util versions. This package is officially on its way to becoming defunct. Abandon ship!!! Index: Base64.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-codec/src/java/org/commonjava/codec/Base64.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Base64.java 18 Sep 2003 00:38:36 -0000 1.1 +++ Base64.java 16 Feb 2004 07:03:24 -0000 1.2 @@ -10,6 +10,7 @@ /** Encode/Decode Base-64... * @author John Casey + * @deprecated Use commonjava-util/Base64 instead. */ public final class Base64 { |
From: <joh...@co...> - 2004-02-16 07:11:12
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-codec/src/java/org/commonjava/codec/encode In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31886/src/java/org/commonjava/codec/encode Modified Files: ObjectFormatException.java XmlFormatter.java Log Message: deprecated Base64 and XmlFormatter in favor of the commonjava-util versions. This package is officially on its way to becoming defunct. Abandon ship!!! Index: ObjectFormatException.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-codec/src/java/org/commonjava/codec/encode/ObjectFormatException.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ObjectFormatException.java 18 Sep 2003 00:38:36 -0000 1.1 +++ ObjectFormatException.java 16 Feb 2004 07:03:23 -0000 1.2 @@ -8,7 +8,7 @@ /* - * ObjectFormatException.java + * XmlFormatException.java * * Created on September 29, 2002, 5:03 AM */ @@ -23,11 +23,11 @@ */ public class ObjectFormatException extends CommonJavaException{ - /** Creates a new instance of ObjectFormatException */ + /** Creates a new instance of XmlFormatException */ public ObjectFormatException() { } - /** Creates a new instance of ObjectFormatException + /** Creates a new instance of XmlFormatException * @param message The message. * @param root The root cause. */ @@ -35,14 +35,14 @@ super(message, root); } - /** Creates a new instance of ObjectFormatException + /** Creates a new instance of XmlFormatException * @param message The message. */ public ObjectFormatException(String message) { super(message); } - /** Creates a new instance of ObjectFormatException + /** Creates a new instance of XmlFormatException * @param root The root cause. */ public ObjectFormatException(Throwable root) { Index: XmlFormatter.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-codec/src/java/org/commonjava/codec/encode/XmlFormatter.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- XmlFormatter.java 18 Sep 2003 00:38:36 -0000 1.1 +++ XmlFormatter.java 16 Feb 2004 07:03:23 -0000 1.2 @@ -29,6 +29,7 @@ /** Formatter for translating objects into XML. * * @author John Casey + * @deprecated Use commonjava-util/XmlFormatter instead. */ public class XmlFormatter { @@ -78,7 +79,7 @@ } /** Write the opening document header to the sink. - * @throws ObjectFormatException in case of an error writing to the sink. + * @throws XmlFormatException in case of an error writing to the sink. */ public void openDocument() throws ObjectFormatException{ try{ @@ -94,7 +95,7 @@ * @param element The element name to write out. * @param attributes The attributes to write out. * @param namespaces The namespaces for each attribute. - * @throws ObjectFormatException in case of an error writing to the sink. + * @throws XmlFormatException in case of an error writing to the sink. */ public void writeEmptyElement(String element, Map attributes, Map namespaces) throws ObjectFormatException @@ -115,7 +116,7 @@ * @param element The element name to write out. * @param attributes The attributes to write out. * @param namespaces The namespaces for each attribute. - * @throws ObjectFormatException in case of an error writing to the sink. + * @throws XmlFormatException in case of an error writing to the sink. */ public void openElement(String element, Map attributes, Map namespaces) throws ObjectFormatException @@ -136,7 +137,7 @@ /** Close the latest element on the open element stack, and write to the sink. * @return the name of the element closed. - * @throws ObjectFormatException in case of an error writing to the sink. + * @throws XmlFormatException in case of an error writing to the sink. */ public String closeLastElement() throws ObjectFormatException{ return _closeLastElement(); @@ -144,7 +145,7 @@ /** Write an element's body text to the sink. * @param value The text to write to the element's body. - * @throws ObjectFormatException in case of an error writing to the sink. + * @throws XmlFormatException in case of an error writing to the sink. */ public void writeElementValue(String value) throws ObjectFormatException{ if(value == null){return;} @@ -153,7 +154,7 @@ /** Write an element's body text to the sink, wrapped in CDATA tags. * @param value The text to write to the element's body. - * @throws ObjectFormatException in case of an error writing to the sink. + * @throws XmlFormatException in case of an error writing to the sink. */ public void writeCDATAElementValue(String value) throws ObjectFormatException{ if(value == null){return;} @@ -162,7 +163,7 @@ /** Write a boolean to the element's body text in the sink. * @param value The boolean to write to the element's body. - * @throws ObjectFormatException in case of an error writing to the sink. + * @throws XmlFormatException in case of an error writing to the sink. */ public void writeElementValue(boolean value) throws ObjectFormatException{ _writeElementValue(String.valueOf(value)); @@ -170,14 +171,14 @@ /** Write a boolean to the element's body text in the sink, wrapped in CDATA tags. * @param value The boolean to write to the element's body. - * @throws ObjectFormatException in case of an error writing to the sink. + * @throws XmlFormatException in case of an error writing to the sink. */ public void writeCDATAElementValue(boolean value) throws ObjectFormatException{ _writeCDATAElementValue(String.valueOf(value)); } /** Close all open elements, and write them to the sink. - * @throws ObjectFormatException in case of an error writing to the sink. + * @throws XmlFormatException in case of an error writing to the sink. */ public void finishDocument() throws ObjectFormatException{ for(int i=0, len=nestingLevels.size(); i<len; i++){ @@ -200,7 +201,7 @@ * @param element The element name. * @param attributes The element's attributes. * @param namespaces The namespaces for attributes. - * @throws ObjectFormatException in case of an error writing to the sink. + * @throws XmlFormatException in case of an error writing to the sink. */ private void writeElementStart(String element, Map attributes, Map namespaces) throws ObjectFormatException @@ -241,7 +242,7 @@ * dependencies. * * @param value The String to write to the element's body. - * @throws ObjectFormatException in case of an error writing to the sink. + * @throws XmlFormatException in case of an error writing to the sink. */ private void _writeElementValue(String value) throws ObjectFormatException{ if(value == null){return;} @@ -269,7 +270,7 @@ * causing lateral API dependencies. * * @param value The String to write to the element's body. - * @throws ObjectFormatException in case of an error writing to the sink. + * @throws XmlFormatException in case of an error writing to the sink. */ private void _writeCDATAElementValue(String value) throws ObjectFormatException{ if(value == null){return;} @@ -301,7 +302,7 @@ * provided as a common piece of code to promote code reuse between the * closeLastElement() and finishDocument() methods, to avoid lateral API * dependencies. - * @throws ObjectFormatException in case of an error writing to the sink. + * @throws XmlFormatException in case of an error writing to the sink. */ private String _closeLastElement() throws ObjectFormatException{ try{ |
From: <joh...@co...> - 2004-02-16 07:09:35
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-reflection In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31612 Modified Files: project.xml Log Message: updated the name of the project to be Reflective Utilities, and added a description element to the project.xml Index: project.xml =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-reflection/project.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- project.xml 18 Sep 2003 05:55:49 -0000 1.1 +++ project.xml 16 Feb 2004 07:01:47 -0000 1.2 @@ -3,7 +3,7 @@ <project> <pomVersion>3</pomVersion> <id>commonjava-reflection</id> - <name>CommonJava Reflective Utilities</name> + <name>Reflective Utilities</name> <groupId>commonjava</groupId> <currentVersion>2.0</currentVersion> <organization> @@ -13,6 +13,23 @@ <inceptionYear>2002</inceptionYear> <package>org.commonjava.reflection</package> + <description> + Reflective Utilities contains a very narrowly-scoped set of functions. In a nutshell, it provides + cache-enabled reflective method invocation and enhanced JAR-specification service discovery. The + cache-enabled method invocation basically just caches the Method objects once they are found, and + lookups for a method will also search superclasses and implemented interfaces for parameters, in + an ever-widening search. Enhanced JAR-specification service discovery enables searching the + META-INF/services classpath resource base for resources matching interface or abstract class names. + When found, these resources will be read to retrieve the implementation name(s). Once found, these + implementations can be instantiated via constructors using a particular parameter array (this is + where the use of abstract classes comes in handy; you can hint at constructor signatures), or they + can have getInstance(...) invoked on them, also using a particular parameter array. As a final note, + this service search provides methods to instantiate instances for each line in the resource. In this + way, you can retrieve an array of instantiated implementations for a given abstraction. The array + can then be used in some sort of aggregator implementation. Also, when searching for multiple + implementors, the single-implementation case will simply appear as an array of size one. + </description> + <dependencies> <dependency> <groupId>commons-logging</groupId> |
From: <joh...@co...> - 2004-02-16 07:01:07
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30286 Modified Files: project.xml Log Message: updated the name to simply Utilities Index: project.xml =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-util/project.xml,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- project.xml 16 Feb 2004 06:52:39 -0000 1.5 +++ project.xml 16 Feb 2004 06:53:19 -0000 1.6 @@ -3,7 +3,7 @@ <project> <pomVersion>3</pomVersion> <id>commonjava-util</id> - <name>CommonJava General Utilities</name> + <name>Utilities</name> <groupId>commonjava</groupId> <currentVersion>2.0-3</currentVersion> <organization> |
From: <joh...@co...> - 2004-02-16 07:00:27
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-util/src/java/org/commonjava/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30155/src/java/org/commonjava/util Added Files: XmlFormatException.java Base64.java XmlFormatter.java Log Message: added some of the still-good classes from commonjava-codec before that whole project is deprecated. Also, fleshed out a description in the project.xml. --- NEW FILE: XmlFormatException.java --- /* Copyright (c) 2002 John Casey. All rights reserved. SEE licenses/cj-license.txt FOR MORE INFORMATION. */ /* * XmlFormatException.java * * Created on September 29, 2002, 5:03 AM */ package org.commonjava.util; import org.commonjava.lang.CommonJavaException; /** signals an exception during the object formatting process. * * @author John Casey */ public class XmlFormatException extends CommonJavaException{ /** Creates a new instance of XmlFormatException */ public XmlFormatException() { } /** Creates a new instance of XmlFormatException * @param message The message. * @param root The root cause. */ public XmlFormatException(String message, Throwable root) { super(message, root); } /** Creates a new instance of XmlFormatException * @param message The message. */ public XmlFormatException(String message) { super(message); } /** Creates a new instance of XmlFormatException * @param root The root cause. */ public XmlFormatException(Throwable root) { super(root); } } --- NEW FILE: Base64.java --- /* * Created on Apr 7, 2003 */ package org.commonjava.util; import java.io.ByteArrayOutputStream; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** Encode/Decode Base-64... * @author John Casey */ public final class Base64 { private static final Log LOG = LogFactory.getLog(Base64.class); private static final String CRLF = System.getProperty("line.separator"); private static final int LINE_END = 64; public static String encode(byte[] data){ return Base64.encode(data, true); } public static String encode(byte[] data, boolean useLineDelimiter){ if(data == null){ return null; } else if(data.length == 0){ return ""; } int padding = 3 - (data.length % 3); // if(LOG.isDebugEnabled()){LOG.debug("padding = " + padding + " characters.");} StringBuffer buffer = new StringBuffer(); for (int i = 0; i < data.length; i+=3) { // if(LOG.isDebugEnabled()){LOG.debug("iteration base offset = " + i);} int neutral = (data[i] < 0 ? data[i] + 256 : data[i]); int block = (neutral & 0xff); // if(LOG.isDebugEnabled()){LOG.debug("after first byte, block = " + Integer.toBinaryString(block));} boolean inLastSegment = false; block <<= 8; if(i+1 < data.length){ neutral = (data[i+1] < 0 ? data[i+1] + 256 : data[i+1]); block |= (neutral & 0xff); } else{ inLastSegment = true; } // if(LOG.isDebugEnabled()){LOG.debug("after second byte, block = " + Integer.toBinaryString(block) + "; inLastSegment = " + inLastSegment);} block <<= 8; if(i+2 < data.length){ neutral = (data[i+2] < 0 ? data[i+2] + 256 : data[i+2]); block |= (neutral & 0xff); } else{ inLastSegment = true; } // if(LOG.isDebugEnabled()){LOG.debug("after third byte, block = " + Integer.toBinaryString(block) + "; inLastSegment = " + inLastSegment);} char[] encoded = new char[4]; int encIdx = 0; encoded[0] = toBase64Char((block >>> 18) & 0x3f); // if(LOG.isDebugEnabled()){LOG.debug("first character = " + encoded[0]);} encoded[1] = toBase64Char((block >>> 12) & 0x3f); // if(LOG.isDebugEnabled()){LOG.debug("second character = " + encoded[1]);} if(inLastSegment && padding > 1){ encoded[2] = '='; } else{ encoded[2] = toBase64Char((block >>> 6) & 0x3f); } // if(LOG.isDebugEnabled()){LOG.debug("third character = " + encoded[2]);} if(inLastSegment && padding > 0){ encoded[3] = '='; } else{ encoded[3] = toBase64Char(block & 0x3f); } // if(LOG.isDebugEnabled()){LOG.debug("fourth character = " + encoded[3]);} buffer.append(encoded); } if(useLineDelimiter){ return canonicalize(buffer.toString()); } else{ return buffer.toString(); } } public static byte[] decode(String src){ return Base64.decode(src, true); } public static byte[] decode(String src, boolean useLineDelimiter){ if(src == null){ return null; } else if(src.length() < 1){ return new byte[0]; } // if(LOG.isDebugEnabled()){LOG.debug("pre-canonicalization = \n" + src);} String data = src; if(useLineDelimiter){data = deCanonicalize(src);} // if(LOG.isDebugEnabled()){LOG.debug("post-canonicalization = \n" + data);} ByteArrayOutputStream baos = new ByteArrayOutputStream(); char[] input = data.toCharArray(); int index = 0; for (int i = 0; i < input.length; i+=4) { // if(LOG.isDebugEnabled()){LOG.debug("iteration base offset = " + i);} int block = (toBase64Int(input[i]) & 0x3f); // if(LOG.isDebugEnabled()){LOG.debug("block after first char [" + input[i] + "] = " + Integer.toBinaryString(block));} block <<= 6; block |= (toBase64Int(input[i+1]) & 0x3f); // if(LOG.isDebugEnabled()){LOG.debug("block after second char [" + input[i+1] + "] = " + Integer.toBinaryString(block));} boolean inPadding = false; boolean twoCharPadding = false; block <<= 6; if(input[i+2] != '='){ block |= (toBase64Int(input[i+2]) & 0x3f); } else{ twoCharPadding = true; inPadding = true; } // if(LOG.isDebugEnabled()){LOG.debug("block after third char [" + input[i+2] + "] = " + Integer.toBinaryString(block));} block <<= 6; if(input[i+3] != '='){ block |= (toBase64Int(input[i+3]) & 0x3f); } else{ inPadding = true; } // if(LOG.isDebugEnabled()){LOG.debug("block after fourth char [" + input[i+3] + "] = " + Integer.toBinaryString(block));} baos.write((block >>> 16) & 0xff); // if(LOG.isDebugEnabled()){LOG.debug("byte[" + (index++) + "] = " + ((block >>> 16) & 0xff));} if(!inPadding || !twoCharPadding){ baos.write((block >>> 8) & 0xff); // if(LOG.isDebugEnabled()){LOG.debug("byte[" + (index++) + "] = " + ((block >>> 8) & 0xff));} } if(!inPadding){ baos.write(block & 0xff); // if(LOG.isDebugEnabled()){LOG.debug("byte[" + (index++) + "] = " + (block & 0xff));} } } byte[] result = baos.toByteArray(); // if(LOG.isDebugEnabled()){LOG.debug("byte array is " + result.length + " bytes long.");} return result; } private static char toBase64Char(int input){ if(input > -1 && input < 26){ return (char)('A' + input); } else if(input > 25 && input < 52){ return (char)('a' + input - 26); } else if(input > 51 && input < 62){ return (char)('0' + input - 52); } else if(input == 62){ return '+'; } else if(input == 63){ return '/'; } else{ return '?'; } } private static int toBase64Int(char input){ if(input >= 'A' && input <= 'Z'){ return input - 'A'; } else if(input >= 'a' && input <= 'z'){ return input + 26 - 'a'; } else if(input >= '0' && input <= '9'){ return input + 52 - '0'; } else if(input == '+'){ return 62; } else if(input == '/'){ return 63; } else{ return 0; } } private static String deCanonicalize(String data){ if(data == null){return null;} StringBuffer buffer = new StringBuffer(data.length()); for (int i = 0; i < data.length(); i++) { char c = data.charAt(i); if(c != '\r' && c != '\n'){ buffer.append(c); } } return buffer.toString(); } private static String canonicalize(String data){ StringBuffer buffer = new StringBuffer((int)(data.length() * 1.1)); int col = 0; for (int i = 0; i < data.length(); i++) { if(col == LINE_END){ buffer.append(CRLF); col = 0; } buffer.append(data.charAt(i)); col++; } buffer.append(CRLF); return buffer.toString(); } } --- NEW FILE: XmlFormatter.java --- /* Copyright (c) 2002 John Casey. All rights reserved. SEE licenses/cj-license.txt FOR MORE INFORMATION. */ /* * XmlFormatter.java * * Created on September 29, 2002, 4:47 AM */ package org.commonjava.util; import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.Writer; import java.util.Iterator; import java.util.Map; import java.util.Stack; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** Formatter for translating objects into XML. * * @author John Casey */ public class XmlFormatter { private static final Log LOG = LogFactory.getLog(XmlFormatter.class); private String indent; private Writer out; private String lineBreak; private Stack nestingLevels; /** Creates a new instance of XmlFormatter * @param indent The String to use as indentation for one level deep. * @param out The Writer to send xml to. * @param lineBreak The lineBreak String to use. */ public XmlFormatter(String indent, Writer out, String lineBreak) { this.indent = indent; this.out = out; this.lineBreak = lineBreak; this.nestingLevels = new Stack(); } /** Creates a new instance of XmlFormatter * @param indent The String to use as indentation for one level deep. * @param out The OutputStream to send xml to. * @param lineBreak The lineBreak String to use. */ public XmlFormatter(String indent, OutputStream out, String lineBreak){ this(indent, new OutputStreamWriter(out), lineBreak); } /** Creates a new instance of XmlFormatter * @param indent The String to use as indentation for one level deep. * @param out The Writer to send xml to. */ public XmlFormatter(String indent, Writer out) { this(indent, out, "\n"); } /** Creates a new instance of XmlFormatter * @param indent The String to use as indentation for one level deep. * @param out The OutputStream to send xml to. */ public XmlFormatter(String indent, OutputStream out){ this(indent, new OutputStreamWriter(out), "\n"); } /** Write the opening document header to the sink. * @throws XmlFormatException in case of an error writing to the sink. */ public void openDocument() throws XmlFormatException{ try{ out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); out.write(lineBreak); } catch(IOException ex){ throw new XmlFormatException(ex); } } /** Write an empty element (no body) to the sink. * @param element The element name to write out. * @param attributes The attributes to write out. * @param namespaces The namespaces for each attribute. * @throws XmlFormatException in case of an error writing to the sink. */ public void writeEmptyElement(String element, Map attributes, Map namespaces) throws XmlFormatException { if(element == null){return;} try{ writeElementStart(element, attributes, namespaces); out.write(" />"); out.write(lineBreak); } catch(IOException ex){ throw new XmlFormatException(ex); } } /** Write an opening element tag to the sink. * @param element The element name to write out. * @param attributes The attributes to write out. * @param namespaces The namespaces for each attribute. * @throws XmlFormatException in case of an error writing to the sink. */ public void openElement(String element, Map attributes, Map namespaces) throws XmlFormatException { if(element == null){return;} try{ writeElementStart(element, attributes, namespaces); out.write(">"); out.write(lineBreak); nestingLevels.push(element); } catch(IOException ex){ throw new XmlFormatException(ex); } } /** Close the latest element on the open element stack, and write to the sink. * @return the name of the element closed. * @throws XmlFormatException in case of an error writing to the sink. */ public String closeLastElement() throws XmlFormatException{ return _closeLastElement(); } /** Write an element's body text to the sink. * @param value The text to write to the element's body. * @throws XmlFormatException in case of an error writing to the sink. */ public void writeElementValue(String value) throws XmlFormatException{ if(value == null){return;} _writeElementValue(value); } /** Write an element's body text to the sink, wrapped in CDATA tags. * @param value The text to write to the element's body. * @throws XmlFormatException in case of an error writing to the sink. */ public void writeCDATAElementValue(String value) throws XmlFormatException{ if(value == null){return;} _writeCDATAElementValue(value); } /** Write a boolean to the element's body text in the sink. * @param value The boolean to write to the element's body. * @throws XmlFormatException in case of an error writing to the sink. */ public void writeElementValue(boolean value) throws XmlFormatException{ _writeElementValue(String.valueOf(value)); } /** Write a boolean to the element's body text in the sink, wrapped in CDATA tags. * @param value The boolean to write to the element's body. * @throws XmlFormatException in case of an error writing to the sink. */ public void writeCDATAElementValue(boolean value) throws XmlFormatException{ _writeCDATAElementValue(String.valueOf(value)); } /** Close all open elements, and write them to the sink. * @throws XmlFormatException in case of an error writing to the sink. */ public void finishDocument() throws XmlFormatException{ for(int i=0, len=nestingLevels.size(); i<len; i++){ _closeLastElement(); } try{ out.flush(); } catch(IOException ex){ throw new XmlFormatException(ex); } } /** Write the beginning of an open element tag, up to the attributes, but not * including the closing bracket. This is used to provide a common piece of * code for the two methods used to open an element, * openElement() and writeEmptyElement(), without creating lateral API dependencies. * * @param element The element name. * @param attributes The element's attributes. * @param namespaces The namespaces for attributes. * @throws XmlFormatException in case of an error writing to the sink. */ private void writeElementStart(String element, Map attributes, Map namespaces) throws XmlFormatException { if(element == null){return;} try{ for(int i=0, len=nestingLevels.size(); i<len; i++){ out.write(indent); } out.write("<"); out.write(element); if(attributes != null){ for(Iterator it = attributes.keySet().iterator(); it != null && it.hasNext(); ){ Object obj = it.next(); String key = String.valueOf(obj); String value = String.valueOf(attributes.get(obj)); out.write(" "); out.write(key); out.write("=\""); out.write(value); out.write("\""); } } if(namespaces != null){ //format elment output for introduction of namespaces. } } catch(IOException ex){ throw new XmlFormatException(ex); } } /** Write a String to the element's body text in the sink. This is provided as * a common piece of code to promote code reuse without causing lateral API * dependencies. * * @param value The String to write to the element's body. * @throws XmlFormatException in case of an error writing to the sink. */ private void _writeElementValue(String value) throws XmlFormatException{ if(value == null){return;} try{ int levelCount = nestingLevels.size(); if(levelCount < 1){ throw new XmlFormatException("Cannot write a value with no parent element declared."); } for(int i=0, len=levelCount; i<len; i++){ out.write(indent); } out.write(indent); out.write(value); out.write(lineBreak); } catch(IOException ex){ throw new XmlFormatException(ex); } } /** Write a String to the element's body text in the sink, wrappered in CDATA. * This is provided as a common piece of code to promote code reuse without * causing lateral API dependencies. * * @param value The String to write to the element's body. * @throws XmlFormatException in case of an error writing to the sink. */ private void _writeCDATAElementValue(String value) throws XmlFormatException{ if(value == null){return;} try{ int levelCount = nestingLevels.size(); if(levelCount < 1){ throw new XmlFormatException("Cannot write a value with no parent element declared."); } for(int i=0, len=levelCount; i<len; i++){ out.write(indent); } out.write("<![CDATA["); if(LOG.isDebugEnabled()){ LOG.debug("value=\'" + value + "\'"); } out.write(value); out.write("]]>"); out.write(lineBreak); } catch(IOException ex){ throw new XmlFormatException(ex); } } /** Close the latest element on the open elements stack. This method is * provided as a common piece of code to promote code reuse between the * closeLastElement() and finishDocument() methods, to avoid lateral API * dependencies. * @throws XmlFormatException in case of an error writing to the sink. */ private String _closeLastElement() throws XmlFormatException{ try{ int levelCount = nestingLevels.size(); if(levelCount < 1){ throw new XmlFormatException("Cannot close a non-existent value."); } if(levelCount > 0){ String element = (String)nestingLevels.pop(); for(int i=0, len=levelCount-1; i<len; i++){ out.write(indent); } out.write("</"); out.write(element); out.write(">"); out.write(lineBreak); return element; } } catch(IOException ex){ throw new XmlFormatException(ex); } return null; } } |
From: <joh...@co...> - 2004-02-16 07:00:27
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30155 Modified Files: project.xml Log Message: added some of the still-good classes from commonjava-codec before that whole project is deprecated. Also, fleshed out a description in the project.xml. Index: project.xml =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-util/project.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- project.xml 2 Feb 2004 03:03:49 -0000 1.4 +++ project.xml 16 Feb 2004 06:52:39 -0000 1.5 @@ -13,6 +13,23 @@ <inceptionYear>2002</inceptionYear> <package>org.commonjava.util</package> + <description> + <p> + Util is your basic catch-all utilties repository. It's basically the swiss-army knife of the + commonjava projects, and has bloated over time to include an incredible amount of reusable + components. As such, it is a primary target for refactoring into sub-projects. This refactoring + will allow for trimmer dependency sets for client projects of util. + </p> + <p> + This package contains convenience constants (eg. TimeConstants), File manipulation and search + utilities, data structures, some basic lightweight formatters, some implementations of + FilenameFilter, and much more. And that's just the base org.commonjava.util package! Sub-packages + include base objects for concepts like work queues and pools of volatile objects. Basically + a one-stop-shopping repo for anything not specifically attached to one type of functionality. + Nearly every other CommonJava project depends upon Util. And it needs work. + </p> + </description> + <dependencies> <dependency> <groupId>commonjava</groupId> |
From: <joh...@co...> - 2004-02-16 06:45:19
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-bot In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27992 Modified Files: project.xml Log Message: simply changed the project name to Binary Object Transfer. Index: project.xml =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-bot/project.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- project.xml 18 Sep 2003 00:28:56 -0000 1.1 +++ project.xml 16 Feb 2004 06:37:32 -0000 1.2 @@ -3,7 +3,7 @@ <project> <pomVersion>3</pomVersion> <id>commonjava-bot</id> - <name>CommonJava Binary Object Transfer Library</name> + <name>Binary Object Transfer</name> <groupId>commonjava</groupId> <currentVersion>2.0</currentVersion> <organization> |
From: <joh...@co...> - 2004-02-16 06:42:33
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-bgthreads/src/java/org/commonjava/bgthreads/config In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27538/src/java/org/commonjava/bgthreads/config Added Files: BGServiceMgrConfigParser.java BGServiceMgrConfig.java Log Message: added OPL configuration support, and renamed the project to simply be Background Threads. --- NEW FILE: BGServiceMgrConfigParser.java --- /* Created on Feb 16, 2004 */ package org.commonjava.bgthreads.config; import org.commonjava.config.snapin.SnapInContainer; import org.commonjava.opl.ElementInfo; import org.commonjava.opl.NodeParser; import org.commonjava.opl.OPLContext; import org.commonjava.opl.ParseException; import org.commonjava.util.Strings; /** Parser to instantiate a background service manager's configuration. * @author John Casey */ public class BGServiceMgrConfigParser extends NodeParser { private static final String WAIT_MILLIS = "waitMillis"; private static final String JOIN_MILLIS = "joinMillis"; private static final String MAX_RUNNING = "maxRunning"; private static final String MAX_PENDING = "maxPending"; private BGServiceMgrConfig config = new BGServiceMgrConfig(); /** Create a new background service manager configuration parser * @param context the parse context * @param parent the parent parser */ public BGServiceMgrConfigParser(OPLContext context, NodeParser parent) { super(context, parent); } /** Create a new background service manager configuration parser * @param context the parse context */ public BGServiceMgrConfigParser(OPLContext context) { super(context); } /** Extract wait and join millis, along with max running and pending, and set each if it is not * null on the embedded configuration object. Then, retrieve the ancestor SnapInContainer impl, * and add the embedded configuration object as a new snap-in. * * @param element The element representation from which to extract attribute values. * @param bodyText the text of this element's body. * @see org.commonjava.opl.NodeParser#doAfterChildren(org.commonjava.opl.ElementInfo, java.lang.String) */ protected void doAfterChildren(ElementInfo element, String bodyText) throws ParseException { Long wait = Strings.toLong(getAttribute(WAIT_MILLIS, element, true)); if(wait != null){config.setWaitMillis(wait.longValue());} Long join = Strings.toLong(getAttribute(JOIN_MILLIS, element, true)); if(join != null){config.setJoinMillis(join.longValue());} Integer run = Strings.toInteger(getAttribute(MAX_RUNNING, element, true)); if(run != null){config.setMaxRunning(run.intValue());} Integer pend = Strings.toInteger(getAttribute(MAX_PENDING, element, true)); if(pend != null){config.setMaxPending(pend.intValue());} SnapInContainer container = (SnapInContainer)findAncestorOfType(SnapInContainer.class); container.addSnapIn(config); } } --- NEW FILE: BGServiceMgrConfig.java --- /* Created on Feb 16, 2004 */ package org.commonjava.bgthreads.config; import org.commonjava.config.snapin.ConfigSnapIn; /** Configuration class for the background service manager. * @author John Casey */ public class BGServiceMgrConfig implements ConfigSnapIn { public static final String SNAP_IN_ID = BGServiceMgrConfig.class.getName(); public static final long DEFAULT_WAIT_MILLIS = 100; public static final long DEFAULT_JOIN_MILLIS = 1000; public static final int DEFAULT_MAX_PENDING = 10; public static final int DEFAULT_MAX_RUNNING = 5; private long waitMillis = DEFAULT_WAIT_MILLIS; private long joinMillis = DEFAULT_JOIN_MILLIS; private int maxPending = DEFAULT_MAX_PENDING; private int maxRunning = DEFAULT_MAX_RUNNING; /** Create a new configuration object. */ public BGServiceMgrConfig() { } /** Retrieve the snap-in unique id for this configuration class. */ public String getSnapInId() { return SNAP_IN_ID; } /** Return the duration in millis to wait for a join to complete */ public long getJoinMillis() { return joinMillis; } /** Return the maximum of pending threads in the thread throttle controlled by the * background service manager. */ public int getMaxPending() { return maxPending; } /** Return the maximum of pending threads in the thread throttle controlled by the * background service manager. */ public int getMaxRunning() { return maxRunning; } /** Return the duration in millis to wait for a thread to free up in the thread throttle */ public long getWaitMillis() { return waitMillis; } /** Set the duration in millis to wait for a join to complete */ public void setJoinMillis(long l) { joinMillis = l; } /** Set the maximum of pending threads in the thread throttle controlled by the * background service manager. */ public void setMaxPending(int i) { maxPending = i; } /** Set the maximum of pending threads in the thread throttle controlled by the * background service manager. */ public void setMaxRunning(int i) { maxRunning = i; } /** Return the duration in millis to wait for a thread to free up in the thread throttle */ public void setWaitMillis(long l) { waitMillis = l; } } |
From: <joh...@co...> - 2004-02-16 06:42:33
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-bgthreads In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27538 Modified Files: project.xml .project .classpath Log Message: added OPL configuration support, and renamed the project to simply be Background Threads. Index: project.xml =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-bgthreads/project.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- project.xml 18 Sep 2003 00:23:20 -0000 1.1 +++ project.xml 16 Feb 2004 06:34:45 -0000 1.2 @@ -3,7 +3,7 @@ <project> <pomVersion>3</pomVersion> <id>commonjava-bgthreads</id> - <name>CommonJava Backgrounded Threads Library</name> + <name>Background Threads</name> <groupId>commonjava</groupId> <currentVersion>2.0</currentVersion> <organization> @@ -17,25 +17,46 @@ <dependency> <groupId>commonjava</groupId> <artifactId>commonjava-lang</artifactId> - <version>2.0</version> + <version>2.0-1</version> <url>http://www.sf.net/projects/commonjava</url> </dependency> <dependency> <groupId>commonjava</groupId> <artifactId>commonjava-config</artifactId> + <version>2.1-1</version> + <url>http://www.sf.net/projects/commonjava</url> + </dependency> + + <dependency> + <groupId>commonjava</groupId> + <artifactId>commonjava-opl</artifactId> + <version>2.1-5</version> + <url>http://www.sf.net/projects/commonjava</url> + </dependency> + + <dependency> + <groupId>commonjava</groupId> + <artifactId>commonjava-io</artifactId> <version>2.0</version> <url>http://www.sf.net/projects/commonjava</url> </dependency> <dependency> <groupId>commonjava</groupId> - <artifactId>commonjava-util</artifactId> + <artifactId>commonjava-reflection</artifactId> <version>2.0</version> <url>http://www.sf.net/projects/commonjava</url> </dependency> <dependency> + <groupId>commonjava</groupId> + <artifactId>commonjava-util</artifactId> + <version>2.0-3</version> + <url>http://www.sf.net/projects/commonjava</url> + </dependency> + + <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> <version>1.0.2</version> Index: .project =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-bgthreads/.project,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- .project 18 Sep 2003 00:23:20 -0000 1.1 +++ .project 16 Feb 2004 06:34:45 -0000 1.2 @@ -1,19 +1,24 @@ <?xml version="1.0" encoding="UTF-8"?> - <projectDescription> - <name>commonjava-bgthreads</name> - <comment> + <name>commonjava-bgthreads</name> + <comment> </comment> - <projects> - </projects> - <buildSpec> - <buildCommand> - <name>org.eclipse.jdt.core.javabuilder</name> - <arguments> - </arguments> - </buildCommand> - </buildSpec> - <natures> - <nature>org.eclipse.jdt.core.javanature</nature> - </natures> -</projectDescription> \ No newline at end of file + <projects> + <project>commonjava-config</project> + <project>commonjava-io</project> + <project>commonjava-lang</project> + <project>commonjava-opl</project> + <project>commonjava-reflection</project> + <project>commonjava-util</project> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> Index: .classpath =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-bgthreads/.classpath,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- .classpath 15 Dec 2003 01:51:17 -0000 1.3 +++ .classpath 16 Feb 2004 06:34:45 -0000 1.4 @@ -1,18 +1,13 @@ <?xml version="1.0" encoding="UTF-8"?> - <classpath> - <classpathentry kind="src" path="src/java"> - </classpathentry> - <classpathentry kind="var" rootpath="JRE_SRCROOT" path="JRE_LIB" sourcepath="JRE_SRC"> - </classpathentry> - <classpathentry kind="var" path="MAVEN_REPO/commonjava/jars/commonjava-lang-2.0.jar"> - </classpathentry> - <classpathentry kind="var" path="MAVEN_REPO/commonjava/jars/commonjava-config-2.0.jar"> - </classpathentry> - <classpathentry kind="var" path="MAVEN_REPO/commonjava/jars/commonjava-util-2.0.jar"> - </classpathentry> - <classpathentry kind="var" path="MAVEN_REPO/commons-logging/jars/commons-logging-1.0.2.jar"> - </classpathentry> - <classpathentry kind="output" path="target/classes"> - </classpathentry> -</classpath> \ No newline at end of file + <classpathentry kind="src" path="src/java"/> + <classpathentry kind="var" path="JRE_LIB" sourcepath="JRE_SRC"/> + <classpathentry kind="var" path="MAVEN_REPO/commons-logging/jars/commons-logging-1.0.2.jar"/> + <classpathentry kind="src" path="/commonjava-config"/> + <classpathentry kind="src" path="/commonjava-io"/> + <classpathentry kind="src" path="/commonjava-lang"/> + <classpathentry kind="src" path="/commonjava-opl"/> + <classpathentry kind="src" path="/commonjava-util"/> + <classpathentry kind="src" path="/commonjava-reflection"/> + <classpathentry kind="output" path="target/classes"/> +</classpath> |
From: <joh...@co...> - 2004-02-16 06:42:33
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-bgthreads/src/java/org/commonjava/bgthreads In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27538/src/java/org/commonjava/bgthreads Modified Files: BackgroundServiceManager.java Log Message: added OPL configuration support, and renamed the project to simply be Background Threads. Index: BackgroundServiceManager.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-bgthreads/src/java/org/commonjava/bgthreads/BackgroundServiceManager.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- BackgroundServiceManager.java 18 Sep 2003 00:23:20 -0000 1.1 +++ BackgroundServiceManager.java 16 Feb 2004 06:34:46 -0000 1.2 @@ -12,18 +12,16 @@ import org.commonjava.util.PriorityQueue; import org.commonjava.util.Queue; import org.commonjava.util.ThreadThrottle; -import org.commonjava.config.Configuration; -import org.commonjava.config.ConfigurationEvent; -import org.commonjava.config.ConfigurationListener; -import org.commonjava.config.ConfigurationManager; -import org.commonjava.config.ConfigurationManagerException; +import org.commonjava.bgthreads.config.BGServiceMgrConfig; +import org.commonjava.config.snapin.SnapInContainerLoader; +import org.commonjava.config.snapin.SnapInLoaderException; /** Manager class for all services to be run in a background thread. This class is * intended to provide thread throttling en masse to all backgrounded threads. * * @author John Casey */ -public class BackgroundServiceManager implements ConfigurationListener{ +public class BackgroundServiceManager{ private static final Log LOG = LogFactory.getLog(BackgroundServiceManager.class); @@ -37,7 +35,6 @@ Queue.OptimizedAction.PUSH ); - private Configuration config; private long threadWaitMillis; private long threadJoinMillis; @@ -45,12 +42,21 @@ /** Deny instantiation of BackgroundServiceManager */ private BackgroundServiceManager() { - ConfigurationManager.getInstance().addConfigurationListener( - BackgroundServiceConstants.CONFIG_FILE, - this + BGServiceMgrConfig config = loadConfig(); + this.throttle = new ThreadThrottle( + config.getMaxPending(), + config.getMaxRunning(), + config.getWaitMillis() ); - doInit(); + this.servicer = new BackgroundServiceManager.Servicer( + serviceQueue, throttle, config.getWaitMillis() + ); + + this.servicerThread = throttle.getThread(servicer); + this.servicerThread.setPriority(Thread.currentThread().getPriority()-1); + this.servicerThread.setDaemon(true); + this.servicerThread.start(); } /** Return the singleton instance of the manager. @@ -84,68 +90,23 @@ servicer.doResume(); } - /** Initialize the manager. - */ - private synchronized void doInit(){ + private BGServiceMgrConfig loadConfig(){ + BGServiceMgrConfig config = null; try{ - config = ConfigurationManager.getInstance().getConfiguration( - BackgroundServiceConstants.CONFIG_FILE + config = (BGServiceMgrConfig)SnapInContainerLoader.getSnapInContainer().getSnapIn( + BGServiceMgrConfig.SNAP_IN_ID ); - } - catch(ConfigurationManagerException ex){ - if(LOG.isInfoEnabled()){ - LOG.info(BackgroundServiceConstants.CONFIG_FILE + " cannot be loaded. Initializing with defaults."); + } catch (SnapInLoaderException e) { + if (LOG.isInfoEnabled()) { + LOG.info( + "Error loading background services configuration from snap-in container. Using defaults.", + e + ); + config = new BGServiceMgrConfig(); } } - if(config == null){config = new Configuration();} - - if(throttle == null){ - int pending = config.getIntegerProperty( - BackgroundServiceConstants.MAX_PENDING_THREADS, - BackgroundServiceConstants.DEFAULT_MAX_PENDING_THREADS - ); - - int running = config.getIntegerProperty( - BackgroundServiceConstants.MAX_RUNNING_THREADS, - BackgroundServiceConstants.DEFAULT_MAX_RUNNING_THREADS - ) + 1; - - int priority = config.getIntegerProperty( - BackgroundServiceConstants.THREAD_PRIORITY, - Thread.currentThread().getPriority()-1 - ); - - throttle = new ThreadThrottle(pending, running, priority); - - this.threadWaitMillis = config.getLongProperty( - BackgroundServiceConstants.THREAD_WAIT_MILLIS, - BackgroundServiceConstants.DEFAULT_THREAD_WAIT_MILLIS - ); - - this.threadJoinMillis = config.getLongProperty( - BackgroundServiceConstants.THREAD_JOIN_MILLIS, - BackgroundServiceConstants.DEFAULT_THREAD_JOIN_MILLIS - ); - - this.servicer = new BackgroundServiceManager.Servicer( - serviceQueue, throttle, threadWaitMillis - ); - - this.servicerThread = throttle.getThread(servicer); - this.servicerThread.setPriority(priority); - this.servicerThread.setDaemon(true); - this.servicerThread.start(); - } - } - - /** Signals that a configuration file that this listener is bount to - * has changed. - * @param evt The ConfigurationEvent triggering this callback. - * - */ - public void configurationChanged(ConfigurationEvent evt) { - doInit(); + return config; } /** Runnable that handles the execution of background services. |
From: <joh...@co...> - 2004-02-16 06:42:32
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-bgthreads/src/java/META-INF/parsers In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27538/src/java/META-INF/parsers Added Files: bgthreads.opl Log Message: added OPL configuration support, and renamed the project to simply be Background Threads. --- NEW FILE: bgthreads.opl --- <?xml version="1.0" encoding="UTF-8"?> <parser-library xmlns="dynalib" ignore-unrecognized="false"> <parser node="config" class="org.commonjava.bgthreads.config.BGServiceMgrConfigParser"/> </parser-library> |
From: <joh...@co...> - 2004-02-16 06:42:20
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-bgthreads/src/java/META-INF In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27487/src/java/META-INF Log Message: Directory /cvsroot/commonjava/commonjava-projects/commonjava-bgthreads/src/java/META-INF added to the repository |
From: <joh...@co...> - 2004-02-16 06:42:20
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-bgthreads/src/java/META-INF/parsers In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27487/src/java/META-INF/parsers Log Message: Directory /cvsroot/commonjava/commonjava-projects/commonjava-bgthreads/src/java/META-INF/parsers added to the repository |
From: <joh...@co...> - 2004-02-16 06:42:20
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-bgthreads/src/java/org/commonjava/bgthreads/config In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27487/src/java/org/commonjava/bgthreads/config Log Message: Directory /cvsroot/commonjava/commonjava-projects/commonjava-bgthreads/src/java/org/commonjava/bgthreads/config added to the repository |
From: <joh...@co...> - 2004-02-06 18:52:09
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-lang/src/java/org/commonjava/lang In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12559/src/java/org/commonjava/lang Modified Files: AbstractID.java Log Message: made AbstractID comparable. Index: AbstractID.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-lang/src/java/org/commonjava/lang/AbstractID.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- AbstractID.java 2 Feb 2004 02:20:35 -0000 1.2 +++ AbstractID.java 6 Feb 2004 18:49:24 -0000 1.3 @@ -22,7 +22,7 @@ * @author James Lewis * @version 1.0 */ -public abstract class AbstractID implements Serializable, Cloneable +public abstract class AbstractID implements Comparable, Serializable, Cloneable { /** |
From: <joh...@co...> - 2004-02-02 15:30:56
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-dirdigester/src/java/org/commonjava/dirdigester In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20013/src/java/org/commonjava/dirdigester Modified Files: DirectoryDigester.java Log Message: added junit config for maven, and added the compareAndWriteDirectoryDigest() method to allow for incremental calculation and recording... Index: DirectoryDigester.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-dirdigester/src/java/org/commonjava/dirdigester/DirectoryDigester.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- DirectoryDigester.java 2 Feb 2004 15:09:50 -0000 1.3 +++ DirectoryDigester.java 2 Feb 2004 15:28:52 -0000 1.4 @@ -12,7 +12,6 @@ import java.io.ObjectOutputStream; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; -import java.util.ArrayList; import java.util.HashMap; import java.util.Map; @@ -50,15 +49,21 @@ private DirectoryDigest _writeDirectoryDigest(DirDigestOptions info) throws DirectoryDigestException { + DirectoryDigest digest = _generateDigests(info); + doDigestWrite(digest); + + return digest; + } + + private void doDigestWrite(DirectoryDigest digest) throws DirectoryDigestException{ try { - DirectoryDigest digest = _generateDigests(info); - BufferedOutputStream bufferOut = new BufferedOutputStream(new FileOutputStream(info.getFile())); + BufferedOutputStream bufferOut = new BufferedOutputStream( + new FileOutputStream(digest.getOptions().getFile()) + ); ObjectOutputStream out = new ObjectOutputStream(bufferOut); out.writeObject(digest); out.flush(); out.close(); - - return digest; } catch (FileNotFoundException e){ throw new DirectoryDigestException("Error opening digest info file for writing.", e); @@ -77,14 +82,23 @@ public String[] compareDirectoryWithDigest(DirDigestOptions info) throws DirectoryDigestException { - ArrayList deltas = new ArrayList(); - DirectoryDigest stored = _readDirectoryDigest(info); DirectoryDigest generated = _generateDigests(info); return generated.compareWithoutOptions(stored); } + public String[] compareAndWriteDirectoryDigest(DirDigestOptions info) + throws DirectoryDigestException + { + DirectoryDigest stored = _readDirectoryDigest(info); + DirectoryDigest generated = _generateDigests(info); + + String[] results = generated.compareWithoutOptions(stored); + doDigestWrite(generated); + return results; + } + private DirectoryDigest _readDirectoryDigest(DirDigestOptions info) throws DirectoryDigestException { |
From: <joh...@co...> - 2004-02-02 15:30:56
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-dirdigester In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20013 Added Files: project.properties Log Message: added junit config for maven, and added the compareAndWriteDirectoryDigest() method to allow for incremental calculation and recording... --- NEW FILE: project.properties --- maven.junit.fork=true maven.junit.usefile=${basedir}/junit.log |
From: <joh...@co...> - 2004-02-02 15:11:54
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-dirdigester/src/java/org/commonjava/dirdigester In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2155/src/java/org/commonjava/dirdigester Modified Files: DirectoryDigester.java Log Message: Added writeAndReturnDirectoryDigest() method, to allow immediate manipulation of the generated digest. Index: DirectoryDigester.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-dirdigester/src/java/org/commonjava/dirdigester/DirectoryDigester.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- DirectoryDigester.java 2 Feb 2004 07:03:53 -0000 1.2 +++ DirectoryDigester.java 2 Feb 2004 15:09:50 -0000 1.3 @@ -35,9 +35,21 @@ return INSTANCE; } + public DirectoryDigest writeAndReturnDirectoryDigest(DirDigestOptions info) + throws DirectoryDigestException + { + return _writeDirectoryDigest(info); + } + public void writeDirectoryDigest(DirDigestOptions info) throws DirectoryDigestException { + _writeDirectoryDigest(info); + } + + private DirectoryDigest _writeDirectoryDigest(DirDigestOptions info) + throws DirectoryDigestException + { try { DirectoryDigest digest = _generateDigests(info); BufferedOutputStream bufferOut = new BufferedOutputStream(new FileOutputStream(info.getFile())); @@ -45,6 +57,8 @@ out.writeObject(digest); out.flush(); out.close(); + + return digest; } catch (FileNotFoundException e){ throw new DirectoryDigestException("Error opening digest info file for writing.", e); |
Update of /cvsroot/commonjava/commonjava-projects/commonjava-util/src/java/org/commonjava/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19603/src/java/org/commonjava/util Modified Files: OrLogicFilenameFilter.java AndLogicFilenameFilter.java CompoundFilenameFilter.java RegexFilenameFilter.java Log Message: made all FilenameFilter implementations Serializable. Index: OrLogicFilenameFilter.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-util/src/java/org/commonjava/util/OrLogicFilenameFilter.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- OrLogicFilenameFilter.java 5 Jan 2004 14:50:17 -0000 1.3 +++ OrLogicFilenameFilter.java 2 Feb 2004 07:04:28 -0000 1.4 @@ -3,12 +3,13 @@ import java.io.File; import java.io.FilenameFilter; +import java.io.Serializable; import java.util.Iterator; /** * @author jdcasey */ -public class OrLogicFilenameFilter extends CompoundFilenameFilter +public class OrLogicFilenameFilter extends CompoundFilenameFilter implements Serializable { /** Index: AndLogicFilenameFilter.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-util/src/java/org/commonjava/util/AndLogicFilenameFilter.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- AndLogicFilenameFilter.java 5 Jan 2004 14:50:17 -0000 1.3 +++ AndLogicFilenameFilter.java 2 Feb 2004 07:04:28 -0000 1.4 @@ -3,12 +3,13 @@ import java.io.File; import java.io.FilenameFilter; +import java.io.Serializable; import java.util.Iterator; /** * @author jdcasey */ -public class AndLogicFilenameFilter extends CompoundFilenameFilter +public class AndLogicFilenameFilter extends CompoundFilenameFilter implements Serializable { /** Index: CompoundFilenameFilter.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-util/src/java/org/commonjava/util/CompoundFilenameFilter.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- CompoundFilenameFilter.java 5 Jan 2004 04:53:34 -0000 1.2 +++ CompoundFilenameFilter.java 2 Feb 2004 07:04:28 -0000 1.3 @@ -2,6 +2,10 @@ package org.commonjava.util; import java.io.FilenameFilter; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; import java.util.HashSet; import java.util.Iterator; import java.util.Set; @@ -9,7 +13,7 @@ /** * @author jdcasey */ -public abstract class CompoundFilenameFilter implements FilenameFilter +public abstract class CompoundFilenameFilter implements FilenameFilter, Serializable { private Set filters = new HashSet(); @@ -32,5 +36,13 @@ protected boolean hasSubFilters() { return filters.size() > 0; } + + protected void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException{ + this.filters = (Set)in.readObject(); + } + + protected void writeObject(ObjectOutputStream out) throws IOException{ + out.writeObject(filters); + } } Index: RegexFilenameFilter.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-util/src/java/org/commonjava/util/RegexFilenameFilter.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- RegexFilenameFilter.java 5 Jan 2004 04:53:34 -0000 1.3 +++ RegexFilenameFilter.java 2 Feb 2004 07:04:28 -0000 1.4 @@ -8,6 +8,10 @@ import java.io.File; import java.io.FilenameFilter; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; /** * FilenameFilter that compares a file's name (and optionally dir + file name) @@ -15,7 +19,7 @@ * * @author John Casey */ -public class RegexFilenameFilter implements FilenameFilter { +public class RegexFilenameFilter implements FilenameFilter, Serializable { private String pattern; private boolean includeDirInCheck; @@ -72,4 +76,16 @@ return result; } + protected void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException{ + this.pattern = (String)in.readObject(); + this.includeDirInCheck = in.readBoolean(); + this.negated = in.readBoolean(); + } + + protected void writeObject(ObjectOutputStream out) throws IOException{ + out.writeObject(pattern); + out.writeBoolean(includeDirInCheck); + out.writeBoolean(negated); + } + } |
From: <joh...@co...> - 2004-02-02 07:05:56
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-dirdigester In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19044 Modified Files: .project .classpath project.xml Log Message: modified options class to accept a filename filter directly, and made the digester check for this before creating one from the fileMask. Index: .project =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-dirdigester/.project,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- .project 31 Dec 2003 23:58:05 -0000 1.1.1.1 +++ .project 2 Feb 2004 07:03:52 -0000 1.2 @@ -1,17 +1,19 @@ <?xml version="1.0" encoding="UTF-8"?> + <projectDescription> - <name>commonjava-dirdigester</name> - <comment></comment> - <projects> - </projects> - <buildSpec> - <buildCommand> - <name>org.eclipse.jdt.core.javabuilder</name> - <arguments> - </arguments> - </buildCommand> - </buildSpec> - <natures> - <nature>org.eclipse.jdt.core.javanature</nature> - </natures> -</projectDescription> + <name>commonjava-dirdigester</name> + <comment> + </comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> \ No newline at end of file Index: .classpath =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-dirdigester/.classpath,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- .classpath 31 Dec 2003 23:58:05 -0000 1.1.1.1 +++ .classpath 2 Feb 2004 07:03:52 -0000 1.2 @@ -1,13 +1,18 @@ <?xml version="1.0" encoding="UTF-8"?> + <classpath> - <classpathentry kind="src" path="src/java"/> - <classpathentry kind="src" path="src/test"/> - <classpathentry kind="src" path="jelly-tags/src/java"/> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> - <classpathentry sourcepath="ECLIPSE_HOME/workspace/commonjava-lang/src/java" kind="var" path="MAVEN_REPO/commonjava/jars/commonjava-lang-2.0.jar"/> - <classpathentry sourcepath="ECLIPSE_HOME/workspace/commonjava-util/src" kind="var" path="MAVEN_REPO/commonjava/jars/commonjava-util-2.0.jar"/> - <classpathentry kind="var" path="MAVEN_REPO/junit/jars/junit-3.8.1.jar"/> - <classpathentry kind="var" path="MAVEN_HOME/lib/commons-jelly-20030902.160215.jar"/> - <classpathentry kind="var" path="MAVEN_REPO/commons-logging/jars/commons-logging-1.0.3.jar"/> - <classpathentry kind="output" path="target/classes"/> -</classpath> + <classpathentry kind="src" path="src/java"> + </classpathentry> + <classpathentry output="target/test-classes" kind="src" path="src/test"> + </classpathentry> + <classpathentry kind="var" path="MAVEN_REPO/junit/jars/junit-3.8.1.jar"> + </classpathentry> + <classpathentry kind="var" rootpath="JRE_SRCROOT" path="JRE_LIB" sourcepath="JRE_SRC"> + </classpathentry> + <classpathentry kind="var" path="MAVEN_REPO/commonjava/jars/commonjava-lang-2.0-1.jar"> + </classpathentry> + <classpathentry kind="var" path="MAVEN_REPO/commonjava/jars/commonjava-util-2.0-3.jar"> + </classpathentry> + <classpathentry kind="output" path="target/classes"> + </classpathentry> +</classpath> \ No newline at end of file Index: project.xml =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-dirdigester/project.xml,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- project.xml 31 Dec 2003 23:58:05 -0000 1.1.1.1 +++ project.xml 2 Feb 2004 07:03:52 -0000 1.2 @@ -5,7 +5,7 @@ <id>commonjava-dirdigester</id> <name>CommonJava Directory Fingerprint Generator</name> <groupId>commonjava</groupId> - <currentVersion>2.0</currentVersion> + <currentVersion>2.0-1</currentVersion> <organization> <name>CommonJava Open Component Project</name> <url>http://www.commonjava.org</url> @@ -17,13 +17,13 @@ <dependency> <groupId>commonjava</groupId> <artifactId>commonjava-lang</artifactId> - <version>2.0</version> + <version>2.0-1</version> </dependency> <dependency> <groupId>commonjava</groupId> <artifactId>commonjava-util</artifactId> - <version>2.0</version> + <version>2.0-3</version> </dependency> <dependency> |
From: <joh...@co...> - 2004-02-02 07:05:56
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-dirdigester/src/java/org/commonjava/dirdigester In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19044/src/java/org/commonjava/dirdigester Modified Files: DirectoryDigester.java DirDigestOptions.java Log Message: modified options class to accept a filename filter directly, and made the digester check for this before creating one from the fileMask. Index: DirectoryDigester.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-dirdigester/src/java/org/commonjava/dirdigester/DirectoryDigester.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- DirectoryDigester.java 17 Jan 2004 04:13:35 -0000 1.1.1.1 +++ DirectoryDigester.java 2 Feb 2004 07:03:53 -0000 1.2 @@ -101,10 +101,12 @@ private DirectoryDigest _generateDigests(DirDigestOptions info) throws DirectoryDigestException { try { - String mask = info.getFileMask(); - FilenameFilter filter = null; - if(mask != null) { - filter = new RegexFilenameFilter(mask, info.maskAbsolutePath()); + FilenameFilter filter = info.getFilenameFilter(); + if(filter == null){ + String mask = info.getFileMask(); + if(mask != null) { + filter = new RegexFilenameFilter(mask, info.maskAbsolutePath()); + } } String[] filenames = null; Index: DirDigestOptions.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-dirdigester/src/java/org/commonjava/dirdigester/DirDigestOptions.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- DirDigestOptions.java 31 Dec 2003 01:19:57 -0000 1.1.1.1 +++ DirDigestOptions.java 2 Feb 2004 07:03:53 -0000 1.2 @@ -1,6 +1,7 @@ /* Created on Dec 30, 2003 */ package org.commonjava.dirdigester; +import java.io.FilenameFilter; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; @@ -14,6 +15,7 @@ private String file; private String directory; private String fileMask; + private FilenameFilter filenameFilter; private boolean maskAbsolutePath = true; private boolean recurse = true; private boolean trimBaseDir = false; @@ -136,6 +138,7 @@ this.file = (String)in.readObject(); this.directory = (String)in.readObject(); this.fileMask = (String)in.readObject(); + this.filenameFilter = (FilenameFilter)in.readObject(); this.maskAbsolutePath = in.readBoolean(); this.recurse = in.readBoolean(); this.trimBaseDir = in.readBoolean(); @@ -145,9 +148,30 @@ out.writeObject(file); out.writeObject(directory); out.writeObject(fileMask); + out.writeObject(filenameFilter); out.writeBoolean(maskAbsolutePath); out.writeBoolean(recurse); out.writeBoolean(trimBaseDir); } + /** + * @return + */ + public FilenameFilter getFilenameFilter() { + return filenameFilter; + } + + /** + * @param filter + */ + public void setFilenameFilter(FilenameFilter filter) { + if(!(filter instanceof Serializable)){ + throw new IllegalArgumentException( + "Cannot use non-serializable FilenameFilter in DirDigestOptions, " + "since options must persist with directory signature." + ); + } + + filenameFilter = filter; + } + } |