Repository: deltaspike Updated Branches: refs/heads/master 53790137b -> b0ce121ac
DELTASPIKE-420 Move EM holder into JPA module API Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/ffb16f7a Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/ffb16f7a Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/ffb16f7a Branch: refs/heads/master Commit: ffb16f7a624c900fc4ffdb47a0dec3969008ac7e Parents: 5379013 Author: Thomas Hug <[email protected]> Authored: Mon Mar 3 13:27:06 2014 +0100 Committer: Thomas Hug <[email protected]> Committed: Mon Mar 3 13:27:06 2014 +0100 ---------------------------------------------------------------------- .../data/impl/tx/TransactionalQueryRunner.java | 8 ++-- .../ActiveEntityManagerHolder.java | 39 ++++++++++++++++++++ .../DefaultEntityManagerHolder.java | 4 +- .../impl/entitymanager/EntityManagerHolder.java | 34 ----------------- .../ResourceLocalTransactionStrategy.java | 4 +- 5 files changed, 48 insertions(+), 41 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ffb16f7a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/tx/TransactionalQueryRunner.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/tx/TransactionalQueryRunner.java b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/tx/TransactionalQueryRunner.java index d1b7d00..74079ad 100644 --- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/tx/TransactionalQueryRunner.java +++ b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/tx/TransactionalQueryRunner.java @@ -30,7 +30,7 @@ import org.apache.deltaspike.data.impl.handler.CdiQueryInvocationContext; import org.apache.deltaspike.data.impl.handler.EntityRepositoryHandler; import org.apache.deltaspike.data.impl.handler.QueryRunner; import org.apache.deltaspike.data.impl.meta.RequiresTransaction; -import org.apache.deltaspike.jpa.impl.entitymanager.EntityManagerHolder; +import org.apache.deltaspike.jpa.spi.entitymanager.ActiveEntityManagerHolder; import org.apache.deltaspike.jpa.spi.transaction.TransactionStrategy; public class TransactionalQueryRunner implements QueryRunner @@ -40,7 +40,7 @@ public class TransactionalQueryRunner implements QueryRunner private TransactionStrategy strategy; @Inject - private EntityManagerHolder entityManagerHolder; + private ActiveEntityManagerHolder activeEntityManagerHolder; @Override public Object executeQuery(final QueryBuilder builder, final CdiQueryInvocationContext context) @@ -50,12 +50,12 @@ public class TransactionalQueryRunner implements QueryRunner { try { - entityManagerHolder.set(context.getEntityManager()); + activeEntityManagerHolder.set(context.getEntityManager()); return executeTransactional(builder, context); } finally { - entityManagerHolder.dispose(); + activeEntityManagerHolder.dispose(); } } return executeNonTransactional(builder, context); http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ffb16f7a/deltaspike/modules/jpa/api/src/main/java/org/apache/deltaspike/jpa/spi/entitymanager/ActiveEntityManagerHolder.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/jpa/api/src/main/java/org/apache/deltaspike/jpa/spi/entitymanager/ActiveEntityManagerHolder.java b/deltaspike/modules/jpa/api/src/main/java/org/apache/deltaspike/jpa/spi/entitymanager/ActiveEntityManagerHolder.java new file mode 100644 index 0000000..19ee6a6 --- /dev/null +++ b/deltaspike/modules/jpa/api/src/main/java/org/apache/deltaspike/jpa/spi/entitymanager/ActiveEntityManagerHolder.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.deltaspike.jpa.spi.entitymanager; + +import javax.persistence.EntityManager; + +/** + * Optional holder which allows to customize the handling of the {@link EntityManager}. + * Multiple Entity-Managers with different qualifiers aren't supported. + * See the data-module for further details. + */ +public interface ActiveEntityManagerHolder +{ + + void set(EntityManager entityManager); + + boolean isSet(); + + EntityManager get(); + + void dispose(); + +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ffb16f7a/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/entitymanager/DefaultEntityManagerHolder.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/entitymanager/DefaultEntityManagerHolder.java b/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/entitymanager/DefaultEntityManagerHolder.java index d0995f3..29eb630 100644 --- a/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/entitymanager/DefaultEntityManagerHolder.java +++ b/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/entitymanager/DefaultEntityManagerHolder.java @@ -20,11 +20,13 @@ package org.apache.deltaspike.jpa.impl.entitymanager; import javax.persistence.EntityManager; +import org.apache.deltaspike.jpa.spi.entitymanager.ActiveEntityManagerHolder; + /** * Empty holder. Override and specialize in using module. * Currently only used by the data module. */ -public class DefaultEntityManagerHolder implements EntityManagerHolder +public class DefaultEntityManagerHolder implements ActiveEntityManagerHolder { @Override http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ffb16f7a/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/entitymanager/EntityManagerHolder.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/entitymanager/EntityManagerHolder.java b/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/entitymanager/EntityManagerHolder.java deleted file mode 100644 index af4f589..0000000 --- a/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/entitymanager/EntityManagerHolder.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.deltaspike.jpa.impl.entitymanager; - -import javax.persistence.EntityManager; - -public interface EntityManagerHolder -{ - - void set(EntityManager entityManager); - - boolean isSet(); - - EntityManager get(); - - void dispose(); - -} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ffb16f7a/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/transaction/ResourceLocalTransactionStrategy.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/transaction/ResourceLocalTransactionStrategy.java b/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/transaction/ResourceLocalTransactionStrategy.java index d5819ae..26ce151 100644 --- a/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/transaction/ResourceLocalTransactionStrategy.java +++ b/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/transaction/ResourceLocalTransactionStrategy.java @@ -38,9 +38,9 @@ import javax.persistence.EntityTransaction; import org.apache.deltaspike.core.api.literal.AnyLiteral; import org.apache.deltaspike.core.util.ProxyUtils; import org.apache.deltaspike.jpa.api.transaction.Transactional; -import org.apache.deltaspike.jpa.impl.entitymanager.EntityManagerHolder; import org.apache.deltaspike.jpa.impl.transaction.context.EntityManagerEntry; import org.apache.deltaspike.jpa.impl.transaction.context.TransactionBeanStorage; +import org.apache.deltaspike.jpa.spi.entitymanager.ActiveEntityManagerHolder; import org.apache.deltaspike.jpa.spi.transaction.TransactionStrategy; /** @@ -74,7 +74,7 @@ public class ResourceLocalTransactionStrategy implements TransactionStrategy private TransactionStrategyHelper transactionHelper; @Inject - private EntityManagerHolder emHolder; + private ActiveEntityManagerHolder emHolder; @Override public Object execute(InvocationContext invocationContext) throws Exception
