Commit 52738040a2aebe1dd41a1635a48e0f0696a77d9d
Exists in
master
Merge branch '2.3' of git@github.com:demoiselle/framework.git into 2.3
Showing
6 changed files
with
77 additions
and
96 deletions
Show diff stats
archetype/jsf-jpa/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/beans.xml
| @@ -6,6 +6,7 @@ | @@ -6,6 +6,7 @@ | ||
| 6 | <class>br.gov.frameworkdemoiselle.internal.interceptor.RequiredPermissionInterceptor</class> | 6 | <class>br.gov.frameworkdemoiselle.internal.interceptor.RequiredPermissionInterceptor</class> |
| 7 | <class>br.gov.frameworkdemoiselle.internal.interceptor.RequiredRoleInterceptor</class> | 7 | <class>br.gov.frameworkdemoiselle.internal.interceptor.RequiredRoleInterceptor</class> |
| 8 | <class>br.gov.frameworkdemoiselle.internal.interceptor.TransactionalInterceptor</class> | 8 | <class>br.gov.frameworkdemoiselle.internal.interceptor.TransactionalInterceptor</class> |
| 9 | + <class>br.gov.frameworkdemoiselle.internal.interceptor.ConfigurationInterceptor</class> | ||
| 9 | </interceptors> | 10 | </interceptors> |
| 10 | 11 | ||
| 11 | </beans> | 12 | </beans> |
archetype/minimal/src/main/resources/archetype-resources/src/main/resources/META-INF/beans.xml
| @@ -6,6 +6,7 @@ | @@ -6,6 +6,7 @@ | ||
| 6 | <class>br.gov.frameworkdemoiselle.internal.interceptor.RequiredPermissionInterceptor</class> | 6 | <class>br.gov.frameworkdemoiselle.internal.interceptor.RequiredPermissionInterceptor</class> |
| 7 | <class>br.gov.frameworkdemoiselle.internal.interceptor.RequiredRoleInterceptor</class> | 7 | <class>br.gov.frameworkdemoiselle.internal.interceptor.RequiredRoleInterceptor</class> |
| 8 | <class>br.gov.frameworkdemoiselle.internal.interceptor.TransactionalInterceptor</class> | 8 | <class>br.gov.frameworkdemoiselle.internal.interceptor.TransactionalInterceptor</class> |
| 9 | + <class>br.gov.frameworkdemoiselle.internal.interceptor.ConfigurationInterceptor</class> | ||
| 9 | </interceptors> | 10 | </interceptors> |
| 10 | 11 | ||
| 11 | </beans> | 12 | </beans> |
impl/core/src/main/java/br/gov/frameworkdemoiselle/configuration/Configuration.java
| @@ -45,6 +45,7 @@ import java.lang.annotation.Target; | @@ -45,6 +45,7 @@ import java.lang.annotation.Target; | ||
| 45 | 45 | ||
| 46 | import javax.enterprise.inject.Stereotype; | 46 | import javax.enterprise.inject.Stereotype; |
| 47 | import javax.inject.Singleton; | 47 | import javax.inject.Singleton; |
| 48 | +import javax.interceptor.InterceptorBinding; | ||
| 48 | 49 | ||
| 49 | /** | 50 | /** |
| 50 | * Identifies a <b>configuration class</b>, that is, a structure reserved to store configuration values retrieved from a | 51 | * Identifies a <b>configuration class</b>, that is, a structure reserved to store configuration values retrieved from a |
| @@ -64,6 +65,7 @@ import javax.inject.Singleton; | @@ -64,6 +65,7 @@ import javax.inject.Singleton; | ||
| 64 | @Singleton | 65 | @Singleton |
| 65 | @Stereotype | 66 | @Stereotype |
| 66 | @Inherited | 67 | @Inherited |
| 68 | +@InterceptorBinding | ||
| 67 | @Target(TYPE) | 69 | @Target(TYPE) |
| 68 | @Retention(RUNTIME) | 70 | @Retention(RUNTIME) |
| 69 | public @interface Configuration { | 71 | public @interface Configuration { |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/ConfigurationBootstrap.java
| @@ -1,95 +0,0 @@ | @@ -1,95 +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 | -import java.util.ArrayList; | ||
| 40 | -import java.util.Collections; | ||
| 41 | -import java.util.List; | ||
| 42 | - | ||
| 43 | -import javax.enterprise.context.RequestScoped; | ||
| 44 | -import javax.enterprise.context.SessionScoped; | ||
| 45 | -import javax.enterprise.event.Observes; | ||
| 46 | -import javax.enterprise.inject.spi.AfterBeanDiscovery; | ||
| 47 | -import javax.enterprise.inject.spi.AfterDeploymentValidation; | ||
| 48 | -import javax.enterprise.inject.spi.AnnotatedType; | ||
| 49 | -import javax.enterprise.inject.spi.BeanManager; | ||
| 50 | -import javax.enterprise.inject.spi.ProcessAnnotatedType; | ||
| 51 | - | ||
| 52 | -import br.gov.frameworkdemoiselle.configuration.Configuration; | ||
| 53 | -import br.gov.frameworkdemoiselle.configuration.ConfigurationException; | ||
| 54 | -import br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoader; | ||
| 55 | -import br.gov.frameworkdemoiselle.internal.context.ThreadLocalContext; | ||
| 56 | -import br.gov.frameworkdemoiselle.util.Beans; | ||
| 57 | - | ||
| 58 | -/** | ||
| 59 | - * @author SERPRO | ||
| 60 | - */ | ||
| 61 | -public class ConfigurationBootstrap extends AbstractBootstrap { | ||
| 62 | - | ||
| 63 | - private static List<AnnotatedType<?>> types = Collections.synchronizedList(new ArrayList<AnnotatedType<?>>()); | ||
| 64 | - | ||
| 65 | - private static final String MSG_PROCESSING = "bootstrap.configuration.processing"; | ||
| 66 | - | ||
| 67 | - private ThreadLocalContext c1; | ||
| 68 | - | ||
| 69 | - private ThreadLocalContext c2; | ||
| 70 | - | ||
| 71 | - public <T> void detectAnnotation(@Observes final ProcessAnnotatedType<T> event, final BeanManager beanManager) { | ||
| 72 | - if (event.getAnnotatedType().isAnnotationPresent(Configuration.class)) { | ||
| 73 | - types.add(event.getAnnotatedType()); | ||
| 74 | - } | ||
| 75 | - } | ||
| 76 | - | ||
| 77 | - public void loadTempContexts(@Observes final AfterBeanDiscovery event) { | ||
| 78 | - c1 = new ThreadLocalContext(RequestScoped.class); | ||
| 79 | - addContext(c1, event); | ||
| 80 | - c2 = new ThreadLocalContext(SessionScoped.class); | ||
| 81 | - addContext(c2, event); | ||
| 82 | - } | ||
| 83 | - | ||
| 84 | - public void processLoader(@Observes final AfterDeploymentValidation event) | ||
| 85 | - throws ConfigurationException { | ||
| 86 | - ConfigurationLoader configurationLoader = Beans.getReference(ConfigurationLoader.class); | ||
| 87 | - for (AnnotatedType<?> type : types) { | ||
| 88 | - getLogger().debug(getBundle().getString(MSG_PROCESSING, type.toString())); | ||
| 89 | - configurationLoader.load(Beans.getReference(type.getJavaClass())); | ||
| 90 | - } | ||
| 91 | - disableContext(c1); | ||
| 92 | - disableContext(c2); | ||
| 93 | - } | ||
| 94 | - | ||
| 95 | -} |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/interceptor/ConfigurationInterceptor.java
0 → 100644
| @@ -0,0 +1,73 @@ | @@ -0,0 +1,73 @@ | ||
| 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.interceptor; | ||
| 38 | + | ||
| 39 | +import java.io.Serializable; | ||
| 40 | +import java.util.ArrayList; | ||
| 41 | +import java.util.List; | ||
| 42 | + | ||
| 43 | +import javax.interceptor.AroundInvoke; | ||
| 44 | +import javax.interceptor.Interceptor; | ||
| 45 | +import javax.interceptor.InvocationContext; | ||
| 46 | + | ||
| 47 | +import br.gov.frameworkdemoiselle.configuration.Configuration; | ||
| 48 | +import br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoader; | ||
| 49 | +import br.gov.frameworkdemoiselle.util.Beans; | ||
| 50 | + | ||
| 51 | +@Interceptor | ||
| 52 | +@Configuration | ||
| 53 | +@SuppressWarnings("cdi-scope") | ||
| 54 | +public class ConfigurationInterceptor implements Serializable { | ||
| 55 | + | ||
| 56 | + private static final long serialVersionUID = 1L; | ||
| 57 | + | ||
| 58 | + private static List<Class<?>> cache = new ArrayList<Class<?>>(); | ||
| 59 | + | ||
| 60 | + @AroundInvoke | ||
| 61 | + public static synchronized Object manage(final InvocationContext ic) throws Exception { | ||
| 62 | + Class<?> type = ic.getTarget().getClass(); | ||
| 63 | + | ||
| 64 | + if (!cache.contains(type)) { | ||
| 65 | + ConfigurationLoader loader = Beans.getReference(ConfigurationLoader.class); | ||
| 66 | + loader.load(ic.getTarget()); | ||
| 67 | + | ||
| 68 | + cache.add(type); | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + return ic.proceed(); | ||
| 72 | + } | ||
| 73 | +} |
impl/core/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
| 1 | br.gov.frameworkdemoiselle.internal.bootstrap.CoreBootstrap | 1 | br.gov.frameworkdemoiselle.internal.bootstrap.CoreBootstrap |
| 2 | -br.gov.frameworkdemoiselle.internal.bootstrap.ConfigurationBootstrap | ||
| 3 | br.gov.frameworkdemoiselle.internal.bootstrap.TransactionBootstrap | 2 | br.gov.frameworkdemoiselle.internal.bootstrap.TransactionBootstrap |
| 4 | br.gov.frameworkdemoiselle.internal.bootstrap.AuthenticatorBootstrap | 3 | br.gov.frameworkdemoiselle.internal.bootstrap.AuthenticatorBootstrap |
| 5 | br.gov.frameworkdemoiselle.internal.bootstrap.AuthorizerBootstrap | 4 | br.gov.frameworkdemoiselle.internal.bootstrap.AuthorizerBootstrap |