Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## things.data.transport.smtp
Class TouchySMTPClientManager

    java.lang.Object
      things.data.transport.smtp.TouchySMTPClientManager

All Implemented Interfaces:
  SMTPClientManager

    public class TouchySMTPClientManager

extends java.lang.Object
implements SMTPClientManager

This is a simple manager for a clean SMTP client.

Version:
  1.0

  Version History

      EPG - Adapted from another project - 23 NOV 06

Author:
  Erich P. Gatejen

Field Summary
`static int` | `CONNECTION_TIMEOUT`
`static int` | `DEFAULT_STREAM_MAX` This is the default number of messages sent per stream.

Constructor Summary
`TouchySMTPClientManager()`

Method Summary
`void` | `disconnect()` Force a disconnection.
`void` | `init(Logger aLogger, java.lang.String name, java.lang.String targetAddress, int targetPort, boolean isStreaming, boolean extensions)` Init the system.
`boolean` | `isExtensionsSet()` Are extensions supported?
`RESULT` | `meassuredSubmit(java.lang.String senderInet, java.lang.String recipientInet, java.lang.String id, java.io.InputStream... dataStream)` Submit a message and return the result.
`void` | `setDSN(DSN dsn)` Set a DSN for all subsequent sends.
`void` | `setStreamMax(int max)` Set the maximum number of messages a stream can send before it is closed and reestablished.
`void` | `setTimeout(int timeout)` Set a new timeout.
`Reply` | `submit(java.lang.String senderInet, java.lang.String recipientInet, java.io.InputStream... dataStream)` Submit a message.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### CONNECTION_TIMEOUT

    public static final int CONNECTION_TIMEOUT

See Also:
  Constant Field Values

### DEFAULT_STREAM_MAX

    public static final int DEFAULT_STREAM_MAX

  This is the default number of messages sent per stream. After this number, the connection is always closed and reestablished. This was done to avoid platform problems associated with seriously aged sockets. Yes, they really exist and it they aren't my bugs. :&)

  See Also:
    Constant Field Values

Constructor Detail

### TouchySMTPClientManager

    public TouchySMTPClientManager()

Method Detail

### init

    public void init(Logger aLogger,
                     java.lang.String name,
                     java.lang.String targetAddress,
                     int targetPort,
                     boolean isStreaming,
                     boolean extensions)
              throws ThingsException,
                     java.lang.InterruptedException

  Init the system. This is a one-time deal. The managers are one use only. By default, no extensions will be supported.

  Specified by:
    `init` in interface `SMTPClientManager`
  Parameters:
    `aLogger` -
    `name` -
    `targetAddress` -
    `targetPort` -
    `isStreaming` - does it stream? (Streaming attempts to reuse the connection).
    `extensions` - if true, server extensions will be supported.
  Throws:
    `UserException`
    `ThingsException`
    `java.lang.InterruptedException`

### setStreamMax

    public void setStreamMax(int max)
                      throws ThingsException,
                             java.lang.InterruptedException

  Set the maximum number of messages a stream can send before it is closed and reestablished.

  Specified by:
    `setStreamMax` in interface `SMTPClientManager`
  Parameters:
    `max` - the maximum number. It must be 1 or greater or you'll get an exception.
  Throws:
    `ThingsException`
    `java.lang.InterruptedException`

### setTimeout

    public void setTimeout(int timeout)
                    throws ThingsException

  Set a new timeout. It'll take effect after the next connection is made (which might not be obvious).

  Specified by:
    `setTimeout` in interface `SMTPClientManager`
  Parameters:
    `timeout` - in milliseconds.
  Throws:
    `ThingsException`

### setDSN

    public void setDSN(DSN dsn)

  Set a DSN for all subsequent sends. If set to null, it will not be used. Extensions must be supported for this to work.

  Specified by:
    `setDSN` in interface `SMTPClientManager`
  Parameters:
    `dsn` - the dsn

### isExtensionsSet

    public boolean isExtensionsSet()

  Are extensions supported?

  Specified by:
    `isExtensionsSet` in interface `SMTPClientManager`
  Returns:
    true if they are

### submit

    public Reply submit(java.lang.String senderInet,
                        java.lang.String recipientInet,
                        java.io.InputStream... dataStream)
                 throws ThingsException,
                        java.lang.InterruptedException

  Submit a message. We'll let InterruptedExceptions out like a good THINGS citizen.

  Specified by:
    `submit` in interface `SMTPClientManager`
  Parameters:
    `senderInet` -
    `recipientInet` -
    `dataStream` - InputStreams to be sent in turn. Null entries are allowed and ignored.
  Returns:
    the SMTP reply for the send. The size field is useful.
  Throws:
    `ThingsException` - if not successful for any reason. (Don't change this without modifying the other submit methods.)
    `java.lang.InterruptedException`

### meassuredSubmit

    public RESULT meassuredSubmit(java.lang.String senderInet,
                                  java.lang.String recipientInet,
                                  java.lang.String id,
                                  java.io.InputStream... dataStream)
                           throws UserException,
                                  java.lang.InterruptedException

  Submit a message and return the result. We'll let InterruptedExceptions out like a good THINGS citizen. It will not let any other exception escape, but will reflect them in the RESULT. (It will log complex info if debug is enabled.)

  A FAULT will result in a Type.EXCEPTION. An ERROR will result in a Type.FAIL. A successful transaction will result in a Type.PASS.

  The metrics will contain a valid size giving the actual byte sent in the difference field, as well as count values.

  Specified by:
    `meassuredSubmit` in interface `SMTPClientManager`
  Parameters:
    `senderInet` -
    `recipientInet` -
    `dataStream` - InputStreams to send in turn.
    `id` - the id of the operations.
  Throws:
    `UserException` - for any really serious stuff. Most problems will be returned in the RESULT.
    `java.lang.InterruptedException`

### disconnect

    public void disconnect()
                    throws ThingsException,
                           java.lang.InterruptedException

  Force a disconnection. It is nice, but not necessary, to call this when you are done--or just done for a while. It doesn't ruin the client. You could still use it again (but remember, init is only once!).

  Specified by:
    `disconnect` in interface `SMTPClientManager`
  Throws:
    `ThingsException`
    `java.lang.InterruptedException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Things.