Commit 31573b333ed5adb5085f6be0a949b36e766a3f7c

Authored by Cleverson Sacramento
1 parent 6a0fb063
Exists in master

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 0 → 100644
... ... @@ -0,0 +1,72 @@
  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 javax.enterprise.event.Observes;
  40 +import javax.enterprise.inject.spi.ProcessAnnotatedType;
  41 +
  42 +import org.apache.commons.configuration.Configuration;
  43 +import org.apache.commons.configuration.ConfigurationException;
  44 +import org.apache.commons.configuration.PropertiesConfiguration;
  45 +
  46 +import br.gov.frameworkdemoiselle.internal.implementation.DefaultTransaction;
  47 +import br.gov.frameworkdemoiselle.transaction.Transaction;
  48 +
  49 +public class TransactionBootstrap extends AbstractBootstrap {
  50 +
  51 + public <T> void processAnnotatedType(@Observes final ProcessAnnotatedType<T> event) throws ConfigurationException {
  52 +
  53 + Configuration config = new PropertiesConfiguration("demoiselle.properties");
  54 + String selected = config.getString("frameworkdemoiselle.transaction.class");
  55 +
  56 + Class<?> type = event.getAnnotatedType().getJavaClass();
  57 + if (Transaction.class.isAssignableFrom(type) && type != Transaction.class && type != DefaultTransaction.class) {
  58 + if (selected != null && !selected.equals(type.getCanonicalName())) {
  59 + event.veto();
  60 + }
  61 + }
  62 +
  63 + // final AnnotatedType<T> annotatedType = event.getAnnotatedType();
  64 + // for (AnnotatedMethod<?> am : annotatedType.getMethods()) {
  65 + // if (am.isAnnotationPresent(annotationClass)) {
  66 + // @SuppressWarnings("unchecked")
  67 + // AnnotatedMethod<T> annotatedMethod = (AnnotatedMethod<T>) am;
  68 + // processors.add(new StartupProcessor<T>(annotatedMethod, beanManager));
  69 + // }
  70 + // }
  71 + }
  72 +}
... ...
impl/core/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
1 1 br.gov.frameworkdemoiselle.internal.bootstrap.CoreBootstrap
2 2 br.gov.frameworkdemoiselle.internal.bootstrap.ConfigurationBootstrap
3   -
  3 +br.gov.frameworkdemoiselle.internal.bootstrap.TransactionBootstrap
4 4 br.gov.frameworkdemoiselle.internal.bootstrap.StartupBootstrap
5 5 br.gov.frameworkdemoiselle.internal.bootstrap.ShutdownBootstrap
... ...