Commit 46d86bd63e4fd32ae64b9ec7f5f028c5fc80d904

Authored by Cleverson Sacramento
1 parent 1758ac00
Exists in master

Mais experimentos mal sucedidos para tentar obter a estratégia de

transação sem o uso do demoiselle.properties. É... não tem jeito,
teremos que usar o properties mesmo.
impl/core/pom.xml
... ... @@ -34,7 +34,8 @@
34 34 ou escreva para a Fundação do Software Livre (FSF) Inc.,
35 35 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
36 36 -->
37   -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  37 +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  38 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
38 39  
39 40 <modelVersion>4.0.0</modelVersion>
40 41  
... ...
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/DefaultTransactionBootstrap.java 0 → 100644
... ... @@ -0,0 +1,140 @@
  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.lang.reflect.Field;
  40 +import java.util.ArrayList;
  41 +import java.util.List;
  42 +
  43 +import javax.enterprise.event.Observes;
  44 +import javax.enterprise.inject.spi.Extension;
  45 +import javax.enterprise.inject.spi.ProcessAnnotatedType;
  46 +
  47 +import br.gov.frameworkdemoiselle.transaction.Transaction;
  48 +import br.gov.frameworkdemoiselle.util.Reflections;
  49 +
  50 +//public class DefaultTransactionBootstrap extends AbstractVetoBootstrap<Transaction, DefaultTransaction> {
  51 +public class DefaultTransactionBootstrap implements Extension {
  52 +
  53 + private static void x() {
  54 + try {
  55 + ClassLoader cl = Thread.currentThread().getContextClassLoader();
  56 + Class<?> clClass = cl.getClass();
  57 +
  58 + while (clClass != ClassLoader.class) {
  59 + clClass = clClass.getSuperclass();
  60 + }
  61 +
  62 + Field field = clClass.getDeclaredField("classes");
  63 +
  64 + field.setAccessible(true);
  65 + @SuppressWarnings("unchecked")
  66 + // Vector<Class<?>> classes = (Vector<Class<?>>) field.get(cl);
  67 + List<Class<?>> classes = new ArrayList<Class<?>>((List<Class<?>>) field.get(cl));
  68 + // List<Class<?>> classes = (List<Class<?>>) field.get(cl);
  69 + field.setAccessible(false);
  70 +
  71 + // for (Iterator<Class<?>> iter = classes.iterator(); iter.hasNext();) {
  72 + // Class<?> clazz = iter.next();
  73 + //
  74 + // if (Reflections.isOfType(clazz, Transaction.class)) {
  75 + // System.out.println("......... " + clazz);
  76 + // }
  77 + // }
  78 +
  79 + for (Class<?> clazz : classes) {
  80 + if (Reflections.isOfType(clazz, Transaction.class)) {
  81 + // if (Transaction.class.isAssignableFrom(clazz) && clazz != Transaction.class) {
  82 + System.out.println("......... " + clazz);
  83 + }
  84 + }
  85 +
  86 + } catch (Exception cause) {
  87 + cause.printStackTrace();
  88 + }
  89 + }
  90 +
  91 + // private static Class<?> cache;
  92 +
  93 + public void beforeBeanDiscovery(@Observes final ProcessAnnotatedType<?> event) {
  94 +
  95 +// public void beforeBeanDiscovery(@Observes final BeforeBeanDiscovery event) {
  96 +
  97 + x();
  98 + System.out.println();
  99 +
  100 +// ClassLoader cl
  101 +
  102 + // private static ProcessAnnotatedType<?> cachedEvent;
  103 + //
  104 + // protected <A> void processAnnotatedType(@Observes final ProcessAnnotatedType<A> event) {
  105 + // Class<?> annotated = event.getAnnotatedType().getJavaClass();
  106 + //
  107 + // if (Reflections.isOfType(annotated, Transaction.class)) {
  108 + //
  109 + // if(cachedEvent == null) {
  110 + // cachedEvent = event;
  111 + //
  112 + // } else {
  113 + // Class<?> cachedClass = cachedEvent.getAnnotatedType().getJavaClass();
  114 + //
  115 + // if (getPriority(annotated) > getPriority(cachedClass)) {
  116 + // cachedEvent.veto();
  117 + // cachedEvent = event;
  118 + //
  119 + // } else {
  120 + // event.veto();
  121 + // }
  122 + // }
  123 + // }
  124 + // }
  125 + //
  126 + // private int getPriority(Class<?> type) {
  127 + // int priority = Priority.MAX_PRIORITY;
  128 + //
  129 + // if (type == null) {
  130 + // priority = Priority.MIN_PRIORITY;
  131 + //
  132 + // } else if (type.isAnnotationPresent(Priority.class)) {
  133 + // Priority annotation = type.getAnnotation(Priority.class);
  134 + // priority = annotation.value();
  135 + // }
  136 + //
  137 + // return priority;
  138 + }
  139 +
  140 +}
... ...
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 +br.gov.frameworkdemoiselle.internal.bootstrap.DefaultTransactionBootstrap
3 4 br.gov.frameworkdemoiselle.internal.bootstrap.StartupBootstrap
4 5 br.gov.frameworkdemoiselle.internal.bootstrap.ShutdownBootstrap
... ...
impl/extension/jpa/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/JPATransactionBootstrap.java
... ... @@ -40,5 +40,5 @@ import br.gov.frameworkdemoiselle.transaction.JPATransaction;
40 40 import br.gov.frameworkdemoiselle.transaction.Transaction;
41 41  
42 42 public class JPATransactionBootstrap extends AbstractVetoBootstrap<Transaction, JPATransaction> {
43   -
  43 +
44 44 }
... ...