Commit f9b2d89fc6f83efc54556f0533079edb0da767c5
Exists in
master
Merge branch '2.3' of https://github.com/demoiselle/framework.git into 2.3
Showing
17 changed files
with
123 additions
and
165 deletions
Show diff stats
archetype/jsf-jpa/src/main/resources/archetype-resources/pom.xml
| ... | ... | @@ -38,9 +38,10 @@ |
| 38 | 38 | <artifactId>primefaces</artifactId> |
| 39 | 39 | <scope>compile</scope> |
| 40 | 40 | </dependency> |
| 41 | + | |
| 41 | 42 | <dependency> |
| 42 | - <groupId>org.powermock</groupId> | |
| 43 | - <artifactId>powermock-api-easymock</artifactId> | |
| 43 | + <groupId>org.slf4j</groupId> | |
| 44 | + <artifactId>slf4j-log4j12</artifactId> | |
| 44 | 45 | <scope>test</scope> |
| 45 | 46 | </dependency> |
| 46 | 47 | </dependencies> | ... | ... |
archetype/jsf-jpa/src/main/resources/archetype-resources/src/main/java/persistence/BookmarkDAO.java
archetype/jsf-jpa/src/main/resources/archetype-resources/src/main/resources/log4j.properties
| 1 | -# Set root logger level to DEBUG and its only appender to A1. | |
| 2 | 1 | log4j.rootLogger=INFO, A1 |
| 3 | -log4j.logger.br.gov.demoiselle=DEBUG, A1 | |
| 4 | - | |
| 5 | -# A1 is set to be a ConsoleAppender. | |
| 6 | 2 | log4j.appender.A1=org.apache.log4j.ConsoleAppender |
| 7 | - | |
| 8 | -# A1 uses PatternLayout. | |
| 9 | 3 | log4j.appender.A1.layout=org.apache.log4j.PatternLayout |
| 10 | -log4j.appender.A1.layout.ConversionPattern=%-4r %-5p %c - %m%n | |
| 11 | 4 | \ No newline at end of file |
| 5 | +log4j.appender.A1.layout.ConversionPattern=%-4r %-5p %c - %m%n | ... | ... |
archetype/jsf-jpa/src/main/resources/archetype-resources/src/test/java/readme.txt
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/ApplicationLifecycleEvent.java
| ... | ... | @@ -1,42 +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.bootstrap; | |
| 38 | - | |
| 39 | -interface ApplicationLifecycleEvent { | |
| 40 | - | |
| 41 | - boolean removeProcessors(); | |
| 42 | -} |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/AsbratctLifecycleBootstrap.java
| ... | ... | @@ -72,6 +72,8 @@ public abstract class AsbratctLifecycleBootstrap<A extends Annotation> extends A |
| 72 | 72 | |
| 73 | 73 | private AfterBeanDiscovery afterBeanDiscoveryEvent; |
| 74 | 74 | |
| 75 | + private boolean registered = false; | |
| 76 | + | |
| 75 | 77 | protected abstract <T> AnnotatedMethodProcessor<T> newProcessorInstance(AnnotatedMethod<T> annotatedMethod, |
| 76 | 78 | BeanManager beanManager); |
| 77 | 79 | |
| ... | ... | @@ -105,22 +107,20 @@ public abstract class AsbratctLifecycleBootstrap<A extends Annotation> extends A |
| 105 | 107 | afterBeanDiscoveryEvent = event; |
| 106 | 108 | } |
| 107 | 109 | |
| 108 | - private boolean x = true; | |
| 109 | - | |
| 110 | 110 | @SuppressWarnings({ "unchecked", "rawtypes" }) |
| 111 | - protected synchronized void proccessEvent(final ApplicationLifecycleEvent event) { | |
| 111 | + protected synchronized void proccessEvent() { | |
| 112 | 112 | getLogger().debug( |
| 113 | 113 | getBundle("demoiselle-core-bundle").getString("executing-all", annotationClass.getSimpleName())); |
| 114 | 114 | |
| 115 | 115 | Collections.sort(processors); |
| 116 | 116 | Throwable failure = null; |
| 117 | 117 | |
| 118 | - if (x) { | |
| 118 | + if (!registered) { | |
| 119 | 119 | for (CustomContext tempContext : tempContexts) { |
| 120 | 120 | addContext(tempContext, afterBeanDiscoveryEvent); |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - x = false; | |
| 123 | + registered = true; | |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | for (Iterator<AnnotatedMethodProcessor> iter = processors.iterator(); iter.hasNext();) { |
| ... | ... | @@ -132,10 +132,7 @@ public abstract class AsbratctLifecycleBootstrap<A extends Annotation> extends A |
| 132 | 132 | |
| 133 | 133 | if (Thread.currentThread().getContextClassLoader().equals(classLoader)) { |
| 134 | 134 | processor.process(); |
| 135 | - | |
| 136 | - if (event.removeProcessors()) { | |
| 137 | - iter.remove(); | |
| 138 | - } | |
| 135 | + iter.remove(); | |
| 139 | 136 | } |
| 140 | 137 | |
| 141 | 138 | } catch (Throwable cause) { | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/BeforeApplicationFinalization.java
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/BeforeApplicationInitialization.java
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/ShutdownBootstrap.java
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/StartupBootstrap.java
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/TrancationContextImpl.java
| ... | ... | @@ -1,60 +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.implementation; | |
| 38 | - | |
| 39 | -import javax.inject.Named; | |
| 40 | - | |
| 41 | -import br.gov.frameworkdemoiselle.transaction.Transaction; | |
| 42 | -import br.gov.frameworkdemoiselle.transaction.TransactionContext; | |
| 43 | - | |
| 44 | -/** | |
| 45 | - * This is the default implementation of {@link TransactionContext} interface. | |
| 46 | - * | |
| 47 | - * @author SERPRO | |
| 48 | - */ | |
| 49 | -@Named("transactionContext") | |
| 50 | -public class TrancationContextImpl implements TransactionContext { | |
| 51 | - | |
| 52 | - private static final long serialVersionUID = 1L; | |
| 53 | - | |
| 54 | - @Override | |
| 55 | - public Transaction getCurrentTransaction() { | |
| 56 | - return StrategySelector.getReference("frameworkdemoiselle.transaction.class", Transaction.class, | |
| 57 | - DefaultTransaction.class); | |
| 58 | - } | |
| 59 | - | |
| 60 | -} |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/TransactionContextImpl.java
0 → 100644
| ... | ... | @@ -0,0 +1,60 @@ |
| 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.implementation; | |
| 38 | + | |
| 39 | +import javax.inject.Named; | |
| 40 | + | |
| 41 | +import br.gov.frameworkdemoiselle.transaction.Transaction; | |
| 42 | +import br.gov.frameworkdemoiselle.transaction.TransactionContext; | |
| 43 | + | |
| 44 | +/** | |
| 45 | + * This is the default implementation of {@link TransactionContext} interface. | |
| 46 | + * | |
| 47 | + * @author SERPRO | |
| 48 | + */ | |
| 49 | +@Named("transactionContext") | |
| 50 | +public class TransactionContextImpl implements TransactionContext { | |
| 51 | + | |
| 52 | + private static final long serialVersionUID = 1L; | |
| 53 | + | |
| 54 | + @Override | |
| 55 | + public Transaction getCurrentTransaction() { | |
| 56 | + return StrategySelector.getReference("frameworkdemoiselle.transaction.class", Transaction.class, | |
| 57 | + DefaultTransaction.class); | |
| 58 | + } | |
| 59 | + | |
| 60 | +} | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/processor/AbstractProcessor.java
| ... | ... | @@ -39,13 +39,13 @@ package br.gov.frameworkdemoiselle.internal.processor; |
| 39 | 39 | import java.util.Locale; |
| 40 | 40 | |
| 41 | 41 | import javax.enterprise.inject.spi.AnnotatedCallable; |
| 42 | -import javax.enterprise.inject.spi.Bean; | |
| 43 | 42 | import javax.enterprise.inject.spi.BeanManager; |
| 44 | 43 | |
| 45 | 44 | import org.slf4j.Logger; |
| 46 | 45 | |
| 47 | 46 | import br.gov.frameworkdemoiselle.internal.producer.LoggerProducer; |
| 48 | 47 | import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer; |
| 48 | +import br.gov.frameworkdemoiselle.util.Beans; | |
| 49 | 49 | import br.gov.frameworkdemoiselle.util.ResourceBundle; |
| 50 | 50 | |
| 51 | 51 | /** |
| ... | ... | @@ -92,13 +92,7 @@ public abstract class AbstractProcessor<T> implements Processor { |
| 92 | 92 | @SuppressWarnings("unchecked") |
| 93 | 93 | protected T getReferencedBean() { |
| 94 | 94 | Class<T> classType = (Class<T>) getAnnotatedCallable().getJavaMember().getDeclaringClass(); |
| 95 | - return getReferencedBean(classType); | |
| 96 | - } | |
| 97 | - | |
| 98 | - @SuppressWarnings("unchecked") | |
| 99 | - protected T getReferencedBean(final Class<T> type) { | |
| 100 | - Bean<T> bean = (Bean<T>) beanManager.getBeans(type).iterator().next(); | |
| 101 | - return (T) beanManager.getReference(bean, type, beanManager.createCreationalContext(bean)); | |
| 95 | + return Beans.getReference(classType); | |
| 102 | 96 | } |
| 103 | 97 | |
| 104 | 98 | protected ResourceBundle getBundle() { | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/transaction/TransactionContext.java
impl/core/src/main/java/br/gov/frameworkdemoiselle/util/Beans.java
| ... | ... | @@ -76,33 +76,62 @@ public final class Beans { |
| 76 | 76 | |
| 77 | 77 | @SuppressWarnings("unchecked") |
| 78 | 78 | public static <T> T getReference(final Class<T> beanClass, Annotation... qualifiers) { |
| 79 | - return (T) getReference(manager.getBeans(beanClass, qualifiers)); | |
| 79 | + T instance; | |
| 80 | + | |
| 81 | + try { | |
| 82 | + instance = (T) getReference(manager.getBeans(beanClass, qualifiers)); | |
| 83 | + | |
| 84 | + } catch (NoSuchElementException cause) { | |
| 85 | + StringBuffer buffer = new StringBuffer(); | |
| 86 | + buffer.append(beanClass.getCanonicalName()); | |
| 87 | + | |
| 88 | + for (Annotation qualifier : qualifiers) { | |
| 89 | + buffer.append(", "); | |
| 90 | + buffer.append(qualifier.getClass().getCanonicalName()); | |
| 91 | + } | |
| 92 | + | |
| 93 | + String message = getBundle() | |
| 94 | + .getString("bean-not-found", buffer.toString()); | |
| 95 | + throw new DemoiselleException(message, cause); | |
| 96 | + } | |
| 97 | + | |
| 98 | + return instance; | |
| 80 | 99 | } |
| 81 | 100 | |
| 82 | - @SuppressWarnings("unchecked") | |
| 83 | 101 | public static <T> T getReference(final Class<T> beanClass) { |
| 84 | - return (T) getReference(manager.getBeans(beanClass)); | |
| 102 | + | |
| 103 | + T instance; | |
| 104 | + | |
| 105 | + try { | |
| 106 | + instance = (T) getReference(manager.getBeans(beanClass)); | |
| 107 | + }catch (NoSuchElementException cause) { | |
| 108 | + String message = getBundle() | |
| 109 | + .getString("bean-not-found", beanClass.getCanonicalName()); | |
| 110 | + throw new DemoiselleException(message, cause); | |
| 111 | + } | |
| 112 | + | |
| 113 | + return instance; | |
| 85 | 114 | } |
| 86 | 115 | |
| 87 | 116 | @SuppressWarnings("unchecked") |
| 88 | 117 | public static <T> T getReference(String beanName) { |
| 89 | - return (T) getReference(manager.getBeans(beanName)); | |
| 90 | - } | |
| 91 | - | |
| 92 | - @SuppressWarnings("unchecked") | |
| 93 | - private static <T> T getReference(Set<Bean<?>> beans) { | |
| 94 | - T result = null; | |
| 95 | - | |
| 118 | + T instance; | |
| 119 | + | |
| 96 | 120 | try { |
| 97 | - Bean<?> bean = beans.iterator().next(); | |
| 98 | - result = (T) manager.getReference(bean, bean.getBeanClass(), manager.createCreationalContext(bean)); | |
| 99 | - | |
| 100 | - } catch (NoSuchElementException cause) { | |
| 101 | - String message = getBundle().getString("bean-not-found"); | |
| 121 | + instance = (T) getReference(manager.getBeans(beanName)); | |
| 122 | + }catch (NoSuchElementException cause) { | |
| 123 | + String message = getBundle() | |
| 124 | + .getString("bean-not-found", beanName); | |
| 102 | 125 | throw new DemoiselleException(message, cause); |
| 103 | 126 | } |
| 127 | + | |
| 128 | + return instance; | |
| 129 | + } | |
| 104 | 130 | |
| 105 | - return result; | |
| 131 | + @SuppressWarnings("unchecked") | |
| 132 | + private static <T> T getReference(Set<Bean<?>> beans) { | |
| 133 | + Bean<?> bean = beans.iterator().next(); | |
| 134 | + return (T) manager.getReference(bean, bean.getBeanClass(), manager.createCreationalContext(bean)); | |
| 106 | 135 | } |
| 107 | 136 | |
| 108 | 137 | private static ResourceBundle getBundle() { | ... | ... |
impl/core/src/main/resources/demoiselle-core-bundle.properties
| ... | ... | @@ -34,7 +34,7 @@ |
| 34 | 34 | # 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. |
| 35 | 35 | |
| 36 | 36 | engine-on=Ligando os motores do Demoiselle ${project.version} |
| 37 | -bean-not-found=Voc\u00EA est\u00E1 tentando obter um objeto n\u00E3o reconhecido pelo CDI via Beans.getReference(...) | |
| 37 | +bean-not-found=Voc\u00EA est\u00E1 tentando obter um objeto n\u00E3o reconhecido pelo CDI via Beans.getReference({0}) | |
| 38 | 38 | more-than-one-exceptionhandler-defined-for-same-class=Foi definido mais de um m\u00E9todo na classe {0} para tratar a exce\u00E7\u00E3o {1} |
| 39 | 39 | handling-exception=Tratando a exce\u00E7\u00E3o {0} |
| 40 | 40 | proxy-detected=Detectado o proxy {0} da classe {1} | ... | ... |
impl/extension/servlet/src/main/java/br/gov/frameworkdemoiselle/util/ServletListener.java
| ... | ... | @@ -46,22 +46,12 @@ public class ServletListener implements javax.servlet.ServletContextListener { |
| 46 | 46 | @Override |
| 47 | 47 | public void contextInitialized(ServletContextEvent event) { |
| 48 | 48 | Beans.getBeanManager().fireEvent(new BeforeApplicationInitialization() { |
| 49 | - | |
| 50 | - @Override | |
| 51 | - public boolean removeProcessors() { | |
| 52 | - return true; | |
| 53 | - } | |
| 54 | 49 | }); |
| 55 | 50 | } |
| 56 | 51 | |
| 57 | 52 | @Override |
| 58 | 53 | public void contextDestroyed(ServletContextEvent event) { |
| 59 | 54 | Beans.getBeanManager().fireEvent(new BeforeApplicationFinalization() { |
| 60 | - | |
| 61 | - @Override | |
| 62 | - public boolean removeProcessors() { | |
| 63 | - return true; | |
| 64 | - } | |
| 65 | 55 | }); |
| 66 | 56 | } |
| 67 | 57 | } | ... | ... |