Transport (Java EE 5 SDK)

Java

Java EE 5 SDK

深圳电信培训中心.徐海蛟老师.


javax.mail Class Transport

java.lang.Object
  extended by javax.mail.Service
      extended by javax.mail.Transport

public abstract class Transport
extends Service

An abstract class that models a message transport. Subclasses provide actual implementations.

Note that Transport extends the Service class, which provides many common methods for naming transports, connecting to transports, and listening to connection events.

版本:
1.40, 07/05/17
作者:
John Mani, Max Spivak, Bill Shannon
另请参见:
Service, ConnectionEvent, TransportEvent

字段摘要
 
Fields inherited from class javax.mail.Service
debug, session, url
 
构造器摘要
Transport(Session session, URLName urlname)
          Constructor.
 
方法摘要
 void addTransportListener(TransportListener l)
          Add a listener for Transport events.
protected  void notifyTransportListeners(int type, Address[] validSent, Address[] validUnsent, Address[] invalid, Message msg)
          Notify all TransportListeners.
 void removeTransportListener(TransportListener l)
          Remove a listener for Transport events.
static void send(Message msg)
          Send a message.
static void send(Message msg, Address[] addresses)
          Send the message to the specified addresses, ignoring any recipients specified in the message itself.
abstract  void sendMessage(Message msg, Address[] addresses)
          Send the Message to the specified list of addresses.
 
类方法继承 javax.mail.Service
addConnectionListener, close, connect, connect, connect, connect, finalize, getURLName, isConnected, notifyConnectionListeners, protocolConnect, queueEvent, removeConnectionListener, setConnected, setURLName, toString
 
类方法继承 java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

构造器详细信息

Transport

public Transport(Session session,
                 URLName urlname)
Constructor.

参数:
session - Session object for this Transport.
urlname - URLName object to be used for this Transport

方法详细信息

send

public static void send(Message msg)
                 throws MessagingException
Send a message. The message will be sent to all recipient addresses specified in the message (as returned from the Message method getAllRecipients), using message transports appropriate to each address. The send method calls the saveChanges method on the message before sending it.

If any of the recipient addresses is detected to be invalid by the Transport during message submission, a SendFailedException is thrown. Clients can get more detail about the failure by examining the exception. Whether or not the message is still sent succesfully to any valid addresses depends on the Transport implementation. See SendFailedException for more details. Note also that success does not imply that the message was delivered to the ultimate recipient, as failures may occur in later stages of delivery. Once a Transport accepts a message for delivery to a recipient, failures that occur later should be reported to the user via another mechanism, such as returning the undeliverable message.

Note that send is a static method that creates and manages its own connection. Any connection associated with any Transport instance used to invoke this method is ignored and not used. This method should only be invoked using the form Transport.send(msg);, and should never be invoked using an instance variable.

参数:
msg - the message to send
抛出异常:
SendFailedException - if the message could not be sent to some or any of the recipients.
MessagingException
另请参见:
Message.saveChanges(), Message.getAllRecipients(), send(Message, Address[]), SendFailedException

send

public static void send(Message msg,
                        Address[] addresses)
                 throws MessagingException
Send the message to the specified addresses, ignoring any recipients specified in the message itself. The send method calls the saveChanges method on the message before sending it.

参数:
msg - the message to send
addresses - the addresses to which to send the message
抛出异常:
SendFailedException - if the message could not be sent to some or any of the recipients.
MessagingException
另请参见:
Message.saveChanges(), send(Message), SendFailedException

sendMessage

public abstract void sendMessage(Message msg,
                                 Address[] addresses)
                          throws MessagingException
Send the Message to the specified list of addresses. An appropriate TransportEvent indicating the delivery status is delivered to any TransportListener registered on this Transport. Also, if any of the addresses is invalid, a SendFailedException is thrown. Whether or not the message is still sent succesfully to any valid addresses depends on the Transport implementation.

Unlike the static send method, the sendMessage method does not call the saveChanges method on the message; the caller should do so.

参数:
msg - The Message to be sent
addresses - array of addresses to send this message to
抛出异常:
SendFailedException - if the send failed because of invalid addresses.
MessagingException - if the connection is dead or not in the connected state
另请参见:
TransportEvent

addTransportListener

public void addTransportListener(TransportListener l)
Add a listener for Transport events.

The default implementation provided here adds this listener to an internal list of TransportListeners.

参数:
l - the Listener for Transport events
另请参见:
TransportEvent

removeTransportListener

public void removeTransportListener(TransportListener l)
Remove a listener for Transport events.

The default implementation provided here removes this listener from the internal list of TransportListeners.

参数:
l - the listener
另请参见:
addTransportListener(javax.mail.event.TransportListener)

notifyTransportListeners

protected void notifyTransportListeners(int type,
                                        Address[] validSent,
                                        Address[] validUnsent,
                                        Address[] invalid,
                                        Message msg)
Notify all TransportListeners. Transport implementations are expected to use this method to broadcast TransportEvents.

The provided default implementation queues the event into an internal event queue. An event dispatcher thread dequeues events from the queue and dispatches them to the registered TransportListeners. Note that the event dispatching occurs in a separate thread, thus avoiding potential deadlock problems.


Java EE 5 SDK

深圳电信培训中心.徐海蛟老师.


提交错误或意见

版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。深圳电信培训中心.徐海蛟老师教学参考.