Search in sources :

Example 6 with MailResource

use of org.glassfish.resources.javamail.config.MailResource in project Payara by payara.

the class DeleteJavaMailResourceTest method tearDown.

@After
public void tearDown() throws TransactionFailure {
    ConfigSupport.apply(new SingleConfigCode<Resources>() {

        public Object run(Resources param) throws PropertyVetoException, TransactionFailure {
            Resource target = null;
            for (Resource resource : param.getResources()) {
                if (resource instanceof MailResource) {
                    MailResource r = (MailResource) resource;
                    if (r.getJndiName().equals("mail/MyMailSession")) {
                        target = resource;
                        break;
                    }
                }
            }
            if (target != null) {
                param.getResources().remove(target);
            }
            return null;
        }
    }, resources);
    parameters = new ParameterMap();
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) TransactionFailure(org.jvnet.hk2.config.TransactionFailure) MailResource(org.glassfish.resources.javamail.config.MailResource) Resource(com.sun.enterprise.config.serverbeans.Resource) ParameterMap(org.glassfish.api.admin.ParameterMap) Resources(com.sun.enterprise.config.serverbeans.Resources) MailResource(org.glassfish.resources.javamail.config.MailResource) After(org.junit.After)

Example 7 with MailResource

use of org.glassfish.resources.javamail.config.MailResource in project Payara by payara.

the class MailResourceDeployer method undeployResource.

/**
 * {@inheritDoc}
 */
@Override
public void undeployResource(Object resource, String applicationName, String moduleName) throws Exception {
    MailResource mailRes = (MailResource) resource;
    // converts the config data to j2ee resource
    ResourceInfo resourceInfo = new ResourceInfo(mailRes.getJndiName(), applicationName, moduleName);
    deleteResource(mailRes, resourceInfo);
}
Also used : ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) MailResource(org.glassfish.resources.javamail.config.MailResource)

Example 8 with MailResource

use of org.glassfish.resources.javamail.config.MailResource in project Payara by payara.

the class MailResourceDeployer method deployResource.

/**
 * {@inheritDoc}
 */
@Override
public synchronized void deployResource(Object resource) throws Exception {
    MailResource mailResource = (MailResource) resource;
    ResourceInfo resourceInfo = ResourceUtil.getResourceInfo(mailResource);
    deployResource(resource, resourceInfo.getApplicationName(), resourceInfo.getModuleName());
}
Also used : ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) MailResource(org.glassfish.resources.javamail.config.MailResource)

Example 9 with MailResource

use of org.glassfish.resources.javamail.config.MailResource in project Payara by payara.

the class MailSessionDeployer method deployResource.

@Override
public void deployResource(Object resource) throws Exception {
    assert resource instanceof MailSessionDescriptor;
    final MailSessionDescriptor desc = (MailSessionDescriptor) resource;
    String resourceName = ConnectorsUtil.deriveResourceName(desc.getResourceId(), desc.getName(), desc.getResourceType());
    MailResource mailResource = new MyMailResource(desc, resourceName);
    getDeployer(mailResource).deployResource(mailResource);
    _logger.log(Level.FINE, "Mail-Session resource is deployed having resource-name [" + desc.getName() + "]");
}
Also used : MailResource(org.glassfish.resources.javamail.config.MailResource)

Example 10 with MailResource

use of org.glassfish.resources.javamail.config.MailResource in project Payara by payara.

the class MailSessionDeployer method undeployResource.

@Override
public void undeployResource(Object resource) throws Exception {
    assert resource instanceof MailSessionDescriptor;
    final MailSessionDescriptor desc = (MailSessionDescriptor) resource;
    String resourceName = ConnectorsUtil.deriveResourceName(desc.getResourceId(), desc.getName(), desc.getResourceType());
    MailResource mailResource = new MyMailResource(desc, resourceName);
    getDeployer(mailResource).undeployResource(mailResource);
    _logger.log(Level.FINE, "Mail-Session resource is undeployed having resource-name [" + desc.getName() + "]");
}
Also used : MailResource(org.glassfish.resources.javamail.config.MailResource)

Aggregations

MailResource (org.glassfish.resources.javamail.config.MailResource)16 Resource (com.sun.enterprise.config.serverbeans.Resource)6 Resources (com.sun.enterprise.config.serverbeans.Resources)4 ResourceInfo (org.glassfish.resourcebase.resources.api.ResourceInfo)4 ConfigApiTest (org.glassfish.tests.utils.ConfigApiTest)4 Test (org.junit.Test)4 PropertyVetoException (java.beans.PropertyVetoException)3 ParameterMap (org.glassfish.api.admin.ParameterMap)3 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)3 ResourceRef (com.sun.enterprise.config.serverbeans.ResourceRef)2 ActionReport (org.glassfish.api.ActionReport)2 Domain (com.sun.enterprise.config.serverbeans.Domain)1 Server (com.sun.enterprise.config.serverbeans.Server)1 Servers (com.sun.enterprise.config.serverbeans.Servers)1 PropsFileActionReporter (com.sun.enterprise.v3.common.PropsFileActionReporter)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 AdminCommandContextImpl (org.glassfish.api.admin.AdminCommandContextImpl)1 CommandRunner (org.glassfish.api.admin.CommandRunner)1 ResourceStatus (org.glassfish.resourcebase.resources.api.ResourceStatus)1