From 31573b333ed5adb5085f6be0a949b36e766a3f7c Mon Sep 17 00:00:00 2001 From: Cleverson Sacramento Date: Wed, 4 Jul 2012 12:55:43 -0300 Subject: [PATCH] Implementação incial e experimental da proposta da nova forma de configuração da estratégia de configuração: definindo a propriedade frameworkdemoiselle.transaction.class no demoiselle.properties. --- impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/TransactionBootstrap.java | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ impl/core/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension | 2 +- 2 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/TransactionBootstrap.java diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/TransactionBootstrap.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/TransactionBootstrap.java new file mode 100644 index 0000000..25d02e5 --- /dev/null +++ b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/TransactionBootstrap.java @@ -0,0 +1,72 @@ +/* + * Demoiselle Framework + * Copyright (C) 2010 SERPRO + * ---------------------------------------------------------------------------- + * This file is part of Demoiselle Framework. + * + * Demoiselle Framework is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License version 3 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License version 3 + * along with this program; if not, see + * or write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301, USA. + * ---------------------------------------------------------------------------- + * Este arquivo é parte do Framework Demoiselle. + * + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação + * do Software Livre (FSF). + * + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português + * para maiores detalhes. + * + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título + * "LICENCA.txt", junto com esse programa. Se não, acesse + * ou escreva para a Fundação do Software Livre (FSF) Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. + */ +package br.gov.frameworkdemoiselle.internal.bootstrap; + +import javax.enterprise.event.Observes; +import javax.enterprise.inject.spi.ProcessAnnotatedType; + +import org.apache.commons.configuration.Configuration; +import org.apache.commons.configuration.ConfigurationException; +import org.apache.commons.configuration.PropertiesConfiguration; + +import br.gov.frameworkdemoiselle.internal.implementation.DefaultTransaction; +import br.gov.frameworkdemoiselle.transaction.Transaction; + +public class TransactionBootstrap extends AbstractBootstrap { + + public void processAnnotatedType(@Observes final ProcessAnnotatedType event) throws ConfigurationException { + + Configuration config = new PropertiesConfiguration("demoiselle.properties"); + String selected = config.getString("frameworkdemoiselle.transaction.class"); + + Class type = event.getAnnotatedType().getJavaClass(); + if (Transaction.class.isAssignableFrom(type) && type != Transaction.class && type != DefaultTransaction.class) { + if (selected != null && !selected.equals(type.getCanonicalName())) { + event.veto(); + } + } + + // final AnnotatedType annotatedType = event.getAnnotatedType(); + // for (AnnotatedMethod am : annotatedType.getMethods()) { + // if (am.isAnnotationPresent(annotationClass)) { + // @SuppressWarnings("unchecked") + // AnnotatedMethod annotatedMethod = (AnnotatedMethod) am; + // processors.add(new StartupProcessor(annotatedMethod, beanManager)); + // } + // } + } +} diff --git a/impl/core/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension b/impl/core/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension index ab90f6e..188a7f9 100644 --- a/impl/core/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension +++ b/impl/core/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension @@ -1,5 +1,5 @@ br.gov.frameworkdemoiselle.internal.bootstrap.CoreBootstrap br.gov.frameworkdemoiselle.internal.bootstrap.ConfigurationBootstrap - +br.gov.frameworkdemoiselle.internal.bootstrap.TransactionBootstrap br.gov.frameworkdemoiselle.internal.bootstrap.StartupBootstrap br.gov.frameworkdemoiselle.internal.bootstrap.ShutdownBootstrap -- libgit2 0.21.2