BAEL-150 - deltaspike, minor changes

This commit is contained in:
slavisa-baeldung
2016-08-23 23:46:27 +02:00
parent ca84ed7ff0
commit 9dc17848a5
8 changed files with 19 additions and 82 deletions
@@ -10,23 +10,19 @@ import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceUnit;
@ApplicationScoped
public class EntityManagerProducer
{
public class EntityManagerProducer {
@PersistenceUnit(unitName = "primary")
private EntityManagerFactory entityManagerFactory;
@Produces
@Default
@RequestScoped
public EntityManager create()
{
public EntityManager create() {
return this.entityManagerFactory.createEntityManager();
}
public void dispose(@Disposes @Default EntityManager entityManager)
{
if (entityManager.isOpen())
{
public void dispose(@Disposes @Default EntityManager entityManager) {
if (entityManager.isOpen()) {
entityManager.close();
}
}
@@ -10,8 +10,7 @@ import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceUnit;
@ApplicationScoped
public class SecondaryEntityManagerProducer
{
public class SecondaryEntityManagerProducer {
@PersistenceUnit(unitName = "secondary")
private EntityManagerFactory entityManagerFactory;
@@ -19,15 +18,12 @@ public class SecondaryEntityManagerProducer
@Default
@RequestScoped
@SecondaryPersistenceUnit
public EntityManager create()
{
public EntityManager create() {
return this.entityManagerFactory.createEntityManager();
}
public void dispose(@Disposes @Default EntityManager entityManager)
{
if (entityManager.isOpen())
{
public void dispose(@Disposes @Default EntityManager entityManager) {
if (entityManager.isOpen()) {
entityManager.close();
}
}
@@ -22,7 +22,7 @@ import javax.ws.rs.core.Application;
/**
* A class extending {@link Application} and annotated with @ApplicationPath is the Java EE 7 "no XML" approach to activating
* JAX-RS.
*
* <p>
* <p>
* Resources are served relative to the servlet path specified in the {@link ApplicationPath} annotation.
* </p>
@@ -128,10 +128,10 @@ public class MemberResourceRESTService {
* If the error is caused because an existing member with the same email is registered it throws a regular validation
* exception so that it can be interpreted separately.
* </p>
*
*
* @param member Member to be validated
* @throws ConstraintViolationException If Bean Validation errors exist
* @throws ValidationException If member with the same email already exists
* @throws ValidationException If member with the same email already exists
*/
private void validateMember(Member member) throws ConstraintViolationException, ValidationException {
// Create a bean validator and check for issues.
@@ -150,7 +150,7 @@ public class MemberResourceRESTService {
/**
* Creates a JAX-RS "Bad Request" response including a map of all violation fields, and their message. This can then be used
* by clients to show violations.
*
*
* @param violations A set of violations that needs to be reported
* @return JAX-RS response containing all violations
*/
@@ -169,7 +169,7 @@ public class MemberResourceRESTService {
/**
* Checks if a member with the same email address is already registered. This is the only way to easily capture the
* "@UniqueConstraint(columnNames = "email")" constraint from the Member class.
*
*
* @param email The email to check
* @return True if the email already exists, and false otherwise
*/
@@ -27,11 +27,11 @@ import javax.persistence.PersistenceContext;
/**
* This class uses CDI to alias Java EE resources, such as the persistence context, to CDI beans
*
* <p>
* <p>
* Example injection on a managed bean field:
* </p>
*
* <p>
* <pre>
* &#064;Inject
* private EntityManager em;