MailConfigurationpublic class MailConfiguration extends Object implements SerializableThis class represent the configuration information of the JavaMail
Session object within J2EE. |
Fields Summary |
---|
private static String | PROTOCOL_TYPE_IMAP | private static String | PROTOCOL_TYPE_POP3 | private static String | PROTOCOL_TYPE_SMTP | private static String | PROP_NAME_PREFIX | private static String | PROP_NAME_SUFFIX_HOST | private static String | PROP_NAME_SUFFIX_USER | private static char | PROP_NAME_DELIM | private static String | DEF_VAL_STORE_PROTOCOL | private static String | DEF_VAL_STORE_PROTOCOL_CLASS | private static String | DEF_VAL_TRANSPORT_PROTOCOL | private static String | DEF_VAL_TRANSPORT_PROTOCOL_CLASS | private static String | DEF_VAL_HOST | private static String | DEF_VAL_USER | private static String | DEF_VAL_FROM | private static boolean | DEF_VAL_DEBUG | private static String | MAIL_STORE_PROTOCOL | private static String | MAIL_TRANSPORT_PROTOCOL | private static String | MAIL_HOST | private static String | MAIL_USER | private static String | MAIL_FROM | private static String | MAIL_DEBUG | private static String | MAIL_PREFIX | private static String | MAIL_SUFFIX_CLASS | private static String | MAIL_SUFFIX_HOST | private static String | MAIL_SUFFIX_USER | private static char | MAIL_DELIM | private String | descriptionMail resource attributes | private String | jndiName | private boolean | enabled | private String | storeProtocol | private String | storeProtocolClass | private String | transportProtocol | private String | transportProtocolClass | private String | mailHost | private String | username | private String | mailFrom | private boolean | debug | private Properties | mailProperties | static Logger | _logger |
Constructors Summary |
---|
public MailConfiguration(String username, String mailFrom)This constructs the mail configuration based on the username and
the from address. This constructor is deprecated.
this.username = username;
this.mailFrom = mailFrom;
this.mailHost = "";
mailProperties.put(MAIL_FROM, this.getMailFrom());
mailProperties.put(MAIL_USER, this.getUsername());
mailProperties.put(MAIL_HOST, this.getMailHost());
| public MailConfiguration(String username, String mailFrom, String mailHost)Construct a specification of mail configuration with the given username,
Mail From Address and mail hostname.
this.username = username;
this.mailFrom = mailFrom;
this.mailHost = mailHost;
mailProperties.put(MAIL_FROM, this.getMailFrom());
mailProperties.put(MAIL_USER, this.getUsername());
mailProperties.put(MAIL_HOST, this.getMailHost());
| public MailConfiguration(com.sun.enterprise.deployment.interfaces.MailResourceIntf mailRes)Construct a specification of mail configuration.
try {
loadMailResources(mailRes);
}
catch (Exception ce) {
//ce.printStackTrace();
_logger.log(Level.INFO,"enterprise.deployment_mail_cfgexcp",ce);
}
|
Methods Summary |
---|
public java.lang.String | getDescription()Get the mail description for the mail session the server will provide.
return this.description;
| public boolean | getEnabled()Get the mail enable flag for the mail session the server will provide.
return this.enabled;
| public java.lang.String | getJndiName()Get the mail JNDI name for the mail session the server will provide.
return this.jndiName;
| public boolean | getMailDebug()Get the mail debug flag for the mail session the server will provide.
return this.debug;
| public java.lang.String | getMailFrom()Get the mail from address for the mail session the server will provide.
return this.mailFrom;
| public java.lang.String | getMailHost()Get the mail hostname for the mail session the server will provide.
return this.mailHost;
| public java.util.Properties | getMailProperties()Get the mail session properties as per JavaMail.
/* IASRI 4629057
Properties mailProperties = new Properties();
mailProperties.put(MAIL_FROM, this.getMailFrom());
mailProperties.put(MAIL_USER, this.getUsername());
mailProperties.put(MAIL_HOST, this.getMailHost());
*/
return mailProperties;
| public java.lang.String | getMailStoreProtocol()Get the default Message Access Protocol for the mail session the server
will provide.
return this.storeProtocol;
| public java.lang.String | getMailStoreProtocolClass()Get the default Message Access Protocol class for the mail session the
server will provide.
return this.storeProtocolClass;
| public java.lang.String | getMailTransportProtocol()Get the default Transport Protocol for the mail session the server will
provide.
return this.transportProtocol;
| public java.lang.String | getMailTransportProtocolClass()Get the default Transport Protocol class for the mail session the server
will provide.
return this.transportProtocolClass;
| public java.lang.String | getUsername()Get the username for the mail session the server will provide.
return this.username;
| private void | loadMailResources(com.sun.enterprise.deployment.interfaces.MailResourceIntf mailResource)Load all configuration information from the mail resource node in
server.xml for the JavaMail Session object within J2EE.
if (mailResource == null) {
_logger.log(Level.FINE,
"MailConfiguration: no MailResource object. mailResource=" +
mailResource);
return;
}
jndiName = mailResource.getName();
description = mailResource.getDescription();
enabled = mailResource.isEnabled();
storeProtocol = mailResource.getStoreProtocol();
storeProtocolClass = mailResource.getStoreProtocolClass();
transportProtocol = mailResource.getTransportProtocol();
transportProtocolClass = mailResource.getTransportProtocolClass();
mailHost = mailResource.getMailHost();
username = mailResource.getUsername();
mailFrom = mailResource.getMailFrom();
debug = mailResource.isDebug();
// Save to Property list
String storeProtocolClassName = MAIL_PREFIX + storeProtocol +
MAIL_SUFFIX_CLASS;
String transportProtocolClassName = MAIL_PREFIX + transportProtocol +
MAIL_SUFFIX_CLASS;
mailProperties.put(MAIL_STORE_PROTOCOL, storeProtocol);
mailProperties.put(MAIL_TRANSPORT_PROTOCOL, transportProtocol);
mailProperties.put(storeProtocolClassName, storeProtocolClass);
mailProperties.put(transportProtocolClassName, transportProtocolClass);
mailProperties.put(MAIL_FROM, mailFrom);
mailProperties.put(MAIL_DEBUG, (debug ? "true" : "false"));
// Get the properties and save to Property list
Set properties = mailResource.getProperties();
ResourceProperty property = null;
String name = null;
String value = null;
String protRelatedHostPropName = PROP_NAME_PREFIX + storeProtocol +
PROP_NAME_SUFFIX_HOST;
String protRelatedUserPropName = PROP_NAME_PREFIX + storeProtocol +
PROP_NAME_SUFFIX_USER;
String protRelatedHostName = MAIL_PREFIX + storeProtocol +
MAIL_SUFFIX_HOST;
String protRelatedUserName = MAIL_PREFIX + storeProtocol +
MAIL_SUFFIX_USER;
for (Iterator it = properties.iterator(); it.hasNext();) {
property = (ResourceProperty)it.next();
name = property.getName();
value = (String)property.getValue();
if (name.startsWith(PROP_NAME_PREFIX)) {
if (name.equals(protRelatedHostPropName)) {
mailHost = value;
mailProperties.put(protRelatedHostName, value);
}
else if (name.equals(protRelatedUserPropName)) {
username = value;
mailProperties.put(protRelatedUserName, value);
}
else {
name = name.replace(PROP_NAME_DELIM, MAIL_DELIM);
mailProperties.put(name, value);
}
}
}
// Save mail.host and mail.user to Property list
mailProperties.put(MAIL_HOST, mailHost);
mailProperties.put(MAIL_USER, username);
| public void | print(java.lang.StringBuffer toStringBuffer)A formatted representation of my state.
/* IASRI 4629057
return "MailConfiguration: [" + username + "," + mailFrom + "," +
mailHost + "]";
*/
// START OF IASRI 4629057
toStringBuffer.append("MailConfiguration: [");
toStringBuffer.append("description=").append(description);
toStringBuffer.append( ", jndiName=").append(jndiName);
toStringBuffer.append( ", enabled=").append(enabled);
toStringBuffer.append( ", storeProtocol=").append(storeProtocol);
toStringBuffer.append( ", transportProtocol=").append(transportProtocol);
toStringBuffer.append( ", storeProtocolClass=").append(storeProtocolClass);
toStringBuffer.append( ", transportProtocolClass=").append(transportProtocolClass);
toStringBuffer.append( ", mailHost=").append(mailHost);
toStringBuffer.append( ", username=").append(username);
toStringBuffer.append( ", mailFrom=").append(mailFrom);
toStringBuffer.append( ", debug=").append(debug);
toStringBuffer.append( ", mailProperties: [");
Enumeration e = mailProperties.propertyNames();
String name;
String value;
boolean isFirst = true;
while (e.hasMoreElements()) {
name = (String)e.nextElement();
value = mailProperties.getProperty(name);
if (isFirst) {
toStringBuffer.append(name).append("=").append(value);
isFirst = false;
}
else {
toStringBuffer.append( ", ").append(name).append("=").append(value);
}
}
toStringBuffer.append( "]]");
// END OF IASRI 4629057
|
|