Commit 184cd307a4c6fcca4b09107f415d6a915a59b039

Authored by Cleverson Sacramento
1 parent b0c0e3ab
Exists in master

Ajustes na implementação

impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/DefaultTransactionBootstrap.java
@@ -1,140 +0,0 @@ @@ -1,140 +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.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/java/br/gov/frameworkdemoiselle/internal/bootstrap/TransactionBootstrap.java
@@ -54,17 +54,12 @@ public class TransactionBootstrap extends AbstractBootstrap { @@ -54,17 +54,12 @@ public class TransactionBootstrap extends AbstractBootstrap {
54 54
55 public void beforeBeanDiscovery(@Observes final BeforeBeanDiscovery event) { 55 public void beforeBeanDiscovery(@Observes final BeforeBeanDiscovery event) {
56 selected = loadSelected(); 56 selected = loadSelected();
57 -  
58 - if (selected == null) {  
59 - selected = DefaultTransaction.class;  
60 - }  
61 -  
62 } 57 }
63 58
64 public <T> void processAnnotatedType(@Observes final ProcessAnnotatedType<T> event) { 59 public <T> void processAnnotatedType(@Observes final ProcessAnnotatedType<T> event) {
65 - Class<?> annotated = event.getAnnotatedType().getJavaClass(); 60 + Class<T> annotated = event.getAnnotatedType().getJavaClass();
66 61
67 - if (Reflections.isOfType(annotated, Transaction.class) && annotated != loadSelected()) { 62 + if (Reflections.isOfType(annotated, Transaction.class) && annotated != selected) {
68 event.veto(); 63 event.veto();
69 } 64 }
70 } 65 }