Commit 77a5174386f5bdf8ad0a0aa531b94484f28cc218
1 parent
eedb5dbb
Exists in
master
Implementando escopo configuravel para Entity Manager
Showing
2 changed files
with
30 additions
and
4 deletions
Show diff stats
impl/extension/jpa/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/EntityManagerBootstrap.java
... | ... | @@ -16,10 +16,11 @@ import javax.enterprise.inject.spi.AnnotatedField; |
16 | 16 | import javax.enterprise.inject.spi.AnnotatedMethod; |
17 | 17 | import javax.enterprise.inject.spi.AnnotatedType; |
18 | 18 | import javax.enterprise.inject.spi.BeanManager; |
19 | +import javax.enterprise.inject.spi.BeforeBeanDiscovery; | |
19 | 20 | import javax.enterprise.inject.spi.Extension; |
20 | 21 | import javax.enterprise.inject.spi.ProcessAnnotatedType; |
21 | 22 | import javax.enterprise.inject.spi.ProcessBean; |
22 | -import javax.enterprise.util.AnnotationLiteral; | |
23 | +import javax.enterprise.inject.spi.ProcessManagedBean; | |
23 | 24 | |
24 | 25 | import org.apache.commons.configuration.PropertiesConfiguration; |
25 | 26 | import org.slf4j.Logger; |
... | ... | @@ -42,6 +43,7 @@ public class EntityManagerBootstrap implements Extension { |
42 | 43 | private EntityManagerScope selectedScope; |
43 | 44 | |
44 | 45 | public void replaceAnnotatedType(@Observes final ProcessAnnotatedType<EntityManagerProducer> event , BeanManager manager){ |
46 | + | |
45 | 47 | if (event.getAnnotatedType().getJavaClass().equals(EntityManagerProducer.class)){ |
46 | 48 | AnnotatedType<EntityManagerProducer> wrapper = new AnnotatedType<EntityManagerProducer>() { |
47 | 49 | |
... | ... | @@ -67,9 +69,10 @@ public class EntityManagerBootstrap implements Extension { |
67 | 69 | return delegate.getMethods(); |
68 | 70 | } |
69 | 71 | |
70 | - @SuppressWarnings("unchecked") | |
71 | 72 | public <T extends Annotation> T getAnnotation(Class<T> annotationType) { |
72 | - T returnedAnnotation; | |
73 | + return delegate.getAnnotation(annotationType); | |
74 | + | |
75 | + /*T returnedAnnotation; | |
73 | 76 | switch(getConfiguredEntityManagerScope()){ |
74 | 77 | case APPLICATION: |
75 | 78 | returnedAnnotation = (T) (annotationType.equals(ApplicationScoped.class) ? new AnnotationLiteral<ApplicationScoped>() { |
... | ... | @@ -97,7 +100,7 @@ public class EntityManagerBootstrap implements Extension { |
97 | 100 | returnedAnnotation = delegate.getAnnotation(annotationType); |
98 | 101 | } |
99 | 102 | |
100 | - return returnedAnnotation; | |
103 | + return returnedAnnotation;*/ | |
101 | 104 | } |
102 | 105 | |
103 | 106 | public Set<AnnotatedField<? super EntityManagerProducer>> getFields() { |
... | ... | @@ -132,6 +135,9 @@ public class EntityManagerBootstrap implements Extension { |
132 | 135 | } |
133 | 136 | } |
134 | 137 | |
138 | + public void a(@Observes BeforeBeanDiscovery event){ | |
139 | + } | |
140 | + | |
135 | 141 | public void configureBean(@Observes ProcessBean<EntityManagerProducer> event , BeanManager manager){ |
136 | 142 | Class<? extends Annotation> beanScope = event.getBean().getScope(); |
137 | 143 | System.out.println(beanScope.toString()); | ... | ... |
impl/extension/jpa/src/main/java/br/gov/frameworkdemoiselle/internal/producer/RequestScopedProducer.java
0 → 100644
... | ... | @@ -0,0 +1,20 @@ |
1 | +package br.gov.frameworkdemoiselle.internal.producer; | |
2 | + | |
3 | +import static java.lang.annotation.ElementType.TYPE; | |
4 | +import static java.lang.annotation.RetentionPolicy.RUNTIME; | |
5 | + | |
6 | +import java.lang.annotation.Inherited; | |
7 | +import java.lang.annotation.Retention; | |
8 | +import java.lang.annotation.Target; | |
9 | + | |
10 | +import javax.enterprise.context.RequestScoped; | |
11 | +import javax.enterprise.inject.Stereotype; | |
12 | + | |
13 | +@RequestScoped | |
14 | +@Stereotype | |
15 | +@Inherited | |
16 | +@Retention(RUNTIME) | |
17 | +@Target({ TYPE }) | |
18 | +public @interface RequestScopedProducer { | |
19 | + | |
20 | +} | ... | ... |