Commit b476f3ea3c2292fca055117968ed9623f184f45f
1 parent
e9b7a931
Exists in
master
Ajustes relacionados à serialização de objetos
Showing
3 changed files
with
32 additions
and
23 deletions
Show diff stats
impl/core/src/main/java/br/gov/frameworkdemoiselle/template/DelegateCrud.java
| ... | ... | @@ -51,28 +51,28 @@ public class DelegateCrud<T, I, C extends Crud<T, I>> implements Crud<T, I> { |
| 51 | 51 | |
| 52 | 52 | private Class<C> delegateClass; |
| 53 | 53 | |
| 54 | - private C delegate; | |
| 55 | - | |
| 54 | + private transient C delegate; | |
| 55 | + | |
| 56 | 56 | @Override |
| 57 | 57 | public void delete(final I id) { |
| 58 | - if(isRunningTransactionalOperations()) { | |
| 58 | + if (isRunningTransactionalOperations()) { | |
| 59 | 59 | transactionalDelete(id); |
| 60 | 60 | } else { |
| 61 | 61 | nonTransactionalDelete(id); |
| 62 | 62 | } |
| 63 | 63 | } |
| 64 | - | |
| 64 | + | |
| 65 | 65 | @Transactional |
| 66 | 66 | private void transactionalDelete(final I id) { |
| 67 | 67 | nonTransactionalDelete(id); |
| 68 | 68 | } |
| 69 | - | |
| 69 | + | |
| 70 | 70 | private void nonTransactionalDelete(final I id) { |
| 71 | 71 | getDelegate().delete(id); |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | public void delete(final List<I> ids) { |
| 75 | - if(isRunningTransactionalOperations()) { | |
| 75 | + if (isRunningTransactionalOperations()) { | |
| 76 | 76 | transactionalDelete(ids); |
| 77 | 77 | } else { |
| 78 | 78 | nonTransactionalDelete(ids); |
| ... | ... | @@ -83,14 +83,14 @@ public class DelegateCrud<T, I, C extends Crud<T, I>> implements Crud<T, I> { |
| 83 | 83 | private void transactionalDelete(final List<I> ids) { |
| 84 | 84 | nonTransactionalDelete(ids); |
| 85 | 85 | } |
| 86 | - | |
| 86 | + | |
| 87 | 87 | private void nonTransactionalDelete(final List<I> ids) { |
| 88 | 88 | ListIterator<I> iter = ids.listIterator(); |
| 89 | 89 | while (iter.hasNext()) { |
| 90 | 90 | this.delete(iter.next()); |
| 91 | 91 | } |
| 92 | 92 | } |
| 93 | - | |
| 93 | + | |
| 94 | 94 | @Override |
| 95 | 95 | public List<T> findAll() { |
| 96 | 96 | return getDelegate().findAll(); |
| ... | ... | @@ -100,6 +100,7 @@ public class DelegateCrud<T, I, C extends Crud<T, I>> implements Crud<T, I> { |
| 100 | 100 | if (this.delegate == null) { |
| 101 | 101 | this.delegate = Beans.getReference(getDelegateClass()); |
| 102 | 102 | } |
| 103 | + | |
| 103 | 104 | return this.delegate; |
| 104 | 105 | } |
| 105 | 106 | |
| ... | ... | @@ -107,23 +108,24 @@ public class DelegateCrud<T, I, C extends Crud<T, I>> implements Crud<T, I> { |
| 107 | 108 | if (this.delegateClass == null) { |
| 108 | 109 | this.delegateClass = Reflections.getGenericTypeArgument(this.getClass(), 2); |
| 109 | 110 | } |
| 111 | + | |
| 110 | 112 | return this.delegateClass; |
| 111 | 113 | } |
| 112 | 114 | |
| 113 | 115 | @Override |
| 114 | 116 | public void insert(final T bean) { |
| 115 | - if(isRunningTransactionalOperations()) { | |
| 117 | + if (isRunningTransactionalOperations()) { | |
| 116 | 118 | transactionalInsert(bean); |
| 117 | 119 | } else { |
| 118 | 120 | nonTransactionalInsert(bean); |
| 119 | 121 | } |
| 120 | 122 | } |
| 121 | - | |
| 123 | + | |
| 122 | 124 | @Transactional |
| 123 | 125 | private void transactionalInsert(final T bean) { |
| 124 | 126 | nonTransactionalInsert(bean); |
| 125 | 127 | } |
| 126 | - | |
| 128 | + | |
| 127 | 129 | private void nonTransactionalInsert(final T bean) { |
| 128 | 130 | getDelegate().insert(bean); |
| 129 | 131 | } |
| ... | ... | @@ -135,7 +137,7 @@ public class DelegateCrud<T, I, C extends Crud<T, I>> implements Crud<T, I> { |
| 135 | 137 | |
| 136 | 138 | @Override |
| 137 | 139 | public void update(final T bean) { |
| 138 | - if(isRunningTransactionalOperations()) { | |
| 140 | + if (isRunningTransactionalOperations()) { | |
| 139 | 141 | transactionalUpdate(bean); |
| 140 | 142 | } else { |
| 141 | 143 | nonTransactionalUpdate(bean); |
| ... | ... | @@ -146,11 +148,11 @@ public class DelegateCrud<T, I, C extends Crud<T, I>> implements Crud<T, I> { |
| 146 | 148 | private void transactionalUpdate(final T bean) { |
| 147 | 149 | nonTransactionalUpdate(bean); |
| 148 | 150 | } |
| 149 | - | |
| 151 | + | |
| 150 | 152 | private void nonTransactionalUpdate(final T bean) { |
| 151 | 153 | getDelegate().update(bean); |
| 152 | 154 | } |
| 153 | - | |
| 155 | + | |
| 154 | 156 | private boolean isRunningTransactionalOperations() { |
| 155 | 157 | return !(Beans.getReference(Transaction.class) instanceof DefaultTransaction); |
| 156 | 158 | } | ... | ... |
impl/extension/jpa/src/main/java/br/gov/frameworkdemoiselle/template/JPACrud.java
| ... | ... | @@ -59,6 +59,7 @@ import br.gov.frameworkdemoiselle.configuration.Configuration; |
| 59 | 59 | import br.gov.frameworkdemoiselle.pagination.Pagination; |
| 60 | 60 | import br.gov.frameworkdemoiselle.pagination.PaginationContext; |
| 61 | 61 | import br.gov.frameworkdemoiselle.transaction.Transactional; |
| 62 | +import br.gov.frameworkdemoiselle.util.Beans; | |
| 62 | 63 | import br.gov.frameworkdemoiselle.util.Reflections; |
| 63 | 64 | import br.gov.frameworkdemoiselle.util.ResourceBundle; |
| 64 | 65 | |
| ... | ... | @@ -76,7 +77,6 @@ public class JPACrud<T, I> implements Crud<T, I> { |
| 76 | 77 | |
| 77 | 78 | private static final long serialVersionUID = 1L; |
| 78 | 79 | |
| 79 | - @Inject | |
| 80 | 80 | private EntityManager entityManager; |
| 81 | 81 | |
| 82 | 82 | @Inject |
| ... | ... | @@ -91,7 +91,6 @@ public class JPACrud<T, I> implements Crud<T, I> { |
| 91 | 91 | private Class<T> beanClass; |
| 92 | 92 | |
| 93 | 93 | protected Class<T> getBeanClass() { |
| 94 | - | |
| 95 | 94 | if (this.beanClass == null) { |
| 96 | 95 | this.beanClass = Reflections.getGenericTypeArgument(this.getClass(), 0); |
| 97 | 96 | } |
| ... | ... | @@ -104,6 +103,10 @@ public class JPACrud<T, I> implements Crud<T, I> { |
| 104 | 103 | } |
| 105 | 104 | |
| 106 | 105 | protected EntityManager getEntityManager() { |
| 106 | + if(this.entityManager == null) { | |
| 107 | + this.entityManager = Beans.getReference(EntityManager.class); | |
| 108 | + } | |
| 109 | + | |
| 107 | 110 | return this.entityManager; |
| 108 | 111 | } |
| 109 | 112 | ... | ... |
parent/jsf/pom.xml
| ... | ... | @@ -79,13 +79,6 @@ |
| 79 | 79 | <artifactId>demoiselle-jsf</artifactId> |
| 80 | 80 | <scope>compile</scope> |
| 81 | 81 | </dependency> |
| 82 | - <!-- | |
| 83 | - <dependency> | |
| 84 | - <groupId>javax.el</groupId> | |
| 85 | - <artifactId>el-api</artifactId> | |
| 86 | - <scope>provided</scope> | |
| 87 | - </dependency> | |
| 88 | - --> | |
| 89 | 82 | </dependencies> |
| 90 | 83 | |
| 91 | 84 | <dependencyManagement> |
| ... | ... | @@ -238,6 +231,11 @@ |
| 238 | 231 | <scope>runtime</scope> |
| 239 | 232 | </dependency> |
| 240 | 233 | <dependency> |
| 234 | + <groupId>org.glassfish.web</groupId> | |
| 235 | + <artifactId>el-impl</artifactId> | |
| 236 | + <scope>runtime</scope> | |
| 237 | + </dependency> | |
| 238 | + <dependency> | |
| 241 | 239 | <groupId>org.hibernate</groupId> |
| 242 | 240 | <artifactId>hibernate-validator</artifactId> |
| 243 | 241 | <scope>runtime</scope> |
| ... | ... | @@ -253,6 +251,12 @@ |
| 253 | 251 | <version>${gae.version}</version> |
| 254 | 252 | </dependency> |
| 255 | 253 | </dependencies> |
| 254 | + <repositories> | |
| 255 | + <repository> | |
| 256 | + <id>objectify-appengine</id> | |
| 257 | + <url>http://objectify-appengine.googlecode.com/svn/maven</url> | |
| 258 | + </repository> | |
| 259 | + </repositories> | |
| 256 | 260 | <properties> |
| 257 | 261 | <gae.version>1.7.0</gae.version> |
| 258 | 262 | <kindleit.plugin.version>0.9.4</kindleit.plugin.version> | ... | ... |