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

        FacesContext wrappedContext = getWrapped().getFacesContext(context, request, response, lifecycle);

        if (wrappedContext instanceof PrimeFacesContext) {
            return wrappedContext;
        }

        return new PrimeFacesContext(wrappedContext);
    }
{@link FacesContextFactory} to wrap the {@link FacesContext} with our {@link PrimeFacesContext}.
primefaces/src/main/java/org/primefaces/context/PrimeFacesContextFactory.java