コード例 #1
0
  private void validateAddressesCache() {
    senderCache.clear();

    if (messageSource == null || serverDescriptor == null) {
      return;
    }

    for (Language language : Language.values()) {
      for (Sender sender : Sender.values()) {
        try {
          final String address =
              messageSource.getMessage(
                  "mail.address." + sender.getCode(),
                  null,
                  sender.getCode() + "@" + serverDescriptor.getMailHostName(),
                  language.getLocale());

          final String personal =
              messageSource.getMessage(
                  "mail.personal." + sender.getCode(), null, sender.name(), language.getLocale());

          senderCache.put(
              new SenderKey(sender, language), new InternetAddress(address, personal, "UTF-8"));
        } catch (UnsupportedEncodingException ex) {
          log.error("JAVA SYSTEM ERROR - NOT UTF8!", ex);
        }
      }

      for (Recipient.MailBox mailBox : Recipient.MailBox.values()) {
        try {
          final String address =
              messageSource.getMessage(
                  "mail.address." + mailBox.getCode(),
                  null,
                  mailBox.getCode() + "@" + serverDescriptor.getMailHostName(),
                  language.getLocale());

          final String personal =
              messageSource.getMessage(
                  "mail.personal." + mailBox.getCode(), null, mailBox.name(), language.getLocale());

          recipientCache.put(
              new RecipientKey(mailBox, language), new InternetAddress(address, personal, "UTF-8"));
        } catch (UnsupportedEncodingException ex) {
          log.error("JAVA SYSTEM ERROR - NOT UTF8!", ex);
        }
      }
    }
  }
コード例 #2
0
 @Override
 public int hashCode() {
   int result = language.hashCode();
   result = 31 * result + sender.hashCode();
   return result;
 }