You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by pg...@apache.org on 2002/08/17 20:16:24 UTC
cvs commit: jakarta-james/src/java/org/apache/james/core package.html AvalonMailStore.java AvalonUsersStore.java MailHeaders.java MailImpl.java MailetConfigImpl.java MatcherConfigImpl.java MimeMessageInputStreamSource.java MimeMessageSource.java MimeMessageWrapper.java
pgoldstein 2002/08/17 11:16:24
Modified: src/java/org/apache/james/core AvalonMailStore.java
AvalonUsersStore.java MailHeaders.java
MailImpl.java MailetConfigImpl.java
MatcherConfigImpl.java
MimeMessageInputStreamSource.java
MimeMessageSource.java MimeMessageWrapper.java
Added: src/java/org/apache/james/core package.html
Log:
Added extensive comments.
Minor threading bugfix for access to counter
Changed a couple of RuntimeExceptions to the more specific subclass IllegalStateException
Revision Changes Path
1.13 +119 -12 jakarta-james/src/java/org/apache/james/core/AvalonMailStore.java
Index: AvalonMailStore.java
===================================================================
RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/core/AvalonMailStore.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- AvalonMailStore.java 7 Aug 2002 23:30:16 -0000 1.12
+++ AvalonMailStore.java 17 Aug 2002 18:16:23 -0000 1.13
@@ -28,9 +28,8 @@
import java.util.HashMap;
/**
- * Provides Registry of mail repositories. A mail repository is uniquely
- * identified
- * by destinationURL, type and model.
+ * Provides a registry of mail repositories. A mail repository is uniquely
+ * identified by its destinationURL, type and model.
*
* @author <a href="mailto:fede@apache.org">Federico Barbieri</a>
* @author Darrell DeBoer <dd...@bigdaz.com>
@@ -39,8 +38,13 @@
extends AbstractLogEnabled
implements Contextualizable, Composable, Configurable, Initializable, MailStore {
+ // Prefix for repository names
private static final String REPOSITORY_NAME = "Repository";
+
+ // Static variable used to name individual repositories. Should only
+ // be accessed when a lock on the AvalonMailStore.class is held
private static long id;
+
// map of [destinationURL + type]->Repository
private HashMap repositories;
@@ -50,29 +54,70 @@
// map of [Repository Class]->default config for repository.
private HashMap defaultConfigs;
+ /**
+ * The Avalon context used by the instance
+ */
protected Context context;
+
+ /**
+ * The Avalon configuration used by the instance
+ */
protected Configuration configuration;
+
+ /**
+ * The Avalon component manager used by the instance
+ */
protected ComponentManager componentManager;
private SpoolRepository inboundSpool;
+ /**
+ * Pass the Context to the component.
+ * This method is called after the setLogger()
+ * method and before any other method.
+ *
+ * @param context the context
+ * @throws ContextException if context is invalid
+ */
public void contextualize(final Context context)
throws ContextException {
this.context = context;
}
+ /**
+ * Pass the <code>ComponentManager</code> to the instance.
+ * The instance uses the specified <code>ComponentManager</code> to
+ * acquire the components it needs for execution.
+ *
+ * @param componentManager The <code>ComponentManager</code> which this
+ * <code>Composable</code> uses.
+ * @throws ComponentException if an error occurs
+ */
public void compose( final ComponentManager componentManager )
throws ComponentException
{
this.componentManager = componentManager;
}
+ /**
+ * Pass the <code>Configuration</code> to the instance.
+ *
+ * @param configuration the class configurations.
+ * @throws ConfigurationException if an error occurs
+ */
public void configure( final Configuration configuration )
throws ConfigurationException
{
this.configuration = configuration;
}
+ /**
+ * Initialize the component. Initialization includes
+ * allocating any resources required throughout the
+ * components lifecycle.
+ *
+ * @throws Exception if an error occurs
+ */
public void initialize()
throws Exception {
@@ -103,6 +148,19 @@
}
}
+ /**
+ * <p>Registers a new mail repository type in the mail store's
+ * registry based upon a passed in <code>Configuration</code> object.</p>
+ *
+ * <p>This is presumably synchronized to prevent corruption of the
+ * internal registry.</p>
+ *
+ * @param repConf the Configuration object used to register the
+ * repository
+ *
+ * @throws ConfigurationException if an error occurs accessing the
+ * Configuration object
+ */
public synchronized void registerRepository(Configuration repConf)
throws ConfigurationException {
String className = repConf.getAttribute("class");
@@ -141,13 +199,25 @@
}
}
- public void release(Component component)
- {
- }
-
- public synchronized Component select(Object hint) throws ComponentException
- {
-
+ /**
+ * This method accept a Configuration object as hint and return the
+ * corresponding MailRepository.
+ * The Configuration must be in the form of:
+ * <repository destinationURL="[URL of this mail repository]"
+ * type="[repository type ex. OBJECT or STREAM or MAIL etc.]"
+ * model="[repository model ex. PERSISTENT or CACHE etc.]">
+ * [addition configuration]
+ * </repository>
+ *
+ * @param hint the Configuration object used to look up the repository
+ *
+ * @return the selected repository
+ *
+ * @throws ComponentException if any error occurs while parsing the
+ * Configuration or retrieving the
+ * MailRepository
+ */
+ public synchronized Component select(Object hint) throws ComponentException {
Configuration repConf = null;
try {
repConf = (Configuration) hint;
@@ -262,18 +332,44 @@
}
}
+ /**
+ * <p>Returns a new name for a repository.</p>
+ *
+ * <p>Synchronized on the AvalonMailStore.class object to ensure
+ * against duplication of the repository name</p>
+ *
+ * @return a new repository name
+ */
public static final String getName() {
- return REPOSITORY_NAME + id++;
+ synchronized (AvalonMailStore.class) {
+ return REPOSITORY_NAME + id++;
+ }
}
+ /**
+ * Returns the mail spool associated with this AvalonMailStore
+ *
+ * @return the mail spool
+ *
+ * @throws IllegalStateException if the inbound spool has not
+ * yet been set
+ */
public SpoolRepository getInboundSpool() {
if (inboundSpool != null) {
return inboundSpool;
} else {
- throw new RuntimeException("Inbound spool not defined");
+ throw new IllegalStateException("Inbound spool not defined");
}
}
+ /**
+ * Returns whether the mail store has a repository corresponding to
+ * the passed in hint.
+ *
+ * @param hint the Configuration object used to look up the repository
+ *
+ * @return whether the mail store has a repository corresponding to this hint
+ */
public boolean hasComponent( Object hint ) {
Component comp = null;
try {
@@ -289,6 +385,9 @@
/**
* Copies values from one config into another, overwriting duplicate attributes
* and merging children.
+ *
+ * @param fromConfig the Configuration to be copied
+ * @param toConfig the Configuration to which data is being copied
*/
private void copyConfig(Configuration fromConfig, DefaultConfiguration toConfig)
{
@@ -320,4 +419,12 @@
toConfig.setValue(val);
}
}
+
+ /**
+ * Return the <code>Component</code> when you are finished with it. In this
+ * implementation it does nothing
+ *
+ * @param component The Component we are releasing.
+ */
+ public void release(Component component) {}
}
1.10 +4 -2 jakarta-james/src/java/org/apache/james/core/AvalonUsersStore.java
Index: AvalonUsersStore.java
===================================================================
RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/core/AvalonUsersStore.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- AvalonUsersStore.java 16 Aug 2002 17:10:42 -0000 1.9
+++ AvalonUsersStore.java 17 Aug 2002 18:16:24 -0000 1.10
@@ -34,8 +34,10 @@
extends AbstractLogEnabled
implements Component, Contextualizable, Composable, Configurable, Initializable, UsersStore {
- // A mapping of respository identifiers to actual repositories
- // This mapping is obtained from the component configuration
+ /**
+ * A mapping of respository identifiers to actual repositories
+ * This mapping is obtained from the component configuration
+ */
private HashMap repositories;
/**
1.3 +52 -9 jakarta-james/src/java/org/apache/james/core/MailHeaders.java
Index: MailHeaders.java
===================================================================
RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/core/MailHeaders.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- MailHeaders.java 18 Jan 2002 02:48:35 -0000 1.2
+++ MailHeaders.java 17 Aug 2002 18:16:24 -0000 1.3
@@ -1,11 +1,10 @@
-/*****************************************************************************
- * Copyright (C) The Apache Software Foundation. All rights reserved. *
- * ------------------------------------------------------------------------- *
- * This software is published under the terms of the Apache Software License *
- * version 1.1, a copy of which has been included with this distribution in *
- * the LICENSE file. *
- *****************************************************************************/
-
+/*
+ * Copyright (C) The Apache Software Foundation. All rights reserved.
+ *
+ * This software is published under the terms of the Apache Software License
+ * version 1.1, a copy of which has been included with this distribution in
+ * the LICENSE file.
+ */
package org.apache.james.core;
import javax.mail.MessagingException;
@@ -21,14 +20,38 @@
*/
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);
}
+// TODO: Overloading error. This is extremely dangerous, as the overloaded call
+// does not behave like an overridden call. Specifically, the choice of
+// which method to invoke is made at compile time, not at runtime.
+// Potentially very, very bad if the behaviors diverge.
+
+ /**
+ * Write the headers to an PrintStream
+ *
+ * @param writer the stream to which to write the headers
+ */
public void writeTo(PrintStream writer) {
for (Enumeration e = super.getAllHeaderLines(); e.hasMoreElements(); ) {
writer.println((String) e.nextElement());
@@ -36,23 +59,43 @@
writer.println("");
}
+ /**
+ * Write the headers to an output stream
+ *
+ * @param out the stream to which to write the headers
+ */
public void writeTo(OutputStream out) {
writeTo(new PrintStream(out));
}
+ /**
+ * 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() {
- // Check if MimeMessage contains REQUIRED headers fields as specified in RFC 822.
return (isSet("Date") && isSet("To") && isSet("From"));
}
}
1.13 +270 -53 jakarta-james/src/java/org/apache/james/core/MailImpl.java
Index: MailImpl.java
===================================================================
RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/core/MailImpl.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- MailImpl.java 30 Jul 2002 10:46:50 -0000 1.12
+++ MailImpl.java 17 Aug 2002 18:16:24 -0000 1.13
@@ -22,31 +22,80 @@
import java.util.HashSet;
/**
- * Wrap a MimeMessage adding routing informations (from SMTP) and same simple API.
+ * Wraps a MimeMessage adding routing information (from SMTP) and some simple
+ * API enhancements.
* @author Federico Barbieri <sc...@systemy.it>
* @author Serge Knystautas <se...@lokitech.com>
* @author Stuart Roebuck <st...@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)
+ /**
+ * 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;
@@ -54,6 +103,15 @@
this.recipients = recipients;
}
+ /**
+ * 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);
@@ -62,27 +120,37 @@
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);
}
- public void clean() {
- message = null;
- }
-
+ /**
+ * Duplicate the MailImpl.
+ *
+ * @return a MailImpl that is a duplicate of this one
+ */
public Mail duplicate() {
- try {
- MailImpl newMail = new MailImpl(name, sender, recipients, getMessage());
- newMail.setRemoteHost(remoteHost);
- newMail.setRemoteAddr(remoteAddr);
- newMail.setLastUpdated(lastUpdated);
- return newMail;
- } catch (MessagingException me) {
- }
- return (Mail) null;
+ 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());
@@ -91,46 +159,97 @@
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;
}
@@ -144,6 +263,8 @@
* 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
@@ -164,60 +285,91 @@
return size;
}
- private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
- try {
- Object obj = in.readObject();
- if (obj == null) {
- sender = null;
- } else if (obj instanceof String) {
- sender = new MailAddress((String)obj);
- } else if (obj instanceof MailAddress) {
- sender = (MailAddress)obj;
- }
- } catch (ParseException pe) {
- throw new IOException("Error parsing sender address: " + pe.getMessage());
- }
- recipients = (Collection) in.readObject();
- state = (String) in.readObject();
- errorMessage = (String) in.readObject();
- name = (String) in.readObject();
- remoteHost = (String) in.readObject();
- remoteAddr = (String) in.readObject();
- lastUpdated = (Date) in.readObject();
- }
-
+ /**
+ * 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);
@@ -226,19 +378,16 @@
}
}
- private void writeObject(java.io.ObjectOutputStream out) throws IOException {
- lastUpdated = new Date();
- out.writeObject(sender);
- out.writeObject(recipients);
- out.writeObject(state);
- out.writeObject(errorMessage);
- out.writeObject(name);
- out.writeObject(remoteHost);
- out.writeObject(remoteAddr);
- out.writeObject(lastUpdated);
- }
-
- public Mail bounce(String message) throws MessagingException {
+ /**
+ * 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();
@@ -249,12 +398,22 @@
InternetAddress addr[] = {new InternetAddress(getSender().toString())};
reply.setRecipients(Message.RecipientType.TO, addr);
reply.setFrom(new InternetAddress(getRecipients().iterator().next().toString()));
- reply.setText(message);
+ reply.setText(bounceText);
reply.setHeader("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;
@@ -262,7 +421,9 @@
if(message != null) {
br = new BufferedReader(new InputStreamReader(message.getInputStream()));
while(lines-- > 0) {
- if((line = br.readLine()) == null) break;
+ if((line = br.readLine()) == null) {
+ break;
+ }
line += "\r\n";
out.write(line.getBytes());
}
@@ -270,4 +431,60 @@
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) {
+ sender = null;
+ } else if (obj instanceof String) {
+ sender = new MailAddress((String)obj);
+ } else if (obj instanceof MailAddress) {
+ sender = (MailAddress)obj;
+ }
+ } catch (ParseException pe) {
+ throw new IOException("Error parsing sender address: " + pe.getMessage());
+ }
+ recipients = (Collection) in.readObject();
+ state = (String) in.readObject();
+ errorMessage = (String) in.readObject();
+ name = (String) in.readObject();
+ remoteHost = (String) in.readObject();
+ remoteAddr = (String) in.readObject();
+ setLastUpdated((Date) in.readObject());
+ }
+
+ /**
+ * Write the MailImpl to an <code>ObjectOutputStream</code>.
+ *
+ * @param in the ObjectOutputStream to which the object is written
+ *
+ * @throws IOException if an error occurs while writing to the stream
+ */
+ private void writeObject(java.io.ObjectOutputStream out) throws IOException {
+ lastUpdated = new Date();
+ out.writeObject(sender);
+ out.writeObject(recipients);
+ out.writeObject(state);
+ out.writeObject(errorMessage);
+ out.writeObject(name);
+ out.writeObject(remoteHost);
+ out.writeObject(remoteAddr);
+ out.writeObject(lastUpdated);
+ }
+
}
1.3 +57 -5 jakarta-james/src/java/org/apache/james/core/MailetConfigImpl.java
Index: MailetConfigImpl.java
===================================================================
RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/core/MailetConfigImpl.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- MailetConfigImpl.java 18 Jan 2002 02:48:35 -0000 1.2
+++ MailetConfigImpl.java 17 Aug 2002 18:16:24 -0000 1.3
@@ -15,21 +15,43 @@
import java.util.Iterator;
/**
+ * Implements the configuration object for a Mailet.
*
* @author Serge Knystautas <se...@lokitech.com>
*/
public class MailetConfigImpl implements MailetConfig {
+
+ /**
+ * The mailet MailetContext
+ */
private MailetContext mailetContext;
+
+ /**
+ * The mailet name
+ */
private String name;
+
//This would probably be better.
//Properties params = new Properties();
//Instead, we're tied to the Configuration object
+ /**
+ * The mailet Avalon Configuration
+ */
private Configuration configuration;
- public MailetConfigImpl() {
-
- }
-
+ /**
+ * No argument constructor for this object.
+ */
+ public MailetConfigImpl() {}
+
+ /**
+ * Get the value of an parameter stored in this MailetConfig. Multi-valued
+ * parameters are returned as a comma-delineated string.
+ *
+ * @param name the name of the parameter whose value is to be retrieved.
+ *
+ * @return the parameter value
+ */
public String getInitParameter(String name) {
try {
String result = null;
@@ -53,27 +75,57 @@
}
+ /**
+ * Returns an iterator over the set of configuration parameter names.
+ *
+ * @throws UnsupportedOperationException in all cases, as this is not implemented
+ */
public Iterator getInitParameterNames() {
- throw new RuntimeException("Not yet implemented");
+ throw new UnsupportedOperationException("Not yet implemented");
//return params.keySet().iterator();
}
+ /**
+ * Get the mailet's MailetContext object.
+ *
+ * @return the MailetContext for the mailet
+ */
public MailetContext getMailetContext() {
return mailetContext;
}
+ /**
+ * Get the mailet's Avalon Configuration object.
+ *
+ * @return the Configuration for the mailet
+ */
public void setMailetContext(MailetContext newContext) {
mailetContext = newContext;
}
+ /**
+ * Set the Avalon Configuration object for the mailet.
+ *
+ * @param newConfiguration the new Configuration for the mailet
+ */
public void setConfiguration(Configuration newConfiguration) {
configuration = newConfiguration;
}
+ /**
+ * Get the name of the mailet.
+ *
+ * @return the name of the mailet
+ */
public String getMailetName() {
return name;
}
+ /**
+ * Set the name for the mailet.
+ *
+ * @param newName the new name for the mailet
+ */
public void setMailetName(String newName) {
name = newName;
}
1.4 +47 -1 jakarta-james/src/java/org/apache/james/core/MatcherConfigImpl.java
Index: MatcherConfigImpl.java
===================================================================
RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/core/MatcherConfigImpl.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- MatcherConfigImpl.java 18 Jan 2002 02:48:35 -0000 1.3
+++ MatcherConfigImpl.java 17 Aug 2002 18:16:24 -0000 1.4
@@ -11,35 +11,81 @@
import org.apache.mailet.MatcherConfig;
/**
- * The implementation of the configuration object for a Matcher.
+ * Implements the configuration object for a Matcher.
*
* @author Serge Knystautas <se...@lokitech.com>
*/
public class MatcherConfigImpl implements MatcherConfig {
+
+ /**
+ * A String representation of the value for the matching condition
+ */
private String condition;
+
+ /**
+ * The name of the Matcher
+ */
private String name;
+
+ /**
+ * The MailetContext associated with the Matcher configuration
+ */
private MailetContext context;
+ /**
+ * The simple condition defined for this matcher, e.g., for
+ * SenderIs=admin@localhost, this would return admin@localhost.
+ *
+ * @return a String containing the value of the initialization parameter
+ */
public String getCondition() {
return condition;
}
+ /**
+ * Set the simple condition defined for this matcher configuration.
+ */
public void setCondition(String newCondition) {
condition = newCondition;
}
+ /**
+ * Returns the name of this matcher instance. The name may be provided via server
+ * administration, assigned in the application deployment descriptor, or for
+ * an unregistered (and thus unnamed) matcher instance it will be the matcher's
+ * class name.
+ *
+ * @return the name of the matcher instance
+ */
public String getMatcherName() {
return name;
}
+ /**
+ * Sets the name of this matcher instance.
+ *
+ * @param newName the name of the matcher instance
+ */
public void setMatcherName(String newName) {
name = newName;
}
+ /**
+ * Returns a reference to the MailetContext in which the matcher is executing
+ *
+ * @return a MailetContext object, used by the matcher to interact with its
+ * mailet container
+ */
public MailetContext getMailetContext() {
return context;
}
+ /**
+ * Sets a reference to the MailetContext in which the matcher is executing
+ *
+ * @param newContext a MailetContext object, used by the matcher to interact
+ * with its mailet container
+ */
public void setMailetContext(MailetContext newContext) {
context = newContext;
}
1.7 +31 -4 jakarta-james/src/java/org/apache/james/core/MimeMessageInputStreamSource.java
Index: MimeMessageInputStreamSource.java
===================================================================
RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/core/MimeMessageInputStreamSource.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- MimeMessageInputStreamSource.java 9 Aug 2002 06:01:44 -0000 1.6
+++ MimeMessageInputStreamSource.java 17 Aug 2002 18:16:24 -0000 1.7
@@ -26,9 +26,24 @@
*/
public class MimeMessageInputStreamSource extends MimeMessageSource {
+ /**
+ * A temporary file used to hold the message stream
+ */
File file = null;
+
+ /**
+ * The full path of the temporary file
+ */
String sourceId = null;
+ /**
+ * Construct a new MimeMessageInputStreamSource from an
+ * <code>InputStream</code> that contains the bytes of a
+ * MimeMessage.
+ *
+ * @param key the prefix for the name of the temp file
+ * @param in the stream containing the MimeMessage
+ */
public MimeMessageInputStreamSource(String key, InputStream in) {
//We want to immediately read this into a temporary file
//Create a temp file and channel the input stream into it
@@ -63,31 +78,42 @@
// Ignored - logging unavailable to log this non-fatal error.
}
}
-
-
}
/**
* Returns the unique identifier of this input stream source
+ *
+ * @return the unique identifier for this MimeMessageInputStreamSource
*/
public String getSourceId() {
return sourceId;
}
/**
- * Return an input stream to the data
+ * Get an input stream to retrieve the data stored in the temporary file
+ *
+ * @return a <code>BufferedInputStream</code> containing the data
*/
public synchronized InputStream getInputStream() throws IOException {
return new BufferedInputStream(new FileInputStream(file));
}
/**
- * Return the size of the temp file
+ * Get the size of the temp file
+ *
+ * @return the size of the temp file
+ *
+ * @throws IOException if an error is encoutered while computing the size of the message
*/
public long getMessageSize() throws IOException {
return file.length();
}
+ /**
+ * <p>Finalizer that closes and deletes the temp file. Very bad.</p>
+ * <p>TODO: Should be replaced with a more robust cleanup mechanism</p>
+ *
+ */
public void finalize() {
try {
if (file != null && file.exists()) {
@@ -96,5 +122,6 @@
} catch (Exception e) {
//ignore
}
+ file = null;
}
}
1.7 +14 -4 jakarta-james/src/java/org/apache/james/core/MimeMessageSource.java
Index: MimeMessageSource.java
===================================================================
RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/core/MimeMessageSource.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- MimeMessageSource.java 9 Aug 2002 06:01:44 -0000 1.6
+++ MimeMessageSource.java 17 Aug 2002 18:16:24 -0000 1.7
@@ -19,20 +19,30 @@
*/
public abstract class MimeMessageSource {
/**
- * Returns a unique String ID that represents where this file is loaded
- * from. This will be used to identify where the data is, primarily to
- * avoid situations where this data would get overwritten.
+ * Returns a unique String ID that represents the location from where
+ * this file is loaded. This will be used to identify where the data
+ * is, primarily to avoid situations where this data would get overwritten.
+ *
+ * @return the String ID
*/
public abstract String getSourceId();
/**
- * Return an input stream to the data
+ * Get an input stream to retrieve the data stored in the datasource
+ *
+ * @return a <code>InputStream</code> containing the data
+ *
+ * @throws IOException if an error occurs while generating the
+ * InputStream
*/
public abstract InputStream getInputStream() throws IOException;
/**
* Return the size of all the data.
* Default implementation... others can override to do this much faster
+ *
+ * @return the size of the data represented by this source
+ * @throws IOException if an error is encountered while computing the message size
*/
public long getMessageSize() throws IOException {
int size = 0;
1.12 +12 -3 jakarta-james/src/java/org/apache/james/core/MimeMessageWrapper.java
Index: MimeMessageWrapper.java
===================================================================
RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/core/MimeMessageWrapper.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- MimeMessageWrapper.java 7 Aug 2002 23:30:16 -0000 1.11
+++ MimeMessageWrapper.java 17 Aug 2002 18:16:24 -0000 1.12
@@ -46,6 +46,12 @@
*/
RFC822DateFormat mailDateFormat = new RFC822DateFormat();
+ /**
+ * A constructor that instantiates a MimeMessageWrapper based on
+ * a MimeMessageSource
+ *
+ * @param source the MimeMessageSource
+ */
public MimeMessageWrapper(MimeMessageSource source) {
super(javax.mail.Session.getDefaultInstance(System.getProperties(), null));
this.source = source;
@@ -136,7 +142,9 @@
/**
- * Special methods you can call
+ * Get whether the message has been modified.
+ *
+ * @return whether the message has been modified
*/
public boolean isModified() {
return modified;
@@ -251,7 +259,6 @@
/**
* Various reader methods
*/
-
public Address[] getFrom() throws MessagingException {
if (headers == null) {
loadHeaders();
@@ -599,7 +606,9 @@
/**
- * Writes content only, ie not headers, to the specified outputstream.
+ * Writes content only, ie not headers, to the specified OutputStream.
+ *
+ * @param outs the OutputStream to which the content is written
*/
public void writeContentTo(OutputStream outs)
throws java.io.IOException, MessagingException {
1.1 jakarta-james/src/java/org/apache/james/core/package.html
Index: package.html
===================================================================
<body>
<p>Implementations of core James services and concepts.</p>
</body>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>