Class LocalMailService

java.lang.Object
com.google.appengine.tools.development.AbstractLocalRpcService
com.google.appengine.api.mail.dev.LocalMailService
All Implemented Interfaces:
LocalRpcService

@AutoService(LocalRpcService.class) public final class LocalMailService extends AbstractLocalRpcService
Stub implementation of the Google App Engine mail api. This implementation logs messages using a Logger associated with this class and keeps messages that were sent in memory. If you want to access the list of sent messages you can get ahold of the registered LocalMailService instance as follows:
 ApiProxyLocal proxy = (ApiProxyLocal) ApiProxy.getDelegate();
 LocalMailService mailService =
     (LocalMailService) proxy.getService(LocalMailService.PACKAGE);
 
You can then access the list via getSentMessages() and clear the list via clearSentMessages(). By default, messages are logged at Level.INFO and the body of the message is excluded. The log level and whether or not the body of the message is logged can be configured. See LOG_MAIL_BODY_PROPERTY and LOG_MAIL_LEVEL_PROPERTY for more information.
  • Field Details

    • PACKAGE

      public static final String PACKAGE
      The package name for this service.
      See Also:
    • LOG_MAIL_BODY_PROPERTY

      public static final String LOG_MAIL_BODY_PROPERTY
      Init property that determines whether or not we log the body of the email. Value must be a string representation of either Boolean.TRUE or Boolean.FALSE.
      See Also:
    • LOG_MAIL_LEVEL_PROPERTY

      public static final String LOG_MAIL_LEVEL_PROPERTY
      Init property that specifies the Level at which we log mail messages. Value must be a string representation of a Level (calling Level.parse(String) with the value as the arg should return a valid instance).
      See Also:
  • Constructor Details

    • LocalMailService

      public LocalMailService()
  • Method Details

    • getPackage

      public String getPackage()
      Description copied from interface: LocalRpcService
      Returns the package for the service, for example, "datastore_v3".
      Returns:
      a not null package name.
    • init

      public void init(LocalServiceContext context, Map<String,String> properties)
      Description copied from interface: LocalRpcService
      Initializes the service with a set of configuration properties. Must be called before a service is started.
      Specified by:
      init in interface LocalRpcService
      Overrides:
      init in class AbstractLocalRpcService
      Parameters:
      context - A context object for the application
      properties - A read-only Map of properties.
    • start

      public void start()
      Description copied from interface: LocalRpcService
      Puts a new service into "serving" mode. Aside from setting properties, the service is not functional until after having been started.
      Specified by:
      start in interface LocalRpcService
      Overrides:
      start in class AbstractLocalRpcService
    • stop

      public void stop()
      Description copied from interface: LocalRpcService
      Stops the service, releasing all of its resources.
      Specified by:
      stop in interface LocalRpcService
      Overrides:
      stop in class AbstractLocalRpcService
    • send

      public com.google.apphosting.base.protos.api.ApiBasePb.VoidProto send(LocalRpcService.Status status, com.google.appengine.api.mail.MailServicePb.MailMessage msg)
    • sendToAdmins

      public com.google.apphosting.base.protos.api.ApiBasePb.VoidProto sendToAdmins(LocalRpcService.Status status, com.google.appengine.api.mail.MailServicePb.MailMessage msg)
    • getSentMessages

      public List<com.google.appengine.api.mail.MailServicePb.MailMessage> getSentMessages()
      Returns:
      A list of all messages that have been sent.
    • clearSentMessages

      public void clearSentMessages()
      Clear the list of sent messages.
    • getMaxApiRequestSize

      public Integer getMaxApiRequestSize()
      Description copied from interface: LocalRpcService
      Returns the maximum size of an encoded API request in bytes, or null for the default size.
      Specified by:
      getMaxApiRequestSize in interface LocalRpcService
      Overrides:
      getMaxApiRequestSize in class AbstractLocalRpcService