Commit 0cce422fd58109f34cdc3fa8f95f1cd37e63d31c
1 parent
c1e5f12c
Exists in
master
Retirada do @Inject na criação do PaginationContext.
Showing
1 changed file
with
8 additions
and
5 deletions
Show diff stats
impl/extension/jpa/src/main/java/br/gov/frameworkdemoiselle/template/JPACrud.java
| ... | ... | @@ -42,6 +42,7 @@ import java.util.List; |
| 42 | 42 | import java.util.regex.Matcher; |
| 43 | 43 | import java.util.regex.Pattern; |
| 44 | 44 | |
| 45 | +import javax.enterprise.context.ContextNotActiveException; | |
| 45 | 46 | import javax.enterprise.inject.Instance; |
| 46 | 47 | import javax.inject.Inject; |
| 47 | 48 | import javax.persistence.Basic; |
| ... | ... | @@ -82,9 +83,6 @@ public class JPACrud<T, I> implements Crud<T, I> { |
| 82 | 83 | |
| 83 | 84 | private EntityManager entityManager; |
| 84 | 85 | |
| 85 | - @Inject | |
| 86 | - private Instance<PaginationContext> paginationContext; | |
| 87 | - | |
| 88 | 86 | private Pagination pagination; |
| 89 | 87 | |
| 90 | 88 | @Inject |
| ... | ... | @@ -115,8 +113,13 @@ public class JPACrud<T, I> implements Crud<T, I> { |
| 115 | 113 | |
| 116 | 114 | protected Pagination getPagination() { |
| 117 | 115 | if (pagination == null) { |
| 118 | - PaginationContext context = paginationContext.get(); | |
| 119 | - pagination = context.getPagination(getBeanClass()); | |
| 116 | + try { | |
| 117 | + PaginationContext context = Beans.getReference(PaginationContext.class); | |
| 118 | + pagination = context.getPagination(getBeanClass()); | |
| 119 | + | |
| 120 | + } catch (ContextNotActiveException cause) { | |
| 121 | + pagination = null; | |
| 122 | + } | |
| 120 | 123 | } |
| 121 | 124 | |
| 122 | 125 | return pagination; | ... | ... |