The web application resource-type element specifies the Java class type of
the data source.
Result result = getInitializedResult();
ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
if (descriptor.getResourceReferences().hasMoreElements()) {
boolean oneFailed = false;
boolean foundIt = false;
// get the errorpage's in this .war
for (Enumeration e = descriptor.getResourceReferences() ; e.hasMoreElements() ;) {
foundIt = false;
ResourceReferenceDescriptor next = (ResourceReferenceDescriptor) e.nextElement();
String resType = next.getType();
logger.log(Level.FINE, "servlet resType: " + resType);
if ((resType.equals("javax.sql.DataSource")) ||
(resType.equals("javax.jms.QueueConnectionFactory")) ||
(resType.equals("javax.jms.TopicConnectionFactory")) ||
(resType.equals("javax.mail.Session")) ||
(resType.equals("java.net.URL"))) {
foundIt = true;
} else {
foundIt = false;
String specVerStr = descriptor.getSpecVersion();
double specVer = 0;
specVer = (Double.valueOf(specVerStr)).doubleValue();
if (Double.compare(specVer, 2.4) >= 0) {
// with J2EE 1.4, resource-ref can be any userdefined types
foundIt = true;
}
}
if (foundIt) {
result.addGoodDetails(smh.getLocalString
("tests.componentNameConstructor",
"For [ {0} ]",
new Object[] {compName.toString()}));
result.addGoodDetails(smh.getLocalString
(getClass().getName() + ".passed",
"The resource-type [ {0} ] element specifies the Java class type of the data source within web application [ {1} ]",
new Object[] {resType, descriptor.getName()}));
} else {
if (!oneFailed) {
oneFailed = true;
}
result.addErrorDetails(smh.getLocalString
("tests.componentNameConstructor",
"For [ {0} ]",
new Object[] {compName.toString()}));
result.addErrorDetails(smh.getLocalString
(getClass().getName() + ".failed",
"Error: The resource-type [ {0} ] element does not specify valid Java class type of the data source within web application [ {1} ]",
new Object[] {resType, descriptor.getName()}));
}
}
if (oneFailed) {
result.setStatus(Result.FAILED);
} else {
result.setStatus(Result.PASSED);
}
} else {
result.addNaDetails(smh.getLocalString
("tests.componentNameConstructor",
"For [ {0} ]",
new Object[] {compName.toString()}));
result.notApplicable(smh.getLocalString
(getClass().getName() + ".notApplicable",
"There are no resource-type elements within the web archive [ {0} ]",
new Object[] {descriptor.getName()}));
}
return result;