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