diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/AbstractLifecycleBootstrap.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/AbstractLifecycleBootstrap.java
new file mode 100644
index 0000000..c23778f
--- /dev/null
+++ b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/AbstractLifecycleBootstrap.java
@@ -0,0 +1,157 @@
+/*
+ * 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 java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.enterprise.context.ConversationScoped;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.context.SessionScoped;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.AfterBeanDiscovery;
+import javax.enterprise.inject.spi.AnnotatedMethod;
+import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.ProcessAnnotatedType;
+
+import br.gov.frameworkdemoiselle.DemoiselleException;
+import br.gov.frameworkdemoiselle.annotation.ViewScoped;
+import br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoader;
+import br.gov.frameworkdemoiselle.internal.context.CustomContext;
+import br.gov.frameworkdemoiselle.internal.context.ThreadLocalContext;
+import br.gov.frameworkdemoiselle.internal.processor.AnnotatedMethodProcessor;
+import br.gov.frameworkdemoiselle.util.Reflections;
+
+public abstract class AbstractLifecycleBootstrap extends AbstractBootstrap {
+
+ private Class annotationClass;
+
+ @SuppressWarnings("rawtypes")
+ private final List processors = Collections
+ .synchronizedList(new ArrayList());
+
+ private final List tempContexts = new ArrayList();
+
+ private AfterBeanDiscovery afterBeanDiscoveryEvent;
+
+ private boolean registered = false;
+
+ protected abstract AnnotatedMethodProcessor newProcessorInstance(AnnotatedMethod annotatedMethod,
+ BeanManager beanManager);
+
+ protected Class getAnnotationClass() {
+ if (this.annotationClass == null) {
+ this.annotationClass = Reflections.getGenericTypeArgument(this.getClass(), 0);
+ }
+
+ return this.annotationClass;
+ }
+
+ public void processAnnotatedType(@Observes final ProcessAnnotatedType event, final BeanManager beanManager) {
+ final AnnotatedType annotatedType = event.getAnnotatedType();
+
+ for (AnnotatedMethod> am : annotatedType.getMethods()) {
+ if (am.isAnnotationPresent(getAnnotationClass())) {
+ @SuppressWarnings("unchecked")
+ AnnotatedMethod annotatedMethod = (AnnotatedMethod) am;
+ processors.add(newProcessorInstance(annotatedMethod, beanManager));
+ }
+ }
+ }
+
+ public void loadTempContexts(@Observes final AfterBeanDiscovery event) {
+ // Não registrar o contexto de aplicação pq ele já é registrado pela implementação do CDI
+ tempContexts.add(new ThreadLocalContext(ViewScoped.class));
+ tempContexts.add(new ThreadLocalContext(SessionScoped.class));
+ tempContexts.add(new ThreadLocalContext(ConversationScoped.class));
+ tempContexts.add(new ThreadLocalContext(RequestScoped.class));
+
+ afterBeanDiscoveryEvent = event;
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ protected synchronized void proccessEvent() {
+ getLogger().debug(
+ getBundle("demoiselle-core-bundle").getString("executing-all", annotationClass.getSimpleName()));
+
+ Collections.sort(processors);
+ Throwable failure = null;
+
+ if (!registered) {
+ for (CustomContext tempContext : tempContexts) {
+ addContext(tempContext, afterBeanDiscoveryEvent);
+ }
+
+ registered = true;
+ }
+
+ for (Iterator iter = processors.iterator(); iter.hasNext();) {
+ AnnotatedMethodProcessor> processor = iter.next();
+
+ try {
+ ClassLoader classLoader = ConfigurationLoader.getClassLoaderForClass(processor.getAnnotatedMethod()
+ .getDeclaringType().getJavaClass().getCanonicalName());
+
+ if (Thread.currentThread().getContextClassLoader().equals(classLoader)) {
+ processor.process();
+ iter.remove();
+ }
+
+ } catch (Throwable cause) {
+ failure = cause;
+ }
+ }
+
+ if (processors.isEmpty()) {
+ unloadTempContexts();
+ }
+
+ if (failure != null) {
+ throw new DemoiselleException(failure);
+ }
+ }
+
+ private void unloadTempContexts() {
+ for (CustomContext tempContext : tempContexts) {
+ disableContext(tempContext);
+ }
+ }
+}
diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/AsbratctLifecycleBootstrap.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/AsbratctLifecycleBootstrap.java
deleted file mode 100644
index 3b07be2..0000000
--- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/AsbratctLifecycleBootstrap.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * 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 java.lang.annotation.Annotation;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.enterprise.context.ConversationScoped;
-import javax.enterprise.context.RequestScoped;
-import javax.enterprise.context.SessionScoped;
-import javax.enterprise.event.Observes;
-import javax.enterprise.inject.spi.AfterBeanDiscovery;
-import javax.enterprise.inject.spi.AnnotatedMethod;
-import javax.enterprise.inject.spi.AnnotatedType;
-import javax.enterprise.inject.spi.BeanManager;
-import javax.enterprise.inject.spi.ProcessAnnotatedType;
-
-import br.gov.frameworkdemoiselle.DemoiselleException;
-import br.gov.frameworkdemoiselle.annotation.ViewScoped;
-import br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoader;
-import br.gov.frameworkdemoiselle.internal.context.CustomContext;
-import br.gov.frameworkdemoiselle.internal.context.ThreadLocalContext;
-import br.gov.frameworkdemoiselle.internal.processor.AnnotatedMethodProcessor;
-import br.gov.frameworkdemoiselle.util.Reflections;
-
-public abstract class AsbratctLifecycleBootstrap extends AbstractBootstrap {
-
- private Class annotationClass;
-
- @SuppressWarnings("rawtypes")
- private final List processors = Collections
- .synchronizedList(new ArrayList());
-
- private final List tempContexts = new ArrayList();
-
- private AfterBeanDiscovery afterBeanDiscoveryEvent;
-
- private boolean registered = false;
-
- protected abstract AnnotatedMethodProcessor newProcessorInstance(AnnotatedMethod annotatedMethod,
- BeanManager beanManager);
-
- protected Class getAnnotationClass() {
- if (this.annotationClass == null) {
- this.annotationClass = Reflections.getGenericTypeArgument(this.getClass(), 0);
- }
-
- return this.annotationClass;
- }
-
- public void processAnnotatedType(@Observes final ProcessAnnotatedType event, final BeanManager beanManager) {
- final AnnotatedType annotatedType = event.getAnnotatedType();
-
- for (AnnotatedMethod> am : annotatedType.getMethods()) {
- if (am.isAnnotationPresent(getAnnotationClass())) {
- @SuppressWarnings("unchecked")
- AnnotatedMethod annotatedMethod = (AnnotatedMethod) am;
- processors.add(newProcessorInstance(annotatedMethod, beanManager));
- }
- }
- }
-
- public void loadTempContexts(@Observes final AfterBeanDiscovery event) {
- // Não registrar o contexto de aplicação pq ele já é registrado pela implementação do CDI
- tempContexts.add(new ThreadLocalContext(ViewScoped.class));
- tempContexts.add(new ThreadLocalContext(SessionScoped.class));
- tempContexts.add(new ThreadLocalContext(ConversationScoped.class));
- tempContexts.add(new ThreadLocalContext(RequestScoped.class));
-
- afterBeanDiscoveryEvent = event;
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- protected synchronized void proccessEvent() {
- getLogger().debug(
- getBundle("demoiselle-core-bundle").getString("executing-all", annotationClass.getSimpleName()));
-
- Collections.sort(processors);
- Throwable failure = null;
-
- if (!registered) {
- for (CustomContext tempContext : tempContexts) {
- addContext(tempContext, afterBeanDiscoveryEvent);
- }
-
- registered = true;
- }
-
- for (Iterator iter = processors.iterator(); iter.hasNext();) {
- AnnotatedMethodProcessor> processor = iter.next();
-
- try {
- ClassLoader classLoader = ConfigurationLoader.getClassLoaderForClass(processor.getAnnotatedMethod()
- .getDeclaringType().getJavaClass().getCanonicalName());
-
- if (Thread.currentThread().getContextClassLoader().equals(classLoader)) {
- processor.process();
- iter.remove();
- }
-
- } catch (Throwable cause) {
- failure = cause;
- }
- }
-
- if (processors.isEmpty()) {
- unloadTempContexts();
- }
-
- if (failure != null) {
- throw new DemoiselleException(failure);
- }
- }
-
- private void unloadTempContexts() {
- for (CustomContext tempContext : tempContexts) {
- disableContext(tempContext);
- }
- }
-}
diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/ShutdownBootstrap.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/ShutdownBootstrap.java
index 92f23b5..89641da 100644
--- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/ShutdownBootstrap.java
+++ b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/ShutdownBootstrap.java
@@ -47,7 +47,7 @@ import br.gov.frameworkdemoiselle.internal.processor.ShutdownProcessor;
/**
* This class run at application shutdown
*/
-public class ShutdownBootstrap extends AsbratctLifecycleBootstrap {
+public class ShutdownBootstrap extends AbstractLifecycleBootstrap {
@Override
protected AnnotatedMethodProcessor newProcessorInstance(AnnotatedMethod annotatedMethod,
diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/StartupBootstrap.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/StartupBootstrap.java
index 08af835..f2278ba 100644
--- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/StartupBootstrap.java
+++ b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/StartupBootstrap.java
@@ -47,7 +47,7 @@ import br.gov.frameworkdemoiselle.internal.processor.StartupProcessor;
/**
* This class is the bootstrap to execute the processes at load time.
*/
-public class StartupBootstrap extends AsbratctLifecycleBootstrap {
+public class StartupBootstrap extends AbstractLifecycleBootstrap {
@Override
protected AnnotatedMethodProcessor newProcessorInstance(AnnotatedMethod annotatedMethod,
--
libgit2 0.21.2