Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Initial commit

* bringing 0.6.6 over from https://aspirin.dev.java.net/
	with some changes to threading. See RELEASE_NOTES.mkdn
	for details.
  • Loading branch information...
commit fe79808833b7b801c93d6ca727f7f748c4bd5c11 0 parents
Kate Rhodes authored
Showing with 7,980 additions and 0 deletions.
  1. +12 −0 .classpath
  2. +4 −0 .gitignore
  3. +17 −0 .project
  4. +3 −0  META-INF/MANIFEST.MF
  5. +70 −0 README.mkdn
  6. +15 −0 RELEASE_NOTES.mkdn
  7. +9 −0 build/build.properties
  8. +92 −0 build/build.xml
  9. BIN  lib/activation.jar
  10. BIN  lib/commons-logging-1.0.3.jar
  11. BIN  lib/dnsjava-1.6.4.jar
  12. BIN  lib/junit3.8.1.jar
  13. BIN  lib/mail_1_3.jar
  14. +33 −0 licenses/ASPIRIN-LICENSE-NOTES.txt
  15. +246 −0 licenses/Activation_Framework-license.txt
  16. +59 −0 licenses/Aspirin-and-James-license.txt
  17. +22 −0 licenses/JDom-license.txt
  18. +88 −0 licenses/JUnit-license.txt
  19. +170 −0 licenses/JavaMail-license.txt
  20. +18 −0 licenses/omt-logging-license.txt
  21. +15 −0 prefs/system/org/masukomi/aspirin/core/Configuration.xml
  22. +45 −0 prefs/system/org/masukomi/tools/logging/Logs.xml
  23. +75 −0 src/org/apache/commons/threadpool/CommonsLoggingThreadPoolMonitor.java
  24. +164 −0 src/org/apache/commons/threadpool/DefaultThreadPool.java
  25. +160 −0 src/org/apache/commons/threadpool/MTQueue.java
  26. +69 −0 src/org/apache/commons/threadpool/NullThreadPoolMonitor.java
  27. +81 −0 src/org/apache/commons/threadpool/ThreadPool.java
  28. +75 −0 src/org/apache/commons/threadpool/ThreadPoolMonitor.java
  29. +148 −0 src/org/apache/james/core/MailHeaders.java
  30. +659 −0 src/org/apache/james/core/MailImpl.java
  31. +198 −0 src/org/apache/james/core/MimeMessageInputStreamSource.java
  32. +128 −0 src/org/apache/james/core/MimeMessageSource.java
  33. +1,092 −0 src/org/apache/james/core/MimeMessageWrapper.java
  34. +118 −0 src/org/apache/james/util/Base64.java
  35. +243 −0 src/org/apache/james/util/InternetPrintWriter.java
  36. +219 −0 src/org/apache/james/util/RFC2822Headers.java
  37. +214 −0 src/org/apache/james/util/RFC822Date.java
  38. +102 −0 src/org/apache/james/util/RFC822DateFormat.java
  39. +125 −0 src/org/apache/james/util/SimplifiedDateFormat.java
  40. +205 −0 src/org/apache/james/util/SynchronizedDateFormat.java
  41. +153 −0 src/org/apache/mailet/Mail.java
  42. +442 −0 src/org/apache/mailet/MailAddress.java
  43. 0  src/org/apache/mailet/test.txt
  44. +121 −0 src/org/masukomi/aspirin/core/Bouncer.java
  45. +152 −0 src/org/masukomi/aspirin/core/Configuration.java
  46. +127 −0 src/org/masukomi/aspirin/core/MXLookup.java
  47. +233 −0 src/org/masukomi/aspirin/core/MailQue.java
  48. +37 −0 src/org/masukomi/aspirin/core/MailWatcher.java
  49. +156 −0 src/org/masukomi/aspirin/core/QueManager.java
  50. +268 −0 src/org/masukomi/aspirin/core/QuedItem.java
  51. +554 −0 src/org/masukomi/aspirin/core/RemoteDelivery.java
  52. +105 −0 src/org/masukomi/aspirin/core/SimpleMailWatcherImpl.java
  53. +27 −0 src/org/masukomi/aspirin/core/SimpleMimeMessageGenerator.java
  54. +95 −0 src/org/masukomi/aspirin/core/TrackableThreadPool.java
  55. +41 −0 test/org/masukomi/aspirin/core/DNSJavaTest.java
  56. +71 −0 test/org/masukomi/aspirin/core/MS.java
  57. +262 −0 test/org/masukomi/aspirin/core/MailQueTest.java
  58. +42 −0 test/org/masukomi/aspirin/core/TestMailWatcher.java
  59. +61 −0 test/org/masukomi/aspirin/core/TrackableThreadPoolTest.java
  60. +40 −0 www/configuration.html
  61. BIN  www/pill.gif
12 .classpath
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="test"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="lib" path="lib/mail_1_3.jar"/>
+ <classpathentry kind="lib" path="lib/commons-logging-1.0.3.jar"/>
+ <classpathentry kind="lib" path="lib/junit3.8.1.jar"/>
+ <classpathentry kind="lib" path="lib/dnsjava-1.6.4.jar"/>
+ <classpathentry kind="lib" path="lib/activation.jar"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
4 .gitignore
@@ -0,0 +1,4 @@
+bin
+*.class
+*.swp
+*~
17 .project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>aspirin</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>
3  META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Created-By: Kate Rhodes masukomi@masukomi.org
+Class-Path: ./lib/mail_1_3.jar ./lib/activation.jar ./lib/j2ee.jar ./lib/junit3.8.1.jar ./lib/commons-logging-1.0.3.jar ./lib/dnsjava-1.6.4.jar
70 README.mkdn
@@ -0,0 +1,70 @@
+# Aspirin, because sending mail shouldn't be a headache. #
+
+## What is it? ##
+
+Aspirin is an embeddable send-only SMTP server for Java developers.
+
+## Why would I want that? ##
+
+The JavaMail API doesn't really let you send mail. And that's just annoying. Developers shouldn't have to jump through hoops to send an e-mail and requiring your users to correctly configure the settings for their SMTP servers means you have to write configuration screens and hope that your end users know enough about mail systems to correctly configure a connection to their mail server. And then what happens when they try and use your app on a laptop, where the mail server settings keep changing. Talk about headaches.
+
+Aspirin is good for that kind of headache. Just add Aspirin to your app and you'll be able to send mail from any computer with a net connection regardless of their current mail server configuration.
+
+## Where do I get it? ##
+
+Aspirin can be found on GitHub at [http://github.com/masukomi/aspirin](http://github.com/masukomi/aspirin) Just check it out and run ant to build it. Please read the [RELEASE_NOTES](RELEASE_NOTES.mkdn) before using.
+
+## How do I use it? ##
+
+Using Asprin is pretty simple. All you have to do is generate a standard javax.mail.internet.MimeMessage and then add it to an instance of MailQue via
+
+ myMailQue.queMail(MimeMessage message)
+
+If you don't want to bother with manually creating the Session and Properties objects needed to generate a MimeMessage just call
+
+ SimpleMimeMessageGenerator.getNewMimeMessage()
+
+and it will return you a brand new MimeMessage object ready to be filled with your e-mail.
+
+That's it. Your Mail will be sent.
+
+Want to know if it went through? That's slightly more work.
+
+First you implement
+ org.masukomi.aspirin.core.MailWatcher
+(see SimpleMailWatcherImpl for an example).
+
+Then you call MailQue.addWatcher(MailWatcher watcher) and give it your watcher. Whenever a mail succeeds or fails it will call the appropriate method in MailWatcher. The MailAddress is the address of the recipient it succeded or failed with. Currently the deliverySuccess method is called once for each recipient.
+
+ public void deliverySuccess(MimeMessage message, MailAddress recipient);
+ public void deliveryFailure(MimeMessage message, MailAddress recipient);
+
+For more details on configuring Aspirin's default settings see the configuration page.
+
+## What License? ##
+
+Aspirin is distributed under the Apache 1.1 license because of its significant incorporation of classes from the Apache James project.
+
+## What are the requirements? ##
+
+Aspirin uses the Commons Logging package. This and other required jars can be found in the lib directory. Obviously, if you want mail to actually go through, you need a valid net connection.
+
+## Limitations ##
+
+In most cases mail sent from Aspirin will not be accepted by a server implementing SPF mail authorization. This would be the case with ANY smtp server deployed on a user's desktop or any other machine not specified in the DNS record from corresponding to the "from" addresses host name.
+
+Aspirin will not pass SPF authorization because SPF looks up the DNS record for an e-mail's "from" address's host. If the ip address of the computer you're sending from doesn't match any of the appropriate DNS records in that host it will think you're spoofing the from address which is frequently a sign of spam. Unfortunately this rejects a number of valid e-mails too. For more details and a better explanation visit the SPF site.
+
+### What does this mean to you? ###
+
+If you use aspirin (or any other embeded SMTP server) in an app that's on a user's desktop, with a typical dynamic ip address that most at home users have, their ISPs spam prevention methods will prevent the mail from going out. So, this'll ease your development when running on a server that would be able to send mail from anyway, but sadly not for desktop apps where it would be most helpful (unless you know for a fact that e-mail can be sent directly from an SMTP server on that box).
+
+## Any Notes? ##
+
+Aspirin uses commons logging.
+
+## Who wrote all this stuff? ##
+
+Aspirin is written and maintained by Kate Rhodes masukomi at masukomi dot org. Any code contributions or suggestions would be greatly appreciated.
+
+Aspirin builds upon the great work of Apache's James team. Aspirin takes some of James' core classes and combines them with a new queing system to make a small SMTP server.
15 RELEASE_NOTES.mkdn
@@ -0,0 +1,15 @@
+## Release notes
+
+### Current version (0.6.7b )
+WARNING CURRENTLY UNTESTED!
+This will be updated. I'm just importing what's currently available.
+
+Starting with the most recent code at https://aspirin.dev.java.net/
+this version:
+
+* disables the thread pooling (there was a problem with it not quitting without a System.exit()
+* makes MailQue instantiatable so that you can, if you want have multiple queues
+* makes QueManager end it's run as soon as there are no more items waiting to be sent.
+** adding a new item to the MailQue will restart the QueManager if needed.
+
+
9 build/build.properties
@@ -0,0 +1,9 @@
+classes=./classes
+src=../src
+test=../test
+doc=../doc
+prefs=../src/prefs
+lib=../lib
+debug=on
+runtime=./aspirin
+manifest=../META-INF/MANIFEST.MF
92 build/build.xml
@@ -0,0 +1,92 @@
+<project name="Aspirin" default="all" basedir=".">
+
+ <property file="build.properties"/>
+
+ <path id="classpath">
+ <pathelement location="${src}/"/>
+ <fileset dir="${lib}" includes="**/*.jar" />
+ </path>
+
+ <target name="pre-clean" >
+ <delete dir="${classes}" />
+ <delete dir="${runtime}" />
+ <delete dir="${src}" includes="**/*.class"/>
+ </target>
+
+ <target name="post-clean" >
+ <delete dir="${classes}" />
+ <delete dir="${src}" includes="**/*.class"/>
+ </target>
+
+ <target name="prepare" depends="pre-clean">
+ <mkdir dir="${classes}"/>
+ <mkdir dir="${runtime}"/>
+ </target>
+
+ <target name="compile" depends="prepare">
+ <javac srcdir="${src}" destdir="${classes}" deprecation="on" debug="${debug}">
+ <classpath refid="classpath"/>
+ </javac>
+ <javac srcdir="${test}" destdir="${classes}" deprecation="on" debug="${debug}">
+ <classpath refid="classpath"/>
+ </javac>
+ </target>
+
+ <target name="jar" depends="compile">
+ <jar jarfile="${runtime}/aspirin.jar" manifest="${manifest}">
+ <fileset dir="${classes}">
+ <include name="**/*"/>
+ <exclude name="**/*.java"/>
+ <!--<exclude name="**/*.properties"/>-->
+ <!--<exclude name="**/*.xml"/>-->
+
+ </fileset>
+ <fileset dir="${src}">
+ <include name="**/*.properties"/>
+ <include name="**/*.xml"/>
+ </fileset>
+ <!--<metainf dir="../config">
+ <include name="**/*"/>
+ </metainf> -->
+ </jar>
+ </target>
+
+ <target name="assemble" depends="jar">
+ <!-- no lib or docs to copy
+ <copy todir="${runtime}/lib">
+ <fileset dir="${lib}" includes="**/*"/>
+ </copy>
+
+ <copy todir="${runtime}">
+ <fileset dir="${doc}" includes="**/*"/>
+ </copy>
+ -->
+ <copy todir="${runtime}/lib">
+ <fileset dir="${lib}" includes="**/*"/>
+ </copy>
+ <copy todir="${runtime}/config">
+ <fileset dir="../config" includes="**/*"/>
+ </copy>
+ <!--<copy todir="${runtime}/prefs">
+ <fileset dir="${prefs}">
+ <include name="**/*"/>
+ <exclude name=".source.jam" />
+ </fileset>
+ </copy>-->
+ </target>
+
+ <target name="src">
+ <jar jarfile="${runtime}/aspirin-src.zip" manifest="${manifest}">
+ <fileset dir="${src}">
+ <include name="**/*.java"/>
+ <include name="**/*.properties"/>
+ <include name="**/*.xml"/>
+ <exclude name="**/*.class"/>
+ <exclude name=".source.jam" />
+ </fileset>
+ </jar>
+ </target>
+
+ <target name="all" depends="assemble,src,post-clean" />
+
+</project>
BIN  lib/activation.jar
Binary file not shown
BIN  lib/commons-logging-1.0.3.jar
Binary file not shown
BIN  lib/dnsjava-1.6.4.jar
Binary file not shown
BIN  lib/junit3.8.1.jar
Binary file not shown
BIN  lib/mail_1_3.jar
Binary file not shown
33 licenses/ASPIRIN-LICENSE-NOTES.txt
@@ -0,0 +1,33 @@
+Aspirin is composed of a handful of classes written by
+Kate Rhodes and two classes that build upon a good number of
+classes from the Apache James project. As a result Aspirin is
+also distributed under the Apache 1.1 license.
+
+The libraries included as jars are distributed under the
+corresponding licenses included here. For JDom's license see
+the JDom-license.txt file, for JavaMail see the
+JavaMail-license.txt, etc.
+
+* activation.jar (JavaBeans Activation Framework)
+ http://java.sun.com
+ Sun Microsystems, Inc. Binary Code License Agreement
+* dnsjava-1.2.3.jar
+ http://www.xbill.org/dnsjava/
+ BSD License
+* jdom.jar
+ http://www.jdom.org/
+ Apache Style License
+* junit-3.8.1.jar
+ http://www.junit.org
+ Common Public License v 1.0
+ http://www.opensource.org/licenses/cpl.php
+* mail_1_3.jar
+ http://java.sun.com
+ Sun binary code license with JavaMail addendum
+* omt-logging-1.0.10.jar
+ http://tools.masukomi.org
+ MIT License
+
+Source code should be available at the respective sites. If it isn't
+please contact Kate Rhodes ( masukomi at masukomi dot org )
+http://www.masukomi.org
246 licenses/Activation_Framework-license.txt
@@ -0,0 +1,246 @@
+Sun Microsystems, Inc.
+ Binary Code License Agreement
+
+ READ THE TERMS OF THIS AGREEMENT AND ANY PROVIDED
+ SUPPLEMENTAL LICENSE TERMS (COLLECTIVELY
+ "AGREEMENT") CAREFULLY BEFORE OPENING THE SOFTWARE
+ MEDIA PACKAGE. BY OPENING THE SOFTWARE MEDIA
+ PACKAGE, YOU AGREE TO THE TERMS OF THIS
+ AGREEMENT. IF YOU ARE ACCESSING THE SOFTWARE
+ ELECTRONICALLY, INDICATE YOUR ACCEPTANCE OF THESE
+ TERMS BY SELECTING THE "ACCEPT" BUTTON AT THE END
+ OF THIS AGREEMENT. IF YOU DO NOT AGREE TO ALL
+ THESE TERMS, PROMPTLY RETURN THE UNUSED SOFTWARE
+ TO YOUR PLACE OF PURCHASE FOR A REFUND OR, IF THE
+ SOFTWARE IS ACCESSED ELECTRONICALLY, SELECT THE
+ "DECLINE" BUTTON AT THE END OF THIS AGREEMENT.
+
+ 1. LICENSE TO USE. Sun grants you a
+ non-exclusive and non-transferable license for the
+ internal use only of the accompanying software and
+ documentation and any error corrections provided
+ by Sun (collectively "Software"), by the number of
+ users and the class of computer hardware for which
+ the corresponding fee has been paid.
+
+ 2. RESTRICTIONS. Software is confidential and
+ copyrighted. Title to Software and all associated
+ intellectual property rights is retained by Sun
+ and/or its licensors. Except as specifically
+ authorized in any Supplemental License Terms, you
+ may not make copies of Software, other than a
+ single copy of Software for archival purposes.
+ Unless enforcement is prohibited by applicable
+ law, you may not modify, decompile, or reverse
+ engineer Software. You acknowledge that Software
+ is not designed, licensed or intended for use in
+ the design, construction, operation or maintenance
+ of any nuclear facility. Sun disclaims any
+ express or implied warranty of fitness for such
+ uses. No right, title or interest in or to any
+ trademark, service mark, logo or trade name of Sun
+ or its licensors is granted under this Agreement.
+
+ 3. LIMITED WARRANTY. Sun warrants to you that for
+ a period of ninety (90) days from the date of
+ purchase, as evidenced by a copy of the receipt,
+ the media on which Software is furnished (if any)
+ will be free of defects in materials and
+ workmanship under normal use. Except for the
+ foregoing, Software is provided "AS IS". Your
+ exclusive remedy and Sun's entire liability under
+ this limited warranty will be at Sun's option to
+ replace Software media or refund the fee paid for
+ Software.
+
+ 4. DISCLAIMER OF WARRANTY. UNLESS SPECIFIED IN
+ THIS AGREEMENT, ALL EXPRESS OR IMPLIED CONDITIONS,
+ REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
+ IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ PARTICULAR PURPOSE OR NON-INFRINGEMENT ARE
+ DISCLAIMED, EXCEPT TO THE EXTENT THAT THESE
+ DISCLAIMERS ARE HELD TO BE LEGALLY INVALID.
+
+ 5. LIMITATION OF LIABILITY. TO THE EXTENT NOT
+ PROHIBITED BY LAW, IN NO EVENT WILL SUN OR ITS
+ LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT
+ OR DATA, OR FOR SPECIAL, INDIRECT, CONSEQUENTIAL,
+ INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED
+ REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT
+ OF OR RELATED TO THE USE OF OR INABILITY TO USE
+ SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGES. In no event will
+ Sun's liability to you, whether in contract, tort
+ (including negligence), or otherwise, exceed the
+ amount paid by you for Software under this
+ Agreement. The foregoing limitations will apply
+ even if the above stated warranty fails of its
+ essential purpose.
+
+ 6. Termination. This Agreement is effective
+ until terminated. You may terminate this
+ Agreement at any time by destroying all copies of
+ Software. This Agreement will terminate
+ immediately without notice from Sun if you fail to
+ comply with any provision of this Agreement. Upon
+ Termination, you must destroy all copies of
+ Software.
+
+ 7. Export Regulations. All Software and technical
+ data delivered under this Agreement are subject to
+ US export control laws and may be subject to
+ export or import regulations in other countries.
+ You agree to comply strictly with all such laws
+ and regulations and acknowledge that you have the
+ responsibility to obtain such licenses to export,
+ re-export, or import as may be required after
+ delivery to you.
+
+ 8. U.S. Government Restricted Rights. If
+ Software is being acquired by or on behalf of the
+ U.S. Government or by a U.S. Government prime
+ contractor or subcontractor (at any tier), then
+ the Government's rights in Software and
+ accompanying documentation will be only as set
+ forth in this Agreement; this is in accordance
+ with 48 CFR 227.7201 through 227.7202-4 (for
+ Department of Defense (DOD) acquisitions) and with
+ 48 CFR 2.101 and 12.212 (for non-DOD
+ acquisitions).
+
+ 9. Governing Law. Any action related to this
+ Agreement will be governed by California law and
+ controlling U.S. federal law. No choice of law
+ rules of any jurisdiction will apply.
+
+ 10. Severability. If any provision of this
+ Agreement is held to be unenforceable, this
+ Agreement will remain in effect with the provision
+ omitted, unless omission would frustrate the
+ intent of the parties, in which case this
+ Agreement will immediately terminate.
+
+ 11. Integration. This Agreement is the entire
+ agreement between you and Sun relating to its
+ subject matter. It supersedes all prior or
+ contemporaneous oral or written communications,
+ proposals, representations and warranties and
+ prevails over any conflicting or additional terms
+ of any quote, order, acknowledgment, or other
+ communication between the parties relating to its
+ subject matter during the term of this Agreement.
+ No modification of this Agreement will be binding,
+ unless in writing and signed by an authorized
+ representative of each party.
+
+ JAVA OPTIONAL PACKAGE
+
+ JAVABEANS(TM) ACTIVATION FRAMEWORK, VERSION 1.0.2
+ SUPPLEMENTAL LICENSE TERMS
+
+ These supplemental license terms ("Supplemental
+ Terms") add to or modify the terms of the Binary
+ Code License Agreement (collectively, the
+ "Agreement"). Capitalized terms not defined in
+ these Supplemental Terms shall have the same
+ meanings ascribed to them in the Agreement. These
+ Supplemental Terms shall supersede any
+ inconsistent or conflicting terms in the
+ Agreement, or in any license contained within the
+ Software.
+
+ 1. Software Internal Use and Development License
+ Grant. Subject to the terms and conditions of
+ this Agreement, including, but not limited to
+ Section 3 (Java(TM) Technology Restrictions) of
+ these Supplemental Terms, Sun grants you a
+ non-exclusive, non-transferable, limited license
+ to reproduce internally and use internally the
+ binary form of the Software, complete and
+ unmodified, for the sole purpose of designing,
+ developing and testing your Java applets and
+ applications ("Programs").
+
+ 2. License to Distribute Software. In addition to
+ the license granted in Section 1 (Software
+ Internal Use and Development License Grant) of
+ these Supplemental Terms, subject to the terms and
+ conditions of this Agreement, including but not
+ limited to, Section 3 (Java Technology
+ Restrictions) of these Supplemental Terms, Sun
+ grants you a non-exclusive, non-transferable,
+ limited license to reproduce and distribute the
+ Software in binary code form only, provided that
+ you (i) distribute the Software complete and
+ unmodified and only bundled as part of your
+ Programs, (ii) do not distribute additional
+ software intended to replace any component(s) of
+ the Software, (iii) do not remove or alter any
+ proprietary legends or notices contained in the
+ Software, (iv) only distribute the Software
+ subject to a license agreement that protects Sun's
+ interests consistent with the terms contained in
+ this Agreement, and (v) agree to defend and
+ indemnify Sun and its licensors from and against
+ any damages, costs, liabilities, settlement
+ amounts and/or expenses (including attorneys'
+ fees) incurred in connection with any claim,
+ lawsuit or action by any third party that arises
+ or results from the use or distribution of any and
+ all Programs and/or Software.
+
+ 3. Java Technology Restrictions. You may not
+ modify the Java Platform Interface ("JPI",
+ identified as classes contained within the "java"
+ package or any subpackages of the "java" package),
+ by creating additional classes within the JPI or
+ otherwise causing the addition to or modification
+ of the classes in the JPI. In the event that you
+ create an additional class and associated API(s)
+ which (i) extends the functionality of the Java
+ platform, and (ii) is exposed to third party
+ software developers for the purpose of developing
+ additional software which invokes such additional
+ API, you must promptly publish broadly an accurate
+ specification for such API for free use by all
+ developers. You may not create, or authorize your
+ licensees to create additional classes,
+ interfaces, or subpackages that are in any way
+ identified as "java", "javax", "sun" or similar
+ convention as specified by Sun in any naming
+ convention designation.
+
+ 4. No Support. Sun is under no obligation to
+ support the Software or to provide you with
+ updates or error corrections. You acknowledge that
+ the Software may have defects or deficiencies
+ which cannot or will not be corrected by Sun.
+
+ 5. Trademarks and Logos. You acknowledge and agree
+ as between you and Sun that Sun owns the SUN,
+ SOLARIS, JAVA, JINI, FORTE, and iPLANET trademarks
+ and all SUN, SOLARIS, JAVA, JINI, FORTE, and
+ iPLANET-related trademarks, service marks, logos
+ and other brand designations ("Sun Marks"), and
+ you agree to comply with the Sun Trademark and
+ Logo Usage Requirements currently located at
+ http://www.sun.com/policies/trademarks. Any use
+ you make of the Sun Marks inures to Sun's benefit.
+
+ 6. Source Code. Software may contain source code
+ that is provided solely for reference purposes
+ pursuant to the terms of this Agreement. Source
+ code may not be redistributed unless expressly
+ provided for in this Agreement.
+
+ 7. Termination for Infringement. Either party may
+ terminate this Agreement immediately should any
+ Software become, or in either party's opinion be
+ likely to become, the subject of a claim of
+ infringement of any intellectual property right.
+
+ For inquiries please contact: Sun Microsystems,
+ Inc. 901 San Antonio Road, Palo Alto, California
+ 94303
+ (LFI#115020/Form ID#011801)
+
59 licenses/Aspirin-and-James-license.txt
@@ -0,0 +1,59 @@
+
+ Copyright (C) The Apache Software Foundation. All rights reserved.
+
+ The Apache Software License, Version 1.1
+
+ Copyright (c) 2000-2003 The Apache Software Foundation. All rights
+ reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ 3. The end-user documentation included with the redistribution,
+ if any, must include the following acknowledgment:
+ "This product includes software developed by the
+ Apache Software Foundation (http://www.apache.org/)."
+ Alternately, this acknowledgment may appear in the software itself,
+ if and wherever such third-party acknowledgments normally appear.
+
+ 4. The names "Apache", "Jakarta", "JAMES" and "Apache Software Foundation"
+ must not be used to endorse or promote products derived from this
+ software without prior written permission. For written
+ permission, please contact apache@apache.org.
+
+ 5. Products derived from this software may not be called "Apache",
+ nor may "Apache" appear in their name, without prior written
+ permission of the Apache Software Foundation.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+ ====================================================================
+
+ This software consists of voluntary contributions made by many
+ individuals on behalf of the Apache Software Foundation. For more
+ information on the Apache Software Foundation, please see
+ <http://www.apache.org/>.
+
+ Portions of this software are based upon public domain software
+ originally written at the National Center for Supercomputing Applications,
+ University of Illinois, Urbana-Champaign.
+
22 licenses/JDom-license.txt
@@ -0,0 +1,22 @@
+Appendix�I.�JDOM Software License
+
+ Copyright (C) 2000-2003 Jason Hunter & Brett McLaughlin. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+ Redistributions of source code must retain the above copyright notice, this list of conditions, and the following disclaimer.
+
+ Redistributions in binary form must reproduce the above copyright notice, this list of conditions, and the disclaimer that follows these conditions in the documentation and/or other materials provided with the distribution.
+
+ The name "JDOM" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact <license AT jdom DOT org<.
+
+ Products derived from this software may not be called "JDOM", nor may "JDOM" appear in their name, without prior written permission from the JDOM Project Management <pm AT jdom DOT org>.
+
+ In addition, we request (but do not require) that you include in the end-user documentation provided with the redistribution and/or in the software itself an acknowledgement equivalent to the following:
+ "This product includes software developed by the JDOM Project (http://www.jdom.org/)."
+
+ Alternatively, the acknowledgment may be graphical using the logos available at http://www.jdom.org/images/logos/.
+
+ THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE JDOM AUTHORS OR THE PROJECT CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ This software consists of voluntary contributions made by many individuals on behalf of the JDOM Project and was originally created by Jason Hunter <jhunter AT jdom DOT org> and Brett McLaughlin <brett AT jdom DOT org>. For more information on the JDOM Project, please see http://www.jdom.org/..
88 licenses/JUnit-license.txt
@@ -0,0 +1,88 @@
+Common Public License Version 1.0
+
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+ 1. DEFINITIONS
+
+ "Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+
+ b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+ "Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+ "Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+ 2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
+
+ b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+ a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+
+ ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+
+ iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
+
+ iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
+
+ When the Program is made available in source code form:
+
+ a) it must be made available under this Agreement; and
+
+ b) a copy of this Agreement must be included with each copy of the Program.
+
+ Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
+
+ 4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
+
+ For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
+
+ 5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
+
+ 6. DISCLAIMER OF LIABILITY
+
+ EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+ 7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+ If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+ Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+ This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of
170 licenses/JavaMail-license.txt
@@ -0,0 +1,170 @@
+ Sun Microsystems, Inc.
+ Binary Code License Agreement
+
+READ THE TERMS OF THIS AGREEMENT AND ANY PROVIDED SUPPLEMENTAL LICENSE TERMS
+(COLLECTIVELY "AGREEMENT") CAREFULLY BEFORE OPENING THE SOFTWARE MEDIA
+PACKAGE. BY OPENING THE SOFTWARE MEDIA PACKAGE, YOU AGREE TO THE TERMS OF
+THIS AGREEMENT. IF YOU ARE ACCESSING THE SOFTWARE ELECTRONICALLY, INDICATE
+YOUR ACCEPTANCE OF THESE TERMS BY SELECTING THE "ACCEPT" BUTTON AT THE END
+OF THIS AGREEMENT. IF YOU DO NOT AGREE TO ALL THESE TERMS, PROMPTLY RETURN
+THE UNUSED SOFTWARE TO YOUR PLACE OF PURCHASE FOR A REFUND OR, IF THE
+SOFTWARE IS ACCESSED ELECTRONICALLY, SELECT THE "DECLINE" BUTTON AT THE END
+OF THIS AGREEMENT.
+
+1. LICENSE TO USE. Sun grants you a non-exclusive and non-transferable
+license for the internal use only of the accompanying software and
+documentation and any error corrections provided by Sun (collectively
+"Software"), by the number of users and the class of computer hardware for
+which the corresponding fee has been paid.
+
+2. RESTRICTIONS. Software is confidential and copyrighted. Title to
+Software and all associated intellectual property rights is retained by Sun
+and/or its licensors. Except as specifically authorized in any Supplemental
+License Terms, you may not make copies of Software, other than a single copy
+of Software for archival purposes. Unless enforcement is prohibited by
+applicable law, you may not modify, decompile, or reverse engineer
+Software. You acknowledge that Software is not designed, licensed or
+intended for use in the design, construction, operation or maintenance of
+any nuclear facility. Sun disclaims any express or implied warranty of
+fitness for such uses. No right, title or interest in or to any trademark,
+service mark, logo or trade name of Sun or its licensors is granted under
+this Agreement.
+
+3. LIMITED WARRANTY. Sun warrants to you that for a period of ninety (90)
+days from the date of purchase, as evidenced by a copy of the receipt, the
+media on which Software is furnished (if any) will be free of defects in
+materials and workmanship under normal use. Except for the foregoing,
+Software is provided "AS IS". Your exclusive remedy and Sun's entire
+liability under this limited warranty will be at Sun's option to replace
+Software media or refund the fee paid for Software.
+
+4. DISCLAIMER OF WARRANTY. UNLESS SPECIFIED IN THIS AGREEMENT, ALL EXPRESS
+OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED
+WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
+NON-INFRINGEMENT ARE DISCLAIMED, EXCEPT TO THE EXTENT THAT THESE DISCLAIMERS
+ARE HELD TO BE LEGALLY INVALID.
+
+5. LIMITATION OF LIABILITY. TO THE EXTENT NOT PROHIBITED BY LAW, IN NO
+EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR
+DATA, OR FOR SPECIAL, INDIRECT, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+DAMAGES, HOWEVER CAUSED REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT
+OF OR RELATED TO THE USE OF OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS
+BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. In no event will Sun's
+liability to you, whether in contract, tort (including negligence), or
+otherwise, exceed the amount paid by you for Software under this Agreement.
+The foregoing limitations will apply even if the above stated warranty fails
+of its essential purpose.
+
+6. Termination. This Agreement is effective until terminated. You may
+terminate this Agreement at any time by destroying all copies of Software.
+This Agreement will terminate immediately without notice from Sun if you
+fail to comply with any provision of this Agreement. Upon Termination, you
+must destroy all copies of Software.
+
+7. Export Regulations. All Software and technical data delivered under this
+Agreement are subject to US export control laws and may be subject to export
+or import regulations in other countries. You agree to comply strictly with
+all such laws and regulations and acknowledge that you have the
+responsibility to obtain such licenses to export, re-export, or import as
+may be required after delivery to you.
+
+8. U.S. Government Restricted Rights. If Software is being acquired by or
+on behalf of the U.S. Government or by a U.S. Government prime contractor or
+subcontractor (at any tier), then the Government's rights in Software and
+accompanying documentation will be only as set forth in this Agreement; this
+is in accordance with 48 CFR 227.7201 through 227.7202-4 (for Department of
+Defense (DOD) acquisitions) and with 48 CFR 2.101 and 12.212 (for non-DOD
+acquisitions).
+
+9. Governing Law. Any action related to this Agreement will be governed by
+California law and controlling U.S. federal law. No choice of law rules of
+any jurisdiction will apply.
+
+10. Severability. If any provision of this Agreement is held to be
+unenforceable, this Agreement will remain in effect with the provision
+omitted, unless omission would frustrate the intent of the parties, in which
+case this Agreement will immediately terminate.
+
+11. Integration. This Agreement is the entire agreement between you and
+Sun relating to its subject matter. It supersedes all prior or
+contemporaneous oral or written communications, proposals, representations
+and warranties and prevails over any conflicting or additional terms of any
+quote, order, acknowledgment, or other communication between the parties
+relating to its subject matter during the term of this Agreement. No
+modification of this Agreement will be binding, unless in writing and signed
+by an authorized representative of each party.
+
+
+
+ JAVAMAIL, VERSION 1.2
+ SUPPLEMENTAL LICENSE TERMS
+
+These supplemental license terms ("Supplemental Terms") add to or modify the
+terms of the Binary Code License Agreement (collectively, the "Agreement").
+Capitalized terms not defined in these Supplemental Terms shall have the
+same meanings ascribed to them in the Agreement. These Supplemental Terms
+shall supersede any inconsistent or conflicting terms in the Agreement, or
+in any license contained within the Software.
+
+1. Software Internal Use and Development License Grant. Subject to the
+terms and conditions of this Agreement, including, but not limited to
+Section 3 (Java(TM) Technology Restrictions) of these Supplemental Terms,
+Sun grants you a non-exclusive, non-transferable, limited license to
+reproduce internally and use internally the binary form of the Software,
+complete and unmodified, for the sole purpose of designing, developing and
+testing your Java applets and applications ("Programs").
+
+2. License to Distribute Software. Subject to the terms and conditions of
+this Agreement, including, but not limited to Section 3 (Java (TM)
+Technology Restrictions) of these Supplemental Terms, Sun grants you a
+non-exclusive, non-transferable, limited license to reproduce and distribute
+the Software in binary code form only, provided that (i) you distribute the
+Software complete and unmodified and only bundled as part of, and for the
+sole purpose of running, your Java applets or applications ("Programs"),
+(ii) the Programs add significant and primary functionality to the Software,
+(iii) you do not distribute additional software intended to replace any
+component(s) of the Software, (iv) you do not remove or alter any
+proprietary legends or notices contained in the Software, (v) you only
+distribute the Software subject to a license agreement that protects Sun's
+interests consistent with the terms contained in this Agreement, and (vi)
+you agree to defend and indemnify Sun and its licensors from and against any
+damages, costs, liabilities, settlement amounts and/or expenses (including
+attorneys' fees) incurred in connection with any claim, lawsuit or action by
+any third party that arises or results from the use or distribution of any
+and all Programs and/or Software.
+
+3. Java Technology Restrictions. You may not modify the Java Platform
+Interface ("JPI", identified as classes contained within the "java" package
+or any subpackages of the "java" package), by creating additional classes
+within the JPI or otherwise causing the addition to or modification of the
+classes in the JPI. In the event that you create an additional class and
+associated API(s) which (i) extends the functionality of the Java platform,
+and (ii) is exposed to third party software developers for the purpose of
+developing additional software which invokes such additional API, you must
+promptly publish broadly an accurate specification for such API for free use
+by all developers. You may not create, or authorize your licensees to
+create additional classes, interfaces, or subpackages that are in any way
+identified as "java", "javax", "sun" or similar convention as specified by
+Sun in any naming convention designation.
+
+4. Trademarks and Logos. You acknowledge and agree as between you and Sun
+that Sun owns the SUN, SOLARIS, JAVA, JINI, FORTE, STAROFFICE, STARPORTAL
+and iPLANET trademarks and all SUN, SOLARIS, JAVA, JINI, FORTE, STAROFFICE,
+STARPORTAL and iPLANET-related trademarks, service marks, logos and other
+brand designations ("Sun Marks"), and you agree to comply with the Sun
+Trademark and Logo Usage Requirements currently located at
+http://www.sun.com/policies/trademarks. Any use you make of the Sun Marks
+inures to Sun's benefit.
+
+5. Source Code. Software may contain source code that is provided solely for
+reference purposes pursuant to the terms of this Agreement. Source code may
+not be redistributed unless expressly provided for in this Agreement.
+
+6. Termination for Infringement. Either party may terminate this Agreement
+immediately should any Software become, or in either party's opinion be
+likely to become, the subject of a claim of infringement of any intellectual
+property right.
+
+For inquiries please contact: Sun Microsystems, Inc. 901 San Antonio Road,
+Palo Alto, California 94303
+
18 licenses/omt-logging-license.txt
@@ -0,0 +1,18 @@
+Copyright (c) 2004 Katherine Rhodes (masukomi at masukomi dot org)
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15 prefs/system/org/masukomi/aspirin/core/Configuration.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<preferences EXTERNAL_XML_VERSION="1.0">
+ <root type="file">
+ <map />
+ <node name="root">
+ <map>
+ <entry key="maxAttempts" value="1" group="" />
+ <entry key="postmaster" value="root@localhost" group="" />
+ <entry key="deliveryThreads" value="1" group="" />
+ <entry key="retryInterval" value="60000" group="" />
+ </map>
+ </node>
+ </root>
+</preferences>
+
45 prefs/system/org/masukomi/tools/logging/Logs.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<preferences EXTERNAL_XML_VERSION="1.0">
+ <root type="system">
+ <map />
+ <node name="org">
+ <map />
+ <node name="masukomi">
+ <map />
+ <node name="tools">
+ <map />
+ <node name="logging">
+ <map />
+ <node name="Logs">
+ <map>
+ <entry key="entriesLogFile" value="" />
+ <!-- enter the path to a log file as the value if you wish to have one -->
+ <entry key="logFileRequired" value="false" />
+ <!-- if this is true and it can't open the log file specified in entriesLogFile
+ it will barf -->
+ <entry key="entriesToSystemOut" value="false" />
+ <!--
+ would you like nicely formatted log messages printed to standard out?
+ -->
+ <entry key="entryLogThreshold" value="DEBUG" />
+ <!-- options for entryLogThreshold are:
+ DEBUG
+ INFO
+ WARN
+ ERROR
+ -->
+ <entry key="entriesWarningLevel" value="-1" />
+ <!-- leave the following entries. they aren't currently used in Aspirin-->
+ <entry key="webmaster" value="masukomi@masukomi.org" />
+ <entry key="smtpServer" value="localhost" />
+ <entry key="FATAL_htmlColor" value="#ff4533" />
+ <entry key="ERROR_htmlColor" value="#ffa018" />
+ <entry key="WARN_htmlColor" value="#ffce0b" />
+ </map>
+ </node>
+ </node>
+ </node>
+ </node>
+ </node>
+ </root>
+</preferences>
75 src/org/apache/commons/threadpool/CommonsLoggingThreadPoolMonitor.java
@@ -0,0 +1,75 @@
+/*
+ * $Header: /cvs/aspirin/src/org/apache/commons/threadpool/CommonsLoggingThreadPoolMonitor.java,v 1.3 2004/09/15 02:11:10 masukomi Exp $
+ * $Revision: 1.3 $
+ * $Date: 2004/09/15 02:11:10 $
+ *
+ * ====================================================================
+ *
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 1999-2002 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowlegement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowlegement may appear in the software itself,
+ * if and wherever such third-party acknowlegements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Commons", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Group.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.commons.threadpool;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class CommonsLoggingThreadPoolMonitor implements ThreadPoolMonitor {
+ static private Log log = LogFactory.getLog(CommonsLoggingThreadPoolMonitor.class);
+
+ public void handleThrowable(Class clazz, Runnable runnable,
+ Throwable throwable) {
+ log.warn( "Caught: " + throwable + " in runnable " + runnable);
+ log.error(throwable);
+ }
+}
164 src/org/apache/commons/threadpool/DefaultThreadPool.java
@@ -0,0 +1,164 @@
+/*
+ * $Header: /cvs/aspirin/src/org/apache/commons/threadpool/DefaultThreadPool.java,v 1.2 2004/09/15 02:12:02 masukomi Exp $
+ * $Revision: 1.2 $
+ * $Date: 2004/09/15 02:12:02 $
+ *
+ * ====================================================================
+ *
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 1999-2002 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowledgement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgement may appear in the software itself,
+ * if and wherever such third-party acknowledgements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Commons", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ * $Id: DefaultThreadPool.java,v 1.2 2004/09/15 02:12:02 masukomi Exp $
+ */
+package org.apache.commons.threadpool;
+
+/**
+ * A default implementation of a ThreadPool
+ * which is constructed with a given number of threads.
+ *
+ * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
+ * @version $Revision: 1.2 $
+ */
+public class DefaultThreadPool implements Runnable, ThreadPool {
+
+ /** The Log to which logging calls will be made. */
+
+ protected MTQueue queue = new MTQueue();
+ protected boolean stopped = false;
+ protected final ThreadPoolMonitor monitor;
+
+ public DefaultThreadPool(ThreadPoolMonitor monitor,
+ int numberOfThreads, int threadPriority) {
+ this.monitor = monitor;
+ for ( int i = 0; i < numberOfThreads; i++ ) {
+ startThread(threadPriority);
+ }
+ }
+
+ public DefaultThreadPool(ThreadPoolMonitor monitor,
+ int numberOfThreads) {
+ this.monitor = monitor;
+ for ( int i = 0; i < numberOfThreads; i++ ) {
+ startThread();
+ }
+ }
+
+ public DefaultThreadPool() {
+ this.monitor = new CommonsLoggingThreadPoolMonitor();
+ // typically a thread pool should have at least 1 thread
+ startThread();
+ }
+
+ public DefaultThreadPool(int numberOfThreads) {
+ this(new CommonsLoggingThreadPoolMonitor(), numberOfThreads);
+ }
+
+ public DefaultThreadPool(int numberOfThreads, int threadPriority) {
+ this(new CommonsLoggingThreadPoolMonitor(), numberOfThreads, threadPriority);
+ }
+
+ /** Start a new thread running */
+ public Thread startThread() {
+ Thread thread = new Thread( this );
+ thread.start();
+ return thread;
+ }
+
+ public Thread startThread(int priority) {
+ Thread thread = new Thread( this );
+ thread.setPriority(priority);
+ thread.start();
+ return thread;
+ }
+
+ public void stop() {
+ stopped = true;
+ }
+
+ /**
+ * Returns number of runnable object in the queue.
+ */
+ public int getRunnableCount() {
+ return queue.size();
+ }
+
+
+ // ThreadPool interface
+ //-------------------------------------------------------------------------
+
+ /**
+ * Dispatch a new task onto this pool
+ * to be invoked asynchronously later
+ */
+ public void invokeLater(Runnable task) {
+ queue.add( task );
+ }
+
+ // Runnable interface
+ //-------------------------------------------------------------------------
+
+ /** The method ran by the pool of background threads
+ */
+ public void run() {
+ while ( ! stopped ) {
+ Runnable task = (Runnable) queue.remove();
+ if ( task != null ) {
+ try {
+ task.run();
+ }
+ catch (Throwable t) {
+ monitor.handleThrowable(this.getClass(), task, t);
+ }
+ }
+ }
+ }
+}
160 src/org/apache/commons/threadpool/MTQueue.java
@@ -0,0 +1,160 @@
+/*
+ * $Header: /cvs/aspirin/src/org/apache/commons/threadpool/MTQueue.java,v 1.2 2004/05/05 15:47:42 masukomi Exp $
+ * $Revision: 1.2 $
+ * $Date: 2004/05/05 15:47:42 $
+ *
+ * ====================================================================
+ *
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 1999-2002 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowledgement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgement may appear in the software itself,
+ * if and wherever such third-party acknowledgements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Commons", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ * $Id: MTQueue.java,v 1.2 2004/05/05 15:47:42 masukomi Exp $
+ */
+package org.apache.commons.threadpool;
+
+import java.util.LinkedList;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+//import org.masukomi.tools.logging.Logs;
+/**
+ * A multithreaded blocking queue which is very useful for
+ * implementing producer-consumer style threading patterns.
+ * <p>
+ * Multiple blocking threads can wait for items being added
+ * to the queue while other threads add to the queue.
+ * <p>
+ * Non blocking and timout based modes of access are possible as well.
+ *
+ * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
+ * @version $Revision: 1.2 $
+ */
+public class MTQueue {
+ static private Log log = LogFactory.getLog(MTQueue.class);
+ /** The Log to which logging calls will be made. */
+ //private Log log = LogFactory.getLog(MTQueue.class);
+
+
+ private LinkedList list = new LinkedList();
+ private long defaultTimeout = 10000;
+
+ public MTQueue() {
+ }
+
+ /**
+ * Returns the current number of object in the queue
+ */
+ public synchronized int size() {
+ return list.size();
+ }
+
+ /**
+ * adds a new object to the end of the queue.
+ * At least one thread will be notified.
+ */
+ public synchronized void add(Object object) {
+ list.add( object );
+ notify();
+ }
+
+ /**
+ * Removes the first object from the queue, blocking until one is available.
+ * Note that this method will never return null and could block forever.
+ */
+ public synchronized Object remove() {
+ while (true) {
+ Object answer = removeNoWait();
+ if ( answer != null ) {
+ return answer;
+ }
+ try {
+ wait( defaultTimeout );
+ }
+ catch (InterruptedException e) {
+ log.error( e );
+ }
+ }
+ }
+
+ /**
+ * Removes the first object from the queue, blocking only up to the given
+ * timeout time.
+ */
+ public synchronized Object remove(long timeout) {
+ Object answer = removeNoWait();
+ if (answer == null) {
+ try {
+ wait( timeout );
+ }
+ catch (InterruptedException e) {
+ log.error( "Thread was interrupted: " + e);
+ }
+ answer = removeNoWait();
+ }
+ return answer;
+ }
+
+ /**
+ * Removes the first object from the queue without blocking.
+ * This method will return immediately with an item from the queue or null.
+ *
+ * @return the first object removed from the queue or null if the
+ * queue is empty
+ */
+ public synchronized Object removeNoWait() {
+ if ( ! list.isEmpty() ) {
+ return list.removeFirst();
+ }
+ return null;
+ }
+
+}
69 src/org/apache/commons/threadpool/NullThreadPoolMonitor.java
@@ -0,0 +1,69 @@
+/*
+ * $Header: /cvs/aspirin/src/org/apache/commons/threadpool/NullThreadPoolMonitor.java,v 1.1 2004/03/07 01:26:46 masukomi Exp $
+ * $Revision: 1.1 $
+ * $Date: 2004/03/07 01:26:46 $
+ *
+ * ====================================================================
+ *
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 1999-2002 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowlegement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowlegement may appear in the software itself,
+ * if and wherever such third-party acknowlegements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Commons", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Group.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.commons.threadpool;
+/**
+ * NullObject pattern impl of ThreadPoolMonitor
+ */
+public class NullThreadPoolMonitor implements ThreadPoolMonitor {
+ public void handleThrowable(Class clazz, Runnable runnable, Throwable t) {
+ }
+}
81 src/org/apache/commons/threadpool/ThreadPool.java
@@ -0,0 +1,81 @@
+/*
+ * $Header: /cvs/aspirin/src/org/apache/commons/threadpool/ThreadPool.java,v 1.1 2004/03/07 01:26:47 masukomi Exp $
+ * $Revision: 1.1 $
+ * $Date: 2004/03/07 01:26:47 $
+ *
+ * ====================================================================
+ *
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 1999-2002 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowledgement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgement may appear in the software itself,
+ * if and wherever such third-party acknowledgements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Commons", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ * $Id: ThreadPool.java,v 1.1 2004/03/07 01:26:47 masukomi Exp $
+ */
+package org.apache.commons.threadpool;
+
+/**
+ * An interface representing some kind of thread pool which allows
+ * asynchronous dispatching of Runnable tasks. It is the responsibility
+ * of the Runnable task to handle exceptions gracefully. Any non handled
+ * exception will typically just be logged.
+ * Though a ThreadPool implementation could have some custom Exception handler
+ *
+ * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
+ * @version $Revision: 1.1 $
+ */
+public interface ThreadPool {
+
+ /**
+ * Dispatch a new task onto this pool
+ * to be invoked asynchronously later.
+ */
+ public void invokeLater(Runnable task);
+}
75 src/org/apache/commons/threadpool/ThreadPoolMonitor.java
@@ -0,0 +1,75 @@
+/*
+ * $Header: /cvs/aspirin/src/org/apache/commons/threadpool/ThreadPoolMonitor.java,v 1.1 2004/03/07 01:26:47 masukomi Exp $
+ * $Revision: 1.1 $
+ * $Date: 2004/03/07 01:26:47 $
+ *
+ * ====================================================================
+ *
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 1999-2002 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowlegement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowlegement may appear in the software itself,
+ * if and wherever such third-party acknowlegements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Commons", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Group.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.commons.threadpool;
+/**
+ * The idea is that the end-user can write a implementation of
+ * this class that allows them have a deterministic for the
+ * events that are monitored for. I.e. they can change the state
+ * of other parts of their system (or not).
+ *
+ * One implementation of this is logging....
+ * @see CommonsLoggingThreadPoolMonitor
+ * @see NullThreadPoolMonitor
+ */
+public interface ThreadPoolMonitor {
+ void handleThrowable(Class clazz, Runnable runnable, Throwable t);
+}
148 src/org/apache/james/core/MailHeaders.java
@@ -0,0 +1,148 @@
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2000-2003 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache", "Jakarta", "JAMES" and "Apache Software Foundation"
+ * must not be used to endorse or promote products derived from this
+ * software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ * Portions of this software are based upon public domain software
+ * originally written at the National Center for Supercomputing Applications,
+ * University of Illinois, Urbana-Champaign.
+ */
+
+package org.apache.james.core;
+
+import javax.mail.MessagingException;
+import javax.mail.internet.InternetHeaders;
+import java.io.*;
+import java.util.Enumeration;
+
+import org.apache.james.util.RFC2822Headers;
+
+/**
+ * This interface defines a container for mail headers. Each header must use
+ * MIME format: <pre>name: value</pre>.
+ *
+ * @author Federico Barbieri <scoobie@systemy.it>
+ */
+public class MailHeaders extends InternetHeaders implements Serializable, Cloneable {
+
+ /**
+ * No argument constructor
+ *
+ * @throws MessagingException if the super class cannot be properly instantiated
+ */
+ public MailHeaders() throws MessagingException {
+ super();
+ }
+
+ /**
+ * Constructor that takes an InputStream containing the contents
+ * of the set of mail headers.
+ *
+ * @param in the InputStream containing the header data
+ *
+ * @throws MessagingException if the super class cannot be properly instantiated
+ * based on the stream
+ */
+ public MailHeaders(InputStream in) throws MessagingException {
+ super(in);
+ }
+
+ /**
+ * Write the headers to an output stream
+ *
+ * @param writer the stream to which to write the headers
+ */
+ public void writeTo(OutputStream out) {
+ PrintStream pout;
+ if (out instanceof PrintStream) {
+ pout = (PrintStream)out;
+ } else {
+ pout = new PrintStream(out);
+ }
+ for (Enumeration e = super.getAllHeaderLines(); e.hasMoreElements(); ) {
+ pout.print((String) e.nextElement());
+ pout.print("\r\n");
+ }
+ // Print trailing CRLF
+ pout.print("\r\n");
+ }
+
+ /**
+ * Generate a representation of the headers as a series of bytes.
+ *
+ * @return the byte array containing the headers
+ */
+ public byte[] toByteArray() {
+ ByteArrayOutputStream headersBytes = new ByteArrayOutputStream();
+ writeTo(headersBytes);
+ return headersBytes.toByteArray();
+ }
+
+ /**
+ * Check if a particular header is present.
+ *
+ * @return true if the header is present, false otherwise
+ */
+ public boolean isSet(String name) {
+ String[] value = super.getHeader(name);
+ return (value != null && value.length != 0);
+ }
+
+ /**
+ * Check if all REQUIRED headers fields as specified in RFC 822
+ * are present.
+ *
+ * @return true if the headers are present, false otherwise
+ */
+ public boolean isValid() {
+ return (isSet(RFC2822Headers.DATE) && isSet(RFC2822Headers.TO) && isSet(RFC2822Headers.FROM));
+ }
+}
659 src/org/apache/james/core/MailImpl.java
@@ -0,0 +1,659 @@
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2000-2003 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache", "Jakarta", "JAMES" and "Apache Software Foundation"
+ * must not be used to endorse or promote products derived from this
+ * software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ * Portions of this software are based upon public domain software
+ * originally written at the National Center for Supercomputing Applications,
+ * University of Illinois, Urbana-Champaign.
+ */
+
+package org.apache.james.core;
+
+//import org.apache.avalon.framework.activity.Disposable;
+
+import org.apache.james.util.RFC2822Headers;
+import org.apache.mailet.Mail;
+import org.apache.mailet.MailAddress;
+
+import javax.mail.Address;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeMessage;
+import javax.mail.internet.ParseException;
+import java.io.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Iterator;
+
+/**
+ * Wraps a MimeMessage adding routing information (from SMTP) and some simple
+ * API enhancements.
+ *
+ * @author Federico Barbieri <scoobie@systemy.it>
+ * @author Serge Knystautas <sergek@lokitech.com>
+ * @author Stuart Roebuck <stuart.roebuck@adolos.co.uk>
+ * @version 0.9
+ */
+public class MailImpl implements Mail {
+ /**
+ * We hardcode the serialVersionUID so that from James 1.2 on, MailImpl will
+ * be deserializable (so your mail doesn't get lost)
+ */
+ public static final long serialVersionUID = -4289663364703986260L;
+
+ /**
+ * The error message, if any, associated with this mail.
+ */
+ private String errorMessage;
+
+ /**
+ * The state of this mail, which determines how it is processed.
+ */
+ private String state;
+
+ /**
+ * The MimeMessage that holds the mail data.
+ */
+ private MimeMessage message;
+
+ /**
+ * The sender of this mail.
+ */
+ private MailAddress sender;
+
+ /**
+ * The collection of recipients to whom this mail was sent.
+ */
+ private Collection recipients;
+
+ /**
+ * The identifier for this mail message
+ */
+ private String name;
+
+ /**
+ * The remote host from which this mail was sent.
+ */
+ private String remoteHost = "localhost";
+
+ /**
+ * The remote address from which this mail was sent.
+ */
+ private String remoteAddr = "127.0.0.1";
+
+ /**
+ * The last time this message was updated.
+ */
+ private Date lastUpdated = new Date();
+
+ /**
+ * A constructor that creates a new, uninitialized MailImpl
+ */
+ public MailImpl() {
+ setState(Mail.DEFAULT);
+ }
+
+ /**
+ * A constructor that creates a MailImpl with the specified name, sender,
+ * and recipients.
+ *
+ * @param name
+ * the name of the MailImpl
+ * @param sender
+ * the sender for this MailImpl
+ * @param recipients
+ * the collection of recipients of this MailImpl
+ */
+ public MailImpl(String name, MailAddress sender, Collection recipients) {
+ this();
+ this.name = name;
+ this.sender = sender;
+ this.recipients = null;
+
+ // Copy the recipient list
+ if (recipients != null) {
+ Iterator theIterator = recipients.iterator();
+ this.recipients = new ArrayList();
+ while (theIterator.hasNext()) {
+ this.recipients.add(theIterator.next());
+ }
+ }
+ }
+
+ /**
+ * A constructor that creates a MailImpl with the specified name, sender,
+ * recipients, and message data.
+ *
+ * @param name
+ * the name of the MailImpl
+ * @param sender
+ * the sender for this MailImpl
+ * @param recipients
+ * the collection of recipients of this MailImpl
+ * @param messageIn
+ * a stream containing the message source
+ */
+ public MailImpl(String name, MailAddress sender, Collection recipients,
+ InputStream messageIn) throws MessagingException {
+ this(name, sender, recipients);
+ MimeMessageSource source = new MimeMessageInputStreamSource(name,
+ messageIn);
+ MimeMessageWrapper wrapper = new MimeMessageWrapper(source);
+ this.setMessage(wrapper);
+ }
+
+ /**
+ * A constructor that creates a MailImpl with the specified name, sender,
+ * recipients, and MimeMessage.
+ *
+ * @param name
+ * the name of the MailImpl
+ * @param sender
+ * the sender for this MailImpl
+ * @param recipients
+ * the collection of recipients of this MailImpl
+ * @param message
+ * the MimeMessage associated with this MailImpl
+ */
+ public MailImpl(String name, MailAddress sender, Collection recipients,
+ MimeMessage message) {
+ this(name, sender, recipients);
+ this.setMessage(message);
+ }
+
+ /**
+ * A constructor which will attempt to obtain sender and recipients from the
+ * headers of the MimeMessage supplied.
+ *
+ * @param message -
+ * a MimeMessage from which to construct a Mail
+ */
+ public MailImpl(MimeMessage message) throws MessagingException {
+ this();
+ Address[] addresses;
+ addresses = message.getFrom();
+ MailAddress sender = new MailAddress(new InternetAddress(addresses[0]
+ .toString()));
+ Collection recipients = new ArrayList();
+ addresses = message.getRecipients(MimeMessage.RecipientType.TO);
+ if (addresses != null) {
+ for (int i = 0; i < addresses.length; i++) {
+ recipients.add(new MailAddress(new InternetAddress(addresses[i]
+ .toString())));
+ }
+ }
+
+ // Added by masukomi
+ // prior to this it would barf if it was lacking a To even if it had a CC or BCC
+ addresses = message.getRecipients(MimeMessage.RecipientType.CC);
+ if (addresses != null) {
+ for (int i = 0; i < addresses.length; i++) {
+ recipients.add(new MailAddress(new InternetAddress(addresses[i]
+ .toString())));
+ }
+ }
+ addresses = message.getRecipients(MimeMessage.RecipientType.BCC);
+ if (addresses != null) {
+ for (int i = 0; i < addresses.length; i++) {
+ recipients.add(new MailAddress(new InternetAddress(addresses[i]
+ .toString())));
+ }
+ }
+ // end added by masukomi
+ this.name = message.toString();
+ this.sender = sender;
+ this.recipients = recipients;
+ this.setMessage(message);
+ }
+
+ /**
+ * Duplicate the MailImpl.
+ *
+ * @return a MailImpl that is a duplicate of this one
+ */
+ public Mail duplicate() {
+ return duplicate(name);
+ }
+
+ /**
+ * Duplicate the MailImpl, replacing the mail name with the one passed in as
+ * an argument.
+ *
+ * @param newName
+ * the name for the duplicated mail
+ *
+ * @return a MailImpl that is a duplicate of this one with a different name
+ */
+ public Mail duplicate(String newName) {
+ try {
+ MailImpl newMail = new MailImpl(newName, sender, recipients,
+ getMessage());
+ newMail.setRemoteHost(remoteHost);
+ newMail.setRemoteAddr(remoteAddr);
+ newMail.setLastUpdated(lastUpdated);
+ return newMail;
+ } catch (MessagingException me) {
+ // Ignored. Return null in the case of an error.
+ }
+ return (Mail) null;
+ }
+
+ /**
+ * Get the error message associated with this MailImpl.
+ *
+ * @return the error message associated with this MailImpl
+ */
+ public String getErrorMessage() {
+ return errorMessage;
+ }
+
+ /**
+ * Get the MimeMessage associated with this MailImpl.
+ *
+ * @return the MimeMessage associated with this MailImpl
+ */
+ public MimeMessage getMessage() throws MessagingException {
+ return message;
+ }
+
+ /**
+ * Set the name of this MailImpl.
+ *
+ * @param name
+ * the name of this MailImpl
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Get the name of this MailImpl.
+ *
+ * @return the name of this MailImpl
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Get the recipients of this MailImpl.
+ *
+ * @return the recipients of this MailImpl
+ */
+ public Collection getRecipients() {
+ return recipients;
+ }
+
+ /**
+ * Get the sender of this MailImpl.
+ *
+ * @return the sender of this MailImpl
+ */
+ public MailAddress getSender() {
+ return sender;
+ }
+
+ /**
+ * Get the state of this MailImpl.
+ *
+ * @return the state of this MailImpl
+ */
+ public String getState() {
+ return state;
+ }
+
+ /**
+ * Get the remote host associated with this MailImpl.
+ *
+ * @return the remote host associated with this MailImpl
+ */
+ public String getRemoteHost() {
+ return remoteHost;
+ }
+
+ /**
+ * Get the remote address associated with this MailImpl.
+ *
+ * @return the remote address associated with this MailImpl
+ */
+ public String getRemoteAddr() {
+ return remoteAddr;
+ }
+
+ /**
+ * Get the last updated time for this MailImpl.
+ *
+ * @return the last updated time for this MailImpl
+ */
+ public Date getLastUpdated() {
+ return lastUpdated;
+ }
+
+ /**
+ * <p>
+ * Return the size of the message including its headers.
+ * MimeMessage.getSize() method only returns the size of the message body.
+ * </p>
+ *
+ * <p>
+ * Note: this size is not guaranteed to be accurate - see Sun's
+ * documentation of MimeMessage.getSize().
+ * </p>
+ *
+ * @return approximate size of full message including headers.
+ *
+ * @throws MessagingException
+ * if a problem occurs while computing the message size
+ */
+ public long getMessageSize() throws MessagingException {
+ //If we have a MimeMessageWrapper, then we can ask it for just the
+ // message size and skip calculating it
+ if (message instanceof MimeMessageWrapper) {
+ MimeMessageWrapper wrapper = (MimeMessageWrapper) message;
+ return wrapper.getMessageSize();
+ }
+ //SK: Should probably eventually store this as a locally
+ // maintained value (so we don't have to load and reparse
+ // messages each time).
+ long size = message.getSize();
+ Enumeration e = message.getAllHeaderLines();
+ while (e.hasMoreElements()) {
+ size += ((String) e.nextElement()).length();
+ }
+ return size;
+ }
+
+ /**
+ * Set the error message associated with this MailImpl.
+ *
+ * @param msg
+ * the new error message associated with this MailImpl
+ */
+ public void setErrorMessage(String msg) {
+ this.errorMessage = msg;
+ }
+
+ /**
+ * Set the MimeMessage associated with this MailImpl.
+ *
+ * @param message
+ * the new MimeMessage associated with this MailImpl
+ */
+ public void setMessage(MimeMessage message) {
+ this.message = message;
+ }
+
+ /**
+ * Set the recipients for this MailImpl.
+ *
+ * @param recipients
+ * the recipients for this MailImpl
+ */
+ public void setRecipients(Collection recipients) {
+ this.recipients = recipients;
+ }
+
+ /**
+ * Set the sender of this MailImpl.
+ *
+ * @param sender
+ * the sender of this MailImpl
+ */
+ public void setSender(MailAddress sender) {
+ this.sender = sender;
+ }
+
+ /**
+ * Set the state of this MailImpl.
+ *
+ * @param state
+ * the state of this MailImpl
+ */
+ public void setState(String state) {
+ this.state = state;
+ }
+
+ /**
+ * Set the remote address associated with this MailImpl.
+ *
+ * @param remoteHost
+ * the new remote host associated with this MailImpl
+ */
+ public void setRemoteHost(String remoteHost) {
+ this.remoteHost = remoteHost;
+ }
+
+ /**
+ * Set the remote address associated with this MailImpl.
+ *
+ * @param remoteAddr
+ * the new remote address associated with this MailImpl
+ */
+ public void setRemoteAddr(String remoteAddr) {
+ this.remoteAddr = remoteAddr;
+ }
+
+ /**
+ * Set the date this mail was last updated.
+ *
+ * @param lastUpdated
+ * the date the mail was last updated
+ */
+ public void setLastUpdated(Date lastUpdated) {
+ // Make a defensive copy to ensure that the date
+ // doesn't get changed external to the class
+ if (lastUpdated != null) {
+ lastUpdated = new Date(lastUpdated.getTime());
+ }
+ this.lastUpdated = lastUpdated;
+ }
+
+ /**
+ * Writes the message out to an OutputStream.
+ *
+ * @param out
+ * the OutputStream to which to write the content
+ *
+ * @throws MessagingException
+ * if the MimeMessage is not set for this MailImpl
+ * @throws IOException
+ * if an error occurs while reading or writing from the stream
+ */
+ public void writeMessageTo(OutputStream out) throws IOException,
+ MessagingException {
+ if (message != null) {
+ message.writeTo(out);
+ } else {
+ throw new MessagingException("No message set for this MailImpl.");
+ }
+ }
+
+ /**
+ * Generates a bounce mail that is a bounce of the original message.
+ *
+ * @param bounceText
+ * the text to be prepended to the message to describe the bounce
+ * condition
+ *
+ * @return the bounce mail
+ *
+ * @throws MessagingException
+ * if the bounce mail could not be created
+ */
+ public Mail bounce(String bounceText) throws MessagingException {
+ //This sends a message to the james component that is a bounce of the
+ // sent message
+ MimeMessage original = getMessage();
+ MimeMessage reply = (MimeMessage) original.reply(false);
+ reply.setSubject("Re: " + original.getSubject());
+ Collection recipients = new HashSet();
+ recipients.add(getSender());
+ InternetAddress addr[] = { new InternetAddress(getSender().toString()) };
+ reply.setRecipients(Message.RecipientType.TO, addr);
+ reply.setFrom(new InternetAddress(getRecipients().iterator().next()
+ .toString()));
+ reply.setText(bounceText);
+ reply.setHeader(RFC2822Headers.MESSAGE_ID, "replyTo-" + getName());
+ return new MailImpl("replyTo-" + getName(), new MailAddress(
+ getRecipients().iterator().next().toString()), recipients,
+ reply);
+ }
+
+ /**
+ * Writes the content of the message, up to a total number of lines, out to
+ * an OutputStream.
+ *
+ * @param out
+ * the OutputStream to which to write the content
+ * @param lines
+ * the number of lines to write to the stream
+ *
+ * @throws MessagingException
+ * if the MimeMessage is not set for this MailImpl
+ * @throws IOException
+ * if an error occurs while reading or writing from the stream
+ */
+ public void writeContentTo(OutputStream out, int lines) throws IOException,
+ MessagingException {
+ String line;
+ BufferedReader br;
+ if (message != null) {
+ br = new BufferedReader(new InputStreamReader(message
+ .getInputStream()));
+ while (lines-- > 0) {
+ if ((line = br.readLine()) == null) {
+ break;
+ }
+ line += "\r\n";
+ out.write(line.getBytes());
+ }
+ } else {
+ throw new MessagingException("No message set for this MailImpl.");
+ }
+ }
+
+ // Serializable Methods
+ // TODO: These need some work. Currently very tightly coupled to
+ // the internal representation.
+ /**
+ * Read the MailImpl from an <code>ObjectInputStream</code>.
+ *
+ * @param in
+ * the ObjectInputStream from which the object is read
+ *
+ * @throws IOException
+ * if an error occurs while reading from the stream
+ * @throws ClassNotFoundException ?
+ * @throws ClassCastException
+ * if the serialized objects are not of the appropriate type
+ */
+ private void readObject(java.io.ObjectInputStream in) throws IOException,
+ ClassNotFoundException {
+ try {
+ Object obj = in.readObject();
+ if (obj == null) {