Commit 4f73e196028845f286c95b6ff8604fdf13cb2b8e
1 parent
191d6b30
Exists in
master
Escolha automática das estratégias de transacão e controle de acesso com
base nas classes descobertas pelo CDI
Showing
5 changed files
with
172 additions
and
0 deletions
Show diff stats
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/AbstractStrategyBootstrap.java
0 → 100644
| @@ -0,0 +1,43 @@ | @@ -0,0 +1,43 @@ | ||
| 1 | +package br.gov.frameworkdemoiselle.internal.bootstrap; | ||
| 2 | + | ||
| 3 | +import java.util.ArrayList; | ||
| 4 | +import java.util.Collections; | ||
| 5 | +import java.util.List; | ||
| 6 | + | ||
| 7 | +import javax.enterprise.event.Observes; | ||
| 8 | +import javax.enterprise.inject.spi.AnnotatedType; | ||
| 9 | +import javax.enterprise.inject.spi.ProcessAnnotatedType; | ||
| 10 | + | ||
| 11 | +import br.gov.frameworkdemoiselle.util.Reflections; | ||
| 12 | + | ||
| 13 | +public class AbstractStrategyBootstrap<I> extends AbstractBootstrap { | ||
| 14 | + | ||
| 15 | + private Class<I> strategyClass; | ||
| 16 | + | ||
| 17 | + private List<Class<I>> cache; | ||
| 18 | + | ||
| 19 | + protected Class<I> getStrategyClass() { | ||
| 20 | + if (this.strategyClass == null) { | ||
| 21 | + this.strategyClass = Reflections.getGenericTypeArgument(this.getClass(), 0); | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + return this.strategyClass; | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + public List<Class<I>> getCache() { | ||
| 28 | + if (this.cache == null) { | ||
| 29 | + this.cache = Collections.synchronizedList(new ArrayList<Class<I>>()); | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + return this.cache; | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + @SuppressWarnings("unchecked") | ||
| 36 | + public <T> void processAnnotatedType(@Observes final ProcessAnnotatedType<T> event) { | ||
| 37 | + final AnnotatedType<T> annotatedType = event.getAnnotatedType(); | ||
| 38 | + | ||
| 39 | + if (Reflections.isOfType(annotatedType.getJavaClass(), this.getStrategyClass())) { | ||
| 40 | + this.getCache().add((Class<I>) annotatedType.getJavaClass()); | ||
| 41 | + } | ||
| 42 | + } | ||
| 43 | +} |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/AuthenticatorBootstrap.java
0 → 100644
| @@ -0,0 +1,42 @@ | @@ -0,0 +1,42 @@ | ||
| 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 br.gov.frameworkdemoiselle.security.Authenticator; | ||
| 40 | + | ||
| 41 | +public class AuthenticatorBootstrap extends AbstractStrategyBootstrap<Authenticator> { | ||
| 42 | +} |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/AuthorizerBootstrap.java
0 → 100644
| @@ -0,0 +1,42 @@ | @@ -0,0 +1,42 @@ | ||
| 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 br.gov.frameworkdemoiselle.security.Authorizer; | ||
| 40 | + | ||
| 41 | +public class AuthorizerBootstrap extends AbstractStrategyBootstrap<Authorizer> { | ||
| 42 | +} |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/TransactionBootstrap.java
0 → 100644
| @@ -0,0 +1,42 @@ | @@ -0,0 +1,42 @@ | ||
| 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 br.gov.frameworkdemoiselle.transaction.Transaction; | ||
| 40 | + | ||
| 41 | +public class TransactionBootstrap extends AbstractStrategyBootstrap<Transaction> { | ||
| 42 | +} |
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.TransactionBootstrap | ||
| 3 | +br.gov.frameworkdemoiselle.internal.bootstrap.AuthenticatorBootstrap | ||
| 4 | +br.gov.frameworkdemoiselle.internal.bootstrap.AuthorizerBootstrap | ||
| 2 | br.gov.frameworkdemoiselle.internal.bootstrap.StartupBootstrap | 5 | br.gov.frameworkdemoiselle.internal.bootstrap.StartupBootstrap |
| 3 | br.gov.frameworkdemoiselle.internal.bootstrap.ShutdownBootstrap | 6 | br.gov.frameworkdemoiselle.internal.bootstrap.ShutdownBootstrap |