package org.gluu.jsf2.service;

import javax.enterprise.context.Dependent;
import javax.enterprise.inject.Produces;
import javax.faces.application.ViewHandler;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletRequest;

/**
 * @author Yuriy Movchan
 * @version 03/17/2017
 */
public class FacesResources {

	@Produces
	@Dependent
	public FacesContext getFacesContext() {
		return FacesContext.getCurrentInstance();
	}

	@Produces
	@Dependent
	public ExternalContext getExternalContext() {
		FacesContext facesContext = getFacesContext();
		if (facesContext != null) {
			return facesContext.getExternalContext();
		}
		
		return null;
	}

	@Produces
	@Dependent
	public ViewHandler getViewHandler() {
		FacesContext facesContext = getFacesContext();
		if (facesContext != null) {
			return facesContext.getApplication().getViewHandler();
		}
		
		return null;
	}

}

@@ -67,24 +67,72 @@
 Dependent;%0D%0A
+import javax.enterprise.context.RequestScoped;%0D%0A
 import javax
@@ -161,16 +161,16 @@
 duces;%0D%0A
-
 import j
@@ -296,55 +296,8 @@
 xt;%0D
-%0Aimport javax.servlet.http.HttpServletRequest;%0D
 %0A%0D%0A/
@@ -398,33 +398,37 @@
 Produces%0D%0A%09@
-Dependent
+RequestScoped
 %0D%0A%09public Fa
@@ -520,33 +520,37 @@
 Produces%0D%0A%09@
-Dependent
+RequestScoped
 %0D%0A%09public Ex

Fix External and Faces contexts scopes