Java Doc for SendMailTransformer.java in  » Content-Management-System » apache-lenya-2.0 » org » apache » cocoon » mail » transformation » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Content Management System » apache lenya 2.0 » org.apache.cocoon.mail.transformation 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.apache.cocoon.transformation.AbstractSAXTransformer
   org.apache.cocoon.mail.transformation.SendMailTransformer

SendMailTransformer
public class SendMailTransformer extends AbstractSAXTransformer (Code)
The SendMailTransformer send mails with optional attachments using a SMTP server and delivers furthermore a status report of each sent mail.

The SendMailTransformer requires the Sun's JavaMail API implementation. Please download and copy the following files to the Cocoon lib directory:

  • mail.jar from http://java.sun.com/products/javamail/
  • activation.jar from http://java.sun.com/products/javabeans/glasgow/jaf.html
  • Use the following sitemap component declaration to define, configure and parameterize the transformer. in the map:sitemap/map:components/map:transformers:

     <map:transformer name="sendmail" src="org.apache.cocoon.mail.transformation.SendMailTransformer">
     <smtphost>smtp.foo.com</smtphost>
     <from>sender@localhost</from>
     </map:transformer>
     
    where
    • <smtphost> is the SMTP server host name, e.g. smtp.foo.com
    • <from> is the sender e-mail address

    Furthermore, these parameters can be defined in the sitemap pipeline section:

    • smtphost, from - If they are defined, this values overwrite the values from component section described above.
    • to - email addresses of recipients e.g.: <map:parameter name="to" value="customer1@target.com,customer2@target.com"/>
    • subject - a string, can also come from an input module e.g.; <map:parameter name="subject" value="{request-param:subject}"/>
    • body - a string, can also come from an input module e.g.; <map:parameter name="body" value="{request-param:body}"/>
    • sendpartial - a boolean, define how to send the mails. When mail is being send to more than one recipient and the parameter is set to false, then all email addresses will appear concatenated in the address field at the mail client of the recipient. The default is true.

    More configurations can be made in a specific configuration file, which can be retrieved with a generator as the input document. The input document should have the following configuration entities:

    • <email:smtphost>, <email:from> and <email:subject> can be set to overwrite values from the sitemap
    • <email:to> - each entry will be append to the list of email addresses
    • <email:body> - Overwrites the value from the sitemap. If there is a src attribute, the transformer will try to retrieve the file and place it instead of a text-string as the mail body.
    • <email:attachment> - each entry defines a attachment. The attribute name defines the name of the attachment. The mime-type attribute defines the content of the attachment. If there is a nested <email:content> - element, text can be included and the attachment will then be a plain text-file. Is there a url attribute, the transformer tries to retrieve the appropriate file and handle it as an attachment. To use a file as an attachment, retrieved over a protocol like http or cocoon, use the src attribute.

    Input document sample:

     <?xml version="1.0" encoding="UTF-8"?>
     <document xmlns:email="http://apache.org/cocoon/transformation/sendmail">
     <email:sendmail>
     <email:smtphost>hostname.company.com</email:smtphost>
     <email:from>info@company.com</email:from>
     <email:to>customer3@target.com</email:to>
     <email:to>customer4@target.com</email:to>
     <email:to>customer5@target.com</email:to>
     <email:to>customer6@target.com</email:to>
     <email:subject>subject-content</email:subject>
     <email:body src="cocoon:/softwareupdate.html?locale=en&country=UK"/>
     <!-- <email:body>some Text</email:body> -->
     <email:attachment name="hello.html" mime-type="text/html">
     <email:content>
     Dear Customer, please visit out new Product-Shop.
     </email:content>
     </email:attachment>
     <email:attachment name="hello2.html" mime-type="text/html" src="cocoon:/src1"/>
     <email:attachment name="hello3.html" mime-type="text/html"
     url="C:\path\softwareupdate.html"/>
     <email:attachment name="hello.gif" mime-type="image/gif"
     url="c:\path\powered.gif"/>
     </email:sendmail>
     </document>
     

    After the transformation a report will be generated, where the state for each sent mail can be seen. In case of an exception, the exception-message and a stacktrace will be reported.

    FIXME: Known Issues:


    author:
       Peter Klassen
    version:
       $Id: SendMailTransformer.java 525980 2007-04-05 22:18:04Z hepabolu $

Inner Class :static class AttachmentDescriptor
Inner Class :static class AddressHandler

Field Summary
final public static  StringDEFAULT_BODY_MIMETYPE
    
final public static  StringELEMENT_ATTACHMENT
    
final public static  StringELEMENT_ATTACHMENT_CONTENT
    
final public static  StringELEMENT_EMAIL_PREFIX
    
final public static  StringELEMENT_ERROR
    
final public static  StringELEMENT_FAILURE
    
final public static  StringELEMENT_MAILBODY
    
final public static  StringELEMENT_MAILFROM
    
final public static  StringELEMENT_MAILSUBJECT
    
final public static  StringELEMENT_MAILTO
    
final public static  StringELEMENT_REPLYTO
    
final public static  StringELEMENT_RESULT
    
final public static  StringELEMENT_SENDMAIL
    
final public static  StringELEMENT_SMTPHOST
    
final public static  StringELEMENT_SMTPPORT
    
final public static  StringELEMENT_SUCCESS
    
final protected static  intMODE_ATTACHMENT
    
final protected static  intMODE_ATTACHMENT_CONTENT
    
final protected static  intMODE_BODY
    
final protected static  intMODE_FROM
    
final protected static  intMODE_NONE
    
final protected static  intMODE_REPLY_TO
    
final protected static  intMODE_SMTPHOST
    
final protected static  intMODE_SMTPPORT
    
final protected static  intMODE_SUBJECT
    
final protected static  intMODE_TO
    
final public static  StringNAMESPACE
    
final public static  StringPARAM_BODY
    
final public static  StringPARAM_FROM
    
final public static  StringPARAM_REPLY_TO
    
final public static  StringPARAM_SENDPARTIAL
    
final public static  StringPARAM_SMTPHOST
    
final public static  StringPARAM_SMTPPORT
    
final public static  StringPARAM_SUBJECT
    
final public static  StringPARAM_TO
    
protected  AttachmentDescriptorattachmentDescriptor
    
protected  Listattachments
    
protected  Stringbody
    
protected  StringbodyMimeType
    
protected  StringbodyURI
    
protected  StringcontextPath
    
protected  StringdefaultFromAddress
    
protected  ListdefaultReplyToAddresses
    
protected  StringdefaultSmtpHost
    
protected  intdefaultSmtpPort
    
protected  ListdefaultToAddresses
    
protected  StringfromAddress
    
protected  StringmailHost
    
protected  intmailPort
    
protected  intmode
    
protected  intport
    
protected  ListreplyToAddresses
    
protected  booleansendPartial
    
protected  MessagesmtpMessage
    
protected  Stringsubject
    
protected  ListtoAddresses
    
protected  ListusedSources
    

Constructor Summary
public  SendMailTransformer()
    

Method Summary
public  voidconfigure(Configuration configuration)
    
public  voidendTransformingElement(String uri, String name, String raw)
    
public static  InternetAddress[]getAddresses(AddressHandler[] handlerArr)
    
public  voidrecycle()
    
public  voidsetup(SourceResolver resolver, Map objectModel, String src, Parameters par)
    
public  voidstartTransformingElement(String uri, String name, String raw, Attributes attr)
    

Field Detail
DEFAULT_BODY_MIMETYPE
final public static String DEFAULT_BODY_MIMETYPE(Code)



ELEMENT_ATTACHMENT
final public static String ELEMENT_ATTACHMENT(Code)



ELEMENT_ATTACHMENT_CONTENT
final public static String ELEMENT_ATTACHMENT_CONTENT(Code)



ELEMENT_EMAIL_PREFIX
final public static String ELEMENT_EMAIL_PREFIX(Code)



ELEMENT_ERROR
final public static String ELEMENT_ERROR(Code)



ELEMENT_FAILURE
final public static String ELEMENT_FAILURE(Code)



ELEMENT_MAILBODY
final public static String ELEMENT_MAILBODY(Code)



ELEMENT_MAILFROM
final public static String ELEMENT_MAILFROM(Code)



ELEMENT_MAILSUBJECT
final public static String ELEMENT_MAILSUBJECT(Code)



ELEMENT_MAILTO
final public static String ELEMENT_MAILTO(Code)



ELEMENT_REPLYTO
final public static String ELEMENT_REPLYTO(Code)



ELEMENT_RESULT
final public static String ELEMENT_RESULT(Code)



ELEMENT_SENDMAIL
final public static String ELEMENT_SENDMAIL(Code)



ELEMENT_SMTPHOST
final public static String ELEMENT_SMTPHOST(Code)



ELEMENT_SMTPPORT
final public static String ELEMENT_SMTPPORT(Code)



ELEMENT_SUCCESS
final public static String ELEMENT_SUCCESS(Code)



MODE_ATTACHMENT
final protected static int MODE_ATTACHMENT(Code)



MODE_ATTACHMENT_CONTENT
final protected static int MODE_ATTACHMENT_CONTENT(Code)



MODE_BODY
final protected static int MODE_BODY(Code)



MODE_FROM
final protected static int MODE_FROM(Code)



MODE_NONE
final protected static int MODE_NONE(Code)



MODE_REPLY_TO
final protected static int MODE_REPLY_TO(Code)



MODE_SMTPHOST
final protected static int MODE_SMTPHOST(Code)



MODE_SMTPPORT
final protected static int MODE_SMTPPORT(Code)



MODE_SUBJECT
final protected static int MODE_SUBJECT(Code)



MODE_TO
final protected static int MODE_TO(Code)



NAMESPACE
final public static String NAMESPACE(Code)



PARAM_BODY
final public static String PARAM_BODY(Code)



PARAM_FROM
final public static String PARAM_FROM(Code)



PARAM_REPLY_TO
final public static String PARAM_REPLY_TO(Code)



PARAM_SENDPARTIAL
final public static String PARAM_SENDPARTIAL(Code)



PARAM_SMTPHOST
final public static String PARAM_SMTPHOST(Code)



PARAM_SMTPPORT
final public static String PARAM_SMTPPORT(Code)



PARAM_SUBJECT
final public static String PARAM_SUBJECT(Code)



PARAM_TO
final public static String PARAM_TO(Code)



attachmentDescriptor
protected AttachmentDescriptor attachmentDescriptor(Code)



attachments
protected List attachments(Code)



body
protected String body(Code)



bodyMimeType
protected String bodyMimeType(Code)



bodyURI
protected String bodyURI(Code)



contextPath
protected String contextPath(Code)



defaultFromAddress
protected String defaultFromAddress(Code)



defaultReplyToAddresses
protected List defaultReplyToAddresses(Code)



defaultSmtpHost
protected String defaultSmtpHost(Code)



defaultSmtpPort
protected int defaultSmtpPort(Code)



defaultToAddresses
protected List defaultToAddresses(Code)



fromAddress
protected String fromAddress(Code)



mailHost
protected String mailHost(Code)



mailPort
protected int mailPort(Code)



mode
protected int mode(Code)



port
protected int port(Code)



replyToAddresses
protected List replyToAddresses(Code)



sendPartial
protected boolean sendPartial(Code)



smtpMessage
protected Message smtpMessage(Code)



subject
protected String subject(Code)



toAddresses
protected List toAddresses(Code)



usedSources
protected List usedSources(Code)




Constructor Detail
SendMailTransformer
public SendMailTransformer()(Code)
create a new Transformer




Method Detail
configure
public void configure(Configuration configuration) throws ConfigurationException(Code)



endTransformingElement
public void endTransformingElement(String uri, String name, String raw) throws SAXException, ProcessingException(Code)



getAddresses
public static InternetAddress[] getAddresses(AddressHandler[] handlerArr)(Code)



recycle
public void recycle()(Code)

See Also:   org.apache.avalon.excalibur.pool.Recyclable.recycle



setup
public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par) throws ProcessingException, SAXException, IOException(Code)
invoked every time when the transformer is triggered by the pipeline



startTransformingElement
public void startTransformingElement(String uri, String name, String raw, Attributes attr) throws SAXException(Code)



Fields inherited from org.apache.cocoon.transformation.AbstractSAXTransformer
final protected static Attributes EMPTY_ATTRIBUTES(Code)(Java Doc)
protected Context context(Code)(Java Doc)
protected String defaultNamespaceURI(Code)(Java Doc)
protected Attributes emptyAttributes(Code)(Java Doc)
protected boolean ignoreEmptyCharacters(Code)(Java Doc)
protected int ignoreEventsCount(Code)(Java Doc)
protected int ignoreHooksCount(Code)(Java Doc)
protected boolean ignoreWhitespaces(Code)(Java Doc)
protected ServiceManager manager(Code)(Java Doc)
protected String namespaceURI(Code)(Java Doc)
protected Map objectModel(Code)(Java Doc)
protected Parameters parameters(Code)(Java Doc)
final protected Stack recorderStack(Code)(Java Doc)
protected Request request(Code)(Java Doc)
protected SourceResolver resolver(Code)(Java Doc)
protected Response response(Code)(Java Doc)
protected String source(Code)(Java Doc)
final protected Stack stack(Code)(Java Doc)

Methods inherited from org.apache.cocoon.transformation.AbstractSAXTransformer
protected void addRecorder(XMLConsumer recorder)(Code)(Java Doc)
public void characters(char[] p0, int p1, int p2) throws SAXException(Code)(Java Doc)
public void comment(char ary, int start, int length) throws SAXException(Code)(Java Doc)
public void configure(Configuration configuration) throws ConfigurationException(Code)(Java Doc)
public void dispose()(Code)(Java Doc)
public void endCDATA() throws SAXException(Code)(Java Doc)
public void endDTD() throws SAXException(Code)(Java Doc)
public void endDocument() throws SAXException(Code)(Java Doc)
public void endElement(String uri, String name, String raw) throws SAXException(Code)(Java Doc)
public void endEntity(String name) throws SAXException(Code)(Java Doc)
public SourceParameters endParametersRecording(Parameters source) throws SAXException(Code)(Java Doc)
public SourceParameters endParametersRecording(SourceParameters source) throws SAXException(Code)(Java Doc)
public void endPrefixMapping(String prefix) throws SAXException(Code)(Java Doc)
public DocumentFragment endRecording() throws SAXException(Code)(Java Doc)
public XMLizable endSAXRecording() throws SAXException(Code)(Java Doc)
public String endSerializedXMLRecording() throws SAXException, ProcessingException(Code)(Java Doc)
public String endTextRecording() throws SAXException(Code)(Java Doc)
public void endTransformingElement(String uri, String name, String raw) throws ProcessingException, IOException, SAXException(Code)(Java Doc)
protected String findPrefixMapping(String uri)(Code)(Java Doc)
protected AttributesImpl getMutableAttributes(Attributes a)(Code)(Java Doc)
public void ignorableWhitespace(char[] p0, int p1, int p2) throws SAXException(Code)(Java Doc)
public void processingInstruction(String target, String data) throws SAXException(Code)(Java Doc)
public void recycle()(Code)(Java Doc)
protected Object removeRecorder()(Code)(Java Doc)
public void sendEndElementEvent(String localname) throws SAXException(Code)(Java Doc)
public void sendEndElementEventNS(String localname) throws SAXException(Code)(Java Doc)
protected void sendEndPrefixMapping() throws SAXException(Code)(Java Doc)
public void sendEvents(Node node) throws SAXException(Code)(Java Doc)
public void sendParametersEvents(SourceParameters pars) throws SAXException(Code)(Java Doc)
public void sendStartElementEvent(String localname) throws SAXException(Code)(Java Doc)
public void sendStartElementEvent(String localname, Attributes attr) throws SAXException(Code)(Java Doc)
public void sendStartElementEventNS(String localname) throws SAXException(Code)(Java Doc)
public void sendStartElementEventNS(String localname, Attributes attr) throws SAXException(Code)(Java Doc)
protected void sendStartPrefixMapping() throws SAXException(Code)(Java Doc)
public void sendTextEvent(String text) throws SAXException(Code)(Java Doc)
public void service(ServiceManager manager) throws ServiceException(Code)(Java Doc)
public void setDocumentLocator(Locator locator)(Code)(Java Doc)
public void setup(SourceResolver resolver, Map objectModel, String src, Parameters params) throws ProcessingException, SAXException, IOException(Code)(Java Doc)
public void setupTransforming() throws IOException, ProcessingException, SAXException(Code)(Java Doc)
public void skippedEntity(String name) throws SAXException(Code)(Java Doc)
public void startCDATA() throws SAXException(Code)(Java Doc)
public void startDTD(String name, String public_id, String system_id) throws SAXException(Code)(Java Doc)
public void startDocument() throws SAXException(Code)(Java Doc)
public void startElement(String uri, String name, String raw, Attributes attr) throws SAXException(Code)(Java Doc)
public void startEntity(String name) throws SAXException(Code)(Java Doc)
public void startParametersRecording() throws SAXException(Code)(Java Doc)
public void startPrefixMapping(String prefix, String uri) throws SAXException(Code)(Java Doc)
public void startRecording() throws SAXException(Code)(Java Doc)
public void startSAXRecording() throws SAXException(Code)(Java Doc)
public void startSerializedXMLRecording(Properties format) throws SAXException(Code)(Java Doc)
public void startTextRecording() throws SAXException(Code)(Java Doc)
public void startTransformingElement(String uri, String name, String raw, Attributes attr) throws ProcessingException, IOException, SAXException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.