Seam SVN: r13552 - in modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject: destination and 1 other directory.
by seam-commits@lists.jboss.org
Author: jganoff
Date: 2010-08-03 22:45:10 -0400 (Tue, 03 Aug 2010)
New Revision: 13552
Added:
modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/destination/
modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/destination/DestinationProducers.java
modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/destination/InjectDestinationViaResource.java
Log:
SEAMJMS-2: Created tests for @Resource injection of destinations
Added: modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/destination/DestinationProducers.java
===================================================================
--- modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/destination/DestinationProducers.java (rev 0)
+++ modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/destination/DestinationProducers.java 2010-08-04 02:45:10 UTC (rev 13552)
@@ -0,0 +1,42 @@
+/*
+ * 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.jms.test.inject.destination;
+
+import javax.annotation.Resource;
+import javax.enterprise.inject.Produces;
+import javax.inject.Named;
+import javax.jms.Queue;
+import javax.jms.Topic;
+
+import org.jboss.seam.jms.test.inject.destination.InjectDestinationViaResource.Q;
+import org.jboss.seam.jms.test.inject.destination.InjectDestinationViaResource.T;
+
+@Named
+public class DestinationProducers
+{
+
+ @Resource(mappedName="/jms/T")
+ @Produces @T Topic t;
+
+ @Resource(mappedName="/jms/Q")
+ @Produces @Q Queue q;
+}
Added: modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/destination/InjectDestinationViaResource.java
===================================================================
--- modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/destination/InjectDestinationViaResource.java (rev 0)
+++ modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/destination/InjectDestinationViaResource.java 2010-08-04 02:45:10 UTC (rev 13552)
@@ -0,0 +1,78 @@
+/*
+ * 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.jms.test.inject.destination;
+
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+
+import javax.enterprise.inject.Instance;
+import javax.inject.Inject;
+import javax.inject.Qualifier;
+import javax.jms.JMSException;
+import javax.jms.Queue;
+import javax.jms.Topic;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.jms.test.Util;
+import org.jboss.shrinkwrap.api.Archive;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+(a)RunWith(Arquillian.class)
+public class InjectDestinationViaResource
+{
+ @Qualifier
+ @Retention(RUNTIME)
+ public @interface Q {}
+
+ @Qualifier
+ @Retention(RUNTIME)
+ public @interface T {}
+
+ @Deployment
+ public static Archive<?> createDeployment()
+ {
+ return Util.createDeployment(InjectDestinationViaResource.class);
+ }
+
+ @Inject @T Instance<Topic> t;
+ @Inject @Q Instance<Queue> q;
+
+ @Test
+ public void injectTopic() throws JMSException
+ {
+ Topic topic = t.get();
+ Assert.assertNotNull(topic);
+ Assert.assertEquals("T", topic.getTopicName());
+ }
+
+ @Test
+ public void injectQueue() throws JMSException
+ {
+ Queue queue = q.get();
+ Assert.assertNotNull(queue);
+ Assert.assertNotNull("Q", queue.getQueueName());
+ }
+}
13 years, 9 months
Seam SVN: r13551 - in modules/jms/trunk: impl/src/main/java/org/jboss/seam/jms/impl/inject and 1 other directories.
by seam-commits@lists.jboss.org
Author: jganoff
Date: 2010-08-03 22:36:57 -0400 (Tue, 03 Aug 2010)
New Revision: 13551
Modified:
modules/jms/trunk/api/src/main/java/org/jboss/seam/jms/annotations/JmsSessionSelector.java
modules/jms/trunk/impl/src/main/java/org/jboss/seam/jms/impl/inject/SessionProducer.java
modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/session/InjectSessionTest.java
modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/session/SessionSelectorBean.java
Log:
SEAMJMS-1: Fixed implementation for JmsSessionSelector.
Modified: modules/jms/trunk/api/src/main/java/org/jboss/seam/jms/annotations/JmsSessionSelector.java
===================================================================
--- modules/jms/trunk/api/src/main/java/org/jboss/seam/jms/annotations/JmsSessionSelector.java 2010-08-03 11:21:26 UTC (rev 13550)
+++ modules/jms/trunk/api/src/main/java/org/jboss/seam/jms/annotations/JmsSessionSelector.java 2010-08-04 02:36:57 UTC (rev 13551)
@@ -8,6 +8,8 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
+import javax.enterprise.util.AnnotationLiteral;
+import javax.enterprise.util.Nonbinding;
import javax.inject.Qualifier;
@Qualifier
@@ -18,10 +20,36 @@
/**
* @see javax.jms.Session#getTransacted()
*/
+ @Nonbinding
boolean transacted() default false;
/**
* @see javax.jms.Session#getAcknowledgeMode()
*/
+ @Nonbinding
int acknowledgementMode() default javax.jms.Session.AUTO_ACKNOWLEDGE;
+
+
+ public class JmsSessionSelectorLiteral extends AnnotationLiteral<JmsSessionSelector> implements JmsSessionSelector
+ {
+ private static final long serialVersionUID = 7495801629674469699L;
+ private int acknowledgementMode;
+ private boolean transacted;
+
+ public JmsSessionSelectorLiteral(boolean transacted, int acknowledgementMode)
+ {
+ this.transacted = transacted;
+ this.acknowledgementMode = acknowledgementMode;
+ }
+
+ public boolean transacted()
+ {
+ return transacted;
+ }
+
+ public int acknowledgementMode()
+ {
+ return acknowledgementMode;
+ }
+ }
}
Modified: modules/jms/trunk/impl/src/main/java/org/jboss/seam/jms/impl/inject/SessionProducer.java
===================================================================
--- modules/jms/trunk/impl/src/main/java/org/jboss/seam/jms/impl/inject/SessionProducer.java 2010-08-03 11:21:26 UTC (rev 13550)
+++ modules/jms/trunk/impl/src/main/java/org/jboss/seam/jms/impl/inject/SessionProducer.java 2010-08-04 02:36:57 UTC (rev 13551)
@@ -22,6 +22,7 @@
package org.jboss.seam.jms.impl.inject;
import java.lang.annotation.Annotation;
+import java.util.Iterator;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.inject.Disposes;
@@ -78,7 +79,21 @@
@JmsSessionSelector
public Session getSelectedSession(InjectionPoint ip, Connection c) throws JMSException
{
- JmsSessionSelector s = ip.getAnnotated().getAnnotation(JmsSessionSelector.class);
+ JmsSessionSelector s = null;
+ Iterator<Annotation> qualifiers = ip.getQualifiers().iterator();
+ while(qualifiers.hasNext())
+ {
+ Annotation qualifier = qualifiers.next();
+ if(JmsSessionSelector.class.isAssignableFrom(qualifier.getClass()))
+ {
+ s = (JmsSessionSelector) qualifier;
+ break;
+ }
+ }
+ if(s == null)
+ {
+ throw new IllegalArgumentException("Injection point " + ip + " does not have @" + JmsSessionSelector.class.getSimpleName() + " qualifier");
+ }
return c.createSession(s.transacted(), s.acknowledgementMode());
}
Modified: modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/session/InjectSessionTest.java
===================================================================
--- modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/session/InjectSessionTest.java 2010-08-03 11:21:26 UTC (rev 13550)
+++ modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/session/InjectSessionTest.java 2010-08-04 02:36:57 UTC (rev 13551)
@@ -98,8 +98,6 @@
Assert.assertEquals(Session.AUTO_ACKNOWLEDGE, s.getAcknowledgeMode());
}
- // TODO Fix this so session selectors work
- @Ignore
@Test
public void injectSessionWithLiteral() throws JMSException
{
Modified: modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/session/SessionSelectorBean.java
===================================================================
--- modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/session/SessionSelectorBean.java 2010-08-03 11:21:26 UTC (rev 13550)
+++ modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/session/SessionSelectorBean.java 2010-08-04 02:36:57 UTC (rev 13551)
@@ -1,33 +1,20 @@
package org.jboss.seam.jms.test.inject.session;
+import javax.enterprise.inject.Any;
import javax.enterprise.inject.Instance;
-import javax.enterprise.util.AnnotationLiteral;
import javax.inject.Inject;
import javax.jms.Session;
-import org.jboss.seam.jms.annotations.JmsSessionSelector;
+import org.jboss.seam.jms.annotations.JmsSessionSelector.JmsSessionSelectorLiteral;
public class SessionSelectorBean
{
-
- class SessionQualifier extends AnnotationLiteral<JmsSessionSelector> implements JmsSessionSelector
- {
- public int acknowledgementMode()
- {
- return Session.DUPS_OK_ACKNOWLEDGE;
- }
-
- public boolean transacted()
- {
- return false;
- }
- }
-
@Inject
+ @Any
Instance<Session> s;
-
+
public Session get()
{
- return s.select(new SessionQualifier()).get();
+ return s.select(new JmsSessionSelectorLiteral(false, Session.DUPS_OK_ACKNOWLEDGE)).get();
}
}
13 years, 9 months
Seam SVN: r13550 - in modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence: transaction/scope and 1 other directories.
by seam-commits@lists.jboss.org
Author: swd847
Date: 2010-08-03 07:21:26 -0400 (Tue, 03 Aug 2010)
New Revision: 13550
Added:
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/AbstractManagedPersistenceContextBeanLifecycle.java
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/PersistenceContextProxyHandler.java
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/InstanceResolver.java
Modified:
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContext.java
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextBeanLifecycle.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/transaction/scope/TransactionScopeContext.java
Log:
update managed persistence context implementation
Added: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/AbstractManagedPersistenceContextBeanLifecycle.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/AbstractManagedPersistenceContextBeanLifecycle.java (rev 0)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/AbstractManagedPersistenceContextBeanLifecycle.java 2010-08-03 11:21:26 UTC (rev 13550)
@@ -0,0 +1,97 @@
+/*
+ * 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.reflect.Constructor;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Proxy;
+
+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.BeanLifecycle;
+
+/**
+ * Class that is responsible for creating and destroying the seam managed
+ * persistence context
+ *
+ * @author Stuart Douglas
+ *
+ */
+public abstract class AbstractManagedPersistenceContextBeanLifecycle implements BeanLifecycle<EntityManager>
+{
+
+ static final Class<?> proxyClass = Proxy.getProxyClass(EntityManager.class.getClassLoader(), EntityManager.class, Serializable.class);
+
+ static final Constructor<?> proxyConstructor;
+
+ private final BeanManager manager;
+
+ protected AbstractManagedPersistenceContextBeanLifecycle(BeanManager manager)
+ {
+ this.manager = manager;
+ }
+
+ static
+ {
+ try
+ {
+ proxyConstructor = proxyClass.getConstructor(InvocationHandler.class);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * creates the proxy
+ */
+ public EntityManager create(Bean<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(Bean<EntityManager> bean, EntityManager em, CreationalContext<EntityManager> arg1)
+ {
+ em.close();
+ arg1.release();
+ }
+
+ protected abstract EntityManagerFactory getEntityManagerFactory();
+
+}
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContext.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContext.java 2010-08-03 09:26:27 UTC (rev 13549)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContext.java 2010-08-03 11:21:26 UTC (rev 13550)
@@ -21,6 +21,8 @@
*/
package org.jboss.seam.persistence;
+import java.io.Serializable;
+
import javax.naming.NamingException;
import javax.persistence.EntityManagerFactory;
@@ -28,26 +30,29 @@
import org.jboss.weld.extensions.core.Veto;
/**
- * Class that enabled the seam managed persitence context to be configured via
+ * Class that enabled the seam managed persistence context to be configured via
* xml.
*
* There are two ways to do this. Either the persistenceUnintJndi name can be
* set, in which case the entityManagerFactory is looked up from JNDI.
*
- * Alternativly the @Inject annotation can be applied to the
- * entityManagerFactory propery along with any qualifiers needed and the
- * entityManagerFactory will be injected
+ * Alternatively the entityManagerFactory property can be set via el in seam-xml
*
- * Any qualifiers that are applied to this class are also applied to the managed
- * persistence context in question
+ * Any qualifier or scope annotations that are applied to this class are also
+ * applied to the managed persistence context in question
*
+ *
* @author Stuart Douglas
*
*/
@Veto
-public class ManagedPersistenceContext
+public class ManagedPersistenceContext implements Serializable
{
+ private String persistenceUnitJndiName;
+
+ private EntityManagerFactory entityManagerFactory;
+
public String getPersistenceUnitJndiName()
{
return persistenceUnitJndiName;
@@ -79,8 +84,4 @@
this.entityManagerFactory = entityManagerFactory;
}
- String persistenceUnitJndiName;
-
- EntityManagerFactory entityManagerFactory;
-
}
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-08-03 09:26:27 UTC (rev 13549)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextBeanLifecycle.java 2010-08-03 11:21:26 UTC (rev 13550)
@@ -21,53 +21,31 @@
*/
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.BeanLifecycle;
-
/**
- * Class that is responsible for creating and destroying the seam managed
- * persistence context
+ * SMPC lifecycle for SMPC's configured via @SeamManaged
*
* @author Stuart Douglas
*
*/
-public class ManagedPersistenceContextBeanLifecycle implements BeanLifecycle<EntityManager>
+public class ManagedPersistenceContextBeanLifecycle extends AbstractManagedPersistenceContextBeanLifecycle
{
+ protected final Annotation[] qualifiers;
+ protected final BeanManager manager;
+
private EntityManagerFactory emf;
- private final Annotation[] qualifiers;
- private final BeanManager manager;
- 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);
- }
- }
-
public ManagedPersistenceContextBeanLifecycle(Set<Annotation> qualifiers, BeanManager manager)
{
+ super(manager);
this.qualifiers = new Annotation[qualifiers.size()];
int i = 0;
for (Annotation a : qualifiers)
@@ -78,34 +56,9 @@
}
/**
- * creates the proxy
- */
- public EntityManager create(Bean<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(Bean<EntityManager> bean, EntityManager em, CreationalContext<EntityManager> arg1)
- {
- em.close();
- arg1.release();
- }
-
- /**
* lazily resolve the relevant EMF
*/
- private EntityManagerFactory getEntityManagerFactory()
+ protected EntityManagerFactory getEntityManagerFactory()
{
if (emf == null)
{
Modified: 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 2010-08-03 09:26:27 UTC (rev 13549)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextProxyHandler.java 2010-08-03 11:21:26 UTC (rev 13550)
@@ -25,19 +25,15 @@
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
-import javax.enterprise.context.spi.CreationalContext;
-import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.Instance;
import javax.enterprise.inject.spi.BeanManager;
import javax.persistence.EntityManager;
-import javax.persistence.Query;
import javax.transaction.Synchronization;
import javax.transaction.SystemException;
-import org.jboss.seam.persistence.transaction.DefaultTransaction;
import org.jboss.seam.persistence.transaction.SeamTransaction;
import org.jboss.seam.persistence.transaction.literal.DefaultTransactionLiteral;
-import org.jboss.weld.extensions.el.Expressions;
-import org.jboss.weld.extensions.literal.DefaultLiteral;
+import org.jboss.seam.persistence.util.InstanceResolver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -49,28 +45,24 @@
* @author Stuart Douglas
*
*/
-public class ManagedPersistenceContextProxyHandler implements InvocationHandler, Serializable, Synchronization
+public class ManagedPersistenceContextProxyHandler extends PersistenceContextProxyHandler implements InvocationHandler, Serializable, Synchronization
{
private static final long serialVersionUID = -6539267789786229774L;
private final EntityManager delegate;
- private transient BeanManager beanManager;
+ private final Instance<SeamTransaction> userTransactionInstance;
- private transient SeamTransaction userTransaction;
-
private transient boolean synchronizationRegistered;
static final Logger log = LoggerFactory.getLogger(ManagedPersistenceContextProxyHandler.class);
- private final Bean<Expressions> expressionsBean;
-
public ManagedPersistenceContextProxyHandler(EntityManager delegate, BeanManager beanManager)
{
+ super(delegate, beanManager);
this.delegate = delegate;
- this.beanManager = beanManager;
- this.expressionsBean = (Bean) beanManager.resolve(beanManager.getBeans(Expressions.class, DefaultLiteral.INSTANCE));
+ this.userTransactionInstance = InstanceResolver.getInstance(SeamTransaction.class, beanManager, DefaultTransactionLiteral.INSTANCE);
}
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
@@ -79,16 +71,12 @@
{
joinTransaction();
}
- if ("createQuery".equals(method.getName()) && method.getParameterTypes().length > 0 && method.getParameterTypes()[0].equals(String.class))
- {
- return handleCreateQueryWithString(method, args);
- }
- return method.invoke(delegate, args);
+ return super.invoke(proxy, method, args);
}
private void joinTransaction() throws SystemException
{
- SeamTransaction transaction = getUserTransaction();
+ SeamTransaction transaction = userTransactionInstance.get();
if (transaction.isActive())
{
transaction.enlist(delegate);
@@ -107,21 +95,6 @@
}
}
- private SeamTransaction getUserTransaction()
- {
- if (userTransaction == null)
- {
- Bean<SeamTransaction> bean = (Bean) beanManager.resolve(beanManager.getBeans(SeamTransaction.class, DefaultTransactionLiteral.INSTANCE));
- if (bean == null)
- {
- throw new RuntimeException("Could not find SeamTransaction bean with qualifier " + DefaultTransaction.class.getName());
- }
- CreationalContext<SeamTransaction> ctx = beanManager.createCreationalContext(bean);
- userTransaction = (SeamTransaction) beanManager.getReference(bean, SeamTransaction.class, ctx);
- }
- return userTransaction;
- }
-
public void afterCompletion(int status)
{
synchronizationRegistered = false;
@@ -132,30 +105,4 @@
}
- protected Object handleCreateQueryWithString(Method method, Object[] args) throws Throwable
- {
- if (args[0] == null)
- {
- return method.invoke(delegate, args);
- }
- String ejbql = (String) args[0];
- if (ejbql.indexOf('#') > 0)
- {
- CreationalContext<Expressions> ctx = beanManager.createCreationalContext(expressionsBean);
- Expressions expressions = (Expressions) beanManager.getReference(expressionsBean, Expressions.class, ctx);
- QueryParser qp = new QueryParser(expressions, ejbql);
- Object[] newArgs = args.clone();
- newArgs[0] = qp.getEjbql();
- Query query = (Query) method.invoke(delegate, newArgs);
- for (int i = 0; i < qp.getParameterValues().size(); i++)
- {
- query.setParameter(QueryParser.getParameterName(i), qp.getParameterValues().get(i));
- }
- return query;
- }
- else
- {
- return method.invoke(delegate, args);
- }
- }
}
Added: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/PersistenceContextProxyHandler.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/PersistenceContextProxyHandler.java (rev 0)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/PersistenceContextProxyHandler.java 2010-08-03 11:21:26 UTC (rev 13550)
@@ -0,0 +1,95 @@
+/*
+ * 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.reflect.Method;
+
+import javax.enterprise.inject.Instance;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.jboss.seam.persistence.util.InstanceResolver;
+import org.jboss.weld.extensions.el.Expressions;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Proxy handler for the entity manager proxy that allows the use of EL in
+ * queries.
+ *
+ * @author Stuart Douglas
+ *
+ */
+public class PersistenceContextProxyHandler implements Serializable
+{
+
+ private static final long serialVersionUID = -6539267789786229774L;
+
+ private final EntityManager delegate;
+
+ private final Instance<Expressions> expressionsInstance;
+
+ static final Logger log = LoggerFactory.getLogger(ManagedPersistenceContextProxyHandler.class);
+
+ public PersistenceContextProxyHandler(EntityManager delegate, BeanManager beanManager)
+ {
+ this.delegate = delegate;
+ expressionsInstance = InstanceResolver.getInstance(Expressions.class, beanManager);
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
+ {
+ if ("createQuery".equals(method.getName()) && method.getParameterTypes().length > 0 && method.getParameterTypes()[0].equals(String.class))
+ {
+ return handleCreateQueryWithString(method, args);
+ }
+ return method.invoke(delegate, args);
+ }
+
+ protected Object handleCreateQueryWithString(Method method, Object[] args) throws Throwable
+ {
+ if (args[0] == null)
+ {
+ return method.invoke(delegate, args);
+ }
+ String ejbql = (String) args[0];
+ if (ejbql.indexOf('#') > 0)
+ {
+ Expressions expressions = expressionsInstance.get();
+ QueryParser qp = new QueryParser(expressions, ejbql);
+ Object[] newArgs = args.clone();
+ newArgs[0] = qp.getEjbql();
+ Query query = (Query) method.invoke(delegate, newArgs);
+ for (int i = 0; i < qp.getParameterValues().size(); i++)
+ {
+ query.setParameter(QueryParser.getParameterName(i), qp.getParameterValues().get(i));
+ }
+ return query;
+ }
+ else
+ {
+ return method.invoke(delegate, args);
+ }
+ }
+}
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/scope/TransactionScopeContext.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/scope/TransactionScopeContext.java 2010-08-03 09:26:27 UTC (rev 13549)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/scope/TransactionScopeContext.java 2010-08-03 11:21:26 UTC (rev 13550)
@@ -68,6 +68,10 @@
}
+ /**
+ * we need to resolve the transaction bean lazily, after startup has
+ * completed
+ */
private void lazyInitialization()
{
if (userTransaction == null)
@@ -88,6 +92,10 @@
}
}
+ /**
+ * registers a syncronization so that the beans can be destroyed when the
+ * transaction ends
+ */
private void registerSyncronization()
{
TransactionScopeData data = contextData.get();
@@ -141,6 +149,9 @@
}
}
+ /**
+ * the transaction is done, destory the beans
+ */
public void afterCompletion(int status)
{
TransactionScopeData data = contextData.get();
Added: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/InstanceResolver.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/InstanceResolver.java (rev 0)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/InstanceResolver.java 2010-08-03 11:21:26 UTC (rev 13550)
@@ -0,0 +1,151 @@
+/*
+ * 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.util;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Member;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.Instance;
+import javax.enterprise.inject.spi.Annotated;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.InjectionPoint;
+
+import org.jboss.weld.extensions.literal.DefaultLiteral;
+
+/**
+ * Utillity class that can get an Instance<T> from the bean manager
+ *
+ * @author stuart
+ *
+ */
+public class InstanceResolver
+{
+ private InstanceResolver()
+ {
+
+ }
+
+ public static <T> Instance<T> getInstance(Class<T> type, BeanManager manager)
+ {
+ return getInstance(type, manager, DefaultLiteral.INSTANCE);
+ }
+
+ public static <T> Instance<T> getInstance(Class<T> type, BeanManager manager, Annotation... qualifiers)
+ {
+ Type instanceType = new InstanceParamatizedTypeImpl<T>(type);
+ Bean<?> bean = manager.resolve(manager.getBeans(instanceType, qualifiers));
+ CreationalContext ctx = manager.createCreationalContext(bean);
+ return (Instance<T>) manager.getInjectableReference(new InstanceInjectionPoint<T>(type, qualifiers), ctx);
+ }
+
+ private static class InstanceParamatizedTypeImpl<T> implements ParameterizedType
+ {
+ private final Class<T> type;
+
+ public InstanceParamatizedTypeImpl(Class<T> type)
+ {
+ this.type = type;
+ }
+
+ public Type[] getActualTypeArguments()
+ {
+ Type[] ret = new Type[1];
+ ret[0] = type;
+ return ret;
+ }
+
+ public Type getOwnerType()
+ {
+ return null;
+ }
+
+ public Type getRawType()
+ {
+ return Instance.class;
+ }
+
+ }
+
+ /**
+ * TODO: this is not portable, needs to be a proper implementation as this
+ * could cause a NPE due to some methods returning null
+ */
+ private static class InstanceInjectionPoint<T> implements InjectionPoint
+ {
+
+ private final Class<T> type;
+ private final Set<Annotation> qualifiers;
+
+ public InstanceInjectionPoint(Class<T> type, Annotation... quals)
+ {
+ this.type = type;
+ qualifiers = new HashSet<Annotation>();
+ for (Annotation a : quals)
+ {
+ qualifiers.add(a);
+ }
+ }
+
+ public Annotated getAnnotated()
+ {
+ return null;
+ }
+
+ public Bean<?> getBean()
+ {
+ return null;
+ }
+
+ public Member getMember()
+ {
+ return null;
+ }
+
+ public Set<Annotation> getQualifiers()
+ {
+
+ return qualifiers;
+ }
+
+ public Type getType()
+ {
+ return new InstanceParamatizedTypeImpl<T>(type);
+ }
+
+ public boolean isDelegate()
+ {
+ return false;
+ }
+
+ public boolean isTransient()
+ {
+ return false;
+ }
+
+ }
+}
13 years, 9 months
Seam SVN: r13549 - in branches/community/Seam_2_2/examples/wiki: src/etc/i18n and 11 other directories.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2010-08-03 05:26:27 -0400 (Tue, 03 Aug 2010)
New Revision: 13549
Added:
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/BlacklistDAO.java
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/ClientAddressFactory.java
branches/community/Seam_2_2/examples/wiki/view/blacklisted.xhtml
Modified:
branches/community/Seam_2_2/examples/wiki/src/etc/WEB-INF/pages.xml
branches/community/Seam_2_2/examples/wiki/src/etc/i18n/messages_en.properties
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/AdminHome.java
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/CommentNodeRemover.java
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/NodeRemover.java
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/UserHome.java
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/WikiIdentity.java
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/SpamReportDAO.java
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/model/User.java
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/ui/WikiUrlRewriteFilter.java
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/util/WikiUtil.java
branches/community/Seam_2_2/examples/wiki/src/plugin/org/jboss/seam/wiki/plugin/blog/templates/blogDirectory.xhtml
branches/community/Seam_2_2/examples/wiki/src/plugin/org/jboss/seam/wiki/plugin/blog/themes/inrelationto/css/blogDirectory.css
branches/community/Seam_2_2/examples/wiki/src/plugin/org/jboss/seam/wiki/plugin/feed/templates/feedAggregator.xhtml
branches/community/Seam_2_2/examples/wiki/src/plugin/org/jboss/seam/wiki/plugin/forum/ForumQueries.hbm.xml
branches/community/Seam_2_2/examples/wiki/src/plugin/org/jboss/seam/wiki/plugin/forum/ReplyHome.java
branches/community/Seam_2_2/examples/wiki/src/plugin/org/jboss/seam/wiki/plugin/forum/TopicHome.java
branches/community/Seam_2_2/examples/wiki/src/plugin/org/jboss/seam/wiki/plugin/forum/themes/sfwkorg/mailtemplates/forumNotifyReplyToList.xhtml
branches/community/Seam_2_2/examples/wiki/src/plugin/org/jboss/seam/wiki/plugin/forum/themes/sfwkorg/mailtemplates/forumNotifyTopicToList.xhtml
branches/community/Seam_2_2/examples/wiki/view/adminHome_d.xhtml
Log:
wiki enhancements
Modified: branches/community/Seam_2_2/examples/wiki/src/etc/WEB-INF/pages.xml
===================================================================
--- branches/community/Seam_2_2/examples/wiki/src/etc/WEB-INF/pages.xml 2010-08-03 07:58:35 UTC (rev 13548)
+++ branches/community/Seam_2_2/examples/wiki/src/etc/WEB-INF/pages.xml 2010-08-03 09:26:27 UTC (rev 13549)
@@ -181,6 +181,11 @@
<action execute="#{userHome.init}"/>
<begin-conversation flush-mode="MANUAL" join="true"/>
<navigation>
+ <rule if-outcome="blacklisted">
+ <end-conversation before-redirect="true"/>
+ <redirect view-id="/blacklisted.xhtml"/>
+ </rule>
+
<rule if-outcome="persisted" if="#{s:hasPermission('User', 'isAdmin', currentUser)}">
<end-conversation before-redirect="true"/>
<redirect view-id="/userHome_#{skin}.xhtml">
Modified: branches/community/Seam_2_2/examples/wiki/src/etc/i18n/messages_en.properties
===================================================================
--- branches/community/Seam_2_2/examples/wiki/src/etc/i18n/messages_en.properties 2010-08-03 07:58:35 UTC (rev 13548)
+++ branches/community/Seam_2_2/examples/wiki/src/etc/i18n/messages_en.properties 2010-08-03 09:26:27 UTC (rev 13549)
@@ -376,6 +376,7 @@
lacewiki.button.adminHome.Preferences=P<u>r</u>eferences
lacewiki.button.adminHome.Preferences.accesskey=R
lacewiki.button.adminHome.SpamReport=Spam Reports
+lacewiki.button.adminHome.Blacklist=Blacklist
lacewiki.button.adminHome.SaveSettings=<u>S</u>ave Settings
lacewiki.button.adminHome.SaveSettings.accesskey=S
@@ -390,7 +391,16 @@
lacewiki.label.adminHome.spamReport.Reporter=Reporter
lacewiki.label.adminHome.spamReport.Comment=Comment
lacewiki.label.adminHome.spamReport.Poster=Comment Poster
+lacewiki.label.adminHome.spamReport.AreYouSureYouWantToDelete=Are you sure you want to delete this spam report
+lacewiki.label.adminHome.spamReport.RemoveComment=Remove Comment
+lacewiki.label.adminHome.spamReport.NotSpam=Not Spam
+lacewiki.label.adminHome.blacklist.IPAddress=IP Address
+lacewiki.label.adminHome.blacklist.Email=E-mail
+lacewiki.label.adminHome.blacklist.Action=Action
+lacewiki.label.adminHome.blacklist.Remove=Remove
+lacewiki.label.adminHome.blacklist.AreYouSureYouWantToDelete=Remove this blacklist entry
+
lacewiki.label.adminHome.TargetWithPlaceHolder=Target with [[link]] placeholder
lacewiki.label.adminHome.NotAvailableForSkin=Administration is not available with this skin.
lacewiki.label.adminHome.plugins.InstalledPlugins=Installed Plugins
Modified: branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/AdminHome.java
===================================================================
--- branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/AdminHome.java 2010-08-03 07:58:35 UTC (rev 13548)
+++ branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/AdminHome.java 2010-08-03 09:26:27 UTC (rev 13549)
@@ -1,5 +1,13 @@
package org.jboss.seam.wiki.core.action;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.persistence.EntityManager;
+
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.TermEnum;
import org.hibernate.search.FullTextSession;
@@ -8,37 +16,39 @@
import org.hibernate.validator.InvalidValue;
import org.jboss.seam.Component;
import org.jboss.seam.ScopeType;
-import org.jboss.seam.international.StatusMessages;
-import org.jboss.seam.international.StatusMessage;
-import org.jboss.seam.annotations.*;
+import org.jboss.seam.annotations.Create;
+import org.jboss.seam.annotations.Factory;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Logger;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Out;
+import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.datamodel.DataModel;
import org.jboss.seam.annotations.datamodel.DataModelSelection;
import org.jboss.seam.annotations.remoting.WebRemote;
import org.jboss.seam.annotations.security.Restrict;
import org.jboss.seam.contexts.Contexts;
import org.jboss.seam.core.Validators;
+import org.jboss.seam.international.StatusMessage;
+import org.jboss.seam.international.StatusMessages;
import org.jboss.seam.log.Log;
import org.jboss.seam.security.AuthorizationException;
import org.jboss.seam.security.Identity;
+import org.jboss.seam.wiki.core.dao.SpamReportDAO;
+import org.jboss.seam.wiki.core.dao.WikiNodeDAO;
+import org.jboss.seam.wiki.core.model.Blacklist;
import org.jboss.seam.wiki.core.model.LinkProtocol;
import org.jboss.seam.wiki.core.model.User;
import org.jboss.seam.wiki.core.model.WikiSpamReport;
+import org.jboss.seam.wiki.core.plugin.PluginRegistry;
+import org.jboss.seam.wiki.core.plugin.metamodel.Plugin;
import org.jboss.seam.wiki.core.search.IndexManager;
import org.jboss.seam.wiki.core.search.metamodel.SearchRegistry;
import org.jboss.seam.wiki.core.search.metamodel.SearchableEntity;
-import org.jboss.seam.wiki.core.plugin.PluginRegistry;
-import org.jboss.seam.wiki.core.plugin.metamodel.Plugin;
+import org.jboss.seam.wiki.preferences.PreferenceVisibility;
import org.jboss.seam.wiki.preferences.metamodel.PreferenceEntity;
-import org.jboss.seam.wiki.preferences.PreferenceVisibility;
import org.jboss.seam.wiki.util.Progress;
-import javax.persistence.EntityManager;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
@Name("adminHome")
@Scope(ScopeType.CONVERSATION)
public class AdminHome implements Serializable {
@@ -51,6 +61,12 @@
@In
EntityManager entityManager;
+
+ @In
+ SpamReportDAO spamReportDAO;
+
+ @In
+ WikiNodeDAO wikiNodeDAO;
@Create
public void create() {
@@ -116,16 +132,6 @@
public LinkProtocol getLinkProtocol() {
return linkProtocol;
}
-
- @DataModel(value = "spamReports")
- private List<WikiSpamReport> spamReports;
-
- @Factory("spamReports")
- public void loadSpamReports()
- {
- spamReports = entityManager.createQuery("select r from WikiSpamReport r")
- .getResultList();
- }
public void addLinkProtocol() {
@@ -149,6 +155,49 @@
entityManager.remove(selectedLinkProtocol);
linkProtocols.remove(selectedLinkProtocol);
}
+
+ // ####################### SPAM REPORTS ##################################
+
+ @DataModel(value = "spamReports")
+ private List<WikiSpamReport> spamReports;
+
+ @Factory(value = "spamReports")
+ public void refreshSpamReports()
+ {
+ spamReports = entityManager.createQuery("select r from WikiSpamReport r")
+ .getResultList();
+ }
+
+ public String removeSpamReport(Long commentId)
+ {
+ spamReportDAO.removeReports(spamReportDAO.findReports(wikiNodeDAO.findWikiComment(commentId)));
+ refreshSpamReports();
+ return null;
+ }
+
+ // ####################### BLACKLIST ##################################
+
+ @DataModel(value = "blacklist")
+ private List<Blacklist> blacklist;
+
+ @Factory(value = "blacklist")
+ public void refreshBlacklist()
+ {
+ blacklist = entityManager.createQuery("select b from Blacklist b").getResultList();
+ }
+
+ public String removeBlacklist(Long id)
+ {
+ Blacklist bl = entityManager.find(Blacklist.class, id);
+ if (bl != null)
+ {
+ entityManager.remove(bl);
+ entityManager.flush();
+ }
+
+ refreshBlacklist();
+ return null;
+ }
// ####################### INDEXING ##################################
Modified: branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/CommentNodeRemover.java
===================================================================
--- branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/CommentNodeRemover.java 2010-08-03 07:58:35 UTC (rev 13548)
+++ branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/CommentNodeRemover.java 2010-08-03 09:26:27 UTC (rev 13549)
@@ -6,8 +6,10 @@
*/
package org.jboss.seam.wiki.core.action;
+import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.AutoCreate;
+import org.jboss.seam.wiki.core.dao.SpamReportDAO;
import org.jboss.seam.wiki.core.model.WikiComment;
import java.io.Serializable;
@@ -19,6 +21,8 @@
@AutoCreate
public class CommentNodeRemover extends NodeRemover<WikiComment> implements Serializable {
+ @In SpamReportDAO spamReportDAO;
+
public boolean isRemovable(WikiComment comment) {
return true;
}
Modified: branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/NodeRemover.java
===================================================================
--- branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/NodeRemover.java 2010-08-03 07:58:35 UTC (rev 13548)
+++ branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/NodeRemover.java 2010-08-03 09:26:27 UTC (rev 13549)
@@ -6,12 +6,15 @@
*/
package org.jboss.seam.wiki.core.action;
+import java.util.Date;
+
+import javax.persistence.EntityManager;
+
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Logger;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.log.Log;
-import org.jboss.seam.wiki.core.dao.SpamReportDAO;
import org.jboss.seam.wiki.core.dao.UserDAO;
import org.jboss.seam.wiki.core.dao.WikiNodeDAO;
import org.jboss.seam.wiki.core.feeds.FeedDAO;
@@ -19,9 +22,6 @@
import org.jboss.seam.wiki.core.model.WikiNode;
import org.jboss.seam.wiki.util.WikiUtil;
-import javax.persistence.EntityManager;
-import java.util.Date;
-
/**
* @author Christian Bauer
*/
@@ -33,9 +33,6 @@
@In
protected FeedDAO feedDAO;
-
- @In
- protected SpamReportDAO spamReportDAO;
@In
protected WikiNodeDAO wikiNodeDAO;
Modified: branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/UserHome.java
===================================================================
--- branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/UserHome.java 2010-08-03 07:58:35 UTC (rev 13548)
+++ branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/UserHome.java 2010-08-03 09:26:27 UTC (rev 13549)
@@ -24,8 +24,10 @@
import org.jboss.seam.security.Identity;
import org.jboss.seam.wiki.core.action.prefs.UserManagementPreferences;
import org.jboss.seam.wiki.core.action.prefs.WikiPreferences;
+import org.jboss.seam.wiki.core.dao.BlacklistDAO;
import org.jboss.seam.wiki.core.dao.UserDAO;
import org.jboss.seam.wiki.core.dao.WikiNodeDAO;
+import org.jboss.seam.wiki.core.model.Blacklist;
import org.jboss.seam.wiki.core.model.Role;
import org.jboss.seam.wiki.core.model.User;
import org.jboss.seam.wiki.core.model.WikiComment;
@@ -52,6 +54,8 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import javax.faces.context.FacesContext;
+
@Name("userHome")
@Scope(ScopeType.CONVERSATION)
public class UserHome extends EntityHome<User> {
@@ -64,11 +68,17 @@
@In
private StatusMessages statusMessages;
+
+ @In(required = false)
+ private String clientAddress;
@In
private UserDAO userDAO;
@In
+ private BlacklistDAO blacklistDAO;
+
+ @In
private Hash hashUtil;
@In(create = true)
@@ -179,6 +189,16 @@
@Override
public String persist() {
+ if (clientAddress != null)
+ {
+ getInstance().setRegisteredAddress(clientAddress);
+ }
+
+ if (isBlacklisted())
+ {
+ return "blacklisted";
+ }
+
// Validate
if (!isUniqueUsername() ||
!passwordAndControlNotNull() ||
@@ -431,9 +451,11 @@
nodesToDelete.remove(nodeToDelete);
}
- // TODO blacklist the user
+ Blacklist blacklist = new Blacklist();
+ blacklist.setEmail(getInstance().getEmail());
+ blacklist.setIpAddress(getInstance().getRegisteredAddress());
+ getEntityManager().persist(blacklist);
-
// Remove preferences for this user
PreferenceProvider prefProvider = (PreferenceProvider)Component.getInstance("preferenceProvider");
prefProvider.deleteUserPreferenceValues(getInstance());
@@ -610,6 +632,12 @@
}
return true;
}
+
+ public boolean isBlacklisted()
+ {
+ return blacklistDAO.isEmailBlacklisted(getInstance().getEmail()) ||
+ blacklistDAO.isIpAddressBlacklisted(getInstance().getRegisteredAddress());
+ }
public void validateUsername() {
isUniqueUsername();
Modified: branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/WikiIdentity.java
===================================================================
--- branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/WikiIdentity.java 2010-08-03 07:58:35 UTC (rev 13548)
+++ branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/WikiIdentity.java 2010-08-03 09:26:27 UTC (rev 13549)
@@ -230,6 +230,7 @@
private boolean checkCommentCreate(WikiDocument doc) {
if (currentAccessLevel == Role.ADMINROLE_ACCESSLEVEL) return true;
if (doc.getReadAccessLevel() <= currentAccessLevel &&
+ currentAccessLevel > Role.GUESTROLE_ACCESSLEVEL &&
doc.isEnableComments() && doc.isEnableCommentForm()) return true;
return false;
}
Added: branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/BlacklistDAO.java
===================================================================
--- branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/BlacklistDAO.java (rev 0)
+++ branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/BlacklistDAO.java 2010-08-03 09:26:27 UTC (rev 13549)
@@ -0,0 +1,38 @@
+package org.jboss.seam.wiki.core.dao;
+
+import javax.persistence.EntityManager;
+
+import org.jboss.seam.annotations.AutoCreate;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Name;
+
+/**
+ * DAO for blacklist-related operations
+ *
+ * @author Shane Bryzak
+ */
+@Name("blacklistDAO")
+@AutoCreate
+public class BlacklistDAO
+{
+ @In
+ protected EntityManager entityManager;
+
+ public boolean isEmailBlacklisted(String email)
+ {
+ if (email == null) return false;
+
+ return entityManager.createQuery("select bl from Blacklist bl where bl.email = :email")
+ .setParameter("email", email)
+ .getResultList().size() > 0;
+ }
+
+ public boolean isIpAddressBlacklisted(String ipAddress)
+ {
+ if (ipAddress == null) return false;
+
+ return entityManager.createQuery("select bl from Blacklist bl where bl.ipAddress = :ipAddress")
+ .setParameter("ipAddress", ipAddress)
+ .getResultList().size() > 0;
+ }
+}
Added: branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/ClientAddressFactory.java
===================================================================
--- branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/ClientAddressFactory.java (rev 0)
+++ branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/ClientAddressFactory.java 2010-08-03 09:26:27 UTC (rev 13549)
@@ -0,0 +1,24 @@
+package org.jboss.seam.wiki.core.dao;
+
+import javax.faces.context.FacesContext;
+import javax.servlet.http.HttpServletRequest;
+
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.Factory;
+import org.jboss.seam.annotations.Name;
+
+@Name("clientAddressFactory")
+public class ClientAddressFactory
+{
+ @Factory(value = "clientAddress", scope = ScopeType.EVENT, autoCreate = true)
+ public String getClientAddress()
+ {
+ Object request = FacesContext.getCurrentInstance().getExternalContext().getRequest();
+ if (request instanceof HttpServletRequest)
+ {
+ return ((HttpServletRequest) request).getRemoteAddr();
+ }
+
+ return null;
+ }
+}
Modified: branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/SpamReportDAO.java
===================================================================
--- branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/SpamReportDAO.java 2010-08-03 07:58:35 UTC (rev 13548)
+++ branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/SpamReportDAO.java 2010-08-03 09:26:27 UTC (rev 13549)
@@ -18,13 +18,14 @@
{
@Logger static Log log;
- @In protected EntityManager restrictedEntityManager;
+ @In
+ protected EntityManager entityManager;
public List<WikiSpamReport> findReports(WikiComment comment) {
if (comment == null || comment.getId() == null) throw new IllegalArgumentException("comment is null or unsaved");
- return restrictedEntityManager
+ return entityManager
.createQuery(
"select distinct r from WikiSpamReport r " +
" where r.comment = :comment"
@@ -37,7 +38,8 @@
{
for (WikiSpamReport report : reports)
{
- restrictedEntityManager.remove(report);
+ entityManager.remove(report);
}
+ entityManager.flush();
}
}
Modified: branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/model/User.java
===================================================================
--- branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/model/User.java 2010-08-03 07:58:35 UTC (rev 13548)
+++ branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/model/User.java 2010-08-03 09:26:27 UTC (rev 13549)
@@ -6,15 +6,31 @@
*/
package org.jboss.seam.wiki.core.model;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.JoinTable;
+import javax.persistence.ManyToMany;
+import javax.persistence.ManyToOne;
+import javax.persistence.OrderBy;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import javax.persistence.Version;
+
+import org.hibernate.validator.Email;
+import org.hibernate.validator.Length;
import org.hibernate.validator.NotNull;
import org.hibernate.validator.Pattern;
-import org.hibernate.validator.Length;
-import org.hibernate.validator.Email;
-import javax.persistence.*;
-import java.io.Serializable;
-import java.util.*;
-
@Entity
@Table(name = "USERS")
@org.hibernate.annotations.BatchSize(size = 20)
@@ -78,6 +94,9 @@
@Column(name = "LAST_LOGIN_ON", nullable = true)
private Date lastLoginOn = new Date();
+
+ @Column(name = "REGISTERED_ADDRESS", length = 255, nullable = true)
+ private String registeredAddress;
@Transient
private Date previousLastLoginOn = new Date();
@@ -156,6 +175,9 @@
public String getActivationCode() { return activationCode; }
public void setActivationCode(String activationCode) { this.activationCode = activationCode; }
+
+ public String getRegisteredAddress() { return registeredAddress; }
+ public void setRegisteredAddress(String registeredAddress) { this.registeredAddress = registeredAddress; }
public WikiDirectory getMemberHome() { return memberHome; }
public void setMemberHome(WikiDirectory memberHome) { this.memberHome = memberHome; }
Modified: branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/ui/WikiUrlRewriteFilter.java
===================================================================
--- branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/ui/WikiUrlRewriteFilter.java 2010-08-03 07:58:35 UTC (rev 13548)
+++ branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/ui/WikiUrlRewriteFilter.java 2010-08-03 09:26:27 UTC (rev 13549)
@@ -29,7 +29,7 @@
@Scope(ScopeType.APPLICATION)
@Name("wikiUrlRewriteFilter")
@BypassInterceptors
-@Filter(within = "org.jboss.seam.web.ajax4jsfFilter")
+@Filter(within = "org.jboss.seam.web.exceptionFilter")
@Install(classDependencies = "org.tuckey.web.filters.urlrewrite.UrlRewriteFilter", precedence = Install.APPLICATION)
public class WikiUrlRewriteFilter extends AbstractFilter {
Modified: branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/util/WikiUtil.java
===================================================================
--- branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/util/WikiUtil.java 2010-08-03 07:58:35 UTC (rev 13548)
+++ branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/util/WikiUtil.java 2010-08-03 09:26:27 UTC (rev 13549)
@@ -219,7 +219,8 @@
public static String removeHtml(String original) {
if (original == null) return null;
- return original.replaceAll("\\<([a-zA-Z]|/){1}?.*?\\>","");
+ //return original.replaceAll("\\<([a-zA-Z]|/){1}?.*?\\>","");
+ return original.replaceAll("<!--.*?-->", "").replaceAll("\\<([a-zA-Z]|/){1}?.*?\\>","");
}
// TODO: Ouch...
Modified: branches/community/Seam_2_2/examples/wiki/src/plugin/org/jboss/seam/wiki/plugin/blog/templates/blogDirectory.xhtml
===================================================================
--- branches/community/Seam_2_2/examples/wiki/src/plugin/org/jboss/seam/wiki/plugin/blog/templates/blogDirectory.xhtml 2010-08-03 07:58:35 UTC (rev 13548)
+++ branches/community/Seam_2_2/examples/wiki/src/plugin/org/jboss/seam/wiki/plugin/blog/templates/blogDirectory.xhtml 2010-08-03 09:26:27 UTC (rev 13549)
@@ -19,9 +19,14 @@
<div class="boxHeader blogEntryHeader">
<div class="title">
- <h:outputText value="#{blogEntry.entryDocument.name}"/>
+ <h:outputLink value="#{wikiURLRenderer.renderURL(blogEntry.entryDocument)}">
+ <h:outputText value="#{blogEntry.entryDocument.name}"/>
+ </h:outputLink>
</div>
+
+
+
<div class="dateAuthor smallFont">
<h:outputText value="#{blogEntry.entryDocument.createdOn}">
<f:convertDateTime pattern="dd. MMM yyyy, HH:mm" timeZone="#{preferences.get('Wiki').timeZone}"/>
@@ -187,4 +192,4 @@
</s:div>
-</wiki:plugin>
\ No newline at end of file
+</wiki:plugin>
Modified: branches/community/Seam_2_2/examples/wiki/src/plugin/org/jboss/seam/wiki/plugin/blog/themes/inrelationto/css/blogDirectory.css
===================================================================
--- branches/community/Seam_2_2/examples/wiki/src/plugin/org/jboss/seam/wiki/plugin/blog/themes/inrelationto/css/blogDirectory.css 2010-08-03 07:58:35 UTC (rev 13548)
+++ branches/community/Seam_2_2/examples/wiki/src/plugin/org/jboss/seam/wiki/plugin/blog/themes/inrelationto/css/blogDirectory.css 2010-08-03 09:26:27 UTC (rev 13549)
@@ -18,6 +18,10 @@
font-size: 120%;
}
+.blogEntryHeader .title a {
+ color: #000000;
+}
+
.blogEntryHeader .dateAuthor {
text-align: right;
white-space: nowrap;
@@ -99,4 +103,4 @@
}
.blogPagerTextColumn {
width: 60%;
-}
\ No newline at end of file
+}
Modified: branches/community/Seam_2_2/examples/wiki/src/plugin/org/jboss/seam/wiki/plugin/feed/templates/feedAggregator.xhtml
===================================================================
--- branches/community/Seam_2_2/examples/wiki/src/plugin/org/jboss/seam/wiki/plugin/feed/templates/feedAggregator.xhtml 2010-08-03 07:58:35 UTC (rev 13548)
+++ branches/community/Seam_2_2/examples/wiki/src/plugin/org/jboss/seam/wiki/plugin/feed/templates/feedAggregator.xhtml 2010-08-03 09:26:27 UTC (rev 13549)
@@ -69,18 +69,14 @@
<s:div styleClass="feedEntryTitle undecoratedLink"
rendered="#{not preferences.get('FeedAggregator', currentMacro).hideTitle}">
<h:outputLink target="_top" value="#{feDTO.feedEntry.link}">
- <h:outputText value="#{wiki:escapeAtSymbol(wiki:removeHtml(stringutils:unescapeHtml(feDTO.feedEntry.title)))}"/>
+ <h:outputText value="#{wiki:removeHtml(stringutils:unescapeHtml(feDTO.feedEntry.title))}"/>
</h:outputLink>
</s:div>
<s:div styleClass="feedEntryBody" rendered="#{not preferences.get('FeedAggregator', currentMacro).hideDescription}">
<h:outputText value="#{wiki:truncateStringOnWordBoundary(
- wiki:escapeAtSymbol(
- wiki:removeHtml(
- stringutils:unescapeHtml(feDTO.feedEntry.descriptionValue)
- )
- ),
- preferences.get('FeedAggregator', currentMacro).truncateDescription)}"/>
+ wiki:removeHtml(stringutils:unescapeHtml(feDTO.feedEntry.descriptionValue)),
+ preferences.get('FeedAggregator', currentMacro).truncateDescription)}"/>
<h:outputLink target="_top" styleClass="feedEntryBodyMoreLink"
value="#{feDTO.feedEntry.link}"
@@ -106,4 +102,4 @@
</s:div>
-</wiki:plugin>
\ No newline at end of file
+</wiki:plugin>
Modified: branches/community/Seam_2_2/examples/wiki/src/plugin/org/jboss/seam/wiki/plugin/forum/ForumQueries.hbm.xml
===================================================================
--- branches/community/Seam_2_2/examples/wiki/src/plugin/org/jboss/seam/wiki/plugin/forum/ForumQueries.hbm.xml 2010-08-03 07:58:35 UTC (rev 13548)
+++ branches/community/Seam_2_2/examples/wiki/src/plugin/org/jboss/seam/wiki/plugin/forum/ForumQueries.hbm.xml 2010-08-03 09:26:27 UTC (rev 13549)
@@ -308,7 +308,8 @@
d2.FOOTER_MACROS as FOOTER_MACROS,
u.USER_ID, u.ACTIVATED, u.ACTIVATION_CODE, u.CREATED_ON, u.EMAIL, u.FIRSTNAME, u.LAST_LOGIN_ON,
- u.LASTNAME, u.MEMBER_HOME_WIKI_DIRECTORY_ID, u.PASSWORDHASH, u.USER_PROFILE_ID, u.USERNAME, u.OBJ_VERSION
+ u.LASTNAME, u.MEMBER_HOME_WIKI_DIRECTORY_ID, u.PASSWORDHASH, u.USER_PROFILE_ID, u.USERNAME, u.OBJ_VERSION,
+ u.REGISTERED_ADDRESS
from
WIKI_NODE d0
@@ -348,6 +349,7 @@
cl0.USE_WIKI_TEXT as USE_WIKI_TEXT,
u.USER_ID, u.ACTIVATED, u.ACTIVATION_CODE, u.CREATED_ON, u.EMAIL, u.FIRSTNAME, u.LAST_LOGIN_ON,
u.LASTNAME, u.MEMBER_HOME_WIKI_DIRECTORY_ID, u.PASSWORDHASH, u.USER_PROFILE_ID, u.USERNAME, u.OBJ_VERSION,
+ u.REGISTERED_ADDRESS,
doc0.NODE_ID as TOPIC_ID,
count(distinct c0.NODE_ID) as NUM_OF_REPLIES
from
@@ -366,7 +368,7 @@
cl1.LAST_MODIFIED_BY_USER_ID, cl1.WRITE_ACCESS_LEVEL, cl1.READ_ACCESS_LEVEL, cl1.WRITE_PROTECTED, cl1.PARENT_NODE_ID,
cl0.SUBJECT, cl0.FROM_USER_NAME, cl0.FROM_USER_EMAIL, cl0.FROM_USER_HOMEPAGE, cl0.USE_WIKI_TEXT,
u.USER_ID, u.ACTIVATED, u.ACTIVATION_CODE, u.CREATED_ON, u.EMAIL, u.FIRSTNAME, u.LAST_LOGIN_ON,
- u.LASTNAME, u.MEMBER_HOME_WIKI_DIRECTORY_ID, u.PASSWORDHASH, u.USER_PROFILE_ID, u.USERNAME, u.OBJ_VERSION,
+ u.LASTNAME, u.MEMBER_HOME_WIKI_DIRECTORY_ID, u.PASSWORDHASH, u.USER_PROFILE_ID, u.USERNAME, u.OBJ_VERSION, u.REGISTERED_ADDRESS,
doc0.NODE_ID
]]>
</sql-query>
@@ -377,7 +379,7 @@
<![CDATA[
select
ur.USER_ID, ur.ACTIVATED, ur.ACTIVATION_CODE, ur.CREATED_ON, ur.EMAIL, ur.FIRSTNAME, ur.LAST_LOGIN_ON,
- ur.LASTNAME, ur.MEMBER_HOME_WIKI_DIRECTORY_ID, ur.PASSWORDHASH, ur.USER_PROFILE_ID, ur.USERNAME, ur.OBJ_VERSION,
+ ur.LASTNAME, ur.MEMBER_HOME_WIKI_DIRECTORY_ID, ur.PASSWORDHASH, ur.USER_PROFILE_ID, ur.USERNAME, ur.OBJ_VERSION, ur.REGISTERED_ADDRESS
sum(ur.RATING) as RATING_POINTS
from
(select distinct
@@ -398,9 +400,9 @@
group by
ur.USER_ID, ur.ACTIVATED, ur.ACTIVATION_CODE, ur.CREATED_ON, ur.EMAIL, ur.FIRSTNAME, ur.LAST_LOGIN_ON,
ur.LASTNAME, ur.MEMBER_HOME_WIKI_DIRECTORY_ID, ur.PASSWORDHASH, ur.USER_PROFILE_ID, ur.USERNAME,
- ur.OBJ_VERSION
+ ur.OBJ_VERSION, ur.REGISTERED_ADDRESS
order by sum(ur.RATING) desc
]]>
</sql-query>
-</hibernate-mapping>
\ No newline at end of file
+</hibernate-mapping>
Modified: branches/community/Seam_2_2/examples/wiki/src/plugin/org/jboss/seam/wiki/plugin/forum/ReplyHome.java
===================================================================
--- branches/community/Seam_2_2/examples/wiki/src/plugin/org/jboss/seam/wiki/plugin/forum/ReplyHome.java 2010-08-03 07:58:35 UTC (rev 13548)
+++ branches/community/Seam_2_2/examples/wiki/src/plugin/org/jboss/seam/wiki/plugin/forum/ReplyHome.java 2010-08-03 09:26:27 UTC (rev 13549)
@@ -9,6 +9,7 @@
import org.jboss.seam.security.Identity;
import org.jboss.seam.wiki.core.action.CommentHome;
import org.jboss.seam.wiki.core.model.WikiComment;
+import org.jboss.seam.wiki.core.model.WikiDirectory;
import org.jboss.seam.wiki.core.model.WikiNode;
import org.jboss.seam.wiki.core.model.User;
import org.jboss.seam.wiki.core.ui.WikiRedirect;
@@ -95,7 +96,48 @@
}
}
+
+ public String getMailSubject()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ String forumName = getForumName();
+
+ if (getInstance().getSubject().toLowerCase().startsWith("re:"))
+ {
+ sb.append("Re: ");
+ if (forumName != null)
+ {
+ sb.append("[");
+ sb.append(forumName);
+ sb.append("] ");
+ }
+ sb.append(getInstance().getSubject().replaceFirst("[Rr]e:", "").trim());
+ }
+ else
+ {
+ if (forumName != null)
+ {
+ sb.append("[");
+ sb.append(forumName);
+ sb.append("] ");
+ }
+ sb.append(getInstance().getSubject());
+ }
+
+ return sb.toString();
+ }
+ public String getForumName()
+ {
+ WikiNode parent = getInstance().getParent();
+ while (parent != null && !(parent instanceof WikiDirectory))
+ {
+ parent = parent.getParent();
+ }
+ return (parent != null && parent instanceof WikiDirectory) ? parent.getName() : null;
+ }
+
@Begin(flushMode = FlushModeType.MANUAL, join = true)
public void replyToDocument() {
Modified: branches/community/Seam_2_2/examples/wiki/src/plugin/org/jboss/seam/wiki/plugin/forum/TopicHome.java
===================================================================
--- branches/community/Seam_2_2/examples/wiki/src/plugin/org/jboss/seam/wiki/plugin/forum/TopicHome.java 2010-08-03 07:58:35 UTC (rev 13548)
+++ branches/community/Seam_2_2/examples/wiki/src/plugin/org/jboss/seam/wiki/plugin/forum/TopicHome.java 2010-08-03 09:26:27 UTC (rev 13549)
@@ -10,6 +10,7 @@
import org.jboss.seam.wiki.core.action.DocumentHome;
import org.jboss.seam.wiki.core.model.WikiDirectory;
import org.jboss.seam.wiki.core.model.WikiDocument;
+import org.jboss.seam.wiki.core.model.WikiNode;
import org.jboss.seam.wiki.core.model.WikiTextMacro;
import org.jboss.seam.wiki.core.ui.WikiRedirect;
import org.jboss.seam.wiki.core.plugin.PluginRegistry;
@@ -117,6 +118,56 @@
}
return null; // Prevent navigation
}
+
+ /**
+ * Have to jiggle with the subject line a bit to get it right
+ * @return
+ */
+ public String getMailSubject()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ String forumName = getForumName();
+
+ if (getInstance().getName().toLowerCase().startsWith("re:"))
+ {
+ sb.append("Re: ");
+ if (forumName != null)
+ {
+ sb.append("[");
+ sb.append(forumName);
+ sb.append("] ");
+ }
+ sb.append(getInstance().getName().replaceFirst("[Rr]e:", "").trim());
+ }
+ else
+ {
+ if (forumName != null)
+ {
+ sb.append("[");
+ sb.append(forumName);
+ sb.append("] ");
+ }
+ sb.append(getInstance().getName());
+ }
+
+ return sb.toString();
+ }
+
+ /**
+ * This *should* return the name of the forum the topic belongs to
+ *
+ * @return
+ */
+ public String getForumName()
+ {
+ WikiNode parent = getInstance().getParent();
+ while (parent != null && !(parent instanceof WikiDirectory))
+ {
+ parent = parent.getParent();
+ }
+ return (parent != null && parent instanceof WikiDirectory) ? parent.getName() : "";
+ }
@Override
public String update() {
Modified: branches/community/Seam_2_2/examples/wiki/src/plugin/org/jboss/seam/wiki/plugin/forum/themes/sfwkorg/mailtemplates/forumNotifyReplyToList.xhtml
===================================================================
--- branches/community/Seam_2_2/examples/wiki/src/plugin/org/jboss/seam/wiki/plugin/forum/themes/sfwkorg/mailtemplates/forumNotifyReplyToList.xhtml 2010-08-03 07:58:35 UTC (rev 13548)
+++ branches/community/Seam_2_2/examples/wiki/src/plugin/org/jboss/seam/wiki/plugin/forum/themes/sfwkorg/mailtemplates/forumNotifyReplyToList.xhtml 2010-08-03 09:26:27 UTC (rev 13549)
@@ -15,7 +15,7 @@
<m:header name="From" value="#{replyHome.instance.createdBy.fullname} <do-not-reply(a)jboss.com>"/>
<m:to name="SeamFramework.org Forums List">#{preferences.get('Forum').notificationMailingList}</m:to>
- <m:subject>#{replyHome.instance.subject}</m:subject>
+ <m:subject>#{replyHome.mailSubject}</m:subject>
<m:body>
<html>
Modified: branches/community/Seam_2_2/examples/wiki/src/plugin/org/jboss/seam/wiki/plugin/forum/themes/sfwkorg/mailtemplates/forumNotifyTopicToList.xhtml
===================================================================
--- branches/community/Seam_2_2/examples/wiki/src/plugin/org/jboss/seam/wiki/plugin/forum/themes/sfwkorg/mailtemplates/forumNotifyTopicToList.xhtml 2010-08-03 07:58:35 UTC (rev 13548)
+++ branches/community/Seam_2_2/examples/wiki/src/plugin/org/jboss/seam/wiki/plugin/forum/themes/sfwkorg/mailtemplates/forumNotifyTopicToList.xhtml 2010-08-03 09:26:27 UTC (rev 13549)
@@ -12,7 +12,7 @@
<m:header name="From" value="#{topicHome.instance.createdBy.fullname} <do-not-reply(a)jboss.com>"/>
<m:to name="SeamFramework.org Forums List">#{topicHome.mailingList}</m:to>
- <m:subject>#{topicHome.instance.name}</m:subject>
+ <m:subject>#{topicHome.mailSubject}</m:subject>
<m:body>
<html>
Modified: branches/community/Seam_2_2/examples/wiki/view/adminHome_d.xhtml
===================================================================
--- branches/community/Seam_2_2/examples/wiki/view/adminHome_d.xhtml 2010-08-03 07:58:35 UTC (rev 13548)
+++ branches/community/Seam_2_2/examples/wiki/view/adminHome_d.xhtml 2010-08-03 09:26:27 UTC (rev 13549)
@@ -71,10 +71,10 @@
accesskey="#{messages['lacewiki.button.adminHome.SystemStatistics.accesskey']}">
<h:outputText escape="false" value="#{messages['lacewiki.button.adminHome.SystemStatistics']}"/>
</a></li>
- <li id="rolesPermissionsTab"><a href="#rolesPermissions"
+ <!--li id="rolesPermissionsTab"><a href="#rolesPermissions"
accesskey="#{messages['lacewiki.button.adminHome.RolesPermissions.accesskey']}">
<h:outputText escape="false" value="#{messages['lacewiki.button.adminHome.RolesPermissions']}"/>
- </a></li>
+ </a></li-->
<li id="pluginsTab"><a href="#plugins"
accesskey="#{messages['lacewiki.button.adminHome.Plugins.accesskey']}">
<h:outputText escape="false" value="#{messages['lacewiki.button.adminHome.Plugins']}"/>
@@ -87,9 +87,14 @@
accesskey="#{messages['lacewiki.button.adminHome.Preferences.accesskey']}">
<h:outputText escape="false" value="#{messages['lacewiki.button.adminHome.Preferences']}"/>
</a></li>
+
<li id="spamReportTab"><a href="#spamReport">
<h:outputText escape="false" value="#{messages['lacewiki.button.adminHome.SpamReport']}"/>
- </a></li>
+ </a></li>
+
+ <li id="blacklistTab"><a href="#blacklist">
+ <h:outputText escape="false" value="#{messages['lacewiki.button.adminHome.Blacklist']}"/>
+ </a></li>
</ul>
@@ -252,6 +257,7 @@
</div>
<div id="spamReport" style="padding: 20px">
+ <s:div id="spamReportContent">
<h:dataTable id="spamReportTable" var="report"
value="#{spamReports}"
rendered="#{spamReports.rowCount >0}"
@@ -299,9 +305,9 @@
<div>
- <s:fragment rendered="#{s:hasPermission('Comment', 'delete', report.comment)}">
+ <s:fragment rendered="#{s:hasPermission('Comment', 'delete', report.comment)}">
<ui:decorate template="includes/confirmationAction.xhtml">
- <ui:param name="label" value="#{messages['lacewiki.button.commentsDisplay.RemoveComment']}"/>
+ <ui:param name="label" value="#{messages['lacewiki.label.adminHome.spamReport.RemoveComment']}"/>
<ui:param name="jsFunctionName" value="deleteCommentId#{report.comment.id}"/>
<ui:param name="message" value="#{messages['lacewiki.label.AreYouSureYouWantToDelete']
.concat(' ')
@@ -311,7 +317,7 @@
.concat('\'?')}"/>
<ui:define name="jsFunction">
<a:jsFunction name="#{jsFunctionName}"
- reRender="commentDisplayForm, messageBoxContainer"
+ reRender="spamReportContent"
action="#{commentHome.remove(report.comment.id)}"
oncomplete="onAjaxRequestComplete()"
status="globalStatus"/>
@@ -319,6 +325,24 @@
</ui:decorate>
</s:fragment>
+
+ <s:fragment rendered="#{s:hasPermission('Comment', 'delete', report.comment)}">
+ <ui:decorate template="includes/confirmationAction.xhtml">
+ <ui:param name="label" value="#{messages['lacewiki.label.adminHome.spamReport.NotSpam']}"/>
+ <ui:param name="jsFunctionName" value="deleteReportId#{report.reportId}"/>
+ <ui:param name="linkClass" value="buttonReport"/>
+ <ui:param name="message" value="#{messages['lacewiki.label.adminHome.spamReport.AreYouSureYouWantToDelete']
+ .concat('?')}"/>
+ <ui:define name="jsFunction">
+ <a:jsFunction name="#{jsFunctionName}"
+ reRender="spamReportContent"
+ action="#{adminHome.removeSpamReport(report.comment.id)}"
+ oncomplete="onAjaxRequestComplete()"
+ status="globalStatus"/>
+ </ui:define>
+ </ui:decorate>
+ </s:fragment>
+
</div>
</div>
@@ -352,8 +376,65 @@
</h:column>
</h:dataTable>
+ </s:div>
</div>
+
+ <div id="blacklist" style="padding: 20px">
+ <s:div id="blacklistContent">
+ <h:dataTable id="blacklistTable" var="bl"
+ value="#{blacklist}"
+ rendered="#{blacklist.rowCount >0}"
+ styleClass="datatable topLeftBottomBorder"
+ headerClass="regularHeader rightBorder smallFont"
+ columnClasses="tenPercentColumn rightBorder alignLeft,
+ defaultColumn rightBorder alignLeft wrapWhitespace,
+ tenPercentColumn rightBorder alignCenter"
+ rowClasses="rowOdd,rowEven"
+ cellpadding="0" cellspacing="0" border="0">
+ <h:column>
+ <f:facet name="header">
+ #{messages['lacewiki.label.adminHome.blacklist.IPAddress']}
+ </f:facet>
+
+ #{bl.ipAddress}
+ </h:column>
+ <h:column>
+ <f:facet name="header">
+ #{messages['lacewiki.label.adminHome.blacklist.Email']}
+ </f:facet>
+
+ #{bl.email}
+ </h:column>
+
+ <h:column>
+ <f:facet name="header">
+ #{messages['lacewiki.label.adminHome.blacklist.Action']}
+ </f:facet>
+
+ <div style="padding:4px">
+ <ui:decorate template="includes/confirmationAction.xhtml">
+ <ui:param name="label" value="#{messages['lacewiki.label.adminHome.blacklist.Remove']}"/>
+ <ui:param name="jsFunctionName" value="deleteBlacklistId#{bl.id}"/>
+ <ui:param name="message" value="#{messages['lacewiki.label.adminHome.blacklist.AreYouSureYouWantToDelete']
+ .concat('?')}"/>
+ <ui:define name="jsFunction">
+ <a:jsFunction name="#{jsFunctionName}"
+ reRender="blacklistContent"
+ action="#{adminHome.removeBlacklist(bl.id)}"
+ oncomplete="onAjaxRequestComplete()"
+ status="globalStatus"/>
+ </ui:define>
+ </ui:decorate>
+ </div>
+
+ </h:column>
+
+ </h:dataTable>
+ </s:div>
+ </div>
+
+
</div>
<div class="formControls wideLabels">
Added: branches/community/Seam_2_2/examples/wiki/view/blacklisted.xhtml
===================================================================
--- branches/community/Seam_2_2/examples/wiki/view/blacklisted.xhtml (rev 0)
+++ branches/community/Seam_2_2/examples/wiki/view/blacklisted.xhtml 2010-08-03 09:26:27 UTC (rev 13549)
@@ -0,0 +1,25 @@
+<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:s="http://jboss.com/products/seam/taglib"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:a="https://ajax4jsf.dev.java.net/ajax"
+ xmlns:wiki="http://jboss.com/products/seam/wiki"
+ template="themes/#{preferences.get('Wiki').themeName}/template.xhtml">
+
+<ui:define name="content">
+
+<h3>Blacklisted</h3>
+
+<span>
+I'm sorry, but you have been blacklisted from this site.
+If you think this is an error, please contact the site administrator.
+</span>
+
+</ui:define>
+
+<ui:define name="footer"> </ui:define>
+
+</ui:composition>
13 years, 9 months
Seam SVN: r13548 - in modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence: util and 1 other directory.
by seam-commits@lists.jboss.org
Author: swd847
Date: 2010-08-03 03:58:35 -0400 (Tue, 03 Aug 2010)
New Revision: 13548
Added:
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/EJBContextUtils.java
Removed:
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/EJB.java
Modified:
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionInvocationHandler.java
Log:
minor refactoring
Deleted: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/EJB.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/EJB.java 2010-08-03 07:52:12 UTC (rev 13547)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/EJB.java 2010-08-03 07:58:35 UTC (rev 13548)
@@ -1,62 +0,0 @@
-/*
- * 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.transaction;
-
-import javax.ejb.EJBContext;
-import javax.naming.NameNotFoundException;
-import javax.naming.NamingException;
-
-import org.jboss.seam.persistence.util.NamingUtils;
-
-/**
- * utility class to look up the EJBContext
- *
- *
- */
-public class EJB
-{
- public static String ejbContextName = "java:comp.ejb3/EJBContext";
- public static final String STANDARD_EJB_CONTEXT_NAME = "java:comp/EJBContext";
-
- public static EJBContext getEJBContext() throws NamingException
- {
- try
- {
- return (EJBContext) NamingUtils.getInitialContext().lookup(ejbContextName);
- }
- catch (NameNotFoundException nnfe)
- {
- return (EJBContext) NamingUtils.getInitialContext().lookup(STANDARD_EJB_CONTEXT_NAME);
- }
- }
-
- protected static String getEjbContextName()
- {
- return ejbContextName;
- }
-
- protected static void setEjbContextName(String ejbContextName)
- {
- EJB.ejbContextName = ejbContextName;
- }
-
-}
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionInvocationHandler.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionInvocationHandler.java 2010-08-03 07:52:12 UTC (rev 13547)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionInvocationHandler.java 2010-08-03 07:58:35 UTC (rev 13548)
@@ -10,6 +10,7 @@
import javax.naming.NameNotFoundException;
import javax.naming.NamingException;
+import org.jboss.seam.persistence.util.EJBContextUtils;
import org.jboss.seam.persistence.util.NamingUtils;
import org.jboss.weld.extensions.literal.DefaultLiteral;
@@ -62,7 +63,7 @@
protected SeamTransaction createCMTTransaction() throws NamingException
{
- return new CMTTransaction(EJB.getEJBContext(), synchronizations);
+ return new CMTTransaction(EJBContextUtils.getEJBContext(), synchronizations);
}
protected SeamTransaction createUTTransaction() throws NamingException
Copied: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/EJBContextUtils.java (from rev 13513, modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/EJB.java)
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/EJBContextUtils.java (rev 0)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/EJBContextUtils.java 2010-08-03 07:58:35 UTC (rev 13548)
@@ -0,0 +1,61 @@
+/*
+ * 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.util;
+
+import javax.ejb.EJBContext;
+import javax.naming.NameNotFoundException;
+import javax.naming.NamingException;
+
+
+/**
+ * utility class to look up the EJBContext
+ *
+ *
+ */
+public class EJBContextUtils
+{
+ public static String ejbContextName = "java:comp.ejb3/EJBContext";
+ public static final String STANDARD_EJB_CONTEXT_NAME = "java:comp/EJBContext";
+
+ public static EJBContext getEJBContext() throws NamingException
+ {
+ try
+ {
+ return (EJBContext) NamingUtils.getInitialContext().lookup(ejbContextName);
+ }
+ catch (NameNotFoundException nnfe)
+ {
+ return (EJBContext) NamingUtils.getInitialContext().lookup(STANDARD_EJB_CONTEXT_NAME);
+ }
+ }
+
+ protected static String getEjbContextName()
+ {
+ return ejbContextName;
+ }
+
+ protected static void setEjbContextName(String ejbContextName)
+ {
+ EJBContextUtils.ejbContextName = ejbContextName;
+ }
+
+}
13 years, 9 months
Seam SVN: r13547 - in modules/persistence/trunk: impl/src/main/java/org/jboss/seam/persistence/transaction and 1 other directory.
by seam-commits@lists.jboss.org
Author: swd847
Date: 2010-08-03 03:52:12 -0400 (Tue, 03 Aug 2010)
New Revision: 13547
Added:
modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/SeamApplicationException.java
Removed:
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/SeamApplicationException.java
Log:
move SeamApplicationException tp API
Added: modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/SeamApplicationException.java
===================================================================
--- modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/SeamApplicationException.java (rev 0)
+++ modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/SeamApplicationException.java 2010-08-03 07:52:12 UTC (rev 13547)
@@ -0,0 +1,32 @@
+package org.jboss.seam.persistence.transaction;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Seam Annotation for identifying an Exception class as an Application
+ * Exception, which does not cause a transaction rollback
+ *
+ */
+(a)Target(ElementType.TYPE)
+(a)Retention(RetentionPolicy.RUNTIME)
+@Documented
+@Inherited
+public @interface SeamApplicationException
+{
+ /**
+ * Indicates whether the application exception designation should apply to
+ * subclasses of the annotated exception class.
+ */
+ boolean inherited() default true;
+
+ /**
+ * Indicates whether the container should cause the transaction to rollback
+ * when the exception is thrown.
+ */
+ boolean rollback() default false;
+}
Deleted: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/SeamApplicationException.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/SeamApplicationException.java 2010-08-03 07:51:11 UTC (rev 13546)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/SeamApplicationException.java 2010-08-03 07:52:12 UTC (rev 13547)
@@ -1,32 +0,0 @@
-package org.jboss.seam.persistence.transaction;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Seam Annotation for identifying an Exception class as an Application
- * Exception, which does not cause a transaction rollback
- *
- */
-(a)Target(ElementType.TYPE)
-(a)Retention(RetentionPolicy.RUNTIME)
-@Documented
-@Inherited
-public @interface SeamApplicationException
-{
- /**
- * Indicates whether the application exception designation should apply to
- * subclasses of the annotated exception class.
- */
- boolean inherited() default true;
-
- /**
- * Indicates whether the container should cause the transaction to rollback
- * when the exception is thrown.
- */
- boolean rollback() default false;
-}
13 years, 9 months
Seam SVN: r13546 - in modules/persistence/trunk/impl: src/main/java/org/jboss/seam/persistence/transaction and 1 other directories.
by seam-commits@lists.jboss.org
Author: swd847
Date: 2010-08-03 03:51:11 -0400 (Tue, 03 Aug 2010)
New Revision: 13546
Added:
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/SeamApplicationException.java
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/ExceptionUtil.java
Modified:
modules/persistence/trunk/impl/pom.xml
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/Work.java
Log:
add seam version of ApplicationException
Modified: modules/persistence/trunk/impl/pom.xml
===================================================================
--- modules/persistence/trunk/impl/pom.xml 2010-08-03 03:22:56 UTC (rev 13545)
+++ modules/persistence/trunk/impl/pom.xml 2010-08-03 07:51:11 UTC (rev 13546)
@@ -16,12 +16,12 @@
<properties>
<seam.version>3.0.0.b01</seam.version>
- <arquillian.version>1.0.0-SNAPSHOT</arquillian.version>
+ <arquillian.version>1.0.0.Alpha3</arquillian.version>
<junit.version>4.8.1</junit.version>
<jboss.home>${env.JBOSS_HOME}</jboss.home>
<jboss.domain>default</jboss.domain>
<glassfish.version>3.0.1-b19</glassfish.version>
- <jboss-as-client.version>6.0.0-SNAPSHOT</jboss-as-client.version>
+ <jboss-as-client.version>6.0.0.20100721-M4</jboss-as-client.version>
<jboss-server-manager.version>1.0.3.GA</jboss-server-manager.version>
</properties>
@@ -136,7 +136,7 @@
</profile>
<profile>
- <id>jbossas-remote-60</id>
+ <id>jbossas-remote-6</id>
<dependencies>
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
@@ -144,13 +144,6 @@
<version>${arquillian.version}</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.jboss.spec</groupId>
- <artifactId>jboss-javaee-6.0</artifactId>
- <version>${jboss-javaee6-spec.version}</version>
- <type>pom</type>
- <scope>provided</scope>
- </dependency>
<!-- need for org.jnp.interfaces.NamingContextFactory -->
<dependency>
<groupId>org.jboss.jbossas</groupId>
Added: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/SeamApplicationException.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/SeamApplicationException.java (rev 0)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/SeamApplicationException.java 2010-08-03 07:51:11 UTC (rev 13546)
@@ -0,0 +1,32 @@
+package org.jboss.seam.persistence.transaction;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Seam Annotation for identifying an Exception class as an Application
+ * Exception, which does not cause a transaction rollback
+ *
+ */
+(a)Target(ElementType.TYPE)
+(a)Retention(RetentionPolicy.RUNTIME)
+@Documented
+@Inherited
+public @interface SeamApplicationException
+{
+ /**
+ * Indicates whether the application exception designation should apply to
+ * subclasses of the annotated exception class.
+ */
+ boolean inherited() default true;
+
+ /**
+ * Indicates whether the container should cause the transaction to rollback
+ * when the exception is thrown.
+ */
+ boolean rollback() default false;
+}
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/Work.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/Work.java 2010-08-03 03:22:56 UTC (rev 13545)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/Work.java 2010-08-03 07:51:11 UTC (rev 13546)
@@ -21,9 +21,9 @@
*/
package org.jboss.seam.persistence.transaction;
-import javax.ejb.ApplicationException;
import javax.transaction.Status;
+import org.jboss.seam.persistence.util.ExceptionUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -77,7 +77,7 @@
{
if (newTransactionRequired && transaction.getStatus() != Status.STATUS_NO_TRANSACTION)
{
- if (isRollbackRequired(e, true))
+ if (ExceptionUtil.exceptionCausesRollback(e))
{
log.debug("rolling back transaction");
transaction.rollback();
@@ -88,7 +88,7 @@
transaction.commit();
}
}
- else if (transaction.getStatus() != Status.STATUS_NO_TRANSACTION && isRollbackRequired(e, true))
+ else if (transaction.getStatus() != Status.STATUS_NO_TRANSACTION && ExceptionUtil.exceptionCausesRollback(e))
{
transaction.setRollbackOnly();
}
@@ -96,19 +96,4 @@
}
}
- public static boolean isRollbackRequired(Exception e, boolean isJavaBean)
- {
- Class<? extends Exception> clazz = e.getClass();
- return (isSystemException(e, isJavaBean, clazz)) || (clazz.isAnnotationPresent(ApplicationException.class) && clazz.getAnnotation(ApplicationException.class).rollback());
- }
-
- private static boolean isSystemException(Exception e, boolean isJavaBean, Class<? extends Exception> clazz)
- {
- return isJavaBean && (e instanceof RuntimeException) && !clazz.isAnnotationPresent(ApplicationException.class);
- // &&
- // TODO: this is hackish, maybe just turn off RollackInterceptor for
- // @Converter/@Validator components
- // !JSF.VALIDATOR_EXCEPTION.isInstance(e) &&
- // !JSF.CONVERTER_EXCEPTION.isInstance(e);
- }
}
Added: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/ExceptionUtil.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/ExceptionUtil.java (rev 0)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/ExceptionUtil.java 2010-08-03 07:51:11 UTC (rev 13546)
@@ -0,0 +1,70 @@
+/*
+ * 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.util;
+
+import java.lang.reflect.Method;
+
+import org.jboss.seam.persistence.transaction.SeamApplicationException;
+
+/**
+ * Utility class for dealing with application exceptions
+ *
+ * @author Stuart Douglas
+ *
+ */
+public class ExceptionUtil
+{
+
+ private ExceptionUtil()
+ {
+
+ }
+
+ public static boolean exceptionCausesRollback(Exception e)
+ {
+ boolean defaultRollback = false;
+ if (e instanceof RuntimeException)
+ {
+ defaultRollback = true;
+ }
+ Class<?> exClass = e.getClass();
+ if (exClass.isAnnotationPresent(SeamApplicationException.class))
+ {
+ SeamApplicationException sae = exClass.getAnnotation(SeamApplicationException.class);
+ return sae.rollback();
+ }
+ else if (exClass.isAnnotationPresent(EjbApi.APPLICATION_EXCEPTION))
+ {
+ Object ae = exClass.getAnnotation(EjbApi.APPLICATION_EXCEPTION);
+ try
+ {
+ Method rollback = EjbApi.APPLICATION_EXCEPTION.getMethod("rollback");
+ return (Boolean) rollback.invoke(ae);
+ }
+ catch (Exception ex)
+ {
+ throw new RuntimeException(ex);
+ }
+ }
+ return defaultRollback;
+ }
+}
13 years, 9 months
Seam SVN: r13545 - in modules/jms/trunk: api/src/main/java/org/jboss/seam/jms/annotations and 11 other directories.
by seam-commits@lists.jboss.org
Author: jganoff
Date: 2010-08-02 23:22:56 -0400 (Mon, 02 Aug 2010)
New Revision: 13545
Added:
modules/jms/trunk/api/src/main/java/org/jboss/seam/jms/annotations/JmsSessionSelector.java
modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/session/
modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/session/EventSession.java
modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/session/InjectSessionTest.java
modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/session/SessionSelectorBean.java
modules/jms/trunk/impl/src/test/resources-jbossas/
modules/jms/trunk/impl/src/test/resources-jbossas/hornetq-jms.xml
modules/jms/trunk/impl/src/test/resources-jbossas/jndi.properties
Removed:
modules/jms/trunk/impl/src/test/resources/
Modified:
modules/jms/trunk/api/src/main/java/org/jboss/seam/jms/annotations/JmsSession.java
modules/jms/trunk/docs/reference/src/main/docbook/en-US/resource-injection.xml
modules/jms/trunk/impl/pom.xml
modules/jms/trunk/impl/src/main/java/org/jboss/seam/jms/impl/inject/SessionProducer.java
modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/MyQueue.java
modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/MyTopic.java
modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/Util.java
modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/bridge/JmsEventBridgeTest.java
modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/bridge/route/RouteTest.java
modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/InjectConnectionTest.java
modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/InjectDestinationTest.java
modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/InjectMessageProducerConsumerTest.java
modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/transmit/SimpleTransmitMessageTest.java
modules/jms/trunk/pom.xml
Log:
Updated Arquillian to 1.0.0-Alpha3. Added jbossas-remote-6 and jbossas-managed-6 profiles, updated for JBoss AS 6 M4 with HornetQ. Started work on SEAMJMS-1.
Modified: modules/jms/trunk/api/src/main/java/org/jboss/seam/jms/annotations/JmsSession.java
===================================================================
--- modules/jms/trunk/api/src/main/java/org/jboss/seam/jms/annotations/JmsSession.java 2010-08-01 21:47:03 UTC (rev 13544)
+++ modules/jms/trunk/api/src/main/java/org/jboss/seam/jms/annotations/JmsSession.java 2010-08-03 03:22:56 UTC (rev 13545)
@@ -21,6 +21,7 @@
*/
package org.jboss.seam.jms.annotations;
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
@@ -36,7 +37,7 @@
* @author Jordan Ganoff
*/
@Documented
-@Target( { FIELD, METHOD, PARAMETER })
+@Target( { FIELD, METHOD, ANNOTATION_TYPE, PARAMETER })
@Retention(RUNTIME)
public @interface JmsSession
{
Added: modules/jms/trunk/api/src/main/java/org/jboss/seam/jms/annotations/JmsSessionSelector.java
===================================================================
--- modules/jms/trunk/api/src/main/java/org/jboss/seam/jms/annotations/JmsSessionSelector.java (rev 0)
+++ modules/jms/trunk/api/src/main/java/org/jboss/seam/jms/annotations/JmsSessionSelector.java 2010-08-03 03:22:56 UTC (rev 13545)
@@ -0,0 +1,27 @@
+package org.jboss.seam.jms.annotations;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+@Target( { FIELD, METHOD, PARAMETER })
+@Retention(RUNTIME)
+public @interface JmsSessionSelector
+{
+ /**
+ * @see javax.jms.Session#getTransacted()
+ */
+ boolean transacted() default false;
+
+ /**
+ * @see javax.jms.Session#getAcknowledgeMode()
+ */
+ int acknowledgementMode() default javax.jms.Session.AUTO_ACKNOWLEDGE;
+}
Modified: modules/jms/trunk/docs/reference/src/main/docbook/en-US/resource-injection.xml
===================================================================
--- modules/jms/trunk/docs/reference/src/main/docbook/en-US/resource-injection.xml 2010-08-01 21:47:03 UTC (rev 13544)
+++ modules/jms/trunk/docs/reference/src/main/docbook/en-US/resource-injection.xml 2010-08-03 03:22:56 UTC (rev 13545)
@@ -100,9 +100,9 @@
<title>Resource Configuration</title>
<para>
- You can use the <literal>@JmsSession</literal> qualifier when injecting <literal>javax.jms.Session</literal> to specify transacted and acknowledgement type:
+ You can use the <literal>@JmsSession</literal> annotation when injecting <literal>javax.jms.Session</literal> to specify transacted and acknowledgement mode:
<programlisting role="Java">
-@Inject @JmsSession(transacted=true, acknowledgementType=Session.CLIENT_ACKNOWLEDGE) Session s;
+@Inject @JmsSession(transacted=false, acknowledgementMode=Session.CLIENT_ACKNOWLEDGE) Session s;
</programlisting>
</para>
Modified: modules/jms/trunk/impl/pom.xml
===================================================================
--- modules/jms/trunk/impl/pom.xml 2010-08-01 21:47:03 UTC (rev 13544)
+++ modules/jms/trunk/impl/pom.xml 2010-08-03 03:22:56 UTC (rev 13545)
@@ -1,96 +1,156 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.jboss.seam.jms</groupId>
- <artifactId>seam-jms-parent</artifactId>
- <version>3.0.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
+ <parent>
+ <groupId>org.jboss.seam.jms</groupId>
+ <artifactId>seam-jms-parent</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
- <artifactId>seam-jms</artifactId>
- <name>Seam JMS Implementation</name>
- <description>Implementation of the Seam JMS Module</description>
+ <artifactId>seam-jms</artifactId>
+ <name>Seam JMS Implementation</name>
+ <description>Implementation of the Seam JMS Module</description>
<packaging>jar</packaging>
- <dependencies>
- <dependency>
- <groupId>javax.enterprise</groupId>
- <artifactId>cdi-api</artifactId>
- <scope>provided</scope>
- </dependency>
+ <properties>
+ <jbossas.version>6.0.0.20100721-M4</jbossas.version>
+ </properties>
- <dependency>
- <groupId>org.jboss.seam.jms</groupId>
- <artifactId>seam-jms-api</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>javax.enterprise</groupId>
+ <artifactId>cdi-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.seam.jms</groupId>
+ <artifactId>seam-jms-api</artifactId>
<version>${project.version}</version>
- </dependency>
+ </dependency>
- <dependency>
- <groupId>org.jboss.weld</groupId>
- <artifactId>weld-extensions</artifactId>
- <scope>runtime</scope>
- </dependency>
+ <dependency>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>weld-extensions</artifactId>
+ <scope>runtime</scope>
+ </dependency>
- <dependency>
- <groupId>javax.jms</groupId>
- <artifactId>jms</artifactId>
- <scope>provided</scope>
- </dependency>
+ <dependency>
+ <groupId>javax.jms</groupId>
+ <artifactId>jms</artifactId>
+ <scope>provided</scope>
+ </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
- <dependency>
- <groupId>org.jboss.arquillian</groupId>
- <artifactId>arquillian-junit</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.arquillian.container</groupId>
- <artifactId>arquillian-jbossas-remote-60</artifactId>
- <scope>test</scope>
- </dependency>
-
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
- </dependencies>
- <profiles>
- <profile>
- <id>code-coverage</id>
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>emma-maven-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>org.codehaus.cargo</groupId>
- <artifactId>cargo-maven2-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-antrun-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>org.sonatype.maven.plugin</groupId>
- <artifactId>emma4it-maven-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
+ <dependency>
+ <groupId>org.jboss.arquillian</groupId>
+ <artifactId>arquillian-junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <profiles>
+ <profile>
+ <id>code-coverage</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>emma-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.cargo</groupId>
+ <artifactId>cargo-maven2-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.sonatype.maven.plugin</groupId>
+ <artifactId>emma4it-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>jbossas-remote-6</id>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.arquillian.container</groupId>
+ <artifactId>arquillian-jbossas-remote-6</artifactId>
+ <version>${arquillian.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-client</artifactId>
+ <version>${jbossas.version}</version>
+ <type>pom</type>
+ </dependency>
+ </dependencies>
+ <build>
+ <testResources>
+ <testResource>
+ <directory>src/test/resources</directory>
+ </testResource>
+ <testResource>
+ <directory>src/test/resources-jbossas</directory>
+ </testResource>
+ </testResources>
+ </build>
+ </profile>
+ <profile>
+ <id>jbossas-managed-6</id>
+ <properties>
+ <bindAddress>localhost</bindAddress>
+ <httpPort>8080</httpPort>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.arquillian.container</groupId>
+ <artifactId>arquillian-jbossas-managed-6</artifactId>
+ <version>${arquillian.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-server-manager</artifactId>
+ <version>1.0.3.GA</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-client</artifactId>
+ <version>${jbossas.version}</version>
+ <type>pom</type>
+ </dependency>
+ </dependencies>
+ <build>
+ <testResources>
+ <testResource>
+ <directory>src/test/resources</directory>
+ </testResource>
+ <testResource>
+ <directory>src/test/resources-jbossas</directory>
+ </testResource>
+ </testResources>
+ </build>
+ </profile>
+ </profiles>
+
</project>
Modified: modules/jms/trunk/impl/src/main/java/org/jboss/seam/jms/impl/inject/SessionProducer.java
===================================================================
--- modules/jms/trunk/impl/src/main/java/org/jboss/seam/jms/impl/inject/SessionProducer.java 2010-08-01 21:47:03 UTC (rev 13544)
+++ modules/jms/trunk/impl/src/main/java/org/jboss/seam/jms/impl/inject/SessionProducer.java 2010-08-03 03:22:56 UTC (rev 13545)
@@ -21,6 +21,8 @@
*/
package org.jboss.seam.jms.impl.inject;
+import java.lang.annotation.Annotation;
+
import javax.enterprise.context.RequestScoped;
import javax.enterprise.inject.Disposes;
import javax.enterprise.inject.Produces;
@@ -30,6 +32,7 @@
import javax.jms.Session;
import org.jboss.seam.jms.annotations.JmsSession;
+import org.jboss.seam.jms.annotations.JmsSessionSelector;
public @RequestScoped
class SessionProducer
@@ -37,19 +40,50 @@
@Produces
public Session getSession(InjectionPoint ip, Connection c) throws JMSException
{
- if (ip != null && ip.getAnnotated().isAnnotationPresent(JmsSession.class))
+ JmsSession s = null;
+ if (ip != null)
{
- JmsSession s = ip.getAnnotated().getAnnotation(JmsSession.class);
- return c.createSession(s.transacted(), s.acknowledgementMode());
+ // Check for JmsSession annotation
+ if (ip.getAnnotated().isAnnotationPresent(JmsSession.class))
+ {
+ s = ip.getAnnotated().getAnnotation(JmsSession.class);
+ }
+ else
+ {
+ // Check meta-annotations
+ for (Annotation a : ip.getAnnotated().getAnnotations())
+ {
+ if (a.annotationType().isAnnotationPresent(JmsSession.class))
+ {
+ s = a.annotationType().getAnnotation(JmsSession.class);
+ }
+ }
+ }
+ if (s != null)
+ {
+ return c.createSession(s.transacted(), s.acknowledgementMode());
+ }
}
- else
- {
- return c.createSession(false, Session.AUTO_ACKNOWLEDGE);
- }
+
+ // Default case where we cannot find an annotation
+ return c.createSession(false, Session.AUTO_ACKNOWLEDGE);
}
public void closeSession(@Disposes Session s) throws JMSException
{
s.close();
}
+
+ @Produces
+ @JmsSessionSelector
+ public Session getSelectedSession(InjectionPoint ip, Connection c) throws JMSException
+ {
+ JmsSessionSelector s = ip.getAnnotated().getAnnotation(JmsSessionSelector.class);
+ return c.createSession(s.transacted(), s.acknowledgementMode());
+ }
+
+ public void closeSelectedSession(@Disposes @JmsSessionSelector Session s) throws JMSException
+ {
+ s.close();
+ }
}
Modified: modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/MyQueue.java
===================================================================
--- modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/MyQueue.java 2010-08-01 21:47:03 UTC (rev 13544)
+++ modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/MyQueue.java 2010-08-03 03:22:56 UTC (rev 13545)
@@ -31,7 +31,7 @@
@Qualifier
@Retention(RUNTIME)
-@JmsDestination(jndiName = "jms/Q")
+@JmsDestination(jndiName = "/jms/Q")
public @interface MyQueue
{
Modified: modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/MyTopic.java
===================================================================
--- modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/MyTopic.java 2010-08-01 21:47:03 UTC (rev 13544)
+++ modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/MyTopic.java 2010-08-03 03:22:56 UTC (rev 13545)
@@ -31,7 +31,7 @@
@Qualifier
@Retention(RUNTIME)
-@JmsDestination(jndiName = "jms/T")
+@JmsDestination(jndiName = "/jms/T")
public @interface MyTopic
{
}
Modified: modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/Util.java
===================================================================
--- modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/Util.java 2010-08-01 21:47:03 UTC (rev 13544)
+++ modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/Util.java 2010-08-03 03:22:56 UTC (rev 13545)
@@ -28,46 +28,37 @@
import org.jboss.seam.jms.bridge.Route;
import org.jboss.seam.jms.impl.inject.ConnectionProducer;
import org.jboss.seam.jms.impl.wrapper.JmsAnnotatedTypeWrapper;
+import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
-import org.jboss.shrinkwrap.impl.base.asset.ByteArrayAsset;
public class Util
{
+ private static final String HORNETQ_JMS_DEPLOYMENT_CONFIG = "hornetq-jms.xml";
- public static JavaArchive createDeployment(Class<?> c)
+ public static Archive<?> createDeployment(Class<?>... classes)
{
- JavaArchive archive = ShrinkWrap.create("test.jar", JavaArchive.class);
- archive.addPackage(Util.class.getPackage());
- archive.addPackage(Seam3JmsExtension.class.getPackage());
- archive.addPackage(JmsSession.class.getPackage());
- archive.addPackage(ConnectionProducer.class.getPackage());
- archive.addPackage(JmsAnnotatedTypeWrapper.class.getPackage());
- archive.addPackage(Route.class.getPackage());
- archive.addManifestResource(new ByteArrayAsset("<beans/>".getBytes()), ArchivePaths.create("beans.xml"));
- archive.addServiceProvider(Extension.class, Seam3JmsExtension.class);
- archive.addManifestResource("topic_T-service.xml");
- archive.addManifestResource("queue_Q-service.xml");
+ JavaArchive ejbModule = ShrinkWrap.create(JavaArchive.class, "test.jar");
+ ejbModule.addPackage(Util.class.getPackage());
+ ejbModule.addPackage(Seam3JmsExtension.class.getPackage());
+ ejbModule.addPackage(JmsSession.class.getPackage());
+ ejbModule.addPackage(ConnectionProducer.class.getPackage());
+ ejbModule.addPackage(JmsAnnotatedTypeWrapper.class.getPackage());
+ ejbModule.addPackage(Route.class.getPackage());
+ ejbModule.addManifestResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));
+ ejbModule.addServiceProvider(Extension.class, Seam3JmsExtension.class);
+ for (Class<?> c : classes)
+ {
+ ejbModule.addPackage(c.getPackage());
+ }
- archive.addPackage(c.getPackage());
+ EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "test.ear");
+ ear.addModule(ejbModule);
+ ear.addResource(HORNETQ_JMS_DEPLOYMENT_CONFIG); // TODO Add this conditionally based on test profile to support other containers
- return archive;
+ return ear;
}
-
- public static JavaArchive addBeansXml(JavaArchive a, Class<?> c)
- {
- return addBeansXml(a, c, "beans.xml");
- }
-
- public static JavaArchive addBeansXml(JavaArchive a, Class<?> c, String beansXmlLocalName)
- {
- return addManifestResource(a, c, beansXmlLocalName, "beans.xml");
- }
-
- public static JavaArchive addManifestResource(JavaArchive a, Class<?> c, String name, String archivePath)
- {
- String basePkg = c.getPackage().getName().replaceAll("\\.", "/");
- return a.addManifestResource(basePkg + "/" + name, ArchivePaths.create(archivePath));
- }
}
Modified: modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/bridge/JmsEventBridgeTest.java
===================================================================
--- modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/bridge/JmsEventBridgeTest.java 2010-08-01 21:47:03 UTC (rev 13544)
+++ modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/bridge/JmsEventBridgeTest.java 2010-08-03 03:22:56 UTC (rev 13545)
@@ -30,7 +30,7 @@
import org.jboss.seam.jms.bridge.Route;
import org.jboss.seam.jms.bridge.RouteType;
import org.jboss.seam.jms.test.Util;
-import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.api.Archive;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -40,7 +40,7 @@
{
@Deployment
- public static JavaArchive createDeployment()
+ public static Archive<?> createDeployment()
{
return Util.createDeployment(JmsEventBridgeTest.class);
}
@@ -62,6 +62,4 @@
Assert.assertEquals(RouteType.EGRESS, r.getType());
Assert.assertEquals(Object.class, r.getPayloadType());
}
-
-
}
Modified: modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/bridge/route/RouteTest.java
===================================================================
--- modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/bridge/route/RouteTest.java 2010-08-01 21:47:03 UTC (rev 13544)
+++ modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/bridge/route/RouteTest.java 2010-08-03 03:22:56 UTC (rev 13545)
@@ -33,7 +33,7 @@
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.seam.jms.annotations.JmsDestination;
import org.jboss.seam.jms.test.Util;
-import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.api.Archive;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -42,7 +42,7 @@
public class RouteTest
{
@Deployment
- public static JavaArchive createDeployment()
+ public static Archive<?> createDeployment()
{
return Util.createDeployment(RouteTest.class);
}
Modified: modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/InjectConnectionTest.java
===================================================================
--- modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/InjectConnectionTest.java 2010-08-01 21:47:03 UTC (rev 13544)
+++ modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/InjectConnectionTest.java 2010-08-03 03:22:56 UTC (rev 13545)
@@ -24,14 +24,11 @@
import javax.enterprise.inject.Instance;
import javax.inject.Inject;
import javax.jms.Connection;
-import javax.jms.JMSException;
-import javax.jms.Session;
import org.jboss.arquillian.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.seam.jms.annotations.JmsSession;
import org.jboss.seam.jms.test.Util;
-import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.api.Archive;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -41,24 +38,17 @@
{
@Deployment
- public static JavaArchive createDeployment()
+ public static Archive<?> createDeployment()
{
return Util.createDeployment(InjectConnectionTest.class);
}
@Inject
private Instance<Connection> c;
-
+
@Inject
private Instance<Connection> c2;
- @Inject
- private Instance<Session> s;
-
- @Inject
- @JmsSession(transacted=false, acknowledgementMode=Session.CLIENT_ACKNOWLEDGE)
- private Instance<Session> configuredSession;
-
@Test
public void injectConnection()
{
@@ -66,23 +56,8 @@
}
@Test
- public void injectSession()
- {
- Assert.assertNotNull(s.get());
- }
-
- @Test
public void sameConnection()
{
Assert.assertEquals(c.get(), c2.get());
}
-
- @Test
- public void configuredSession() throws JMSException
- {
- Session s = configuredSession.get();
- Assert.assertNotNull(s);
- Assert.assertFalse(s.getTransacted());
- Assert.assertEquals(Session.CLIENT_ACKNOWLEDGE, s.getAcknowledgeMode());
- }
}
Modified: modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/InjectDestinationTest.java
===================================================================
--- modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/InjectDestinationTest.java 2010-08-01 21:47:03 UTC (rev 13544)
+++ modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/InjectDestinationTest.java 2010-08-03 03:22:56 UTC (rev 13545)
@@ -27,17 +27,17 @@
import org.jboss.arquillian.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.seam.jms.test.Util;
-import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.api.Archive;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
-(a)RunWith(Arquillian.class)
+(a)RunWith(Arquillian.class)
public class InjectDestinationTest
{
@Deployment
- public static JavaArchive createDeployment()
+ public static Archive<?> createDeployment()
{
return Util.createDeployment(InjectDestinationTest.class);
}
Modified: modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/InjectMessageProducerConsumerTest.java
===================================================================
--- modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/InjectMessageProducerConsumerTest.java 2010-08-01 21:47:03 UTC (rev 13544)
+++ modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/InjectMessageProducerConsumerTest.java 2010-08-03 03:22:56 UTC (rev 13545)
@@ -31,7 +31,7 @@
import org.jboss.arquillian.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.seam.jms.test.Util;
-import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.api.Archive;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -40,7 +40,7 @@
public class InjectMessageProducerConsumerTest
{
@Deployment
- public static JavaArchive createDeployment()
+ public static Archive<?> createDeployment()
{
return Util.createDeployment(InjectMessageProducerConsumerTest.class);
}
Added: modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/session/EventSession.java
===================================================================
--- modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/session/EventSession.java (rev 0)
+++ modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/session/EventSession.java 2010-08-03 03:22:56 UTC (rev 13545)
@@ -0,0 +1,35 @@
+/*
+ * 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.jms.test.inject.session;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+import javax.jms.Session;
+
+import org.jboss.seam.jms.annotations.JmsSession;
+
+(a)Retention(RetentionPolicy.RUNTIME)
+@JmsSession(transacted = false, acknowledgementMode = Session.DUPS_OK_ACKNOWLEDGE)
+public @interface EventSession
+{
+}
Added: modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/session/InjectSessionTest.java
===================================================================
--- modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/session/InjectSessionTest.java (rev 0)
+++ modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/session/InjectSessionTest.java 2010-08-03 03:22:56 UTC (rev 13545)
@@ -0,0 +1,111 @@
+/*
+ * 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.jms.test.inject.session;
+
+import javax.enterprise.inject.Instance;
+import javax.inject.Inject;
+import javax.jms.JMSException;
+import javax.jms.Session;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.jms.annotations.JmsSession;
+import org.jboss.seam.jms.annotations.JmsSessionSelector;
+import org.jboss.seam.jms.test.Util;
+import org.jboss.shrinkwrap.api.Archive;
+import org.junit.Assert;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+(a)RunWith(Arquillian.class)
+public class InjectSessionTest
+{
+
+ @Deployment
+ public static Archive<?> createDeployment()
+ {
+ return Util.createDeployment(InjectSessionTest.class);
+ }
+
+ @Inject
+ private Instance<Session> s;
+
+ @Inject
+ @JmsSessionSelector(transacted=false, acknowledgementMode=Session.AUTO_ACKNOWLEDGE)
+ private Instance<Session> qualified;
+
+ @Inject
+ @JmsSession(transacted = false, acknowledgementMode = Session.CLIENT_ACKNOWLEDGE)
+ private Instance<Session> configuredSession;
+
+ @Inject
+ @EventSession
+ private Instance<Session> eventSession;
+
+ @Inject
+ SessionSelectorBean selectorBean;
+
+ @Test
+ public void injectSession()
+ {
+ Assert.assertNotNull(s.get());
+ }
+
+ @Test
+ public void injectSession_annotated() throws JMSException
+ {
+ Session s = configuredSession.get();
+ Assert.assertNotNull(s);
+ Assert.assertFalse(s.getTransacted());
+ Assert.assertEquals(Session.CLIENT_ACKNOWLEDGE, s.getAcknowledgeMode());
+ }
+
+ @Test
+ public void injectSession_meta_annotated() throws JMSException
+ {
+ Session s = eventSession.get();
+ Assert.assertNotNull(s);
+ Assert.assertFalse(s.getTransacted());
+ Assert.assertEquals(Session.DUPS_OK_ACKNOWLEDGE, s.getAcknowledgeMode());
+ }
+
+ @Test
+ public void injectQualifiedSession() throws JMSException
+ {
+ Session s = qualified.get();
+ Assert.assertNotNull(s);
+ Assert.assertFalse(s.getTransacted());
+ Assert.assertEquals(Session.AUTO_ACKNOWLEDGE, s.getAcknowledgeMode());
+ }
+
+ // TODO Fix this so session selectors work
+ @Ignore
+ @Test
+ public void injectSessionWithLiteral() throws JMSException
+ {
+ Session session = selectorBean.get();
+ Assert.assertNotNull(session);
+ Assert.assertFalse(session.getTransacted());
+ Assert.assertEquals(Session.DUPS_OK_ACKNOWLEDGE, session.getAcknowledgeMode());
+ }
+}
\ No newline at end of file
Added: modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/session/SessionSelectorBean.java
===================================================================
--- modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/session/SessionSelectorBean.java (rev 0)
+++ modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/session/SessionSelectorBean.java 2010-08-03 03:22:56 UTC (rev 13545)
@@ -0,0 +1,33 @@
+package org.jboss.seam.jms.test.inject.session;
+
+import javax.enterprise.inject.Instance;
+import javax.enterprise.util.AnnotationLiteral;
+import javax.inject.Inject;
+import javax.jms.Session;
+
+import org.jboss.seam.jms.annotations.JmsSessionSelector;
+
+public class SessionSelectorBean
+{
+
+ class SessionQualifier extends AnnotationLiteral<JmsSessionSelector> implements JmsSessionSelector
+ {
+ public int acknowledgementMode()
+ {
+ return Session.DUPS_OK_ACKNOWLEDGE;
+ }
+
+ public boolean transacted()
+ {
+ return false;
+ }
+ }
+
+ @Inject
+ Instance<Session> s;
+
+ public Session get()
+ {
+ return s.select(new SessionQualifier()).get();
+ }
+}
Modified: modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/transmit/SimpleTransmitMessageTest.java
===================================================================
--- modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/transmit/SimpleTransmitMessageTest.java 2010-08-01 21:47:03 UTC (rev 13544)
+++ modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/transmit/SimpleTransmitMessageTest.java 2010-08-03 03:22:56 UTC (rev 13545)
@@ -36,7 +36,7 @@
import org.jboss.seam.jms.test.Util;
import org.jboss.seam.jms.test.inject.InjectMessageConsumer;
import org.jboss.seam.jms.test.inject.InjectMessageProducer;
-import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.api.Archive;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -45,11 +45,9 @@
public class SimpleTransmitMessageTest
{
@Deployment
- public static JavaArchive createDeployment()
+ public static Archive<?> createDeployment()
{
- JavaArchive a = Util.createDeployment(SimpleTransmitMessageTest.class);
- a.addPackage(InjectMessageConsumer.class.getPackage());
- return a;
+ return Util.createDeployment(SimpleTransmitMessageTest.class, InjectMessageConsumer.class);
}
@Inject
Added: modules/jms/trunk/impl/src/test/resources-jbossas/hornetq-jms.xml
===================================================================
--- modules/jms/trunk/impl/src/test/resources-jbossas/hornetq-jms.xml (rev 0)
+++ modules/jms/trunk/impl/src/test/resources-jbossas/hornetq-jms.xml 2010-08-03 03:22:56 UTC (rev 13545)
@@ -0,0 +1,13 @@
+<configuration xmlns="urn:hornetq"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:hornetq /schema/hornetq-jms.xsd">
+
+ <topic name="T">
+ <entry name="/jms/T" />
+ </topic>
+
+ <queue name="Q">
+ <entry name="/jms/Q" />
+ </queue>
+
+</configuration>
\ No newline at end of file
Added: modules/jms/trunk/impl/src/test/resources-jbossas/jndi.properties
===================================================================
--- modules/jms/trunk/impl/src/test/resources-jbossas/jndi.properties (rev 0)
+++ modules/jms/trunk/impl/src/test/resources-jbossas/jndi.properties 2010-08-03 03:22:56 UTC (rev 13545)
@@ -0,0 +1,3 @@
+java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
+java.naming.provider.url=jnp://localhost:1099
Modified: modules/jms/trunk/pom.xml
===================================================================
--- modules/jms/trunk/pom.xml 2010-08-01 21:47:03 UTC (rev 13544)
+++ modules/jms/trunk/pom.xml 2010-08-03 03:22:56 UTC (rev 13545)
@@ -19,6 +19,7 @@
<properties>
<seam.version>3.0.0.b01</seam.version>
+ <arquillian.version>1.0.0.Alpha3</arquillian.version>
</properties>
<modules>
13 years, 9 months
Seam SVN: r13544 - modules/xml/trunk.
by seam-commits@lists.jboss.org
Author: swd847
Date: 2010-08-01 17:47:03 -0400 (Sun, 01 Aug 2010)
New Revision: 13544
Removed:
modules/xml/trunk/src/
Modified:
modules/xml/trunk/pom.xml
Log:
update distribution
Modified: modules/xml/trunk/pom.xml
===================================================================
--- modules/xml/trunk/pom.xml 2010-08-01 21:29:30 UTC (rev 13543)
+++ modules/xml/trunk/pom.xml 2010-08-01 21:47:03 UTC (rev 13544)
@@ -26,7 +26,6 @@
<modules>
<module>impl</module>
- <module>docs</module>
</modules>
<dependencyManagement>
13 years, 9 months
Seam SVN: r13543 - modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model.
by seam-commits@lists.jboss.org
Author: swd847
Date: 2010-08-01 17:29:30 -0400 (Sun, 01 Aug 2010)
New Revision: 13543
Modified:
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ValueXmlItem.java
Log:
error checking for inline bean definitions
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ValueXmlItem.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ValueXmlItem.java 2010-08-01 21:23:34 UTC (rev 13542)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ValueXmlItem.java 2010-08-01 21:29:30 UTC (rev 13543)
@@ -25,6 +25,7 @@
import java.util.List;
import java.util.Set;
+import javax.enterprise.context.Dependent;
import javax.enterprise.inject.spi.BeanManager;
import org.jboss.seam.xml.core.BeanResult;
@@ -62,10 +63,15 @@
ClassXmlItem inline = inlineBeans.get(0);
for (AnnotationXmlItem i : inline.getChildrenOfType(AnnotationXmlItem.class))
{
- if (manager.isQualifier((Class) i.getJavaClass()))
+ Class annotation = (Class) i.getJavaClass();
+ if (manager.isQualifier(annotation))
{
- throw new XmlConfigurationException("Cannot define qualifiers on inline beans", i.getDocument(), i.getLineno());
+ throw new XmlConfigurationException("Cannot define qualifiers on inline beans, Qualifier: " + annotation.getName(), i.getDocument(), i.getLineno());
}
+ else if (manager.isScope(annotation) && annotation != Dependent.class)
+ {
+ throw new XmlConfigurationException("Inline beans must have @Dependent scope, Scope: " + annotation.getName(), i.getDocument(), i.getLineno());
+ }
}
syntheticQualifierId = InlineBeanIdCreator.getId();
AnnotationXmlItem syntheticQualifier = new AnnotationXmlItem(this, InlineBeanQualifier.class, "" + syntheticQualifierId, Collections.EMPTY_MAP, getDocument(), getLineno());
13 years, 9 months