Commit 813559f846400e9cda27d357149265163b43b191
Exists in
master
Merge branch '2.3' of https://github.com/demoiselle/framework.git into 2.3
Showing
6 changed files
with
22 additions
and
196 deletions
Show diff stats
impl/extension/jpa/src/main/java/br/gov/frameworkdemoiselle/template/JPACrud.java
| @@ -42,6 +42,7 @@ import java.util.List; | @@ -42,6 +42,7 @@ import java.util.List; | ||
| 42 | import java.util.regex.Matcher; | 42 | import java.util.regex.Matcher; |
| 43 | import java.util.regex.Pattern; | 43 | import java.util.regex.Pattern; |
| 44 | 44 | ||
| 45 | +import javax.enterprise.context.ContextNotActiveException; | ||
| 45 | import javax.enterprise.inject.Instance; | 46 | import javax.enterprise.inject.Instance; |
| 46 | import javax.inject.Inject; | 47 | import javax.inject.Inject; |
| 47 | import javax.persistence.Basic; | 48 | import javax.persistence.Basic; |
| @@ -82,9 +83,6 @@ public class JPACrud<T, I> implements Crud<T, I> { | @@ -82,9 +83,6 @@ public class JPACrud<T, I> implements Crud<T, I> { | ||
| 82 | 83 | ||
| 83 | private EntityManager entityManager; | 84 | private EntityManager entityManager; |
| 84 | 85 | ||
| 85 | - @Inject | ||
| 86 | - private Instance<PaginationContext> paginationContext; | ||
| 87 | - | ||
| 88 | private Pagination pagination; | 86 | private Pagination pagination; |
| 89 | 87 | ||
| 90 | @Inject | 88 | @Inject |
| @@ -115,8 +113,13 @@ public class JPACrud<T, I> implements Crud<T, I> { | @@ -115,8 +113,13 @@ public class JPACrud<T, I> implements Crud<T, I> { | ||
| 115 | 113 | ||
| 116 | protected Pagination getPagination() { | 114 | protected Pagination getPagination() { |
| 117 | if (pagination == null) { | 115 | if (pagination == null) { |
| 118 | - PaginationContext context = paginationContext.get(); | ||
| 119 | - pagination = context.getPagination(getBeanClass()); | 116 | + try { |
| 117 | + PaginationContext context = Beans.getReference(PaginationContext.class); | ||
| 118 | + pagination = context.getPagination(getBeanClass()); | ||
| 119 | + | ||
| 120 | + } catch (ContextNotActiveException cause) { | ||
| 121 | + pagination = null; | ||
| 122 | + } | ||
| 120 | } | 123 | } |
| 121 | 124 | ||
| 122 | return pagination; | 125 | return pagination; |
impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/JsfBootstrap.java
| @@ -38,22 +38,11 @@ package br.gov.frameworkdemoiselle.internal.bootstrap; | @@ -38,22 +38,11 @@ package br.gov.frameworkdemoiselle.internal.bootstrap; | ||
| 38 | 38 | ||
| 39 | import javax.enterprise.event.Observes; | 39 | import javax.enterprise.event.Observes; |
| 40 | import javax.enterprise.inject.spi.AfterBeanDiscovery; | 40 | import javax.enterprise.inject.spi.AfterBeanDiscovery; |
| 41 | -import javax.enterprise.inject.spi.AnnotatedType; | ||
| 42 | -import javax.enterprise.inject.spi.ProcessAnnotatedType; | ||
| 43 | 41 | ||
| 44 | import br.gov.frameworkdemoiselle.internal.context.ViewContext; | 42 | import br.gov.frameworkdemoiselle.internal.context.ViewContext; |
| 45 | -import br.gov.frameworkdemoiselle.internal.producer.ServletLocaleProducer; | ||
| 46 | 43 | ||
| 47 | public class JsfBootstrap extends AbstractBootstrap { | 44 | public class JsfBootstrap extends AbstractBootstrap { |
| 48 | 45 | ||
| 49 | - protected <T> void cancelServletLocaleProducer(@Observes final ProcessAnnotatedType<T> event) { | ||
| 50 | - final AnnotatedType<T> annotatedType = event.getAnnotatedType(); | ||
| 51 | - | ||
| 52 | - if (annotatedType.getJavaClass() == ServletLocaleProducer.class) { | ||
| 53 | - event.veto(); | ||
| 54 | - } | ||
| 55 | - } | ||
| 56 | - | ||
| 57 | public void loadContexts(@Observes final AfterBeanDiscovery event) { | 46 | public void loadContexts(@Observes final AfterBeanDiscovery event) { |
| 58 | addContext(new ViewContext(), event); | 47 | addContext(new ViewContext(), event); |
| 59 | } | 48 | } |
impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/internal/producer/JsfLocaleProducer.java
| @@ -1,66 +0,0 @@ | @@ -1,66 +0,0 @@ | ||
| 1 | -/* | ||
| 2 | - * Demoiselle Framework Copyright (C) 2010 SERPRO | ||
| 3 | - * ---------------------------------------------------------------------------- This file is part of Demoiselle | ||
| 4 | - * Framework. Demoiselle Framework is free software; you can redistribute it and/or modify it under the terms of the GNU | ||
| 5 | - * Lesser General Public License version 3 as published by the Free Software Foundation. This program is distributed in | ||
| 6 | - * the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 7 | - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a | ||
| 8 | - * copy of the GNU Lesser General Public License version 3 along with this program; if not, see | ||
| 9 | - * <http://www.gnu.org/licenses/> or write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
| 10 | - * Boston, MA 02110-1301, USA. ---------------------------------------------------------------------------- Este arquivo | ||
| 11 | - * é parte do Framework Demoiselle. O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | ||
| 12 | - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação do Software Livre (FSF). Este | ||
| 13 | - * programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de | ||
| 14 | - * ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português para | ||
| 15 | - * maiores detalhes. Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título "LICENCA.txt", junto com esse | ||
| 16 | - * programa. Se não, acesse <http://www.gnu.org/licenses/> ou escreva para a Fundação do Software Livre (FSF) Inc., 51 | ||
| 17 | - * Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | ||
| 18 | - */ | ||
| 19 | -package br.gov.frameworkdemoiselle.internal.producer; | ||
| 20 | - | ||
| 21 | -import java.io.Serializable; | ||
| 22 | -import java.util.Locale; | ||
| 23 | - | ||
| 24 | -import javax.enterprise.context.RequestScoped; | ||
| 25 | -import javax.enterprise.inject.Default; | ||
| 26 | -import javax.enterprise.inject.Produces; | ||
| 27 | -import javax.faces.context.FacesContext; | ||
| 28 | -import javax.inject.Named; | ||
| 29 | -import javax.servlet.http.HttpServletRequest; | ||
| 30 | - | ||
| 31 | -import br.gov.frameworkdemoiselle.util.Beans; | ||
| 32 | - | ||
| 33 | -@RequestScoped | ||
| 34 | -public class JsfLocaleProducer implements Serializable { | ||
| 35 | - | ||
| 36 | - private static final long serialVersionUID = 1L; | ||
| 37 | - | ||
| 38 | - private boolean loaded = false; | ||
| 39 | - | ||
| 40 | - @Produces | ||
| 41 | - @Default | ||
| 42 | - @Named("currentLocale") | ||
| 43 | - public Locale create() { | ||
| 44 | - Locale locale; | ||
| 45 | - | ||
| 46 | - try { | ||
| 47 | - FacesContext facesContext = Beans.getReference(FacesContext.class); | ||
| 48 | - | ||
| 49 | - if (!loaded) { | ||
| 50 | - if (facesContext != null) { | ||
| 51 | - locale = Beans.getReference(HttpServletRequest.class).getLocale(); | ||
| 52 | - facesContext.getApplication().setDefaultLocale(locale); | ||
| 53 | - } | ||
| 54 | - | ||
| 55 | - loaded = true; | ||
| 56 | - } | ||
| 57 | - | ||
| 58 | - locale = facesContext.getApplication().getDefaultLocale(); | ||
| 59 | - | ||
| 60 | - } catch (Exception cause) { | ||
| 61 | - locale = Locale.getDefault(); | ||
| 62 | - } | ||
| 63 | - | ||
| 64 | - return locale; | ||
| 65 | - } | ||
| 66 | -} |
impl/extension/jsf/src/test/java/br/gov/frameworkdemoiselle/internal/producer/JsfLocaleProducerTest.java
| @@ -1,109 +0,0 @@ | @@ -1,109 +0,0 @@ | ||
| 1 | -/* | ||
| 2 | - * Demoiselle Framework | ||
| 3 | - * Copyright (C) 2010 SERPRO | ||
| 4 | - * ---------------------------------------------------------------------------- | ||
| 5 | - * This file is part of Demoiselle Framework. | ||
| 6 | - * | ||
| 7 | - * Demoiselle Framework is free software; you can redistribute it and/or | ||
| 8 | - * modify it under the terms of the GNU Lesser General Public License version 3 | ||
| 9 | - * as published by the Free Software Foundation. | ||
| 10 | - * | ||
| 11 | - * This program is distributed in the hope that it will be useful, | ||
| 12 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | - * GNU General Public License for more details. | ||
| 15 | - * | ||
| 16 | - * You should have received a copy of the GNU Lesser General Public License version 3 | ||
| 17 | - * along with this program; if not, see <http://www.gnu.org/licenses/> | ||
| 18 | - * or write to the Free Software Foundation, Inc., 51 Franklin Street, | ||
| 19 | - * Fifth Floor, Boston, MA 02110-1301, USA. | ||
| 20 | - * ---------------------------------------------------------------------------- | ||
| 21 | - * Este arquivo é parte do Framework Demoiselle. | ||
| 22 | - * | ||
| 23 | - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | ||
| 24 | - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | ||
| 25 | - * do Software Livre (FSF). | ||
| 26 | - * | ||
| 27 | - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | ||
| 28 | - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | ||
| 29 | - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | ||
| 30 | - * para maiores detalhes. | ||
| 31 | - * | ||
| 32 | - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | ||
| 33 | - * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | ||
| 34 | - * ou escreva para a Fundação do Software Livre (FSF) Inc., | ||
| 35 | - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | ||
| 36 | - */ | ||
| 37 | -package br.gov.frameworkdemoiselle.internal.producer; | ||
| 38 | -import org.junit.Ignore; | ||
| 39 | -import static junit.framework.Assert.assertEquals; | ||
| 40 | -import static org.easymock.EasyMock.expect; | ||
| 41 | -import static org.powermock.api.easymock.PowerMock.mockStatic; | ||
| 42 | -import static org.powermock.api.easymock.PowerMock.replayAll; | ||
| 43 | -import static org.powermock.api.easymock.PowerMock.verifyAll; | ||
| 44 | - | ||
| 45 | -import java.util.Locale; | ||
| 46 | - | ||
| 47 | -import javax.enterprise.context.ContextNotActiveException; | ||
| 48 | -import javax.faces.application.Application; | ||
| 49 | -import javax.faces.context.ExternalContext; | ||
| 50 | -import javax.faces.context.FacesContext; | ||
| 51 | -import javax.servlet.http.HttpServletRequest; | ||
| 52 | - | ||
| 53 | -import org.junit.Before; | ||
| 54 | -import org.junit.Test; | ||
| 55 | -import org.junit.runner.RunWith; | ||
| 56 | -import org.powermock.api.easymock.PowerMock; | ||
| 57 | -import org.powermock.core.classloader.annotations.PrepareForTest; | ||
| 58 | -import org.powermock.modules.junit4.PowerMockRunner; | ||
| 59 | - | ||
| 60 | -import br.gov.frameworkdemoiselle.util.Beans; | ||
| 61 | -@Ignore | ||
| 62 | -@RunWith(PowerMockRunner.class) | ||
| 63 | -@PrepareForTest({ Beans.class }) | ||
| 64 | -public class JsfLocaleProducerTest { | ||
| 65 | - | ||
| 66 | - private JsfLocaleProducer producer; | ||
| 67 | - | ||
| 68 | - @Before | ||
| 69 | - public void before() { | ||
| 70 | - producer = new JsfLocaleProducer(); | ||
| 71 | - } | ||
| 72 | - | ||
| 73 | - @Test | ||
| 74 | - public void testCreateOK() { | ||
| 75 | - mockStatic(Beans.class); | ||
| 76 | - | ||
| 77 | - Locale locale = PowerMock.createMock(Locale.class); | ||
| 78 | - Application application = PowerMock.createMock(Application.class); | ||
| 79 | - FacesContext facesContext = PowerMock.createMock(FacesContext.class); | ||
| 80 | - ExternalContext externalContext = PowerMock.createMock(ExternalContext.class); | ||
| 81 | - HttpServletRequest httpServletRequest = PowerMock.createMock(HttpServletRequest.class); | ||
| 82 | - | ||
| 83 | - expect(Beans.getReference(FacesContext.class)).andReturn(facesContext); | ||
| 84 | - expect(facesContext.getExternalContext()).andReturn(externalContext); | ||
| 85 | - expect(externalContext.getRequest()).andReturn(httpServletRequest); | ||
| 86 | - expect(httpServletRequest.getLocale()).andReturn(locale); | ||
| 87 | - expect(facesContext.getApplication()).andReturn(application).anyTimes(); | ||
| 88 | - application.setDefaultLocale(locale); | ||
| 89 | - expect(application.getDefaultLocale()).andReturn(locale); | ||
| 90 | - | ||
| 91 | - replayAll(); | ||
| 92 | - | ||
| 93 | - Locale returned = producer.create(); | ||
| 94 | - assertEquals(returned, locale); | ||
| 95 | - | ||
| 96 | - verifyAll(); | ||
| 97 | - } | ||
| 98 | - | ||
| 99 | - @Test | ||
| 100 | - public void testCreateNOK() { | ||
| 101 | - mockStatic(Beans.class); | ||
| 102 | - expect(Beans.getReference(FacesContext.class)).andThrow(new ContextNotActiveException()); | ||
| 103 | - replayAll(); | ||
| 104 | - Locale returned = producer.create(); | ||
| 105 | - assertEquals(Locale.getDefault(), returned); | ||
| 106 | - verifyAll(); | ||
| 107 | - } | ||
| 108 | - | ||
| 109 | -} |
impl/extension/servlet/src/main/java/br/gov/frameworkdemoiselle/internal/producer/ServletLocaleProducer.java
| @@ -43,14 +43,23 @@ import javax.enterprise.inject.Default; | @@ -43,14 +43,23 @@ import javax.enterprise.inject.Default; | ||
| 43 | import javax.enterprise.inject.Produces; | 43 | import javax.enterprise.inject.Produces; |
| 44 | import javax.servlet.http.HttpServletRequest; | 44 | import javax.servlet.http.HttpServletRequest; |
| 45 | 45 | ||
| 46 | +import br.gov.frameworkdemoiselle.util.Beans; | ||
| 47 | + | ||
| 46 | public class ServletLocaleProducer implements Serializable { | 48 | public class ServletLocaleProducer implements Serializable { |
| 47 | 49 | ||
| 48 | private static final long serialVersionUID = 1L; | 50 | private static final long serialVersionUID = 1L; |
| 49 | 51 | ||
| 50 | @Default | 52 | @Default |
| 51 | @Produces | 53 | @Produces |
| 52 | - public Locale create(HttpServletRequest request) { | 54 | + public Locale create() { |
| 53 | Locale result; | 55 | Locale result; |
| 56 | + HttpServletRequest request; | ||
| 57 | + | ||
| 58 | + try { | ||
| 59 | + request = Beans.getReference(HttpServletRequest.class); | ||
| 60 | + } catch (Exception cause) { | ||
| 61 | + request = null; | ||
| 62 | + } | ||
| 54 | 63 | ||
| 55 | if (request == null) { | 64 | if (request == null) { |
| 56 | result = Locale.getDefault(); | 65 | result = Locale.getDefault(); |
site/apt/release-notes.apt
| @@ -44,9 +44,9 @@ Notas de Versão | @@ -44,9 +44,9 @@ Notas de Versão | ||
| 44 | 44 | ||
| 45 | * {{{http://sourceforge.net/apps/mantisbt/demoiselle/view.php?id=0000818}0000818}} [Bug] Injeção de Locale utilizando o ClassLoader correto. | 45 | * {{{http://sourceforge.net/apps/mantisbt/demoiselle/view.php?id=0000818}0000818}} [Bug] Injeção de Locale utilizando o ClassLoader correto. |
| 46 | 46 | ||
| 47 | - * {{{http://sourceforge.net/apps/mantisbt/demoiselle/view.php?id=0000831}0000831}} [Improvement] Criação da anotação @Priority | 47 | + * {{{http://sourceforge.net/apps/mantisbt/demoiselle/view.php?id=0000831}0000831}} [Improvement] Criação da anotação @Priority. |
| 48 | 48 | ||
| 49 | - * {{{http://sourceforge.net/apps/mantisbt/demoiselle/view.php?id=0000830}0000830}} [Improvement] Depreciação do argumento Priority nas anotações Startup e Shutdown | 49 | + * {{{http://sourceforge.net/apps/mantisbt/demoiselle/view.php?id=0000830}0000830}} [Improvement] Depreciação do parâmetro "priority" nas anotações @Startup e @Shutdown. |
| 50 | 50 | ||
| 51 | * {{{http://sourceforge.net/apps/mantisbt/demoiselle/view.php?id=0000827}0000827}} [Improvement] Melhorias para o Configuration, com possibilidade de utilização de tipos complexos como Array e Date. | 51 | * {{{http://sourceforge.net/apps/mantisbt/demoiselle/view.php?id=0000827}0000827}} [Improvement] Melhorias para o Configuration, com possibilidade de utilização de tipos complexos como Array e Date. |
| 52 | 52 | ||
| @@ -58,7 +58,7 @@ Notas de Versão | @@ -58,7 +58,7 @@ Notas de Versão | ||
| 58 | 58 | ||
| 59 | * {{{http://sourceforge.net/apps/mantisbt/demoiselle/view.php?id=0000825}0000825}} [Task] Otimização do cache de EntityManagerFactory para separar fábricas por ClassLoader. | 59 | * {{{http://sourceforge.net/apps/mantisbt/demoiselle/view.php?id=0000825}0000825}} [Task] Otimização do cache de EntityManagerFactory para separar fábricas por ClassLoader. |
| 60 | 60 | ||
| 61 | - * {{{http://sourceforge.net/apps/mantisbt/demoiselle/view.php?id=0000824}0000824}} [Task] Definição das dependencias do SL4J como provided nos profiles do jboss6 e jboss7. | 61 | + * {{{http://sourceforge.net/apps/mantisbt/demoiselle/view.php?id=0000824}0000824}} [Task] Definição das dependencias do SL4J como provided nos profiles do "jboss6" e "jboss7". |
| 62 | 62 | ||
| 63 | * {{{http://sourceforge.net/apps/mantisbt/demoiselle/view.php?id=0000823}0000823}} [Task] Experimentos bem sucedidos com deploy no GAE. | 63 | * {{{http://sourceforge.net/apps/mantisbt/demoiselle/view.php?id=0000823}0000823}} [Task] Experimentos bem sucedidos com deploy no GAE. |
| 64 | 64 | ||
| @@ -67,7 +67,7 @@ Notas de Versão | @@ -67,7 +67,7 @@ Notas de Versão | ||
| 67 | * {{{http://sourceforge.net/apps/mantisbt/demoiselle/view.php?id=0000819}0000819}} [Task] Ajustes relacionados a serialização de objetos internos do Framework. | 67 | * {{{http://sourceforge.net/apps/mantisbt/demoiselle/view.php?id=0000819}0000819}} [Task] Ajustes relacionados a serialização de objetos internos do Framework. |
| 68 | 68 | ||
| 69 | 69 | ||
| 70 | -* v2.3.0-BETA1 | 70 | +* {{{../2.3.0-BETA1/}v2.3.0-BETA1}} |
| 71 | 71 | ||
| 72 | * {{{http://sourceforge.net/apps/mantisbt/demoiselle/view.php?id=0000800}0000800}} [Bug] Correção do erro NoSuchElementException ao usar o Beans.getReference(). | 72 | * {{{http://sourceforge.net/apps/mantisbt/demoiselle/view.php?id=0000800}0000800}} [Bug] Correção do erro NoSuchElementException ao usar o Beans.getReference(). |
| 73 | 73 |