Search in sources :

Example 11 with ConnectionDefDescriptor

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

the class CCITest method isCCIImplemented.

/**
 * <p>
 * Checks whether the resource adapater is implementing the CCI interfaces
 * </p>
 * @param descriptor the deployment descriptor
 * @param result to put the result
 * @return true if the CCI is implemented
 */
protected boolean isCCIImplemented(ConnectorDescriptor descriptor, Result result) {
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    OutboundResourceAdapter outboundRA = descriptor.getOutboundResourceAdapter();
    if (outboundRA == null) {
        return false;
    }
    Set connDefs = outboundRA.getConnectionDefs();
    Iterator iter = connDefs.iterator();
    while (iter.hasNext()) {
        ConnectionDefDescriptor connDefDesc = (ConnectionDefDescriptor) iter.next();
        // check if intf implements javax.resource.cci.ConnectionFactory
        String intf = connDefDesc.getConnectionFactoryIntf();
        Class implClass = null;
        try {
            implClass = Class.forName(intf, false, getVerifierContext().getClassLoader());
        } catch (ClassNotFoundException e) {
            result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
            result.failed(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.connector.ConnectorTest.isClassLoadable.failed", "The class [ {0} ] is not contained in the archive file", new Object[] { intf }));
            continue;
        }
        if (isImplementorOf(implClass, "javax.resource.cci.ConnectionFactory")) {
            return true;
        }
    }
    return false;
}
Also used : Set(java.util.Set) ConnectionDefDescriptor(com.sun.enterprise.deployment.ConnectionDefDescriptor) Iterator(java.util.Iterator) OutboundResourceAdapter(com.sun.enterprise.deployment.OutboundResourceAdapter)

Example 12 with ConnectionDefDescriptor

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

the class ConnectionFactoryTest method getConnectionFactoryImpl.

/**
 * <p>
 * Get the <code>Class</code> object of the class declared as implementing
 * the javax.resource.cci.ConnectionFactory interface and declared in the
 * archive deployment descriptors under the connection-factory-impl-class
 * </p>
 *
 * @param descriptor the rar file deployment descriptor
 * @param result instance to use to put the result of the test
 * @return Class object for the connectionfactoryimpl-class that implements
 * javax.resource.cci.ConnectionFactory
 */
protected Class getConnectionFactoryImpl(ConnectorDescriptor descriptor, Result result) {
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    OutboundResourceAdapter outboundRA = descriptor.getOutboundResourceAdapter();
    if (outboundRA == null) {
        return null;
    }
    Set connDefs = outboundRA.getConnectionDefs();
    Iterator iter = connDefs.iterator();
    while (iter.hasNext()) {
        ConnectionDefDescriptor connDefDesc = (ConnectionDefDescriptor) iter.next();
        String impl = connDefDesc.getConnectionFactoryImpl();
        Class implClass = null;
        try {
            implClass = Class.forName(impl, false, getVerifierContext().getClassLoader());
        } catch (ClassNotFoundException cnfe) {
            result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
            result.failed(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.connector.cci.ConnectionFactoryTest.nonexist", "Error: The class [ {0} ] as defined in the connectionfactory-impl-class deployment descriptor does not exist", new Object[] { impl }));
            return null;
        }
        if (isImplementorOf(implClass, "javax.resource.cci.ConnectionFactory"))
            return implClass;
    }
    return null;
/*String className = descriptor.getConnectionFactoryImpl();
      if (className == null) 
      return null;

      VerifierTestContext context = getVerifierContext();
      ClassLoader jcl = context.getRarClassLoader();
      return jcl.loadClass(className);   */
}
Also used : Set(java.util.Set) ConnectionDefDescriptor(com.sun.enterprise.deployment.ConnectionDefDescriptor) Iterator(java.util.Iterator) OutboundResourceAdapter(com.sun.enterprise.deployment.OutboundResourceAdapter)

Example 13 with ConnectionDefDescriptor

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

the class ConnectionTest method getConnectionImpl.

/**
 * <p>
 * Get the <code>Class</code> object of the class declared as implementing
 * the javax.resource.cci.Connection interface and declared in the
 * archive deployment descriptors under the connection-impl-class
 * </p>
 *
 * @param descriptor the rar file deployment descriptor
 * @param result instance to use to put the result of the test
 * @return Class object for the connectionimpl-class that implements
 * javax.resource.cci.Connection
 */
protected Class getConnectionImpl(ConnectorDescriptor descriptor, Result result) {
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    OutboundResourceAdapter outboundRA = descriptor.getOutboundResourceAdapter();
    if (outboundRA == null) {
        return null;
    }
    Set connDefs = outboundRA.getConnectionDefs();
    Iterator iter = connDefs.iterator();
    while (iter.hasNext()) {
        ConnectionDefDescriptor connDefDesc = (ConnectionDefDescriptor) iter.next();
        String impl = connDefDesc.getConnectionImpl();
        Class implClass = null;
        try {
            implClass = Class.forName(impl, false, getVerifierContext().getClassLoader());
        } catch (ClassNotFoundException cnfe) {
            result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
            result.failed(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.connector.cci.ConnectionTest.nonexist", "Error: The class [ {0} ] as defined in the connection-impl-class deployment descriptor does not exist", new Object[] { impl }));
            return null;
        }
        if (isImplementorOf(implClass, "javax.resource.cci.Connection"))
            return implClass;
    }
    return null;
}
Also used : ConnectionDefDescriptor(com.sun.enterprise.deployment.ConnectionDefDescriptor) OutboundResourceAdapter(com.sun.enterprise.deployment.OutboundResourceAdapter)

Example 14 with ConnectionDefDescriptor

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

the class CheckConnectionFactoryImplClass method check.

/**
 * <p>
 * Test for each connection-definition, that "connection-impl-class"
 * implements "connection-interface".
 * </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) {
    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 connectionInterface = connDefDesc.getConnectionFactoryIntf();
        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, connectionInterface)) {
            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 connectionfactory-interface [ {1} ].", new Object[] { implClass.getName(), connectionInterface }));
            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 their corresponding connectionfactory-interface"));
    }
    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 15 with ConnectionDefDescriptor

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

the class CheckConnectionImplClass method check.

/**
 * <p>
 * Test for each connection-definition, that "connection-impl-class"
 * implements "connection-interface".
 * </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) {
    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 connectionInterface = connDefDesc.getConnectionIntf();
        String connectionImpl = connDefDesc.getConnectionImpl();
        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 connection-impl-class in the deployment descriptor does not exist", new Object[] { connectionImpl }));
            return result;
        }
        if (!isImplementorOf(implClass, connectionInterface)) {
            oneFailed = true;
            result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
            result.failed(smh.getLocalString(getClass().getName() + ".failed", "Error: connection-impl-class [ {0} ] does not implement connection-interface [ {1} ].", new Object[] { implClass.getName(), connectionInterface }));
            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 connection-impl-class implement their corresponding connection-interface"));
    }
    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)

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