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);
}
}
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;
}
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;
}
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); */
}
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;
}
Aggregations