Commit ba206cbf6228982e7c627b68c4d0981ef2bbba35
Exists in
master
Merge pull request #6 from thisoares/master
Implementação para os registros 743, 744 e 745 do mantis.
Showing
4 changed files
with
28 additions
and
18 deletions
Show diff stats
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/interceptor/ExceptionHandlerInterceptor.java
@@ -74,7 +74,7 @@ public class ExceptionHandlerInterceptor implements Serializable { | @@ -74,7 +74,7 @@ public class ExceptionHandlerInterceptor implements Serializable { | ||
74 | 74 | ||
75 | private final Map<Class<?>, Map<Class<?>, Method>> cache = new HashMap<Class<?>, Map<Class<?>, Method>>(); | 75 | private final Map<Class<?>, Map<Class<?>, Method>> cache = new HashMap<Class<?>, Map<Class<?>, Method>>(); |
76 | 76 | ||
77 | - private final boolean handleException(final Exception cause, final InvocationContext ic) throws Throwable { | 77 | + private final boolean handleException(final Exception cause, final InvocationContext ic) throws Exception { |
78 | logger.info(bundle.getString("handling-exception", cause.getClass().getCanonicalName())); | 78 | logger.info(bundle.getString("handling-exception", cause.getClass().getCanonicalName())); |
79 | 79 | ||
80 | boolean handled = false; | 80 | boolean handled = false; |
@@ -164,21 +164,26 @@ public class ExceptionHandlerInterceptor implements Serializable { | @@ -164,21 +164,26 @@ public class ExceptionHandlerInterceptor implements Serializable { | ||
164 | return cache.containsKey(type); | 164 | return cache.containsKey(type); |
165 | } | 165 | } |
166 | 166 | ||
167 | - private final void invoke(final Method method, final Object object, final Exception param) throws Throwable { | 167 | + private final void invoke(final Method method, final Object object, final Exception param) throws Exception { |
168 | boolean accessible = method.isAccessible(); | 168 | boolean accessible = method.isAccessible(); |
169 | method.setAccessible(true); | 169 | method.setAccessible(true); |
170 | 170 | ||
171 | try { | 171 | try { |
172 | method.invoke(object, param); | 172 | method.invoke(object, param); |
173 | } catch (InvocationTargetException cause) { | 173 | } catch (InvocationTargetException cause) { |
174 | - throw cause.getTargetException(); | 174 | + Throwable targetTrowable = cause.getTargetException(); |
175 | + if (targetTrowable instanceof Exception) { | ||
176 | + throw (Exception) targetTrowable; | ||
177 | + } else { | ||
178 | + throw new Exception(targetTrowable); | ||
179 | + } | ||
175 | } | 180 | } |
176 | 181 | ||
177 | method.setAccessible(accessible); | 182 | method.setAccessible(accessible); |
178 | } | 183 | } |
179 | 184 | ||
180 | @AroundInvoke | 185 | @AroundInvoke |
181 | - public Object manage(final InvocationContext ic) throws Throwable { | 186 | + public Object manage(final InvocationContext ic) throws Exception { |
182 | Object result = null; | 187 | Object result = null; |
183 | 188 | ||
184 | try { | 189 | try { |
impl/core/src/main/java/br/gov/frameworkdemoiselle/util/Beans.java
@@ -65,26 +65,24 @@ public class Beans { | @@ -65,26 +65,24 @@ public class Beans { | ||
65 | return manager; | 65 | return manager; |
66 | } | 66 | } |
67 | 67 | ||
68 | - @SuppressWarnings("unchecked") | ||
69 | public static <T> T getReference(final Class<T> beanClass, Annotation... qualifiers) { | 68 | public static <T> T getReference(final Class<T> beanClass, Annotation... qualifiers) { |
70 | Bean<?> bean = manager.getBeans(beanClass, qualifiers).iterator().next(); | 69 | Bean<?> bean = manager.getBeans(beanClass, qualifiers).iterator().next(); |
71 | - return (T) getReference(bean); | 70 | + return (T) getReference(bean, beanClass); |
72 | } | 71 | } |
73 | 72 | ||
74 | - @SuppressWarnings("unchecked") | ||
75 | public static <T> T getReference(final Class<T> beanClass) { | 73 | public static <T> T getReference(final Class<T> beanClass) { |
76 | Bean<?> bean = manager.getBeans(beanClass).iterator().next(); | 74 | Bean<?> bean = manager.getBeans(beanClass).iterator().next(); |
77 | - return (T) getReference(bean); | 75 | + return (T) getReference(bean, beanClass); |
78 | } | 76 | } |
79 | 77 | ||
80 | @SuppressWarnings("unchecked") | 78 | @SuppressWarnings("unchecked") |
81 | public static <T> T getReference(String beanName) { | 79 | public static <T> T getReference(String beanName) { |
82 | Bean<?> bean = manager.getBeans(beanName).iterator().next(); | 80 | Bean<?> bean = manager.getBeans(beanName).iterator().next(); |
83 | - return (T) getReference(bean); | 81 | + return (T) getReference(bean, bean.getBeanClass()); |
84 | } | 82 | } |
85 | 83 | ||
86 | @SuppressWarnings("unchecked") | 84 | @SuppressWarnings("unchecked") |
87 | - private static <T> T getReference(Bean<?> bean) { | ||
88 | - return (T) manager.getReference(bean, bean.getBeanClass(), manager.createCreationalContext(bean)); | 85 | + private static <T> T getReference(Bean<?> bean, final Class<T> beanClass) { |
86 | + return (T) manager.getReference(bean, beanClass, manager.createCreationalContext(bean)); | ||
89 | } | 87 | } |
90 | } | 88 | } |
impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/template/AbstractEditPageBean.java
@@ -43,12 +43,11 @@ import javax.inject.Inject; | @@ -43,12 +43,11 @@ import javax.inject.Inject; | ||
43 | import br.gov.frameworkdemoiselle.DemoiselleException; | 43 | import br.gov.frameworkdemoiselle.DemoiselleException; |
44 | import br.gov.frameworkdemoiselle.annotation.Name; | 44 | import br.gov.frameworkdemoiselle.annotation.Name; |
45 | import br.gov.frameworkdemoiselle.util.Beans; | 45 | import br.gov.frameworkdemoiselle.util.Beans; |
46 | +import br.gov.frameworkdemoiselle.util.Faces; | ||
46 | import br.gov.frameworkdemoiselle.util.Parameter; | 47 | import br.gov.frameworkdemoiselle.util.Parameter; |
47 | import br.gov.frameworkdemoiselle.util.Reflections; | 48 | import br.gov.frameworkdemoiselle.util.Reflections; |
48 | import br.gov.frameworkdemoiselle.util.ResourceBundle; | 49 | import br.gov.frameworkdemoiselle.util.ResourceBundle; |
49 | 50 | ||
50 | -import com.sun.faces.util.Util; | ||
51 | - | ||
52 | public abstract class AbstractEditPageBean<T, I> extends AbstractPageBean implements EditPageBean<T> { | 51 | public abstract class AbstractEditPageBean<T, I> extends AbstractPageBean implements EditPageBean<T> { |
53 | 52 | ||
54 | private static final long serialVersionUID = 1L; | 53 | private static final long serialVersionUID = 1L; |
@@ -120,7 +119,7 @@ public abstract class AbstractEditPageBean<T, I> extends AbstractPageBean implem | @@ -120,7 +119,7 @@ public abstract class AbstractEditPageBean<T, I> extends AbstractPageBean implem | ||
120 | } | 119 | } |
121 | 120 | ||
122 | private Converter getIdConverter() { | 121 | private Converter getIdConverter() { |
123 | - return Util.getConverterForClass(getIdClass(), facesContext); | 122 | + return Faces.getConverter(getIdClass()); |
124 | } | 123 | } |
125 | 124 | ||
126 | protected abstract void handleLoad(); | 125 | protected abstract void handleLoad(); |
impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/util/Faces.java
@@ -44,6 +44,7 @@ import static javax.faces.application.FacesMessage.SEVERITY_WARN; | @@ -44,6 +44,7 @@ import static javax.faces.application.FacesMessage.SEVERITY_WARN; | ||
44 | import java.util.List; | 44 | import java.util.List; |
45 | import java.util.Map; | 45 | import java.util.Map; |
46 | 46 | ||
47 | +import javax.faces.application.Application; | ||
47 | import javax.faces.application.FacesMessage; | 48 | import javax.faces.application.FacesMessage; |
48 | import javax.faces.application.FacesMessage.Severity; | 49 | import javax.faces.application.FacesMessage.Severity; |
49 | import javax.faces.component.UIViewRoot; | 50 | import javax.faces.component.UIViewRoot; |
@@ -54,8 +55,6 @@ import br.gov.frameworkdemoiselle.exception.ApplicationException; | @@ -54,8 +55,6 @@ import br.gov.frameworkdemoiselle.exception.ApplicationException; | ||
54 | import br.gov.frameworkdemoiselle.message.Message; | 55 | import br.gov.frameworkdemoiselle.message.Message; |
55 | import br.gov.frameworkdemoiselle.message.SeverityType; | 56 | import br.gov.frameworkdemoiselle.message.SeverityType; |
56 | 57 | ||
57 | -import com.sun.faces.util.Util; | ||
58 | - | ||
59 | public class Faces { | 58 | public class Faces { |
60 | 59 | ||
61 | public static void addMessages(final List<Message> messages) { | 60 | public static void addMessages(final List<Message> messages) { |
@@ -147,9 +146,18 @@ public class Faces { | @@ -147,9 +146,18 @@ public class Faces { | ||
147 | } | 146 | } |
148 | 147 | ||
149 | public static Converter getConverter(Class<?> clazz) { | 148 | public static Converter getConverter(Class<?> clazz) { |
150 | - return Util.getConverterForClass(clazz, getFacesContext()); | 149 | + FacesContext context = getFacesContext(); |
150 | + if (clazz == null) { | ||
151 | + return null; | ||
152 | + } | ||
153 | + try { | ||
154 | + Application application = context.getApplication(); | ||
155 | + return application.createConverter(clazz); | ||
156 | + } catch (Exception e) { | ||
157 | + return null; | ||
158 | + } | ||
151 | } | 159 | } |
152 | - | 160 | + |
153 | public static Map<String, Object> getViewMap() { | 161 | public static Map<String, Object> getViewMap() { |
154 | UIViewRoot viewRoot = getFacesContext().getViewRoot(); | 162 | UIViewRoot viewRoot = getFacesContext().getViewRoot(); |
155 | return viewRoot.getViewMap(true); | 163 | return viewRoot.getViewMap(true); |