public FacesContext getFacesContext(Object context, Object request,
                                        Object response,
                                        Lifecycle lifecycle) throws FacesException {

        // Select the appropriate MockExternalContext implementation class
        Class clazz = MockExternalContext.class;
        if (jsf12) {
            try {
                clazz = this.getClass().getClassLoader().loadClass
                  ("org.apache.shale.test.mock.MockExternalContext12");
            } catch (RuntimeException e) {
                throw e;
            } catch (Exception e) {
                throw new FacesException(e);
            }
        }

        // Select the constructor we wish to call
        Constructor mecConstructor = null;
        try {
            mecConstructor = clazz.getConstructor(externalContextSignature);
        } catch (RuntimeException e) {
            throw e;
        } catch (Exception e) {
            throw new FacesException(e);
        }

        // Construct an appropriate MockExternalContext instance
        MockExternalContext externalContext = null;
        try {
            externalContext = (MockExternalContext) mecConstructor.newInstance
              (new Object[] { context, request, response });
        } catch (RuntimeException e) {
            throw e;
        } catch (Exception e) {
            throw new FacesException(e);
        }

        // Construct an appropriate MockFacesContext instance and return it
        try {
            return (MockFacesContext)
              constructor.newInstance(new Object[] { externalContext, lifecycle });
        } catch (RuntimeException e) {
            throw e;
        } catch (Exception e) {
            throw new FacesException(e);
        }

    }