FileDocCategorySizeDatePackage
AppClientResourceType.javaAPI DocGlassfish v2 API5779Fri May 04 22:33:28 BST 2007com.sun.enterprise.tools.verifier.tests.appclient.elements

AppClientResourceType

public class AppClientResourceType extends com.sun.enterprise.tools.verifier.tests.appclient.AppClientTest implements com.sun.enterprise.tools.verifier.tests.appclient.AppClientCheck
The application client resource-type element specifies the Java class type of the data source.

Fields Summary
Constructors Summary
Methods Summary
public Resultcheck(ApplicationClientDescriptor descriptor)
The application client resource-type element specifies the Java class type of the data source.

param
descriptor the Application client deployment descriptor
return
Result the results for this assertion


	Result result = getInitializedResult();
	ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();

	if (!descriptor.getResourceReferenceDescriptors().isEmpty()) {
	    boolean oneFailed = false;
	    boolean foundIt = false;
	    Set resources = descriptor.getResourceReferenceDescriptors();
	    Iterator itr = resources.iterator();
	    // get the res-ref's in this .ear
	    while(itr.hasNext()) {
		foundIt = false;
		ResourceReferenceDescriptor next = (ResourceReferenceDescriptor) itr.next();
		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.jms.ConnectionFactory")) ||
		    (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, 1.4) >= 0) {
                      // with J2EE 1.4, resource-ref can be any userdefined type
                      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 application client [ {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 application client [ {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 application client [ {0} ]",
				  new Object[] {descriptor.getName()}));
	}

	return result;