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 ch...@apache.org on 2001/06/21 18:04:55 UTC
cvs commit: jakarta-james/src/java/org/apache/james/transport/mailets RemoteDelivery.java ToRepository.java
charlesb 01/06/21 09:04:55
Modified: src/conf james-config.xml
src/java/org/apache/james James.java
src/java/org/apache/james/core AvalonMailStore.java
src/java/org/apache/james/transport JamesSpoolManager.java
src/java/org/apache/james/transport/mailets
RemoteDelivery.java ToRepository.java
Log:
Removed model attribute for mail/spool repositories
Revision Changes Path
1.5 +8 -29 jakarta-james/src/conf/james-config.xml
Index: james-config.xml
===================================================================
RCS file: /home/cvs/jakarta-james/src/conf/james-config.xml,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- james-config.xml 2001/06/19 16:00:38 1.4
+++ james-config.xml 2001/06/21 16:04:49 1.5
@@ -13,8 +13,8 @@
CONFIRM? comment in the left
margin.
- This is $Revision: 1.4 $
- Committed on $Date: 2001/06/19 16:00:38 $ by: $Author: charlesb $
+ This is $Revision: 1.5 $
+ Committed on $Date: 2001/06/21 16:04:49 $ by: $Author: charlesb $
-->
<config>
@@ -69,16 +69,14 @@
(ex. file://c:/james/spool/) -->
<spoolRepository>
<repository destinationURL="file://var/mail/spool/"
- type="SPOOL"
- model="SYNCHRONOUS">
+ type="SPOOL">
</repository>
</spoolRepository>
<!-- Alternative spool repository definition for Town use
<spoolRepository>
<repository destinationURL="town://mainspool"
- type="SPOOL"
- model="SYNCHRONOUS">
+ type="SPOOL">
<conn>file:///dev/james/dist/var/maildatabase</conn>
<table>Message</table>
</repository>
@@ -88,16 +86,14 @@
<!-- The inbox repository is the location for users inboxes -->
<inboxRepository>
<repository destinationURL="file://var/mail/inboxes/"
- type="MAIL"
- model="SYNCHRONOUS">
+ type="MAIL">
</repository>
</inboxRepository>
<!-- Alternative inbox repository definition for Town use
<inboxRepository>
<repository destinationURL="town://inbox"
- type="SPOOL"
- model="SYNCHRONOUS">
+ type="SPOOL">
<conn>file:///dev/james/dist/var/maildatabase</conn>
<table>Message</table>
</repository>
@@ -114,16 +110,14 @@
to add and process same messages. -->
<spoolRepository>
<repository destinationURL="file://var/mail/spool/"
- type="SPOOL"
- model="SYNCHRONOUS">
+ type="SPOOL">
</repository>
</spoolRepository>
<!-- Alternative spool repository definition for Town use
<spoolRepository>
<repository destinationURL="town://mainspool"
- type="SPOOL"
- model="SYNCHRONOUS">
+ type="SPOOL">
<conn>file:///dev/james/dist/../../store/maildatabase</conn>
<table>Message</table>
</repository>
@@ -461,11 +455,6 @@
<types>
<type>MAIL</type>
</types>
- <models>
- <model>SYNCHRONOUS</model>
- <model>ASYNCHRONOUS</model>
- <model>CACHE</model>
- </models>
</repository>
<repository
class="org.apache.james.mailrepository.AvalonSpoolRepository">
@@ -475,11 +464,6 @@
<types>
<type>SPOOL</type>
</types>
- <models>
- <model>SYNCHRONOUS</model>
- <model>ASYNCHRONOUS</model>
- <model>CACHE</model>
- </models>
</repository>
<repository
@@ -491,11 +475,6 @@
<type>SPOOL</type>
<type>MAIL</type>
</types>
- <models>
- <model>SYNCHRONOUS</model>
- <model>ASYNCHRONOUS</model>
- <model>CACHE</model>
- </models>
</repository>
</repositories>
</mailstore>
1.4 +15 -12 jakarta-james/src/java/org/apache/james/James.java
Index: James.java
===================================================================
RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/James.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- James.java 2001/06/11 09:29:25 1.3
+++ James.java 2001/06/21 16:04:50 1.4
@@ -52,20 +52,22 @@
* @author Federico Barbieri <sc...@pop.systemy.it>
* @author Serge
* @author <a href="mailto:charles@benett1.demon.co.uk">Charles Benett</a>
+ *
+ * This is $Revision: 1.4 $
+ * Committed on $Date: 2001/06/21 16:04:50 $ by: $Author: charlesb $
*/
public class James
extends AbstractLoggable
- implements Block, Contextualizable, Composable, Configurable, Initializable,
- MailServer, MailetContext {
+ implements Block, Contextualizable, Composable, Configurable,
+ Initializable, MailServer, MailetContext {
- public final static String VERSION = "James 1.2.2 Alpha";
+ public final static String VERSION = "James 1.2.2 Alpha"; // FIX!
private DefaultComponentManager compMgr; //Components shared
private DefaultContext context;
private Configuration conf;
private Logger mailetLogger = null;
- //private ThreadPool workerPool;
private MailStore mailstore;
private UsersStore usersStore;
private SpoolRepository spool;
@@ -102,10 +104,10 @@
}
/**
- * Override compose method of AbstractBlock to create new ComponentManager object
+ * Override compose method of AbstractBlock to create new
+ * ComponentManager object
*/
public void compose(ComponentManager comp) {
- //throws ConfigurationException {
compMgr = new DefaultComponentManager(comp);
mailboxes = new HashMap(31);
}
@@ -114,17 +116,19 @@
getLogger().info("JAMES init...");
- //TODO: This should retrieve a more specific named thread pool from BlockContext
- //that is set up in server.xml
- //workerPool = blockContext.getThreadPool( "default" );
+ // TODO: This should retrieve a more specific named thread pool from
+ // BlockContext that is set up in server.xml
+ // workerPool = blockContext.getThreadPool( "default" );
try {
- mailstore = (MailStore) compMgr.lookup("org.apache.james.services.MailStore");
+ mailstore = (MailStore) compMgr.lookup(
+ "org.apache.james.services.MailStore");
} catch (Exception e) {
getLogger().warn("Can't get Store: " + e);
}
getLogger().debug("Using MailStore: " + mailstore.toString());
try {
- usersStore = (UsersStore) compMgr.lookup("org.apache.james.services.UsersStore");
+ usersStore = (UsersStore) compMgr.lookup(
+ "org.apache.james.services.UsersStore");
} catch (Exception e) {
getLogger().warn("Can't get Store: " + e);
}
@@ -372,7 +376,6 @@
= new DefaultConfiguration("repository", "generated:AvalonFileRepository.compose()");
mboxConf.setAttribute("destinationURL", destination);
mboxConf.setAttribute("type", "MAIL");
- mboxConf.setAttribute("model", "SYNCHRONOUS");
try {
userInbox = (MailRepository) mailstore.select(mboxConf);
mailboxes.put(userName, userInbox);
1.2 +23 -37 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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AvalonMailStore.java 2001/05/11 09:15:42 1.1
+++ AvalonMailStore.java 2001/06/21 16:04:51 1.2
@@ -31,7 +31,8 @@
*
* @author <a href="mailto:fede@apache.org">Federico Barbieri</a>
*
- * Provides Registry of mail repositories. A mail repository is uniquely identified
+ * Provides Registry of mail repositories. A mail repository is uniquely
+ * identified
* by destinationURL, type and model.
*/
public class AvalonMailStore
@@ -42,9 +43,8 @@
private static long id;
// map of [destinationURL + type]->Repository
private HashMap repositories;
- // map of [destinationURL + type]->model
- private HashMap models;
- // map of [protocol(destinationURL) + type + model]->classname of repository;
+
+ // map of [protocol(destinationURL) + type ]->classname of repository;
private HashMap classes;
protected Configuration configuration;
protected ComponentManager componentManager;
@@ -66,7 +66,6 @@
getLogger().info("JamesMailStore init...");
repositories = new HashMap();
- models = new HashMap();
classes = new HashMap();
Configuration[] registeredClasses
= configuration.getChild("repositories").getChildren("repository");
@@ -84,8 +83,6 @@
Configuration[] protocols
= repConf.getChild("protocols").getChildren("protocol");
Configuration[] types = repConf.getChild("types").getChildren("type");
- Configuration[] models
- = repConf.getChild("models").getChildren("model");
for ( int i = 0; i < protocols.length; i++ )
{
String protocol = protocols[i].getValue();
@@ -93,14 +90,9 @@
for ( int j = 0; j < types.length; j++ )
{
String type = types[j].getValue();
-
- for ( int k = 0; k < models.length; k++ )
- {
- String model = models[k].getValue();
- String key = protocol + type + model;
- classes.put(key, className);
- getLogger().info("Registered class: " + key+"->"+className);
- }
+ String key = protocol + type ;
+ classes.put(key, className);
+ getLogger().info("Registered class: " + key+"->"+className);
}
}
}
@@ -116,7 +108,8 @@
try {
repConf = (Configuration) hint;
} catch (ClassCastException cce) {
- throw new ComponentException("hint is of the wrong type. Must be a Configuration", cce);
+ throw new ComponentException(
+ "hint is of the wrong type. Must be a Configuration", cce);
}
String destination = null;
String protocol = null;
@@ -124,11 +117,13 @@
destination = repConf.getAttribute("destinationURL");
int idx = destination.indexOf(':');
if ( idx == -1 )
- throw new ComponentException
- ("destination is malformed. Must be a valid URL: "+destination);
+ throw new ComponentException(
+ "destination is malformed. Must be a valid URL: "
+ + destination);
protocol = destination.substring(0,idx);
} catch (ConfigurationException ce) {
- throw new ComponentException("Malformed configuration has no destinationURL attribute", ce);
+ throw new ComponentException(
+ "Malformed configuration has no destinationURL attribute", ce);
}
try
@@ -136,22 +131,19 @@
String type = repConf.getAttribute("type");
String repID = destination + type;
MailRepository reply = (MailRepository) repositories.get(repID);
- String model = (String) repConf.getAttribute("model");
if (reply != null) {
- if (models.get(repID).equals(model)) {
- getLogger().debug("obtained repository: "+repID+","+reply.getClass());
- return (Component)reply;
- } else {
- throw new ComponentException("There is already another repository with the same destination and type but with different model");
- }
+ getLogger().debug("obtained repository: " + repID
+ + "," + reply.getClass());
+ return (Component)reply;
} else {
- String repClass = (String) classes.get( protocol + type + model );
+ String repClass = (String) classes.get( protocol + type );
getLogger().debug( "Need instance of " + repClass +
- " to handle: " + protocol + "," + type + "," +model );
+ " to handle: " + protocol + "," + type );
try {
- reply = (MailRepository) Class.forName(repClass).newInstance();
+ reply
+ = (MailRepository) Class.forName(repClass).newInstance();
if (reply instanceof Loggable) {
setupLogger(reply);
}
@@ -161,25 +153,19 @@
if (reply instanceof Composable) {
((Composable) reply).compose( componentManager );
}
-/* if (reply instanceof Contextualizable) {
- ((Contextualizable) reply).contextualize(context);
- }*/
if (reply instanceof Initializable) {
((Initializable) reply).initialize();
}
repositories.put(repID, reply);
- models.put(repID, model);
getLogger().info("added repository: "+repID+"->"+repClass);
- /* getLogger().info( "New instance of " + repClass +
- * " created for " + destination );
- */
return (Component)reply;
} catch (Exception e) {
getLogger().warn( "Exception while creating repository:" +
e.getMessage(), e );
throw new
- ComponentException( "Cannot find or init repository", e );
+ ComponentException("Cannot find or init repository",
+ e);
}
}
} catch( final ConfigurationException ce ) {
1.2 +65 -36 jakarta-james/src/java/org/apache/james/transport/JamesSpoolManager.java
Index: JamesSpoolManager.java
===================================================================
RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/transport/JamesSpoolManager.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- JamesSpoolManager.java 2001/05/11 10:36:19 1.1
+++ JamesSpoolManager.java 2001/06/21 16:04:52 1.2
@@ -34,10 +34,14 @@
/**
* @author Serge Knystautas <se...@lokitech.com>
* @author Federico Barbieri <sc...@systemy.it>
+ *
+ * This is $Revision: 1.2 $
+ * Committed on $Date: 2001/06/21 16:04:52 $ by: $Author: charlesb $
*/
public class JamesSpoolManager
extends AbstractLoggable
- implements Composable, Configurable, Initializable, Runnable, Disposable, Contextualizable, Block {
+ implements Contextualizable, Composable, Configurable, Initializable,
+ Runnable, Disposable, Block {
private DefaultComponentManager compMgr;
//using implementation as we need put method.
@@ -70,17 +74,18 @@
workerPool = blockContext.getThreadPool( "default" );
Configuration spoolConf = conf.getChild("spoolRepository");
Configuration spoolRepConf = spoolConf.getChild("repository");
- MailStore mailstore = (MailStore) compMgr.lookup("org.apache.james.services.MailStore");
+ MailStore mailstore
+ = (MailStore) compMgr.lookup("org.apache.james.services.MailStore");
try {
this.spool = (SpoolRepository) mailstore.select(spoolRepConf);
} catch (Exception e) {
getLogger().error("Cannot open private SpoolRepository");
throw e;
}
- getLogger().info("Private SpoolRepository Spool opened: "+spool.hashCode());
- //compMgr.put("org.apache.james.services.SpoolRepository", (Component)spool);
- //spool = (SpoolRepository) compMgr.lookup("org.apache.james.services.SpoolRepository");
- mailetcontext = (MailetContext) compMgr.lookup("org.apache.mailet.MailetContext");
+ getLogger().info("Private SpoolRepository Spool opened: "
+ + spool.hashCode());
+ mailetcontext
+ = (MailetContext) compMgr.lookup("org.apache.mailet.MailetContext");
MailetLoader mailetLoader = new MailetLoader();
MatchLoader matchLoader = new MatchLoader();
try {
@@ -90,7 +95,8 @@
compMgr.put(Resources.MATCH_LOADER, matchLoader);
} catch (ConfigurationException ce) {
final String message =
- "Unable to configure mailet/matcher Loaders: " + ce.getMessage();
+ "Unable to configure mailet/matcher Loaders: "
+ + ce.getMessage();
getLogger().error( message, ce );
throw new RuntimeException( message );
}
@@ -110,16 +116,18 @@
processor.initialize();
processors.put(processorName, processor);
- //If this is the root processor, add the PostmasterAlias mailet silently
- // to the top
+ // If this is the root processor, add the PostmasterAlias
+ // mailet silently to the top
if (processorName.equals("root")) {
- Matcher matcher = matchLoader.getMatcher("All", mailetcontext);
- Mailet mailet =
- mailetLoader.getMailet("PostmasterAlias", mailetcontext, null);
+ Matcher matcher = matchLoader.getMatcher("All",
+ mailetcontext);
+ Mailet mailet = mailetLoader.getMailet("PostmasterAlias",
+ mailetcontext, null);
processor.add(matcher, mailet);
}
- final Configuration[] mailetConfs = processorConf.getChildren( "mailet" );
+ final Configuration[] mailetConfs
+ = processorConf.getChildren( "mailet" );
for ( int j = 0; j < mailetConfs.length; j++ )
{
Configuration c = mailetConfs[j];
@@ -128,20 +136,26 @@
Mailet mailet = null;
Matcher matcher = null;
try {
- matcher = matchLoader.getMatcher(matcherName, mailetcontext);
+ matcher = matchLoader.getMatcher(matcherName,
+ mailetcontext);
//The matcher itself should log that it's been inited.
- getLogger().info("Matcher " + matcherName + " instantiated");
+ getLogger().info("Matcher " + matcherName
+ + " instantiated");
} catch (MessagingException ex) {
// **** Do better job printing out exception
- getLogger().error( "Unable to init matcher " + matcherName + ": " + ex.toString(), ex );
+ getLogger().error( "Unable to init matcher "
+ + matcherName + ": " + ex.toString(), ex );
throw ex;
}
try {
- mailet = mailetLoader.getMailet(mailetClassName, mailetcontext, c);
- getLogger().info("Mailet " + mailetClassName + " instantiated");
+ mailet = mailetLoader.getMailet(mailetClassName,
+ mailetcontext, c);
+ getLogger().info("Mailet " + mailetClassName
+ + " instantiated");
} catch (MessagingException ex) {
// **** Do better job printing out exception
- getLogger().error("Unable to init mailet " + mailetClassName + ": " + ex.getMessage());
+ getLogger().error("Unable to init mailet "
+ + mailetClassName + ": " + ex.getMessage());
throw ex;
}
//Add this pair to the proces
@@ -151,15 +165,18 @@
//Loop through all mailets within processor initializing them
//Add a Null mailet with All matcher to the processor
- // this is so if a message gets to the end of a processor, it will always be
- // ghosted
+ // this is so if a message gets to the end of a processor,
+ // it will always be ghosted
Matcher matcher = matchLoader.getMatcher("All", mailetcontext);
- Mailet mailet = mailetLoader.getMailet("Null", mailetcontext, null);
+ Mailet mailet
+ = mailetLoader.getMailet("Null", mailetcontext, null);
processor.add(matcher, mailet);
- getLogger().info("processor " + processorName + " instantiated");
+ getLogger().info("processor " + processorName
+ + " instantiated");
} catch (Exception ex) {
- getLogger().error("Unable to init processor " + processorName + ": " + ex.getMessage());
+ getLogger().error("Unable to init processor " + processorName
+ + ": " + ex.getMessage());
throw ex;
}
}
@@ -169,25 +186,30 @@
}
/**
- * This routinely checks the message spool for messages, and processes them as necessary
+ * This routinely checks the message spool for messages, and processes
+ * them as necessary
*/
public void run() {
- getLogger().info("run JamesSpoolManager: "+Thread.currentThread().getName());
+ getLogger().info("run JamesSpoolManager: "
+ + Thread.currentThread().getName());
getLogger().info("spool="+spool.getClass().getName());
while(true) {
try {
String key = spool.accept();
MailImpl mail = spool.retrieve(key);
- getLogger().info("==== Begin processing mail " + mail.getName() + " ====");
+ getLogger().info("==== Begin processing mail "
+ + mail.getName() + " ====");
process(mail);
spool.remove(key);
- getLogger().info("==== Removed from spool mail " + mail.getName() + " ====");
+ getLogger().info("==== Removed from spool mail "
+ + mail.getName() + " ====");
mail = null;
} catch (Exception e) {
e.printStackTrace();
- getLogger().error("Exception in JamesSpoolManager.run " + e.getMessage());
+ getLogger().error("Exception in JamesSpoolManager.run "
+ + e.getMessage());
}
}
}
@@ -200,19 +222,25 @@
while (true) {
String processorName = mail.getState();
try {
- LinearProcessor processor = (LinearProcessor)processors.get(processorName);
+ LinearProcessor processor
+ = (LinearProcessor)processors.get(processorName);
if (processor == null) {
- throw new MailetException("Unable to find processor " + processorName);
+ throw new MailetException("Unable to find processor "
+ + processorName);
}
- getLogger().info("Processing " + mail.getName() + " through " + processorName);
+ getLogger().info("Processing " + mail.getName() + " through "
+ + processorName);
processor.service(mail);
return;
} catch (Exception e) {
- //This is a strange error situation that shouldn't ordinarily happen
- System.err.println("Exception in processor <" + processorName + ">");
+ // This is a strange error situation that shouldn't ordinarily
+ // happen
+ System.err.println("Exception in processor <" + processorName
+ + ">");
e.printStackTrace();
if (processorName.equals(Mail.ERROR)) {
- //We got an error on the error processor... kill the message
+ // We got an error on the error processor...
+ // kill the message
mail.setState(Mail.GHOST);
mail.setErrorMessage(e.getMessage());
} else {
@@ -221,7 +249,8 @@
mail.setErrorMessage(e.getMessage());
}
}
- getLogger().info("Processed " + mail.getName() + " through " + processorName);
+ getLogger().info("Processed " + mail.getName() + " through "
+ + processorName);
getLogger().info("Result was " + mail.getState());
}
1.5 +3 -2 jakarta-james/src/java/org/apache/james/transport/mailets/RemoteDelivery.java
Index: RemoteDelivery.java
===================================================================
RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/transport/mailets/RemoteDelivery.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- RemoteDelivery.java 2001/06/16 17:10:03 1.4
+++ RemoteDelivery.java 2001/06/21 16:04:53 1.5
@@ -44,6 +44,9 @@
*
* @author Serge Knystautas <se...@lokitech.com>
* @author Federico Barbieri <sc...@pop.systemy.it>
+ *
+ * This is $Revision: 1.5 $
+ * Committed on $Date: 2001/06/21 16:04:53 $ by: $Author: charlesb $
*/
public class RemoteDelivery extends GenericMailet implements Runnable {
@@ -79,8 +82,6 @@
= new DefaultConfiguration("repository", "generated:RemoteDelivery.java");
spoolConf.setAttribute("destinationURL", outgoingPath);
spoolConf.setAttribute("type", "SPOOL");
- spoolConf.setAttribute("model", "SYNCHRONOUS");
-
outgoing = (SpoolRepository) mailstore.select(spoolConf);
} catch (ComponentException cnfe) {
log("Failed to retrieve Store component:" + cnfe.getMessage());
1.3 +3 -2 jakarta-james/src/java/org/apache/james/transport/mailets/ToRepository.java
Index: ToRepository.java
===================================================================
RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/transport/mailets/ToRepository.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ToRepository.java 2001/06/06 13:18:26 1.2
+++ ToRepository.java 2001/06/21 16:04:54 1.3
@@ -25,6 +25,9 @@
* the pipe. If false will be destroyed.
* @version 1.0.0, 24/04/1999
* @author Federico Barbieri <sc...@pop.systemy.it>
+ *
+ * This is $Revision: 1.3 $
+ * Committed on $Date: 2001/06/21 16:04:54 $ by: $Author: charlesb $
*/
public class ToRepository extends GenericMailet {
@@ -46,8 +49,6 @@
= new DefaultConfiguration("repository", "generated:ToRepository");
mailConf.setAttribute("destinationURL", repositoryPath);
mailConf.setAttribute("type", "MAIL");
- mailConf.setAttribute("model", "SYNCHRONOUS");
-
repository = (MailRepository) mailstore.select(mailConf);
} catch (ComponentException cnfe) {
log("Failed to retrieve Store component:" + cnfe.getMessage());
---------------------------------------------------------------------
To unsubscribe, e-mail: james-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: james-dev-help@jakarta.apache.org