毕业论文外文翻译-基于JavaMail框架的互联网电子邮件开发.doc
《毕业论文外文翻译-基于JavaMail框架的互联网电子邮件开发.doc》由会员分享,可在线阅读,更多相关《毕业论文外文翻译-基于JavaMail框架的互联网电子邮件开发.doc(22页珍藏版)》请在沃文网上搜索。
1、JavaMail FrameWork for developing internet-based e-mail client applications原文:E-mail functionality is an important system requirement in areas such as e-commerce, customer care, work-flow management and unified messaging. In addition, some application architectures may need to support not only stand
2、ard mail protocols but also proprietary ones. If youre charged with the task of developing an e-mail client application in Java, you have a number of architectural and design options: building your own services layer to support multiple mail protocols, purchasing third-party components that provide
3、e-mail features or using JavaSofts JavaMail framework.This article focuses on the JavaMail framework for developing Internet-based e-mail client applications. The JavaMail API shields application developers from implementation details of specific mail protocols by providing a layer of abstraction de
4、signed to support current e-mail standards and any future enhancements. JavaMail increases a developers productivity by allowing the developer to focus on the business logic of an application rather than on mail protocol implementation. It provides a platform and protocol-independent means of adding
5、 e-mail client features to your applications. JavaMail version 1.1 is a standard Java extension and requires JDK/JRE 1.1.x or higher.Overview of Internet Mail ProtocolsBefore getting into the details of JavaMail, a quick overview of some messaging terms and Internet e-mail protocols (IMAP, POP, SMTP
6、) is in order. A message is described in terms of a header and content. A message header comprises information such as sender (from), recipient (to), and message ID (a unique message identifier). A messages content is the actual message body and can comprise multiple parts in the form of text and at
7、tachments, as shown in FigureFigure1:An e-mail client is used to transfer messages to and from an e-mail server, which is responsible for sending and receiving e-mail messages across the Internet. These servers store a users messages either permanently or until retrieved by an e-mail client.To devel
8、op an e-mail client you need to deal with protocols for sending and receiving messages. As shown in Figure 2, the common protocol for sending Internet e-mail messages is SMTP (Simple Mail Transfer Protocol). The original SMTP specification limited messages to a certain line length and allowed only 7
9、-bit ASCII characters. The MIME (Multipurpose Internet Mail Extensions) specification builds on SMTP by removing the maximum line length for messages and allowing new types of content (e.g., images, binary files) to be included in e-mail messages. The MIME specification overcomes these limitations b
10、y defining additional fields in a message header to describe new types of content and message structure. MIME defines the content-type header to specify the type and subtype of message content. For example, a message with an HTML attachment would have a content-type header set to text/html. SMTP and
11、 MIME are typically used together to send Internet e-mail messages.Figure2:Two types of protocols are used to retrieve messages from Internet mail servers: POP3 (Post Office Protocol 3) and IMAP4 (Internet Message Access Protocol 4). Although POP3 is more widely used than IMAP4, the latter has a num
12、ber of advantages. First, IMAP supports multiple folders on a remote mail server whereas POP3 supports only the Inbox folder. Second, IMAP supports message status flags (e.g., indicates whether a message has been previously seen); POP3 doesnt. These types of protocol features are important considera
13、tions in designing your application.JavaMail provides implementations of SMTP, IMAP4 and POP3. For more information on these Internet mail protocols, you can consult the pertinent RFCs.JavaMail ArchitectureNow that you have a basic understanding of Internet mail terms, we can begin to discuss the Ja
14、vaMail architecture. As shown in Figure 3, the architecture can be described in terms of three main layers. JavaMails layered architecture allows clients to use the JavaMail API with different message access protocols (POP3, IMAP4) and message transport protocols (SMTP).Figure3:The top layer is the
15、application layer that uses the JavaMail API. The second layer is the JavaMail API that defines a set of abstract classes and interfaces for supporting e-mail client functionality. This is the layer that frees a developer from having to deal with protocol-specific complexities. JavaMail provides con
16、crete subclasses of these abstract classes for Internet mail. The JavaMail API layer depends on concrete implementations of protocols.The implementation layer forms the third layer of the JavaMail architecture. Since JavaMail is protocol independent, its up to service providers to implement specific
17、 message access and message transfer protocols. Service provider implementations play a role similar to that of JDBC drivers. A provider registry allows service providers to register their protocol implementations to be used by JavaMail APIs. The JavaMail Web site has more information on third-party
18、 service providers.JavaBeans Activation FrameworkJavaMail interacts with message content through an intermediate layer called the JavaBeans Activation Framework (JAF), part of the Glasgow specification (a future release of the JavaBeans component model specification). In terms of dealing with e-mail
19、 messages, JAF provides a uniform way of determining the type of a messages content and encapsulating access to it. The JAF is implemented as a standard Java extension. Sun provides a royalty-free implementation of JAF that requires JDK 1.1.x or higher.JAF is used to get and set a messages text and
20、attachments. JavaMail provides convenient methods to interact with JAF. For example, MimeMessages setText() method can be used to set a string as a messages content with a MIME type of text/plain. Another example is MimeMessages getContent() method, which returns a messages content as a Java object
21、by invoking methods on JAFs DataHandler class.JAF can also be used to view e-mail attachments such as a text file (.txt) or an image (.gif) by instantiating a JavaBean that supports a particular command (e.g., view) on a specific type of message content. As shown below, the JAF DataSource object, wh
22、ich encapsulates the attachment, is used to create a DataHandler object. The DataHandler object uses a CommandInfo object to retrieve the pertinent JavaBean that can be used to perform a specific operation on an attachment. The JavaBean component can then be added to a frame, as shown in the code sn
23、ippet below. Currently, reference implementations of JAF-aware JavaBeans are available to view text, GIF and JPEG files. CommandInfo, DataSource and DataHandler are all JAF classes./ file name represents the attachmentFileDataSource attachFds = new FileDataSource(attachmentFilename);DataHandler dh =
24、 new DataHandler(attachFds);CommandInfo viewCi = dh.getCommand(view);Frame attachmentWindow = new Frame(View Attachment);/ add the bean to view the attachment to the main windowattachmentWindow.add(Component)dh.getBean(viewCi);Examples Using JavaMailYou now have a basic overview of the JavaMail arch
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
20 积分
下载 | 加入VIP,下载更划算! |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 毕业论文 外文 翻译 基于 JavaMail 框架 互联网 电子邮件 开发