Commit 5e809c459ee7a7e0803a3aa6146f2928c5c89043
1 parent
ad6d8a64
Exists in
master
Simplificação dos eventos de ciclo-de-vida
Showing
7 changed files
with
10 additions
and
65 deletions
Show diff stats
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/ApplicationLifecycleEvent.java
... | ... | @@ -1,42 +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 | -interface ApplicationLifecycleEvent { | |
40 | - | |
41 | - boolean removeProcessors(); | |
42 | -} |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/AsbratctLifecycleBootstrap.java
... | ... | @@ -72,6 +72,8 @@ public abstract class AsbratctLifecycleBootstrap<A extends Annotation> extends A |
72 | 72 | |
73 | 73 | private AfterBeanDiscovery afterBeanDiscoveryEvent; |
74 | 74 | |
75 | + private boolean registered = false; | |
76 | + | |
75 | 77 | protected abstract <T> AnnotatedMethodProcessor<T> newProcessorInstance(AnnotatedMethod<T> annotatedMethod, |
76 | 78 | BeanManager beanManager); |
77 | 79 | |
... | ... | @@ -105,22 +107,20 @@ public abstract class AsbratctLifecycleBootstrap<A extends Annotation> extends A |
105 | 107 | afterBeanDiscoveryEvent = event; |
106 | 108 | } |
107 | 109 | |
108 | - private boolean x = true; | |
109 | - | |
110 | 110 | @SuppressWarnings({ "unchecked", "rawtypes" }) |
111 | - protected synchronized void proccessEvent(final ApplicationLifecycleEvent event) { | |
111 | + protected synchronized void proccessEvent() { | |
112 | 112 | getLogger().debug( |
113 | 113 | getBundle("demoiselle-core-bundle").getString("executing-all", annotationClass.getSimpleName())); |
114 | 114 | |
115 | 115 | Collections.sort(processors); |
116 | 116 | Throwable failure = null; |
117 | 117 | |
118 | - if (x) { | |
118 | + if (!registered) { | |
119 | 119 | for (CustomContext tempContext : tempContexts) { |
120 | 120 | addContext(tempContext, afterBeanDiscoveryEvent); |
121 | 121 | } |
122 | 122 | |
123 | - x = false; | |
123 | + registered = true; | |
124 | 124 | } |
125 | 125 | |
126 | 126 | for (Iterator<AnnotatedMethodProcessor> iter = processors.iterator(); iter.hasNext();) { |
... | ... | @@ -132,10 +132,7 @@ public abstract class AsbratctLifecycleBootstrap<A extends Annotation> extends A |
132 | 132 | |
133 | 133 | if (Thread.currentThread().getContextClassLoader().equals(classLoader)) { |
134 | 134 | processor.process(); |
135 | - | |
136 | - if (event.removeProcessors()) { | |
137 | - iter.remove(); | |
138 | - } | |
135 | + iter.remove(); | |
139 | 136 | } |
140 | 137 | |
141 | 138 | } catch (Throwable cause) { | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/BeforeApplicationFinalization.java
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/BeforeApplicationInitialization.java
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/ShutdownBootstrap.java
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/StartupBootstrap.java
impl/extension/servlet/src/main/java/br/gov/frameworkdemoiselle/util/ServletListener.java
... | ... | @@ -46,22 +46,12 @@ public class ServletListener implements javax.servlet.ServletContextListener { |
46 | 46 | @Override |
47 | 47 | public void contextInitialized(ServletContextEvent event) { |
48 | 48 | Beans.getBeanManager().fireEvent(new BeforeApplicationInitialization() { |
49 | - | |
50 | - @Override | |
51 | - public boolean removeProcessors() { | |
52 | - return true; | |
53 | - } | |
54 | 49 | }); |
55 | 50 | } |
56 | 51 | |
57 | 52 | @Override |
58 | 53 | public void contextDestroyed(ServletContextEvent event) { |
59 | 54 | Beans.getBeanManager().fireEvent(new BeforeApplicationFinalization() { |
60 | - | |
61 | - @Override | |
62 | - public boolean removeProcessors() { | |
63 | - return true; | |
64 | - } | |
65 | 55 | }); |
66 | 56 | } |
67 | 57 | } | ... | ... |