Search in sources :

Example 1 with MailBean

use of org.glassfish.resources.javamail.beans.MailBean in project Payara by payara.

the class MailResourceDeployer method toMailBean.

/**
 * Returns a new instance of j2ee mail resource from the given config bean.
 * <p/>
 * This method gets called from the mail resource deployer to convert mail
 * config bean into mail j2ee resource.
 *
 * @param mailResourceConfig mail-resource config bean
 * @param resourceInfo
 * @return a new instance of j2ee mail resource
 */
public static MailBean toMailBean(MailResource mailResourceConfig, ResourceInfo resourceInfo) {
    MailBean mailResource = new MailBean(resourceInfo);
    // jr.setDescription(rbean.getDescription()); // FIXME: getting error
    mailResource.setEnabled(Boolean.valueOf(mailResourceConfig.getEnabled()));
    mailResource.setStoreProtocol(mailResourceConfig.getStoreProtocol());
    mailResource.setStoreProtocolClass(mailResourceConfig.getStoreProtocolClass());
    mailResource.setTransportProtocol(mailResourceConfig.getTransportProtocol());
    mailResource.setTransportProtocolClass(mailResourceConfig.getTransportProtocolClass());
    mailResource.setMailHost((String) TranslatedConfigView.getTranslatedValue(mailResourceConfig.getHost()));
    mailResource.setUsername((String) TranslatedConfigView.getTranslatedValue(mailResourceConfig.getUser()));
    mailResource.setPassword((String) TranslatedConfigView.getTranslatedValue(mailResourceConfig.getPassword()));
    mailResource.setAuth(Boolean.valueOf(mailResourceConfig.getAuth()));
    mailResource.setMailFrom((String) TranslatedConfigView.getTranslatedValue(mailResourceConfig.getFrom()));
    mailResource.setDebug(Boolean.valueOf(mailResourceConfig.getDebug()));
    // sets the properties
    List<Property> properties = mailResourceConfig.getProperty();
    if (properties != null) {
        for (Property property : properties) {
            ResourceProperty rp = new org.glassfish.resources.api.ResourcePropertyImpl(property.getName(), property.getValue());
            mailResource.addProperty(rp);
        }
    }
    return mailResource;
}
Also used : ResourceProperty(com.sun.enterprise.repository.ResourceProperty) MailBean(org.glassfish.resources.javamail.beans.MailBean) ResourceProperty(com.sun.enterprise.repository.ResourceProperty) Property(org.jvnet.hk2.config.types.Property)

Aggregations

ResourceProperty (com.sun.enterprise.repository.ResourceProperty)1 MailBean (org.glassfish.resources.javamail.beans.MailBean)1 Property (org.jvnet.hk2.config.types.Property)1