Package org.apache.shale.tiger.register

Examples of org.apache.shale.tiger.register.FacesPhaseListener


        // Save the instance that we are adapting for
        this.instance = instance;

        // Look up the @FacesFacesListener annotation for this class
        FacesPhaseListener fpl = instance.getClass().getAnnotation(FacesPhaseListener.class);
        if (fpl == null) {
            throw new IllegalArgumentException("Implementing class "
              + instance.getClass().getName()
              + " does not have the @FacesPhaseListener annotation");
        }

        // Extract the relevant before and after event methods from the
        // underlying class
        Method[] methods = instance.getClass().getMethods();
        for (int i = 0; i < methods.length; i++) {
            Method method = methods[i];
            Class[] signature = method.getParameterTypes();
            if (method.getAnnotation(BeforePhase.class) != null) {
                if (signature.length != 1) {
                    throw new IllegalArgumentException("Method " + method.getName()
                            + " of class " + instance.getClass().getName()
                            + " does not take a exactly one parameter");
                } else if (!(signature[0] == PhaseEvent.class)) {
                    throw new IllegalArgumentException("Method " + method.getName()
                            + " of class " + instance.getClass().getName()
                            + " does not take a javax.faces.event.PhaaseEvent parameter");
                } else {
                    this.beforePhase = method;
                }
            } else if (method.getAnnotation(AfterPhase.class) != null) {
                if (signature.length != 1) {
                    throw new IllegalArgumentException("Method " + method.getName()
                            + " of class " + instance.getClass().getName()
                            + " does not take a exactly one parameter");
                } else if (!(signature[0] == PhaseEvent.class)) {
                    throw new IllegalArgumentException("Method " + method.getName()
                            + " of class " + instance.getClass().getName()
                            + " does not take a javax.faces.event.PhaaseEvent parameter");
                } else {
                    this.afterPhase = method;
                }
            }
        }

        // Extract the relevant phase identifer from the underlying class
        FacesPhaseListener.PhaseId pi = fpl.phaseId();
        if (pi == FacesPhaseListener.PhaseId.ANY_PHASE) {
            this.phaseId = PhaseId.ANY_PHASE;
        } else if (pi == FacesPhaseListener.PhaseId.RESTORE_VIEW) {
            this.phaseId = PhaseId.RESTORE_VIEW;
        } else if (pi == FacesPhaseListener.PhaseId.APPLY_REQUEST_VALUES) {
View Full Code Here


                log().trace("addConverter(" + conv.value() + "," + clazz.getName() + ")");
            }
            application().addConverter(conv.value(), clazz.getName());
        }

        FacesPhaseListener list = (FacesPhaseListener) clazz.getAnnotation(FacesPhaseListener.class);
        if (list != null) {
            try {
                Lifecycle lifecycle = lifecycle();
                Object instance = clazz.newInstance();
                if (instance instanceof PhaseListener) {
View Full Code Here

TOP

Related Classes of org.apache.shale.tiger.register.FacesPhaseListener

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.