Search in sources :

Example 11 with OutboundResourceAdapter

use of com.sun.enterprise.deployment.OutboundResourceAdapter 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 12 with OutboundResourceAdapter

use of com.sun.enterprise.deployment.OutboundResourceAdapter 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)

Example 13 with OutboundResourceAdapter

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

the class CheckConnectionFactoryImplSerializable method check.

/**
 * <p>
 * Test for each connection-definition, that "connectionfactory-impl-class"
 * implements java.io.Serializable
 * </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, "java.io.Serializable")) {
            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 java.io.Serializable", 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 java.io.Serializable"));
    }
    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 14 with OutboundResourceAdapter

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

the class ManagedConnectionFactoryProperties method check.

/**
 * <p>
 * Test that the class declared implementing the javax.resource.spi.ManagedConnectionFactory
 * interface implements the properties declared under the config-property
 * xml tag under the followind requirements :
 *      - Provide a getter and setter method ala JavaBeans
 *      - Properties should be either bound or constrained
 *      - PropertyListener registration/unregistration methods are public
 * </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;
    }
    boolean oneFailed = false;
    OutboundResourceAdapter outboundRA = descriptor.getOutboundResourceAdapter();
    Set connDefs = outboundRA.getConnectionDefs();
    Iterator iter = connDefs.iterator();
    while (iter.hasNext()) {
        ConnectionDefDescriptor connDefDesc = (ConnectionDefDescriptor) iter.next();
        Set configProperties = connDefDesc.getConfigProperties();
        if (!configProperties.isEmpty()) {
            Iterator propIterator = configProperties.iterator();
            Class mcf = testManagedConnectionFactoryImpl(descriptor, result);
            if (mcf == null) {
                // set the error code now, just abandon
                return result;
            }
            while (propIterator.hasNext()) {
                EnvironmentProperty ep = (EnvironmentProperty) propIterator.next();
                // Set method first
                String propertyName = Character.toUpperCase(ep.getName().charAt(0)) + ep.getName().substring(1);
                String setMethodName = "set" + propertyName;
                Class[] parmTypes = new Class[] { ep.getValueType() };
                Method m = getMethod(mcf, setMethodName, parmTypes);
                if (m != null) {
                    result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                    result.addGoodDetails(smh.getLocalString(getClass().getName() + ".passed", "Found a JavaBeans compliant accessor method [ {0} ] for the config-property [ {1} ]", new Object[] { m, ep.getName() }));
                } else {
                    oneFailed = true;
                    result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                    result.addErrorDetails(smh.getLocalString(getClass().getName() + ".failed", "Error: There is no JavaBeans compliant accessor method [ {0} ] implemented in [ {1} ] for the config-property [ {2} ]", new Object[] { "public void " + setMethodName + "(" + ep.getValueType().getName() + ")", mcf.getName(), ep.getName() }));
                }
                String getMethodName = "get" + propertyName;
                m = getMethod(mcf, getMethodName, null);
                if (m != null) {
                    result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                    result.addGoodDetails(smh.getLocalString(getClass().getName() + ".passed", "Found a JavaBeans compliant accessor method [ {0} ] for the config-property [ {1} ]", new Object[] { m, ep.getName() }));
                } else {
                    oneFailed = true;
                    result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
                    result.addErrorDetails(smh.getLocalString(getClass().getName() + ".failed", "Error: There is no JavaBeans compliant accessor method [ {0} ] implemented in [ {1} ] for the config-property [ {2} ]", new Object[] { "public " + ep.getValueType().getName() + " " + getMethodName, mcf.getName(), ep.getName() }));
                }
            }
        }
    }
    if (oneFailed) {
        result.setStatus(Result.FAILED);
    } else {
        result.setStatus(Result.PASSED);
    }
    return result;
}
Also used : ConnectionDefDescriptor(com.sun.enterprise.deployment.ConnectionDefDescriptor) Method(java.lang.reflect.Method) Result(com.sun.enterprise.tools.verifier.Result) EnvironmentProperty(com.sun.enterprise.deployment.EnvironmentProperty) OutboundResourceAdapter(com.sun.enterprise.deployment.OutboundResourceAdapter)

Example 15 with OutboundResourceAdapter

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

the class ManagedConnectionFactoryTest method getManagedConnectionFactoryImpl.

/**
 * <p>
 * Get the <code>Class</code> object of the class declared to be implementing
 * the javax.resource.spi.ManagedConnectionFactory interface in the
 * archive deployment descriptor
 * </p>
 *
 * @param descriptor the rar file deployment descriptor
 *
 * @throws ClassNotFoundException if the class identified by className
 * cannot be loaded
 */
protected Class getManagedConnectionFactoryImpl(ConnectorDescriptor descriptor) throws ClassNotFoundException {
    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();
        managedConnectionFactoryImpl = connDefDesc.getManagedConnectionFactoryImpl();
        Class implClass = Class.forName(managedConnectionFactoryImpl, false, getVerifierContext().getClassLoader());
        if (isImplementorOf(implClass, "javax.resource.spi.ManagedConnectionFactory")) {
            return implClass;
        }
    }
    return null;
/*  String className = descriptor.getManagedConnectionFactoryImpl();
          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)

Aggregations

OutboundResourceAdapter (com.sun.enterprise.deployment.OutboundResourceAdapter)16 ConnectionDefDescriptor (com.sun.enterprise.deployment.ConnectionDefDescriptor)11 Set (java.util.Set)10 Iterator (java.util.Iterator)9 AuthMechanism (com.sun.enterprise.deployment.AuthMechanism)5 ConnectorDescriptor (com.sun.enterprise.deployment.ConnectorDescriptor)5 Result (com.sun.enterprise.tools.verifier.Result)5 RarBundleContext (com.sun.enterprise.deployment.annotation.context.RarBundleContext)3 AuthenticationMechanism (javax.resource.spi.AuthenticationMechanism)3 BasicPasswordAuthenticationService (com.sun.enterprise.connectors.authentication.BasicPasswordAuthenticationService)1 EnvironmentProperty (com.sun.enterprise.deployment.EnvironmentProperty)1 LicenseDescriptor (com.sun.enterprise.deployment.LicenseDescriptor)1 DeploymentDescriptorNode (com.sun.enterprise.deployment.node.DeploymentDescriptorNode)1 ClassLoader (java.lang.ClassLoader)1 Method (java.lang.reflect.Method)1 SecurityPermission (javax.resource.spi.SecurityPermission)1 WorkContext (javax.resource.spi.work.WorkContext)1 Node (org.w3c.dom.Node)1