public static void setCurrentInstance(PrimeApplicationContext context, FacesContext facesContext) {
        facesContext.getExternalContext().getApplicationMap().put(INSTANCE_KEY, context);

        if (facesContext.getExternalContext().getContext() instanceof ServletContext) {
            ((ServletContext) facesContext.getExternalContext().getContext()).setAttribute(INSTANCE_KEY, context);
        }
    }
A {@link PrimeApplicationContext} is a contextual store for the current application.

It can be accessed via:
<blockquote>
PrimeApplicationContext.getCurrentInstance(context)
</blockquote>
primefaces/src/main/java/org/primefaces/context/PrimeApplicationContext.java