Search in sources :

Example 41 with ResourceStatus

use of org.glassfish.resourcebase.resources.api.ResourceStatus in project Payara by payara.

the class JndiResourceManager method create.

public ResourceStatus create(Resources resources, HashMap attributes, final Properties properties, String target) throws Exception {
    setAttributes(attributes, target);
    ResourceStatus validationStatus = isValid(resources, true, target);
    if (validationStatus.getStatus() == ResourceStatus.FAILURE) {
        return validationStatus;
    }
    try {
        ConfigSupport.apply(new SingleConfigCode<Resources>() {

            public Object run(Resources param) throws PropertyVetoException, TransactionFailure {
                return createResource(param, properties);
            }
        }, resources);
        resourceUtil.createResourceRef(jndiName, enabledValueForTarget, target);
    } catch (TransactionFailure tfe) {
        String msg = localStrings.getLocalString("create.jndi.resource.fail", "Unable to create jndi resource {0}.", jndiName) + " " + tfe.getLocalizedMessage();
        return new ResourceStatus(ResourceStatus.FAILURE, msg, true);
    }
    String msg = localStrings.getLocalString("create.jndi.resource.success", "jndi resource {0} created.", jndiName);
    return new ResourceStatus(ResourceStatus.SUCCESS, msg, true);
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) TransactionFailure(org.jvnet.hk2.config.TransactionFailure) ResourceStatus(org.glassfish.resourcebase.resources.api.ResourceStatus) Resources(com.sun.enterprise.config.serverbeans.Resources)

Example 42 with ResourceStatus

use of org.glassfish.resourcebase.resources.api.ResourceStatus in project Payara by payara.

the class JndiResourceManager method isValid.

private ResourceStatus isValid(Resources resources, boolean validateResourceRef, String target) {
    ResourceStatus status;
    if (resType == null) {
        String msg = localStrings.getLocalString("create.jndi.resource.noResType", "No type defined for JNDI resource.");
        return new ResourceStatus(ResourceStatus.FAILURE, msg, true);
    }
    if (factoryClass == null) {
        String msg = localStrings.getLocalString("create.jndi.resource.noFactoryClassName", "No Factory class name defined for JNDI resource.");
        return new ResourceStatus(ResourceStatus.FAILURE, msg, true);
    }
    if (jndiLookupName == null) {
        String msg = localStrings.getLocalString("create.jndi.resource.noJndiLookupName", "No Jndi Lookup name defined for JNDI resource.");
        return new ResourceStatus(ResourceStatus.FAILURE, msg, true);
    }
    status = resourcesHelper.validateBindableResourceForDuplicates(resources, jndiName, validateResourceRef, target, ExternalJndiResource.class);
    if (status.getStatus() == ResourceStatus.FAILURE) {
        return status;
    }
    return status;
}
Also used : ResourceStatus(org.glassfish.resourcebase.resources.api.ResourceStatus) ExternalJndiResource(org.glassfish.resources.config.ExternalJndiResource)

Example 43 with ResourceStatus

use of org.glassfish.resourcebase.resources.api.ResourceStatus in project Payara by payara.

the class ConnectorConnectionPoolManager method isValidRAName.

private ResourceStatus isValidRAName(String raName) {
    // TODO turn on validation.  For now, turn validation off until connector modules ready
    // boolean retVal = false;
    ResourceStatus status = new ResourceStatus(ResourceStatus.SUCCESS, "");
    if ((raName == null) || (raName.equals(""))) {
        String msg = localStrings.getLocalString("admin.mbeans.rmb.null_res_adapter", "Resource Adapter Name is null.");
        status = new ResourceStatus(ResourceStatus.FAILURE, msg);
    } else {
        // System RA, so don't validate
        if (!ConnectorsUtil.getNonJdbcSystemRars().contains(raName)) {
            // Check if the raName contains double underscore or hash.
            // If that is the case then this is the case of an embedded rar,
            // hence look for the application which embeds this rar,
            // otherwise look for the webconnector module with this raName.
            int indx = raName.indexOf(EMBEDDEDRAR_NAME_DELIMITER);
            if (indx != -1) {
                String appName = raName.substring(0, indx);
                Application app = applications.getModule(Application.class, appName);
                if (app == null) {
                    String msg = localStrings.getLocalString("admin.mbeans.rmb.invalid_ra_app_not_found", "Invalid raname. Application with name {0} not found.", appName);
                    status = new ResourceStatus(ResourceStatus.FAILURE, msg);
                }
            } else {
                Application app = applications.getModule(Application.class, raName);
                if (app == null) {
                    String msg = localStrings.getLocalString("admin.mbeans.rmb.invalid_ra_cm_not_found", "Invalid raname. Connector Module with name {0} not found.", raName);
                    status = new ResourceStatus(ResourceStatus.FAILURE, msg);
                }
            }
        }
    }
    return status;
}
Also used : ResourceStatus(org.glassfish.resourcebase.resources.api.ResourceStatus)

Example 44 with ResourceStatus

use of org.glassfish.resourcebase.resources.api.ResourceStatus in project Payara by payara.

the class ConnectorConnectionPoolManager method createConfigBean.

public Resource createConfigBean(Resources resources, HashMap attributes, Properties properties, boolean validate) throws Exception {
    setParams(attributes);
    ResourceStatus status = null;
    if (!validate) {
        status = new ResourceStatus(ResourceStatus.SUCCESS, "");
    } else {
        status = isValid(resources, false);
    }
    if (status.getStatus() == ResourceStatus.SUCCESS) {
        return createConfigBean(resources, properties);
    } else {
        throw new ResourceException(status.getMessage());
    }
}
Also used : ResourceStatus(org.glassfish.resourcebase.resources.api.ResourceStatus) ResourceException(javax.resource.ResourceException)

Example 45 with ResourceStatus

use of org.glassfish.resourcebase.resources.api.ResourceStatus in project Payara by payara.

the class ManagedThreadFactoryManager method isValid.

private ResourceStatus isValid(Resources resources, boolean validateResourceRef, String target) {
    ResourceStatus status;
    if (jndiName == null) {
        String msg = localStrings.getLocalString("managed.thread.factory.noJndiName", "No JNDI name defined for managed thread factory.");
        return new ResourceStatus(ResourceStatus.FAILURE, msg);
    }
    status = resourcesHelper.validateBindableResourceForDuplicates(resources, jndiName, validateResourceRef, target, ManagedThreadFactory.class);
    return status;
}
Also used : ResourceStatus(org.glassfish.resourcebase.resources.api.ResourceStatus) ManagedThreadFactory(org.glassfish.concurrent.config.ManagedThreadFactory)

Aggregations

ResourceStatus (org.glassfish.resourcebase.resources.api.ResourceStatus)60 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)17 HashMap (java.util.HashMap)15 ActionReport (org.glassfish.api.ActionReport)15 Resources (com.sun.enterprise.config.serverbeans.Resources)14 PropertyVetoException (java.beans.PropertyVetoException)14 ResourceException (javax.resource.ResourceException)13 SingleConfigCode (org.jvnet.hk2.config.SingleConfigCode)4 Resource (com.sun.enterprise.config.serverbeans.Resource)3 ArrayList (java.util.ArrayList)2 Iterator (java.util.Iterator)2 Properties (java.util.Properties)2 ContextService (org.glassfish.concurrent.config.ContextService)2 ManagedExecutorService (org.glassfish.concurrent.config.ManagedExecutorService)2 ManagedThreadFactory (org.glassfish.concurrent.config.ManagedThreadFactory)2 JdbcResource (org.glassfish.jdbc.config.JdbcResource)2 MailResource (org.glassfish.resources.javamail.config.MailResource)2 ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)1 Module (com.sun.enterprise.config.serverbeans.Module)1 ResourcePool (com.sun.enterprise.config.serverbeans.ResourcePool)1