Seam SVN: r13447 - modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence.
by seam-commits@lists.jboss.org
Author: swd847
Date: 2010-07-20 04:48:55 -0400 (Tue, 20 Jul 2010)
New Revision: 13447
Modified:
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextBeanLifecycle.java
Log:
update managed pc
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextBeanLifecycle.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextBeanLifecycle.java 2010-07-20 07:48:58 UTC (rev 13446)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextBeanLifecycle.java 2010-07-20 08:48:55 UTC (rev 13447)
@@ -87,8 +87,9 @@
}
}
- public void destroy(BeanImpl<EntityManager> bean, EntityManager arg0, CreationalContext<EntityManager> arg1)
+ public void destroy(BeanImpl<EntityManager> bean, EntityManager em, CreationalContext<EntityManager> arg1)
{
+ em.close();
arg1.release();
}
14 years, 5 months
Seam SVN: r13446 - modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/picketlink.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2010-07-20 03:48:58 -0400 (Tue, 20 Jul 2010)
New Revision: 13446
Modified:
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/picketlink/JpaIdentityStore.java
Log:
fix removeIdentityObject() for identities with credentials and relationships
Modified: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/picketlink/JpaIdentityStore.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/picketlink/JpaIdentityStore.java 2010-07-20 05:47:48 UTC (rev 13445)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/picketlink/JpaIdentityStore.java 2010-07-20 07:48:58 UTC (rev 13446)
@@ -1408,6 +1408,7 @@
EntityManager em = getEntityManager(ctx);
CriteriaBuilder builder = em.getCriteriaBuilder();
+
CriteriaQuery<?> criteria = builder.createQuery(identityClass);
Root<?> root = criteria.from(identityClass);
@@ -1422,6 +1423,27 @@
try
{
Object instance = em.createQuery(criteria).getSingleResult();
+
+ // If there is a credential class, delete any credentials
+ if (credentialClass != null)
+ {
+ Property<?> credentialIdentityProp = modelProperties.get(PROPERTY_CREDENTIAL_IDENTITY);
+
+ criteria = builder.createQuery(credentialClass);
+ root = criteria.from(credentialClass);
+
+ predicates = new ArrayList<Predicate>();
+ predicates.add(builder.equal(root.get(credentialIdentityProp.getName()),
+ lookupIdentity(identity, em)));
+ criteria.where(predicates.toArray(new Predicate[0]));
+
+ List<?> results = em.createQuery(criteria).getResultList();
+ for (Object result : results)
+ {
+ em.remove(result);
+ }
+ }
+
em.remove(instance);
}
catch (NoResultException ex)
@@ -1700,8 +1722,11 @@
IdentityObject identityObject, IdentityObjectCredential credential)
throws IdentityException
{
+
+
// TODO Auto-generated method stub
System.out.println("*** Invoked unimplemented method updateCredential()");
+
}
public boolean validateCredential(IdentityStoreInvocationContext ctx,
14 years, 5 months
Seam SVN: r13445 - in modules/security/trunk: examples/idmconsole/src/main/webapp/WEB-INF and 2 other directories.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2010-07-20 01:47:48 -0400 (Tue, 20 Jul 2010)
New Revision: 13445
Modified:
modules/security/trunk/examples/idmconsole/src/main/java/org/jboss/seam/security/examples/idmconsole/action/EntityManagerProducer.java
modules/security/trunk/examples/idmconsole/src/main/webapp/WEB-INF/faces-config.xml
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/action/UserSearch.java
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/picketlink/JpaIdentityStore.java
Log:
implement group delete
Modified: modules/security/trunk/examples/idmconsole/src/main/java/org/jboss/seam/security/examples/idmconsole/action/EntityManagerProducer.java
===================================================================
--- modules/security/trunk/examples/idmconsole/src/main/java/org/jboss/seam/security/examples/idmconsole/action/EntityManagerProducer.java 2010-07-19 22:31:04 UTC (rev 13444)
+++ modules/security/trunk/examples/idmconsole/src/main/java/org/jboss/seam/security/examples/idmconsole/action/EntityManagerProducer.java 2010-07-20 05:47:48 UTC (rev 13445)
@@ -4,13 +4,27 @@
import javax.enterprise.context.RequestScoped;
import javax.enterprise.inject.Produces;
import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceUnit;
import org.jboss.seam.drools.qualifiers.Stateless;
+import org.jboss.seam.persistence.SeamManaged;
@Stateless
public class EntityManagerProducer
{
- @Produces /*@ManagedPersistenceContext @ConversationScoped*/ @RequestScoped
- @PersistenceContext(unitName = "idmconsoleDatabase") EntityManager entityManager;
+ //@Produces /*@ManagedPersistenceContext @ConversationScoped*/ @RequestScoped
+ //@PersistenceContext(unitName = "idmconsoleDatabase") EntityManager entityManager;
+
+// @Produces @RequestScoped
+ //public EntityManager produceEM()
+ //{
+ // return entityManager;
+ //}
+ @PersistenceUnit
+ @RequestScoped
+ @Produces
+ @SeamManaged
+ EntityManagerFactory emf;
}
Modified: modules/security/trunk/examples/idmconsole/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- modules/security/trunk/examples/idmconsole/src/main/webapp/WEB-INF/faces-config.xml 2010-07-19 22:31:04 UTC (rev 13444)
+++ modules/security/trunk/examples/idmconsole/src/main/webapp/WEB-INF/faces-config.xml 2010-07-20 05:47:48 UTC (rev 13445)
@@ -23,9 +23,26 @@
<to-view-id>/userdetail.xhtml</to-view-id>
<redirect/>
</navigation-case>
+
+ <navigation-case>
+ <from-action>#{userAction.deleteUser(user.username)}</from-action>
+ <if>#{true}</if>
+ <to-view-id>/manageusers.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
</navigation-rule>
<navigation-rule>
+ <from-view-id>/managegroups.xhtml</from-view-id>
+ <navigation-case>
+ <from-action>#{groupAction.deleteGroup(group.name, group.groupType)}</from-action>
+ <if>#{true}</if>
+ <to-view-id>/managegroups.xhtml</to-view-id>
+ <redirect />
+ </navigation-case>
+ </navigation-rule>
+
+ <navigation-rule>
<from-view-id>/userdetail.xhtml</from-view-id>
<navigation-case>
<from-action>#{userAction.save}</from-action>
Modified: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/action/UserSearch.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/action/UserSearch.java 2010-07-19 22:31:04 UTC (rev 13444)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/action/UserSearch.java 2010-07-20 05:47:48 UTC (rev 13445)
@@ -20,8 +20,11 @@
@Inject IdentityManager identityManager;
- @Inject public void loadUsers()
- {
+ private boolean loaded;
+
+ public void loadUsers()
+ {
+ loaded = true;
users = new ArrayList<UserDTO>();
Collection<User> results = identityManager.findUsers(null);
@@ -51,6 +54,7 @@
public List<UserDTO> getUsers()
{
+ if (!loaded) loadUsers();
return users;
}
Modified: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/picketlink/JpaIdentityStore.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/picketlink/JpaIdentityStore.java 2010-07-19 22:31:04 UTC (rev 13444)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/picketlink/JpaIdentityStore.java 2010-07-20 05:47:48 UTC (rev 13445)
@@ -1400,6 +1400,8 @@
IdentityStoreInvocationContext ctx, IdentityObject identity)
throws IdentityException
{
+ removeRelationships(ctx, identity, null, false);
+
Property<?> nameProperty = modelProperties.get(PROPERTY_IDENTITY_NAME);
Property<?> typeProperty = modelProperties.get(PROPERTY_IDENTITY_TYPE);
@@ -1484,12 +1486,65 @@
}
public void removeRelationships(
- IdentityStoreInvocationContext invocationCtx,
+ IdentityStoreInvocationContext ctx,
IdentityObject identity1, IdentityObject identity2, boolean named)
throws IdentityException
{
- // TODO Auto-generated method stub
- System.out.println("*** Invoked unimplemented method removeRelationships()");
+ EntityManager em = getEntityManager(ctx);
+
+ CriteriaBuilder builder = em.getCriteriaBuilder();
+ CriteriaQuery<?> criteria = builder.createQuery(relationshipClass);
+ Root<?> root = criteria.from(relationshipClass);
+
+ Property<?> relationshipFromProp = modelProperties.get(PROPERTY_RELATIONSHIP_FROM);
+ Property<?> relationshipToProp = modelProperties.get(PROPERTY_RELATIONSHIP_TO);
+
+ List<Predicate> predicates = new ArrayList<Predicate>();
+
+ if (identity1 != null)
+ {
+ predicates.add(builder.equal(root.get(relationshipFromProp.getName()),
+ lookupIdentity(identity1, em)));
+ }
+
+ if (identity2 != null)
+ {
+ predicates.add(builder.equal(root.get(relationshipToProp.getName()),
+ lookupIdentity(identity2, em)));
+ }
+
+ criteria.where(predicates.toArray(new Predicate[0]));
+
+ List<?> results = em.createQuery(criteria).getResultList();
+ for (Object result : results)
+ {
+ em.remove(result);
+ }
+
+ criteria = builder.createQuery(relationshipClass);
+ criteria.from(relationshipClass);
+
+ predicates = new ArrayList<Predicate>();
+
+ if (identity2 != null)
+ {
+ predicates.add(builder.equal(root.get(relationshipFromProp.getName()),
+ lookupIdentity(identity2, em)));
+ }
+
+ if (identity1 != null)
+ {
+ predicates.add(builder.equal(root.get(relationshipToProp.getName()),
+ lookupIdentity(identity1, em)));
+ }
+
+ criteria.where(predicates.toArray(new Predicate[0]));
+
+ results = em.createQuery(criteria).getResultList();
+ for (Object result : results)
+ {
+ em.remove(result);
+ }
}
public Set<IdentityObjectRelationship> resolveRelationships(
14 years, 5 months
Seam SVN: r13444 - in modules/persistence/trunk/impl/src: main/resources/META-INF/services and 5 other directories.
by seam-commits@lists.jboss.org
Author: swd847
Date: 2010-07-19 18:31:04 -0400 (Mon, 19 Jul 2010)
New Revision: 13444
Added:
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextBeanLifecycle.java
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextExtension.java
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextProducer.java
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextProxyHandler.java
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/SeamManaged.java
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/ManagedPersistenceContextTest.java
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/util/Hotel.java
Removed:
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/Hotel.java
Modified:
modules/persistence/trunk/impl/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/TransactionInterceptorTest.java
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/TransactionManagedBean.java
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/TransactionObserver.java
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/TransactionScopedTest.java
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/UserTransactionTest.java
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/util/EntityManagerProvider.java
modules/persistence/trunk/impl/src/test/resources/META-INF/persistence.xml
Log:
very quick and dirty impl of the SMPC
Added: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextBeanLifecycle.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextBeanLifecycle.java (rev 0)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextBeanLifecycle.java 2010-07-19 22:31:04 UTC (rev 13444)
@@ -0,0 +1,115 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.persistence;
+
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Proxy;
+import java.util.Set;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+
+import org.jboss.weld.extensions.bean.BeanImpl;
+import org.jboss.weld.extensions.bean.BeanLifecycle;
+
+public class ManagedPersistenceContextBeanLifecycle implements BeanLifecycle<EntityManager>
+{
+
+ private EntityManagerFactory emf;
+ private final Annotation[] qualifiers;
+ private final BeanManager manager;
+
+ static final Class<?> proxyClass = Proxy.getProxyClass(EntityManager.class.getClassLoader(), EntityManager.class, Serializable.class);
+
+ public ManagedPersistenceContextBeanLifecycle(Set<Annotation> qualifiers, BeanManager manager)
+ {
+ this.qualifiers = new Annotation[qualifiers.size()];
+ int i = 0;
+ for (Annotation a : qualifiers)
+ {
+ this.qualifiers[i++] = a;
+ }
+ this.manager = manager;
+ }
+
+ static final Constructor<?> proxyConstructor;
+
+ static
+ {
+ try
+ {
+ proxyConstructor = proxyClass.getConstructor(InvocationHandler.class);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public EntityManager create(BeanImpl<EntityManager> bean, CreationalContext<EntityManager> arg0)
+ {
+ try
+ {
+ EntityManagerFactory emf = getEntityManagerFactory();
+ EntityManager entityManager = emf.createEntityManager();
+ ManagedPersistenceContextProxyHandler handler = new ManagedPersistenceContextProxyHandler(entityManager, manager);
+ EntityManager proxy = (EntityManager) proxyConstructor.newInstance(handler);
+ return proxy;
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void destroy(BeanImpl<EntityManager> bean, EntityManager arg0, CreationalContext<EntityManager> arg1)
+ {
+ arg1.release();
+ }
+
+ private EntityManagerFactory getEntityManagerFactory()
+ {
+ if (emf == null)
+ {
+ Set<Bean<?>> beans = manager.getBeans(EntityManagerFactory.class, qualifiers);
+ if (beans.size() == 0)
+ {
+ throw new RuntimeException("No bean found with type EntityManagerFactory and qualifiers " + qualifiers);
+ }
+ if (beans.size() != 1)
+ {
+ throw new RuntimeException("More than 1 bean found with type EntityManagerFactory and qualifiers " + qualifiers);
+ }
+ Bean<?> emfBean = beans.iterator().next();
+ CreationalContext<?> emfCreationalContext = manager.createCreationalContext(emfBean);
+ emf = (EntityManagerFactory) manager.getReference(emfBean, EntityManagerFactory.class, emfCreationalContext);
+ }
+ return emf;
+ }
+
+}
Added: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextExtension.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextExtension.java (rev 0)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextExtension.java 2010-07-19 22:31:04 UTC (rev 13444)
@@ -0,0 +1,136 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.persistence;
+
+import java.lang.annotation.Annotation;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.enterprise.context.Dependent;
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.AfterBeanDiscovery;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.Extension;
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.enterprise.inject.spi.InjectionTarget;
+import javax.enterprise.inject.spi.ProcessProducer;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+
+import org.jboss.weld.extensions.annotated.AnnotatedTypeBuilder;
+import org.jboss.weld.extensions.bean.BeanBuilder;
+import org.jboss.weld.extensions.literal.DefaultLiteral;
+
+/**
+ * Extension the wraps producer methods/fields that produce an entity manager to
+ * turn them into Seam Managed Persistence Contexts.
+ *
+ * At present this happens automatically, in future we will need some way to
+ * configure it
+ *
+ * @author stuart
+ *
+ */
+public class ManagedPersistenceContextExtension implements Extension
+{
+
+ Set<Bean<?>> beans = new HashSet<Bean<?>>();
+
+ public <T> void processProducer(@Observes ProcessProducer<T, EntityManagerFactory> event, BeanManager manager)
+ {
+ if (!event.getAnnotatedMember().isAnnotationPresent(SeamManaged.class))
+ {
+ return;
+ }
+ Set<Annotation> qualifiers = new HashSet<Annotation>();
+ Class scope = Dependent.class;
+ for (Annotation a : event.getAnnotatedMember().getAnnotations())
+ {
+ if (manager.isQualifier(a.annotationType()))
+ {
+ qualifiers.add(a);
+ }
+ else if (manager.isScope(a.annotationType()))
+ {
+ scope = a.annotationType();
+ }
+ }
+ if (qualifiers.isEmpty())
+ {
+ qualifiers.add(new DefaultLiteral());
+ }
+ AnnotatedTypeBuilder<EntityManager> typeBuilder = AnnotatedTypeBuilder.newInstance(EntityManager.class);
+ BeanBuilder<EntityManager> builder = new BeanBuilder<EntityManager>(typeBuilder.create(), manager);
+ builder.defineBeanFromAnnotatedType();
+ builder.setQualifiers(qualifiers);
+ builder.setScope(scope);
+ builder.setInjectionTarget(new NoOpInjectionTarget());
+ builder.setBeanLifecycle(new ManagedPersistenceContextBeanLifecycle(qualifiers, manager));
+ beans.add(builder.create());
+ }
+
+ public void afterBeanDiscovery(@Observes AfterBeanDiscovery event)
+ {
+ for (Bean<?> i : beans)
+ {
+ event.addBean(i);
+ }
+ }
+
+ private static class NoOpInjectionTarget implements InjectionTarget<EntityManager>
+ {
+
+ public EntityManager produce(CreationalContext<EntityManager> ctx)
+ {
+ return null;
+ }
+
+ public Set<InjectionPoint> getInjectionPoints()
+ {
+ return Collections.emptySet();
+ }
+
+ public void dispose(EntityManager instance)
+ {
+
+ }
+
+ public void preDestroy(EntityManager instance)
+ {
+
+ }
+
+ public void postConstruct(EntityManager instance)
+ {
+
+ }
+
+ public void inject(EntityManager instance, CreationalContext<EntityManager> ctx)
+ {
+
+ }
+
+ }
+}
Added: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextProducer.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextProducer.java (rev 0)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextProducer.java 2010-07-19 22:31:04 UTC (rev 13444)
@@ -0,0 +1,75 @@
+package org.jboss.seam.persistence;
+
+import java.io.Serializable;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Proxy;
+import java.util.Set;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.enterprise.inject.spi.Producer;
+import javax.persistence.EntityManager;
+
+/**
+ * implementation of Producer that proxies a produced EntityManager
+ *
+ * @author stuart
+ *
+ */
+public class ManagedPersistenceContextProducer implements Producer<EntityManager>
+{
+ static final Class<?> proxyClass = Proxy.getProxyClass(EntityManager.class.getClassLoader(), EntityManager.class, Serializable.class);
+
+ static final Constructor<?> proxyConstructor;
+
+ static
+ {
+ try
+ {
+ proxyConstructor = proxyClass.getConstructor(InvocationHandler.class);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private final Producer<EntityManager> delegate;
+
+ private final BeanManager beanManager;
+
+ public ManagedPersistenceContextProducer(Producer<EntityManager> delegate, BeanManager beanManager)
+ {
+ this.delegate = delegate;
+ this.beanManager = beanManager;
+ }
+
+ public void dispose(EntityManager instance)
+ {
+ delegate.dispose(instance);
+ }
+
+ public Set<InjectionPoint> getInjectionPoints()
+ {
+ return delegate.getInjectionPoints();
+ }
+
+ public EntityManager produce(CreationalContext<EntityManager> ctx)
+ {
+ try
+ {
+ EntityManager entityManager = delegate.produce(ctx);
+ ManagedPersistenceContextProxyHandler handler = new ManagedPersistenceContextProxyHandler(entityManager, beanManager);
+ EntityManager proxy = (EntityManager) proxyConstructor.newInstance(handler);
+ return proxy;
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+
+ }
+
+}
Added: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextProxyHandler.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextProxyHandler.java (rev 0)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextProxyHandler.java 2010-07-19 22:31:04 UTC (rev 13444)
@@ -0,0 +1,110 @@
+package org.jboss.seam.persistence;
+
+import java.io.Serializable;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.util.Set;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.persistence.EntityManager;
+import javax.transaction.Synchronization;
+import javax.transaction.SystemException;
+
+import org.jboss.seam.persistence.transaction.UserTransaction;
+import org.jboss.weld.extensions.beanManager.BeanManagerAccessor;
+import org.jboss.weld.extensions.literal.DefaultLiteral;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ManagedPersistenceContextProxyHandler implements InvocationHandler, Serializable, Synchronization
+{
+
+ private final EntityManager delegate;
+
+ private transient BeanManager beanManager;
+
+ private transient UserTransaction userTransaction;
+
+ private transient boolean synchronizationRegistered;
+
+ static final Logger log = LoggerFactory.getLogger(ManagedPersistenceContextProxyHandler.class);
+
+ public ManagedPersistenceContextProxyHandler(EntityManager delegate, BeanManager beanManager)
+ {
+ this.delegate = delegate;
+ this.beanManager = beanManager;
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
+ {
+ if (!synchronizationRegistered)
+ {
+ joinTransaction();
+ }
+ return method.invoke(delegate, args);
+ }
+
+ private void joinTransaction() throws SystemException
+ {
+ UserTransaction transaction = getUserTransaction();
+ if (transaction.isActive())
+ {
+ transaction.enlist(delegate);
+ try
+ {
+ transaction.registerSynchronization(this);
+ synchronizationRegistered = true;
+ }
+ catch (Exception e)
+ {
+ // synchronizationRegistered =
+ // PersistenceProvider.instance().registerSynchronization(this,
+ // entityManager);
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ private BeanManager getBeanManager()
+ {
+ if (beanManager == null)
+ {
+ beanManager = BeanManagerAccessor.getManager();
+ }
+ return beanManager;
+ }
+
+ private UserTransaction getUserTransaction()
+ {
+ if (userTransaction == null)
+ {
+ Set<Bean<?>> beans = beanManager.getBeans(UserTransaction.class, DefaultLiteral.INSTANCE);
+ if (beans.size() == 0)
+ {
+ throw new RuntimeException("No bean with class" + UserTransaction.class.getName() + " and qualifiers Default found");
+ }
+ else if (beans.size() != 1)
+ {
+ throw new RuntimeException("More than 1 bean with class" + UserTransaction.class.getName() + " and qualifiers Default found");
+ }
+ Bean<UserTransaction> userTransactionBean = (Bean<UserTransaction>) beans.iterator().next();
+ CreationalContext<UserTransaction> ctx = beanManager.createCreationalContext(userTransactionBean);
+ userTransaction = (UserTransaction) beanManager.getReference(userTransactionBean, UserTransaction.class, ctx);
+ }
+ return userTransaction;
+ }
+
+ public void afterCompletion(int status)
+ {
+ synchronizationRegistered = false;
+ }
+
+ public void beforeCompletion()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Added: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/SeamManaged.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/SeamManaged.java (rev 0)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/SeamManaged.java 2010-07-19 22:31:04 UTC (rev 13444)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.persistence;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+(a)Retention(RetentionPolicy.RUNTIME)
+@Target( { ElementType.FIELD })
+public @interface SeamManaged
+{
+
+}
Modified: modules/persistence/trunk/impl/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
===================================================================
--- modules/persistence/trunk/impl/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension 2010-07-19 11:45:15 UTC (rev 13443)
+++ modules/persistence/trunk/impl/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension 2010-07-19 22:31:04 UTC (rev 13444)
@@ -1,3 +1,4 @@
org.jboss.seam.persistence.PersistenceContextExtension
org.jboss.seam.persistence.transaction.TransactionExtension
-org.jboss.seam.persistence.transaction.scope.TransactionScopeExtension
\ No newline at end of file
+org.jboss.seam.persistence.transaction.scope.TransactionScopeExtension
+org.jboss.seam.persistence.ManagedPersistenceContextExtension
\ No newline at end of file
Added: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/ManagedPersistenceContextTest.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/ManagedPersistenceContextTest.java (rev 0)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/ManagedPersistenceContextTest.java 2010-07-19 22:31:04 UTC (rev 13444)
@@ -0,0 +1,76 @@
+package org.jboss.seam.persistence.test;
+
+import java.util.List;
+
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+
+import junit.framework.Assert;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.persistence.PersistenceContextExtension;
+import org.jboss.seam.persistence.transaction.Transaction;
+import org.jboss.seam.persistence.transaction.UserTransaction;
+import org.jboss.seam.transactions.test.util.ArtifactNames;
+import org.jboss.seam.transactions.test.util.EntityManagerProvider;
+import org.jboss.seam.transactions.test.util.Hotel;
+import org.jboss.seam.transactions.test.util.MavenArtifactResolver;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.ByteArrayAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+(a)RunWith(Arquillian.class)
+public class ManagedPersistenceContextTest
+{
+ @Deployment
+ public static Archive<?> createTestArchive()
+ {
+ WebArchive war = ShrinkWrap.createDomain().getArchiveFactory().create(WebArchive.class, "test.war");
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.WELD_EXTENSIONS));
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_API));
+ war.addPackage(Transaction.class.getPackage());
+ war.addPackage(PersistenceContextExtension.class.getPackage());
+ war.addClasses(ManagedPersistenceContextTest.class, Hotel.class, EntityManagerProvider.class);
+ war.addWebResource("META-INF/persistence.xml", "classes/META-INF/persistence.xml");
+ war.addWebResource(new ByteArrayAsset(new byte[0]), "beans.xml");
+ war.addWebResource("META-INF/services/javax.enterprise.inject.spi.Extension", "classes/META-INF/services/javax.enterprise.inject.spi.Extension");
+ return war;
+ }
+
+ @Inject
+ UserTransaction transaction;
+
+ @Inject
+ EntityManager em;
+
+ @Test
+ public void testManagedPsersistenceContext() throws NotSupportedException, SystemException, SecurityException, IllegalStateException, RollbackException, HeuristicMixedException, HeuristicRollbackException
+ {
+ transaction.begin();
+ Hotel h = new Hotel("test", "Fake St", "Wollongong", "NSW", "2518", "Australia");
+ em.persist(h);
+ em.flush();
+ transaction.commit();
+
+ transaction.begin();
+ h = new Hotel("test2", "Fake St", "Wollongong", "NSW", "2518", "Australia");
+ em.persist(h);
+ em.flush();
+ transaction.rollback();
+
+ transaction.begin();
+ List<Hotel> hotels = em.createQuery("select h from Hotel h").getResultList();
+ Assert.assertTrue(hotels.size() == 1);
+ transaction.rollback();
+ }
+
+}
Deleted: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/Hotel.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/Hotel.java 2010-07-19 11:45:15 UTC (rev 13443)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/Hotel.java 2010-07-19 22:31:04 UTC (rev 13444)
@@ -1,205 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.seam.transactions.test;
-
-import java.io.Serializable;
-import java.math.BigDecimal;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.Table;
-import javax.persistence.Transient;
-import javax.validation.constraints.Max;
-import javax.validation.constraints.Min;
-import javax.validation.constraints.NotNull;
-import javax.validation.constraints.Size;
-import org.jboss.weld.extensions.core.Veto;
-
-/**
- * <p>
- * <strong>Hotel</strong> is the model/entity class that represents a hotel.
- * </p>
- *
- * @author Gavin King
- * @author Dan Allen
- */
-@Entity
-@Table(name = "hotel")
-@Veto
-public class Hotel implements Serializable
-{
- private Long id;
- private String name;
- private String address;
- private String city;
- private String state;
- private String zip;
- private String country;
- private Integer stars;
- private BigDecimal price;
-
- public Hotel()
- {
- }
-
- public Hotel(final String name, final String address, final String city, final String state, final String zip, final String country)
- {
- this.name = name;
- this.address = address;
- this.city = city;
- this.state = state;
- this.zip = zip;
- this.country = country;
- }
-
- public Hotel(final int price, final int stars, final String name, final String address, final String city, final String state, final String zip, final String country)
- {
- this.price = new BigDecimal(price);
- this.stars = stars;
- this.name = name;
- this.address = address;
- this.city = city;
- this.state = state;
- this.zip = zip;
- this.country = country;
- }
-
- @Id
- @GeneratedValue
- public Long getId()
- {
- return id;
- }
-
- public void setId(final Long id)
- {
- this.id = id;
- }
-
- @Size(max = 50)
- @NotNull
- public String getName()
- {
- return name;
- }
-
- public void setName(final String name)
- {
- this.name = name;
- }
-
- @Size(max = 100)
- @NotNull
- public String getAddress()
- {
- return address;
- }
-
- public void setAddress(final String address)
- {
- this.address = address;
- }
-
- @Size(max = 40)
- @NotNull
- public String getCity()
- {
- return city;
- }
-
- public void setCity(final String city)
- {
- this.city = city;
- }
-
- @Size(min = 3, max = 6)
- @NotNull
- public String getZip()
- {
- return zip;
- }
-
- public void setZip(final String zip)
- {
- this.zip = zip;
- }
-
- @Size(min = 2, max = 10)
- public String getState()
- {
- return state;
- }
-
- public void setState(final String state)
- {
- this.state = state;
- }
-
- @Size(min = 2, max = 40)
- @NotNull
- public String getCountry()
- {
- return country;
- }
-
- public void setCountry(final String country)
- {
- this.country = country;
- }
-
- @Min(1)
- @Max(5)
- public Integer getStars()
- {
- return stars;
- }
-
- public void setStars(final Integer stars)
- {
- this.stars = stars;
- }
-
- @Column(precision = 6, scale = 2)
- public BigDecimal getPrice()
- {
- return price;
- }
-
- public void setPrice(final BigDecimal price)
- {
- this.price = price;
- }
-
- @Transient
- public String getLocation()
- {
- return city + ", " + state + ", " + country;
- }
-
- @Override
- public String toString()
- {
- return "Hotel(" + name + "," + address + "," + city + "," + zip + ")";
- }
-}
Modified: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/TransactionInterceptorTest.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/TransactionInterceptorTest.java 2010-07-19 11:45:15 UTC (rev 13443)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/TransactionInterceptorTest.java 2010-07-19 22:31:04 UTC (rev 13444)
@@ -21,6 +21,7 @@
import org.jboss.seam.transactions.test.util.ArtifactNames;
import org.jboss.seam.transactions.test.util.DontRollBackException;
import org.jboss.seam.transactions.test.util.EntityManagerProvider;
+import org.jboss.seam.transactions.test.util.Hotel;
import org.jboss.seam.transactions.test.util.MavenArtifactResolver;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
@@ -36,7 +37,7 @@
public static Archive<?> createTestArchive()
{
- WebArchive war = ShrinkWrap.create("test.war", WebArchive.class);
+ WebArchive war = ShrinkWrap.createDomain().getArchiveFactory().create(WebArchive.class, "test.war");
war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.WELD_EXTENSIONS));
war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_API));
war.addPackage(Transaction.class.getPackage());
@@ -87,6 +88,7 @@
catch (DontRollBackException e)
{
}
+ observer.setEnabled(false);
assertHotels(2);
observer.verify();
}
Modified: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/TransactionManagedBean.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/TransactionManagedBean.java 2010-07-19 11:45:15 UTC (rev 13443)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/TransactionManagedBean.java 2010-07-19 22:31:04 UTC (rev 13444)
@@ -6,6 +6,7 @@
import org.jboss.seam.persistence.transaction.TransactionPropagation;
import org.jboss.seam.persistence.transaction.Transactional;
import org.jboss.seam.transactions.test.util.DontRollBackException;
+import org.jboss.seam.transactions.test.util.Hotel;
@Transactional(TransactionPropagation.REQUIRED)
public class TransactionManagedBean
Modified: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/TransactionObserver.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/TransactionObserver.java 2010-07-19 11:45:15 UTC (rev 13443)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/TransactionObserver.java 2010-07-19 22:31:04 UTC (rev 13444)
@@ -47,9 +47,12 @@
public void observeBeforeTransactionCommit(@Observes AfterTransactionCompletion event)
{
afterTransaction = true;
- if (expectSuccess != event.success())
+ if (enabled)
{
- throw new RuntimeException("Expected success to be " + expectSuccess);
+ if (expectSuccess != event.success())
+ {
+ throw new RuntimeException("Expected success to be " + expectSuccess);
+ }
}
}
Modified: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/TransactionScopedTest.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/TransactionScopedTest.java 2010-07-19 11:45:15 UTC (rev 13443)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/TransactionScopedTest.java 2010-07-19 22:31:04 UTC (rev 13444)
@@ -17,6 +17,7 @@
import org.jboss.seam.persistence.transaction.UserTransaction;
import org.jboss.seam.persistence.transaction.scope.TransactionScopeExtension;
import org.jboss.seam.transactions.test.util.ArtifactNames;
+import org.jboss.seam.transactions.test.util.Hotel;
import org.jboss.seam.transactions.test.util.MavenArtifactResolver;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
@@ -31,8 +32,7 @@
@Deployment
public static Archive<?> createTestArchive()
{
-
- WebArchive war = ShrinkWrap.create("test.war", WebArchive.class);
+ WebArchive war = ShrinkWrap.createDomain().getArchiveFactory().create(WebArchive.class, "test.war");
war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.WELD_EXTENSIONS));
war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_API));
war.addPackage(Transaction.class.getPackage());
Modified: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/UserTransactionTest.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/UserTransactionTest.java 2010-07-19 11:45:15 UTC (rev 13443)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/UserTransactionTest.java 2010-07-19 22:31:04 UTC (rev 13444)
@@ -4,8 +4,7 @@
import javax.inject.Inject;
import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.PersistenceUnit;
+import javax.persistence.PersistenceContext;
import javax.transaction.HeuristicMixedException;
import javax.transaction.HeuristicRollbackException;
import javax.transaction.NotSupportedException;
@@ -19,6 +18,7 @@
import org.jboss.seam.persistence.transaction.Transaction;
import org.jboss.seam.persistence.transaction.UserTransaction;
import org.jboss.seam.transactions.test.util.ArtifactNames;
+import org.jboss.seam.transactions.test.util.Hotel;
import org.jboss.seam.transactions.test.util.MavenArtifactResolver;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
@@ -33,8 +33,7 @@
@Deployment
public static Archive<?> createTestArchive()
{
-
- WebArchive war = ShrinkWrap.create("test.war", WebArchive.class);
+ WebArchive war = ShrinkWrap.createDomain().getArchiveFactory().create(WebArchive.class, "test.war");
war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.WELD_EXTENSIONS));
war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_API));
war.addPackage(Transaction.class.getPackage());
@@ -48,34 +47,35 @@
@Inject
UserTransaction transaction;
- @PersistenceUnit
- EntityManagerFactory emf;
+ @PersistenceContext
+ EntityManager em;
@Test
public void userTransactionTest() throws NotSupportedException, SystemException, SecurityException, IllegalStateException, RollbackException, HeuristicMixedException, HeuristicRollbackException
{
transaction.begin();
- EntityManager em = emf.createEntityManager();
em.joinTransaction();
Hotel h = new Hotel("test", "Fake St", "Wollongong", "NSW", "2518", "Australia");
em.persist(h);
em.flush();
transaction.commit();
+ em.clear();
transaction.begin();
- em = emf.createEntityManager();
em.joinTransaction();
h = new Hotel("test2", "Fake St", "Wollongong", "NSW", "2518", "Australia");
em.persist(h);
em.flush();
transaction.rollback();
+ em.clear();
transaction.begin();
- em = emf.createEntityManager();
em.joinTransaction();
List<Hotel> hotels = em.createQuery("select h from Hotel h").getResultList();
Assert.assertTrue(hotels.size() == 1);
transaction.rollback();
+ em.clear();
+
}
}
Modified: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/util/EntityManagerProvider.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/util/EntityManagerProvider.java 2010-07-19 11:45:15 UTC (rev 13443)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/util/EntityManagerProvider.java 2010-07-19 22:31:04 UTC (rev 13444)
@@ -1,12 +1,17 @@
package org.jboss.seam.transactions.test.util;
+import javax.enterprise.context.RequestScoped;
import javax.enterprise.inject.Produces;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceUnit;
+import org.jboss.seam.persistence.SeamManaged;
+
public class EntityManagerProvider
{
- @PersistenceContext
+ @PersistenceUnit
+ @RequestScoped
@Produces
- EntityManager entityManager;
+ @SeamManaged
+ EntityManagerFactory emf;
}
Copied: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/util/Hotel.java (from rev 13431, modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/Hotel.java)
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/util/Hotel.java (rev 0)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/util/Hotel.java 2010-07-19 22:31:04 UTC (rev 13444)
@@ -0,0 +1,205 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.transactions.test.util;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import org.jboss.weld.extensions.core.Veto;
+
+/**
+ * <p>
+ * <strong>Hotel</strong> is the model/entity class that represents a hotel.
+ * </p>
+ *
+ * @author Gavin King
+ * @author Dan Allen
+ */
+@Entity
+@Table(name = "hotel")
+@Veto
+public class Hotel implements Serializable
+{
+ private Long id;
+ private String name;
+ private String address;
+ private String city;
+ private String state;
+ private String zip;
+ private String country;
+ private Integer stars;
+ private BigDecimal price;
+
+ public Hotel()
+ {
+ }
+
+ public Hotel(final String name, final String address, final String city, final String state, final String zip, final String country)
+ {
+ this.name = name;
+ this.address = address;
+ this.city = city;
+ this.state = state;
+ this.zip = zip;
+ this.country = country;
+ }
+
+ public Hotel(final int price, final int stars, final String name, final String address, final String city, final String state, final String zip, final String country)
+ {
+ this.price = new BigDecimal(price);
+ this.stars = stars;
+ this.name = name;
+ this.address = address;
+ this.city = city;
+ this.state = state;
+ this.zip = zip;
+ this.country = country;
+ }
+
+ @Id
+ @GeneratedValue
+ public Long getId()
+ {
+ return id;
+ }
+
+ public void setId(final Long id)
+ {
+ this.id = id;
+ }
+
+ @Size(max = 50)
+ @NotNull
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(final String name)
+ {
+ this.name = name;
+ }
+
+ @Size(max = 100)
+ @NotNull
+ public String getAddress()
+ {
+ return address;
+ }
+
+ public void setAddress(final String address)
+ {
+ this.address = address;
+ }
+
+ @Size(max = 40)
+ @NotNull
+ public String getCity()
+ {
+ return city;
+ }
+
+ public void setCity(final String city)
+ {
+ this.city = city;
+ }
+
+ @Size(min = 3, max = 6)
+ @NotNull
+ public String getZip()
+ {
+ return zip;
+ }
+
+ public void setZip(final String zip)
+ {
+ this.zip = zip;
+ }
+
+ @Size(min = 2, max = 10)
+ public String getState()
+ {
+ return state;
+ }
+
+ public void setState(final String state)
+ {
+ this.state = state;
+ }
+
+ @Size(min = 2, max = 40)
+ @NotNull
+ public String getCountry()
+ {
+ return country;
+ }
+
+ public void setCountry(final String country)
+ {
+ this.country = country;
+ }
+
+ @Min(1)
+ @Max(5)
+ public Integer getStars()
+ {
+ return stars;
+ }
+
+ public void setStars(final Integer stars)
+ {
+ this.stars = stars;
+ }
+
+ @Column(precision = 6, scale = 2)
+ public BigDecimal getPrice()
+ {
+ return price;
+ }
+
+ public void setPrice(final BigDecimal price)
+ {
+ this.price = price;
+ }
+
+ @Transient
+ public String getLocation()
+ {
+ return city + ", " + state + ", " + country;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "Hotel(" + name + "," + address + "," + city + "," + zip + ")";
+ }
+}
Modified: modules/persistence/trunk/impl/src/test/resources/META-INF/persistence.xml
===================================================================
--- modules/persistence/trunk/impl/src/test/resources/META-INF/persistence.xml 2010-07-19 11:45:15 UTC (rev 13443)
+++ modules/persistence/trunk/impl/src/test/resources/META-INF/persistence.xml 2010-07-19 22:31:04 UTC (rev 13444)
@@ -9,7 +9,7 @@
-->
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/DefaultDS</jta-data-source>
- <class>org.jboss.seam.transactions.test.Hotel</class>
+ <class>org.jboss.seam.transactions.test.util.Hotel</class>
<exclude-unlisted-classes/>
<properties>
<!-- Properties for Hibernate (default provider for JBoss AS) -->
14 years, 5 months
Seam SVN: r13443 - branches/community/Seam_2_2/src/test/ftest.
by seam-commits@lists.jboss.org
Author: plenyi(a)redhat.com
Date: 2010-07-19 07:45:15 -0400 (Mon, 19 Jul 2010)
New Revision: 13443
Modified:
branches/community/Seam_2_2/src/test/ftest/readme.txt
Log:
Updated ftest readme file.
Modified: branches/community/Seam_2_2/src/test/ftest/readme.txt
===================================================================
--- branches/community/Seam_2_2/src/test/ftest/readme.txt 2010-07-19 06:59:49 UTC (rev 13442)
+++ branches/community/Seam_2_2/src/test/ftest/readme.txt 2010-07-19 11:45:15 UTC (rev 13443)
@@ -32,6 +32,8 @@
* Set jboss*.home properties in ftest.properties to point to your application server locations
* Set tomcat.home in ftest.properties to be able to run tests on plain Tomcat
* Set jboss-embedded.home in ftest.properties to be able to run tests on Tomcat (with JBoss Embedded)
+* Check if testng jar file was downloaded - its location should be $SEAM_HOME/lib/ (if not, tests will miss some classes and fail)
+ - if there is no testng jar file, change to the $SEAM_HOME directory and run "ant copyseamdependencies"
To run all the functional tests run:
* "ant testall" for JBoss AS 5
14 years, 5 months
Seam SVN: r13442 - in modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management: picketlink and 1 other directory.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2010-07-19 02:59:49 -0400 (Mon, 19 Jul 2010)
New Revision: 13442
Modified:
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/action/GroupAction.java
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/picketlink/JpaIdentityStore.java
Log:
fiddling with transaction stuff
Modified: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/action/GroupAction.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/action/GroupAction.java 2010-07-19 06:25:35 UTC (rev 13441)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/action/GroupAction.java 2010-07-19 06:59:49 UTC (rev 13442)
@@ -4,12 +4,11 @@
import javax.enterprise.context.Conversation;
import javax.enterprise.context.ConversationScoped;
-import javax.enterprise.inject.Instance;
import javax.inject.Inject;
import javax.inject.Named;
-import org.jboss.seam.security.GroupImpl;
import org.jboss.seam.persistence.transaction.Transactional;
+import org.jboss.seam.security.GroupImpl;
import org.picketlink.idm.api.Group;
import org.picketlink.idm.api.IdentitySession;
import org.picketlink.idm.common.exception.IdentityException;
@@ -23,28 +22,28 @@
{
private static final long serialVersionUID = -1553124158319503903L;
- //@Inject Conversation conversation;
+ @Inject Conversation conversation;
- //@Inject IdentitySession identitySession;
+ @Inject IdentitySession identitySession;
private String groupName;
private String groupType;
public void createGroup()
{
- // conversation.begin();
+ conversation.begin();
}
public void deleteGroup(String name, String groupType) throws IdentityException
{
Group group = new GroupImpl(name, groupType);
- // identitySession.getPersistenceManager().removeGroup(group, true);
+ identitySession.getPersistenceManager().removeGroup(group, true);
}
public String save() throws IdentityException
{
- //identitySession.getPersistenceManager().createGroup(groupName, groupType);
- //conversation.end();
+ identitySession.getPersistenceManager().createGroup(groupName, groupType);
+ conversation.end();
return "success";
}
}
Modified: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/picketlink/JpaIdentityStore.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/picketlink/JpaIdentityStore.java 2010-07-19 06:25:35 UTC (rev 13441)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/picketlink/JpaIdentityStore.java 2010-07-19 06:59:49 UTC (rev 13442)
@@ -1075,8 +1075,10 @@
//beanManager.fireEvent(new PrePersistUserEvent(identityInstance));
- getEntityManager(ctx).persist(identityInstance);
+ EntityManager em = getEntityManager(ctx);
+ em.persist(identityInstance);
+
//beanManager.fireEvent(new UserCreatedEvent(identityInstance));
// TODO persist attributes
14 years, 5 months
Seam SVN: r13441 - modules/persistence/trunk/impl.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2010-07-19 02:25:35 -0400 (Mon, 19 Jul 2010)
New Revision: 13441
Modified:
modules/persistence/trunk/impl/pom.xml
Log:
update jta scope
Modified: modules/persistence/trunk/impl/pom.xml
===================================================================
--- modules/persistence/trunk/impl/pom.xml 2010-07-19 06:16:48 UTC (rev 13440)
+++ modules/persistence/trunk/impl/pom.xml 2010-07-19 06:25:35 UTC (rev 13441)
@@ -58,6 +58,7 @@
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
14 years, 5 months
Seam SVN: r13440 - in modules/security/trunk: examples/idmconsole and 7 other directories.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2010-07-19 02:16:48 -0400 (Mon, 19 Jul 2010)
New Revision: 13440
Modified:
modules/security/trunk/api/pom.xml
modules/security/trunk/examples/idmconsole/pom.xml
modules/security/trunk/examples/idmconsole/src/main/webapp/managegroups.xhtml
modules/security/trunk/examples/idmconsole/src/main/webapp/style/default.css
modules/security/trunk/impl/pom.xml
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/GroupImpl.java
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/IdentityManagerImpl.java
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/action/GroupAction.java
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/action/UserAction.java
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/picketlink/JpaIdentityStore.java
Log:
update seam-persistence dependencies, fix group delete
Modified: modules/security/trunk/api/pom.xml
===================================================================
--- modules/security/trunk/api/pom.xml 2010-07-19 06:14:01 UTC (rev 13439)
+++ modules/security/trunk/api/pom.xml 2010-07-19 06:16:48 UTC (rev 13440)
@@ -17,6 +17,12 @@
<dependencies>
<dependency>
+ <groupId>org.jboss.seam.persistence</groupId>
+ <artifactId>seam-persistence-api</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<scope>provided</scope>
Modified: modules/security/trunk/examples/idmconsole/pom.xml
===================================================================
--- modules/security/trunk/examples/idmconsole/pom.xml 2010-07-19 06:14:01 UTC (rev 13439)
+++ modules/security/trunk/examples/idmconsole/pom.xml 2010-07-19 06:16:48 UTC (rev 13440)
@@ -61,22 +61,18 @@
</dependency>
<dependency>
- <groupId>org.jboss.seam</groupId>
- <artifactId>seam-persistence</artifactId>
+ <groupId>org.jboss.seam.persistence</groupId>
+ <artifactId>seam-persistence-api</artifactId>
<version>3.0.0-SNAPSHOT</version>
- <exclusions>
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-core</artifactId>
- </exclusion>
- </exclusions>
</dependency>
<dependency>
+ <groupId>org.jboss.seam.persistence</groupId>
+ <artifactId>seam-persistence-impl</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
<groupId>org.jboss.seam.xml</groupId>
<artifactId>seam-xml-config</artifactId>
<version>3.0.0-SNAPSHOT</version>
Modified: modules/security/trunk/examples/idmconsole/src/main/webapp/managegroups.xhtml
===================================================================
--- modules/security/trunk/examples/idmconsole/src/main/webapp/managegroups.xhtml 2010-07-19 06:14:01 UTC (rev 13439)
+++ modules/security/trunk/examples/idmconsole/src/main/webapp/managegroups.xhtml 2010-07-19 06:16:48 UTC (rev 13440)
@@ -49,12 +49,8 @@
Action
</f:facet>
- <ui:fragment rendered="#{identity.hasPermission('seam.identity', 'update')}">
- <h:commandLink id="edit" value="Edit" action="#{groupAction.editGroup(group.name)}"/>
- <span> | </span>
- </ui:fragment>
<ui:fragment rendered="#{identity.hasPermission('seam.identity', 'delete')}">
- <h:commandLink id="delete" value="Delete" action="#{groupAction.deleteGroup(group.name)}" onclick="return confirmDelete()"/>
+ <h:commandLink id="delete" value="Delete" action="#{groupAction.deleteGroup(group.name, group.groupType)}" onclick="return confirmDelete()"/>
</ui:fragment>
</h:column>
</h:dataTable>
Modified: modules/security/trunk/examples/idmconsole/src/main/webapp/style/default.css
===================================================================
--- modules/security/trunk/examples/idmconsole/src/main/webapp/style/default.css 2010-07-19 06:14:01 UTC (rev 13439)
+++ modules/security/trunk/examples/idmconsole/src/main/webapp/style/default.css 2010-07-19 06:16:48 UTC (rev 13440)
@@ -1,7 +1,7 @@
body {
margin: 0;
padding: 0;
- background-color: #EAECEE;
+ background-color: #5c6066;
font-family: Verdana, sans-serif;
font-size: 0.9em;
}
@@ -46,12 +46,12 @@
text-decoration: none;
}
-input.newuser {
- background: url(btn_newuser.png) top left no-repeat;
- height: 39px;
- width: 113px;
- margin: 4px 4px 4px 4px;
- border: 0px;
- cursor: pointer;
+input.newuser {
+ background: url(btn_newuser.png) top left no-repeat;
+ height: 39px;
+ width: 113px;
+ margin: 4px 4px 4px 4px;
+ border: 0px;
+ cursor: pointer;
}
Modified: modules/security/trunk/impl/pom.xml
===================================================================
--- modules/security/trunk/impl/pom.xml 2010-07-19 06:14:01 UTC (rev 13439)
+++ modules/security/trunk/impl/pom.xml 2010-07-19 06:16:48 UTC (rev 13440)
@@ -131,8 +131,8 @@
</dependency>
<dependency>
- <groupId>org.jboss.seam</groupId>
- <artifactId>seam-persistence</artifactId>
+ <groupId>org.jboss.seam.persistence</groupId>
+ <artifactId>seam-persistence-api</artifactId>
<version>3.0.0-SNAPSHOT</version>
<optional>true</optional>
</dependency>
Modified: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/GroupImpl.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/GroupImpl.java 2010-07-19 06:14:01 UTC (rev 13439)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/GroupImpl.java 2010-07-19 06:16:48 UTC (rev 13440)
@@ -10,7 +10,7 @@
private String groupType;
private String name;
- public GroupImpl(String groupType, String name)
+ public GroupImpl(String name, String groupType)
{
this.groupType = groupType;
this.name = name;
Modified: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/IdentityManagerImpl.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/IdentityManagerImpl.java 2010-07-19 06:14:01 UTC (rev 13439)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/IdentityManagerImpl.java 2010-07-19 06:16:48 UTC (rev 13440)
@@ -13,7 +13,7 @@
import org.jboss.seam.security.Identity;
import org.jboss.seam.security.UserImpl;
import org.jboss.seam.security.util.Strings;
-import org.jboss.seam.transaction.Transactional;
+import org.jboss.seam.persistence.transaction.Transactional;
import org.picketlink.idm.api.Credential;
import org.picketlink.idm.api.Group;
import org.picketlink.idm.api.IdentitySearchCriteria;
Modified: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/action/GroupAction.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/action/GroupAction.java 2010-07-19 06:14:01 UTC (rev 13439)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/action/GroupAction.java 2010-07-19 06:16:48 UTC (rev 13440)
@@ -4,10 +4,12 @@
import javax.enterprise.context.Conversation;
import javax.enterprise.context.ConversationScoped;
+import javax.enterprise.inject.Instance;
import javax.inject.Inject;
import javax.inject.Named;
import org.jboss.seam.security.GroupImpl;
+import org.jboss.seam.persistence.transaction.Transactional;
import org.picketlink.idm.api.Group;
import org.picketlink.idm.api.IdentitySession;
import org.picketlink.idm.common.exception.IdentityException;
@@ -17,32 +19,32 @@
*
* @author Shane Bryzak
*/
-public @Named @ConversationScoped class GroupAction implements Serializable
+public @Transactional @Named @ConversationScoped class GroupAction implements Serializable
{
private static final long serialVersionUID = -1553124158319503903L;
- @Inject Conversation conversation;
+ //@Inject Conversation conversation;
- @Inject IdentitySession identitySession;
+ //@Inject IdentitySession identitySession;
private String groupName;
private String groupType;
public void createGroup()
{
- conversation.begin();
+ // conversation.begin();
}
public void deleteGroup(String name, String groupType) throws IdentityException
{
Group group = new GroupImpl(name, groupType);
- identitySession.getPersistenceManager().removeGroup(group, true);
+ // identitySession.getPersistenceManager().removeGroup(group, true);
}
public String save() throws IdentityException
{
- identitySession.getPersistenceManager().createGroup(groupName, groupType);
- conversation.end();
+ //identitySession.getPersistenceManager().createGroup(groupName, groupType);
+ //conversation.end();
return "success";
}
}
Modified: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/action/UserAction.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/action/UserAction.java 2010-07-19 06:14:01 UTC (rev 13439)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/action/UserAction.java 2010-07-19 06:16:48 UTC (rev 13440)
@@ -19,9 +19,7 @@
*
* @author Shane Bryzak
*/
-@Named
-@ConversationScoped
-public class UserAction implements Serializable
+public @Named @ConversationScoped class UserAction implements Serializable
{
private static final long serialVersionUID = 5820385095080724087L;
Modified: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/picketlink/JpaIdentityStore.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/picketlink/JpaIdentityStore.java 2010-07-19 06:14:01 UTC (rev 13439)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/picketlink/JpaIdentityStore.java 2010-07-19 06:16:48 UTC (rev 13440)
@@ -1415,9 +1415,17 @@
criteria.where(predicates.toArray(new Predicate[0]));
- Object instance = em.createQuery(criteria).getSingleResult();
-
- em.remove(instance);
+ try
+ {
+ Object instance = em.createQuery(criteria).getSingleResult();
+ em.remove(instance);
+ }
+ catch (NoResultException ex)
+ {
+ throw new IdentityException(String.format(
+ "Exception removing identity object - [%s] not found.",
+ identity), ex);
+ }
}
public void removeRelationship(IdentityStoreInvocationContext ctx,
14 years, 5 months
Seam SVN: r13439 - modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2010-07-19 02:14:01 -0400 (Mon, 19 Jul 2010)
New Revision: 13439
Modified:
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionInterceptor.java
Log:
interceptor should be passivation capable
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionInterceptor.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionInterceptor.java 2010-07-19 05:52:25 UTC (rev 13438)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionInterceptor.java 2010-07-19 06:14:01 UTC (rev 13439)
@@ -21,11 +21,13 @@
*/
package org.jboss.seam.persistence.transaction;
+import java.io.Serializable;
import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
+import javax.enterprise.inject.Instance;
import javax.inject.Inject;
import javax.interceptor.AroundInvoke;
import javax.interceptor.Interceptor;
@@ -43,14 +45,13 @@
*/
@Transactional
@Interceptor
-public class TransactionInterceptor
+public class TransactionInterceptor implements Serializable
{
private static final long serialVersionUID = -4364203056333738988L;
transient private Map<AnnotatedElement, TransactionMetadata> transactionMetadata = new HashMap<AnnotatedElement, TransactionMetadata>();
- @Inject
- UserTransaction transaction;
+ @Inject Instance<UserTransaction> transaction;
private class TransactionMetadata
{
@@ -139,7 +140,7 @@
}
}
- }.workInTransaction(transaction);
+ }.workInTransaction(transaction.get());
}
}
14 years, 5 months
Seam SVN: r13438 - modules/persistence/trunk/impl.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2010-07-19 01:52:25 -0400 (Mon, 19 Jul 2010)
New Revision: 13438
Modified:
modules/persistence/trunk/impl/pom.xml
Log:
modify dependency scopes
Modified: modules/persistence/trunk/impl/pom.xml
===================================================================
--- modules/persistence/trunk/impl/pom.xml 2010-07-19 05:50:57 UTC (rev 13437)
+++ modules/persistence/trunk/impl/pom.xml 2010-07-19 05:52:25 UTC (rev 13438)
@@ -40,11 +40,13 @@
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
14 years, 5 months