Commit 588ca76ec8fd5386bfb11baabe81066fcb5a461a
1 parent
187a6500
Exists in
master
Ajuste no startup e shutdown
Showing
2 changed files
with
18 additions
and
8 deletions
Show diff stats
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/ShutdownBootstrap.java
| ... | ... | @@ -55,6 +55,7 @@ import javax.enterprise.inject.spi.ProcessAnnotatedType; |
| 55 | 55 | import br.gov.frameworkdemoiselle.DemoiselleException; |
| 56 | 56 | import br.gov.frameworkdemoiselle.annotation.Shutdown; |
| 57 | 57 | import br.gov.frameworkdemoiselle.annotation.ViewScoped; |
| 58 | +import br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoader; | |
| 58 | 59 | import br.gov.frameworkdemoiselle.internal.context.CustomContext; |
| 59 | 60 | import br.gov.frameworkdemoiselle.internal.context.ThreadLocalContext; |
| 60 | 61 | import br.gov.frameworkdemoiselle.internal.processor.ShutdownProcessor; |
| ... | ... | @@ -128,10 +129,16 @@ public class ShutdownBootstrap extends AbstractBootstrap { |
| 128 | 129 | ShutdownProcessor processor = iter.next(); |
| 129 | 130 | |
| 130 | 131 | try { |
| 131 | - processor.process(); | |
| 132 | + ClassLoader classLoader = ConfigurationLoader.getClassLoaderForClass(processor.getAnnotatedMethod() | |
| 133 | + .getDeclaringType().getJavaClass().getCanonicalName()); | |
| 132 | 134 | |
| 133 | - if (remove) { | |
| 134 | - iter.remove(); | |
| 135 | + if (Thread.currentThread().getContextClassLoader().equals(classLoader)) { | |
| 136 | + | |
| 137 | + processor.process(); | |
| 138 | + | |
| 139 | + if (remove) { | |
| 140 | + iter.remove(); | |
| 141 | + } | |
| 135 | 142 | } |
| 136 | 143 | |
| 137 | 144 | } catch (Throwable cause) { |
| ... | ... | @@ -139,7 +146,9 @@ public class ShutdownBootstrap extends AbstractBootstrap { |
| 139 | 146 | } |
| 140 | 147 | } |
| 141 | 148 | |
| 142 | - unloadTempContexts(); | |
| 149 | + if (processors.isEmpty()) { | |
| 150 | + unloadTempContexts(); | |
| 151 | + } | |
| 143 | 152 | |
| 144 | 153 | if (failure != null) { |
| 145 | 154 | throw new DemoiselleException(failure); | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/StartupBootstrap.java
| ... | ... | @@ -56,6 +56,7 @@ import br.gov.frameworkdemoiselle.DemoiselleException; |
| 56 | 56 | import br.gov.frameworkdemoiselle.annotation.Startup; |
| 57 | 57 | import br.gov.frameworkdemoiselle.annotation.ViewScoped; |
| 58 | 58 | import br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoader; |
| 59 | +import br.gov.frameworkdemoiselle.internal.context.CustomContext; | |
| 59 | 60 | import br.gov.frameworkdemoiselle.internal.context.ThreadLocalContext; |
| 60 | 61 | import br.gov.frameworkdemoiselle.internal.processor.StartupProcessor; |
| 61 | 62 | |
| ... | ... | @@ -66,7 +67,7 @@ public class StartupBootstrap extends AbstractBootstrap { |
| 66 | 67 | |
| 67 | 68 | private static final Class<? extends Annotation> annotationClass = Startup.class; |
| 68 | 69 | |
| 69 | - private static final List<ThreadLocalContext> tempContexts = new ArrayList<ThreadLocalContext>(); | |
| 70 | + private static final List<CustomContext> tempContexts = new ArrayList<CustomContext>(); | |
| 70 | 71 | |
| 71 | 72 | @SuppressWarnings("rawtypes") |
| 72 | 73 | private static final List<StartupProcessor> processors = Collections |
| ... | ... | @@ -97,7 +98,7 @@ public class StartupBootstrap extends AbstractBootstrap { |
| 97 | 98 | tempContexts.add(new ThreadLocalContext(ConversationScoped.class)); |
| 98 | 99 | tempContexts.add(new ThreadLocalContext(RequestScoped.class)); |
| 99 | 100 | |
| 100 | - for (ThreadLocalContext tempContext : tempContexts) { | |
| 101 | + for (CustomContext tempContext : tempContexts) { | |
| 101 | 102 | addContext(tempContext, event); |
| 102 | 103 | } |
| 103 | 104 | } |
| ... | ... | @@ -140,7 +141,7 @@ public class StartupBootstrap extends AbstractBootstrap { |
| 140 | 141 | } |
| 141 | 142 | } |
| 142 | 143 | |
| 143 | - if (processors.isEmpty()){ | |
| 144 | + if (processors.isEmpty()) { | |
| 144 | 145 | unloadTempContexts(); |
| 145 | 146 | } |
| 146 | 147 | |
| ... | ... | @@ -150,7 +151,7 @@ public class StartupBootstrap extends AbstractBootstrap { |
| 150 | 151 | } |
| 151 | 152 | |
| 152 | 153 | private static void unloadTempContexts() { |
| 153 | - for (ThreadLocalContext tempContext : tempContexts) { | |
| 154 | + for (CustomContext tempContext : tempContexts) { | |
| 154 | 155 | disableContext(tempContext); |
| 155 | 156 | } |
| 156 | 157 | } | ... | ... |