Search in sources :

Example 1 with ConnectionDefDescriptor

use of com.sun.enterprise.deployment.ConnectionDefDescriptor in project Payara by payara.

the class CheckConfigPropertyType method check.

/**
 * <p>
 * Properties names defined in the resource adapter config-propery should
 * be of an acceptable type
 * </p>
 *
 * @paramm descriptor deployment descriptor for the rar file
 * @return result object containing the result of the individual test
 * performed
 */
public Result check(ConnectorDescriptor descriptor) {
    boolean oneFailed = false;
    Result result = getInitializedResult();
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    // Set properties = descriptor.getConfigProperties();
    ConnectionDefDescriptor desc = descriptor.getConnectionDefinitionByCFType(null, true);
    Set properties = desc.getConfigProperties();
    if (properties.size() != 0) {
        Iterator iterator = properties.iterator();
        // HashSet hs = new HashSet();
        while (iterator.hasNext()) {
            EnvironmentProperty ep = (EnvironmentProperty) iterator.next();
            String type = ep.getType();
            if (type == null) {
                result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                result.failed(smh.getLocalString(getClass().getName() + ".notdefined", "Error: The configuration property named [ {0} ] has no type ", new Object[] { ep.getName() }));
                return result;
            }
            Class typeClass = null;
            // is it loadable ?
            try {
                typeClass = Class.forName(type);
            } catch (Throwable t) {
                result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                result.failed(smh.getLocalString(getClass().getName() + ".nonexist", "Error: The type [ {0} ] of the configuration property named [ {1} ] cannot be loaded", new Object[] { ep.getType(), ep.getName() }));
                return result;
            }
            boolean allowedType = false;
            for (int i = 0; i < allowedTypes.length; i++) {
                if (allowedTypes[i].equals(typeClass)) {
                    allowedType = true;
                    break;
                }
            }
            if (!allowedType) {
                oneFailed = true;
                result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                result.failed(smh.getLocalString(getClass().getName() + ".failed", "Error: The type [ {0} ] for the configuration property named [ {1} ] is not allowed", new Object[] { ep.getType(), ep.getName() }));
                return result;
            }
        }
        // for failure, result has been set before
        if (!oneFailed) {
            result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
            result.passed(smh.getLocalString(getClass().getName() + ".passed", "Success: all properties have an allowed type"));
        }
    } else {
        result.addNaDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
        result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "Not Applicable: There are no config-property element defined"));
    }
    return result;
}
Also used : ConnectionDefDescriptor(com.sun.enterprise.deployment.ConnectionDefDescriptor) EnvironmentProperty(com.sun.enterprise.deployment.EnvironmentProperty) Result(com.sun.enterprise.tools.verifier.Result)

Example 2 with ConnectionDefDescriptor

use of com.sun.enterprise.deployment.ConnectionDefDescriptor in project Payara by payara.

the class CheckConnectionFactoryImplReferenceable method check.

/**
 * <p>
 * Test for each connection-definition, that "connectionfactory-impl-class"
 * implements javax.resource.Referenceable
 * </p>
 *
 * @param descriptor deployment descriptor for the rar file
 * @return result object containing the result of the individual test
 * performed
 */
public Result check(ConnectorDescriptor descriptor) {
    Result result = getInitializedResult();
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    // test NA for inboundRA
    if (!descriptor.getOutBoundDefined()) {
        result.addNaDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
        result.notApplicable(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.connector.managed.notApplicableForInboundRA", "Resource Adapter does not provide outbound communication"));
        return result;
    }
    OutboundResourceAdapter outboundRA = descriptor.getOutboundResourceAdapter();
    if (outboundRA == null) {
        return null;
    }
    boolean oneFailed = false;
    Set connDefs = outboundRA.getConnectionDefs();
    Iterator iter = connDefs.iterator();
    while (iter.hasNext()) {
        ConnectionDefDescriptor connDefDesc = (ConnectionDefDescriptor) iter.next();
        String connectionImpl = connDefDesc.getConnectionFactoryImpl();
        Class implClass = null;
        try {
            implClass = Class.forName(connectionImpl, false, getVerifierContext().getClassLoader());
        } catch (ClassNotFoundException e) {
            result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
            result.failed(smh.getLocalString(getClass().getName() + ".nonexist", "Error: The class [ {0} ] as defined under connectionfactory-impl-class in the deployment descriptor does not exist", new Object[] { connectionImpl }));
            return result;
        }
        if (!isImplementorOf(implClass, "javax.resource.Referenceable")) {
            oneFailed = true;
            result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
            result.failed(smh.getLocalString(getClass().getName() + ".failed", "Error: connectionfactory-impl-class [ {0} ] does not implement javax.resource.Referenceable", new Object[] { implClass.getName() }));
            return result;
        }
    }
    if (!oneFailed) {
        result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
        result.passed(smh.getLocalString(getClass().getName() + ".passed", "Success: all connectionfactory-impl-class implement javax.resource.Referenceable"));
    }
    return result;
}
Also used : Set(java.util.Set) ConnectionDefDescriptor(com.sun.enterprise.deployment.ConnectionDefDescriptor) Iterator(java.util.Iterator) OutboundResourceAdapter(com.sun.enterprise.deployment.OutboundResourceAdapter) Result(com.sun.enterprise.tools.verifier.Result)

Example 3 with ConnectionDefDescriptor

use of com.sun.enterprise.deployment.ConnectionDefDescriptor in project Payara by payara.

the class ActiveResourceAdapterImpl method createDefaultConnectorResources.

/**
 * Creates default connector resource
 *
 * @throws ConnectorRuntimeException when unable to create connector resources
 */
protected void createDefaultConnectorResources() throws ConnectorRuntimeException {
    for (ConnectionDefDescriptor descriptor : connectionDefs_) {
        String connectionDefName = descriptor.getConnectionFactoryIntf();
        String resourceName = connectorRuntime_.getDefaultResourceName(moduleName_, connectionDefName);
        String poolName = connectorRuntime_.getDefaultPoolName(moduleName_, connectionDefName);
        PoolInfo poolInfo = new PoolInfo(poolName);
        ResourceInfo resourceInfo = new ResourceInfo(resourceName);
        connectorRuntime_.createConnectorResource(resourceInfo, poolInfo, null);
        desc_.addDefaultResourceName(resourceName);
        if (_logger.isLoggable(Level.FINE)) {
            _logger.log(Level.FINE, "Created default connector resource [ " + resourceName + " ] ");
        }
    }
}
Also used : ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) ConnectionDefDescriptor(com.sun.enterprise.deployment.ConnectionDefDescriptor) PoolInfo(org.glassfish.resourcebase.resources.api.PoolInfo)

Example 4 with ConnectionDefDescriptor

use of com.sun.enterprise.deployment.ConnectionDefDescriptor in project Payara by payara.

the class ActiveResourceAdapterImpl method deleteDefaultConnectorConnectionPools.

/**
 * Deletes the default connector connection pools.
 */
protected void deleteDefaultConnectorConnectionPools() {
    for (ConnectionDefDescriptor aConnectionDefs_ : connectionDefs_) {
        String connectionDefName = aConnectionDefs_.getConnectionFactoryIntf();
        String resourceJndiName = connectorRuntime_.getDefaultPoolName(moduleName_, connectionDefName);
        try {
            PoolInfo poolInfo = new PoolInfo(resourceJndiName);
            connectorRuntime_.deleteConnectorConnectionPool(poolInfo);
        } catch (ConnectorRuntimeException cre) {
            _logger.log(Level.WARNING, "rar.undeployment.default_pool_delete_fail", resourceJndiName);
        }
    }
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) ConnectionDefDescriptor(com.sun.enterprise.deployment.ConnectionDefDescriptor) PoolInfo(org.glassfish.resourcebase.resources.api.PoolInfo)

Example 5 with ConnectionDefDescriptor

use of com.sun.enterprise.deployment.ConnectionDefDescriptor in project Payara by payara.

the class ActiveResourceAdapterImpl method deleteDefaultConnectorResources.

/**
 * Deletes the default connector resources.
 */
protected void deleteDefaultConnectorResources() {
    for (ConnectionDefDescriptor aConnectionDefs_ : connectionDefs_) {
        String connectionDefName = aConnectionDefs_.getConnectionFactoryIntf();
        String resourceJndiName = connectorRuntime_.getDefaultResourceName(moduleName_, connectionDefName);
        try {
            ResourceInfo resourceInfo = new ResourceInfo(resourceJndiName);
            connectorRuntime_.deleteConnectorResource(resourceInfo);
        } catch (ConnectorRuntimeException cre) {
            _logger.log(Level.WARNING, "rar.undeployment.default_resource_delete_fail", resourceJndiName);
            if (_logger.isLoggable(Level.FINE)) {
                _logger.log(Level.FINE, "Error while trying to delete the default connector resource", cre);
            }
        }
    }
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) ConnectionDefDescriptor(com.sun.enterprise.deployment.ConnectionDefDescriptor)

Aggregations

ConnectionDefDescriptor (com.sun.enterprise.deployment.ConnectionDefDescriptor)18 OutboundResourceAdapter (com.sun.enterprise.deployment.OutboundResourceAdapter)11 Iterator (java.util.Iterator)8 Set (java.util.Set)8 Result (com.sun.enterprise.tools.verifier.Result)6 PoolInfo (org.glassfish.resourcebase.resources.api.PoolInfo)4 ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)3 ConnectorDescriptor (com.sun.enterprise.deployment.ConnectorDescriptor)3 EnvironmentProperty (com.sun.enterprise.deployment.EnvironmentProperty)2 ResourceInfo (org.glassfish.resourcebase.resources.api.ResourceInfo)2 ConnectorDescriptorInfo (com.sun.enterprise.connectors.ConnectorDescriptorInfo)1 ConnectorRegistry (com.sun.enterprise.connectors.ConnectorRegistry)1 ConnectorConfigProperty (com.sun.enterprise.deployment.ConnectorConfigProperty)1 RarBundleContext (com.sun.enterprise.deployment.annotation.context.RarBundleContext)1 ClassLoader (java.lang.ClassLoader)1 Method (java.lang.reflect.Method)1 ManagedConnectionFactory (javax.resource.spi.ManagedConnectionFactory)1 Property (org.jvnet.hk2.config.types.Property)1