cziegeler 2004/07/22 08:12:45
Modified: src/blocks/mail/java/org/apache/cocoon/mail/transformation
SendMailTransformer.java
Log:
Make implementation match with docs and cleanup code
Revision Changes Path
1.13 +21 -17
cocoon-2.1/src/blocks/mail/java/org/apache/cocoon/mail/transformation/SendMailTransformer.java
Index: SendMailTransformer.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/mail/java/org/apache/cocoon/mail/transformation/SendMailTransformer.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- SendMailTransformer.java 22 Jul 2004 15:03:31 -0000 1.12
+++ SendMailTransformer.java 22 Jul 2004 15:12:44 -0000 1.13
@@ -39,9 +39,9 @@
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
-import org.apache.avalon.excalibur.pool.Recyclable;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.parameters.ParameterException;
-import org.apache.avalon.framework.parameters.Parameterizable;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.environment.SourceResolver;
@@ -173,8 +173,8 @@
* @version CVS $Id$
*
*/
-public class SendMailTransformer extends AbstractSAXTransformer
- implements Parameterizable, Recyclable {
+public class SendMailTransformer extends AbstractSAXTransformer {
+
/*
* constants, related to elements in configuration-file
*/
@@ -231,8 +231,11 @@
protected int port;
protected String contextPath;
protected boolean sendPartial;
- protected Message smtpMessage = null;
+ protected Message smtpMessage;
+ protected String defaultSmtpHost;
+ protected String defaultFromAddress;
+
/**
* create a new Transformer
*/
@@ -240,6 +243,16 @@
this.defaultNamespaceURI = NAMESPACE;
}
+ /* (non-Javadoc)
+ * @see
org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
+ */
+ public void configure(Configuration configuration)
+ throws ConfigurationException {
+ super.configure(configuration);
+ this.defaultSmtpHost =
configuration.getChild("smtphost").getValue("");
+ this.defaultFromAddress =
configuration.getChild("from").getValue("");
+ }
+
/**
* invoked every time when the transformer is triggered by the pipeline
*/
@@ -247,8 +260,8 @@
Parameters par)
throws ProcessingException, SAXException, IOException {
super.setup(resolver, objectModel, src, par);
- this.mailHost = par.getParameter(PARAM_SMTPHOST, "");
- this.fromAddress = par.getParameter(PARAM_FROM, "");
+ this.mailHost = par.getParameter(PARAM_SMTPHOST,
this.defaultSmtpHost);
+ this.fromAddress = par.getParameter(PARAM_FROM,
this.defaultFromAddress);
this.port = this.request.getServerPort();
this.contextPath = this.request.getContextPath();
this.sendPartial = par.getParameterAsBoolean(PARAM_SENDPARTIAL,
true);
@@ -272,15 +285,6 @@
} catch (ParameterException pe) {
this.getLogger().debug("Parameter <body> not set.");
}
-
- this.defaultNamespaceURI = NAMESPACE;
- }
-
- /**
- * invoked initially
- */
- public void parameterize(Parameters parameters) throws
ParameterException {
- // nothing to do by now
}
/**