FileDocCategorySizeDatePackage
ListenerClassImplementsValidInterface.javaAPI DocGlassfish v2 API4540Fri May 04 22:34:10 BST 2007com.sun.enterprise.tools.verifier.tests.web

ListenerClassImplementsValidInterface

public class ListenerClassImplementsValidInterface extends ListenerClass implements WebCheck
Listener class must implement a valid interface. Verify that the Listener class implements one of five valid interfaces.
author
Jerome Dochez
version
1.0

Fields Summary
Constructors Summary
Methods Summary
protected booleanrunIndividualListenerTest(com.sun.enterprise.tools.verifier.Result result, java.lang.Class listenerClass)

Run the verifier test against a declared individual listener class

param
result is used to put the test results in
param
listenerClass is the individual listener class object to test
return
true if the test pass

        
        boolean validInterface = false;
        Class clazz = listenerClass;
        
        if (listenerClass==null) {
            return false;
        }
        
	validInterface = isImplementorOf(clazz,"javax.servlet.ServletContextAttributeListener");
	if (validInterface != true) {
	    validInterface = isImplementorOf(clazz,"javax.servlet.ServletContextListener");
	}
	if (validInterface != true) {
	    validInterface = isImplementorOf(clazz,"javax.servlet.http.HttpSessionAttributeListener");
	}
	if (validInterface != true) {
	    validInterface = isImplementorOf(clazz,"javax.servlet.http.HttpSessionListener");
	}
    if (validInterface != true) {
	    validInterface = isImplementorOf(clazz,"javax.servlet.ServletRequestAttributeListener");
	}if (validInterface != true) {
	    validInterface = isImplementorOf(clazz,"javax.servlet.ServletRequestListener");
	}if (validInterface != true) {
	    validInterface = isImplementorOf(clazz,"javax.servlet.http.HttpSessionBindingListener");
	}

         if (validInterface) {
             result.addGoodDetails(smh.getLocalString
                (getClass().getName() + ".passed",
                 "Listener class [ {0} ] implements a valid interface.",
                 new Object[] {listenerClass.getName()}));
         } else if (!validInterface){
             result.addErrorDetails(smh.getLocalString
                (getClass().getName() + ".failed",
                 "Error: Listener class [ {0} ] does not implement one or more of the following valid interface.\n javax.servlet.ServletContextAttributeListener, javax.servlet.ServletContextListener, javax.servlet.http.HttpSessionAttributeListener, javax.servlet.http.HttpSessionListener",
                  new Object[] {clazz.getName()}));
	 }
	    	                     
        return validInterface;