/** * Construct a specification of mail configuration. */ public MailConfiguration(MailResourceIntf mailRes) { // called from MailResourceDeployer try { loadMailResources(mailRes); } catch (Exception ce) { _logger.log(Level.INFO,"enterprise.deployment_mail_cfgexcp",ce); } }
/** * This constructs the mail configuration based on the username and * the from address. This constructor is deprecated. * @param the username * @param the from address * @deprecated */ public MailConfiguration(String username, String mailFrom) { 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()); }
/** * Construct a specification of mail configuration with the given username, * Mail From Address and mail hostname. * @param the username. * @param the from address. * @param the mail hostname. */ public MailConfiguration(String username, String mailFrom, String mailHost) { // called from MailConfigurationNode, which is never used this.username = username; this.mailFrom = mailFrom; this.mailHost = mailHost; put(MAIL_FROM, mailFrom); put(MAIL_USER, username); put(MAIL_HOST, mailHost); }
/** * notification of the end of XML parsing for this node */ public void postParsing() { getParentNode().addDescriptor(new MailConfiguration(name, mail_from, mail_host)); } }
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment) throws Exception { Reference ref = (Reference) obj; if(_logger.isLoggable(Level.FINE)) { _logger.log(Level.FINE,"MailNamingObjectFactory: " + ref + " Name:" + name); } MailConfiguration config = (MailConfiguration) ref.get(0).getContent(); // Note: javax.mail.Session is not serializable, // but we need to get a new instance on every lookup. Properties props = config.getMailProperties(); javax.mail.Session s = javax.mail.Session.getInstance(props, new MailSessionAuthenticator(props)); if("smtps".equals(props.getProperty("mail.transport.protocol"))) { s.setProtocolForAddress("rfc822", "smtps"); } s.setDebugOut(new PrintStream(new MailLogOutputStream())); s.setDebug(true); return s; } }
/** * notification of the end of XML parsing for this node */ public void postParsing() { getParentNode().addDescriptor(new MailConfiguration(name, mail_from, mail_host)); } }
/** * Installs the given mail resource. This method gets called during server * initialization and from mail resource deployer to handle resource events. * * @param mailResource mail resource */ public void installMailResource(com.sun.enterprise.resource.beans.MailResource mailResource, ResourceInfo resourceInfo) { try { MailConfiguration config = new MailConfiguration(mailResource); javax.naming.Reference ref = new javax.naming.Reference(javax.mail.Session.class.getName(), MailNamingObjectFactory.class.getName(),null); SerializableObjectRefAddr serializableRefAddr = new SerializableObjectRefAddr("jndiName", config); ref.add(serializableRefAddr); // Publish the object namingService.publishObject(resourceInfo, ref, true); } catch (Exception ex) { _logger.log(Level.SEVERE, "mailrsrc.create_obj_error", resourceInfo); _logger.log(Level.SEVERE, "mailrsrc.create_obj_error_excp", ex); } }
/** * Construct a specification of mail configuration with the given username, * Mail From Address and mail hostname. * @param the username. * @param the from address. * @param the mail hostname. */ public MailConfiguration(String username, String mailFrom, String mailHost) { 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()); }
/** * Construct a specification of mail configuration. */ public MailConfiguration(MailResourceIntf mailRes) { try { loadMailResources(mailRes); } catch (Exception ce) { _logger.log(Level.INFO,"enterprise.deployment_mail_cfgexcp",ce); } }
put(MAIL_HOST, mailHost); put(MAIL_USER, username); put(MAIL_STORE_PROTOCOL, storeProtocol); put(MAIL_TRANSPORT_PROTOCOL, transportProtocol); if (storeProtocol != null) put(MAIL_PREFIX + storeProtocol + MAIL_SUFFIX_CLASS, storeProtocolClass); if (transportProtocol != null) put(MAIL_PREFIX + transportProtocol + MAIL_SUFFIX_CLASS, transportProtocolClass); put(MAIL_FROM, mailFrom); put(MAIL_DEBUG, (debug ? "true" : "false")); name = name.replace(PROP_NAME_DELIM_LEGACY, MAIL_DELIM); put(name, value); if (_logger.isLoggable(Level.FINE)) _logger.fine("mail property: " + name + " = " + value);