Search in sources :

Example 6 with OutboundResourceAdapter

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

the class ConnectionDefinitionHandler method handleAnnotation.

private void handleAnnotation(AnnotatedElementHandler aeHandler, ConnectionDefinition connDefn, AnnotationInfo element) {
    RarBundleContext rarContext = (RarBundleContext) aeHandler;
    ConnectorDescriptor desc = rarContext.getDescriptor();
    Class c = (Class) element.getAnnotatedElement();
    String targetClassName = c.getName();
    if (ManagedConnectionFactory.class.isAssignableFrom(c)) {
        if (!desc.getOutBoundDefined()) {
            OutboundResourceAdapter ora = new OutboundResourceAdapter();
            desc.setOutboundResourceAdapter(ora);
        }
        OutboundResourceAdapter ora = desc.getOutboundResourceAdapter();
        if (!ora.hasConnectionDefDescriptor(connDefn.connectionFactory().getName())) {
            ConnectionDefDescriptor cdd = new ConnectionDefDescriptor();
            cdd.setConnectionFactoryImpl(connDefn.connectionFactoryImpl().getName());
            cdd.setConnectionFactoryIntf(connDefn.connectionFactory().getName());
            cdd.setConnectionIntf(connDefn.connection().getName());
            cdd.setConnectionImpl(connDefn.connectionImpl().getName());
            cdd.setManagedConnectionFactoryImpl(targetClassName);
            ora.addConnectionDefDescriptor(cdd);
        }
    // else {
    // ignore the duplicates
    // duplicates can be via :
    // (i) connection-definition defined in DD
    // (ii) as part of this particular annotation processing,
    // already this connection-definition is defined
    // TODO V3 how to handle (ii)
    // }
    } else {
        getFailureResult(element, "Cant handle ConnectionDefinition annotation as the annotated class does not" + "implement ManagedConnectionFactory", true);
    }
}
Also used : ConnectorDescriptor(com.sun.enterprise.deployment.ConnectorDescriptor) ConnectionDefDescriptor(com.sun.enterprise.deployment.ConnectionDefDescriptor) RarBundleContext(com.sun.enterprise.deployment.annotation.context.RarBundleContext) OutboundResourceAdapter(com.sun.enterprise.deployment.OutboundResourceAdapter)

Example 7 with OutboundResourceAdapter

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

the class CCITest method getConnectionInterface.

/**
 * <p>
 * Returns the connection-interface that implements
 * "javax.resource.cci.Connection"
 * </p>
 * @param descriptor the deployment descriptor
 * @param result to put the result
 * @return interface name
 */
protected String getConnectionInterface(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 intf = connDefDesc.getConnectionIntf();
        VerifierTestContext context = getVerifierContext();
        ClassLoader jcl = context.getRarClassLoader();
        Class intfClass = null;
        try {
            intfClass = 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(intfClass, "javax.resource.cci.Connection")) {
            return intf;
        }
    }
    return null;
}
Also used : Set(java.util.Set) ConnectionDefDescriptor(com.sun.enterprise.deployment.ConnectionDefDescriptor) Iterator(java.util.Iterator) ClassLoader(java.lang.ClassLoader) OutboundResourceAdapter(com.sun.enterprise.deployment.OutboundResourceAdapter)

Example 8 with OutboundResourceAdapter

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

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

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

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