Seam SVN: r12696 - modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple.
by seam-commits@lists.jboss.org
Author: jganoff
Date: 2010-05-07 01:21:18 -0400 (Fri, 07 May 2010)
New Revision: 12696
Modified:
modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/SimpleBridgedEventTest.java
Log:
Removed unused session member from simple bridge test to prevent confusion.
Modified: modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/SimpleBridgedEventTest.java
===================================================================
--- modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/SimpleBridgedEventTest.java 2010-05-07 04:54:44 UTC (rev 12695)
+++ modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/SimpleBridgedEventTest.java 2010-05-07 05:21:18 UTC (rev 12696)
@@ -27,7 +27,6 @@
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.ObjectMessage;
-import javax.jms.Session;
import javax.jms.TopicSubscriber;
import org.jboss.arquillian.api.Deployment;
@@ -49,7 +48,6 @@
}
@Inject Connection c;
- @Inject Session s;
@Inject @JmsDestination(jndiName="jms/T") TopicSubscriber ts;
@Inject @Bridged Event<String> event;
13 years, 11 months
Seam SVN: r12695 - modules/jms/trunk/docs/reference/src/main/docbook/en-US.
by seam-commits@lists.jboss.org
Author: jganoff
Date: 2010-05-07 00:54:44 -0400 (Fri, 07 May 2010)
New Revision: 12695
Added:
modules/jms/trunk/docs/reference/src/main/docbook/en-US/installation.xml
Modified:
modules/jms/trunk/docs/reference/src/main/docbook/en-US/gettingstarted.xml
modules/jms/trunk/docs/reference/src/main/docbook/en-US/intro.xml
modules/jms/trunk/docs/reference/src/main/docbook/en-US/master.xml
Log:
Updated documentation
Modified: modules/jms/trunk/docs/reference/src/main/docbook/en-US/gettingstarted.xml
===================================================================
--- modules/jms/trunk/docs/reference/src/main/docbook/en-US/gettingstarted.xml 2010-05-07 03:50:12 UTC (rev 12694)
+++ modules/jms/trunk/docs/reference/src/main/docbook/en-US/gettingstarted.xml 2010-05-07 04:54:44 UTC (rev 12695)
@@ -23,30 +23,90 @@
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" []>
<chapter id="gettingstarted">
+ <title>Getting Started</title>
- <title>Getting started</title>
+ <para>
+ In this chapter we'll look at how to inject JMS resources and route events over JMS.
+ </para>
- <para>
- In this chapter we'll look at how to setup a Maven project to use the
- JMS module, how to inject JMS resources and how to route events over
- JMS.
- </para>
-
- <section>
- <title>Setting up a Maven project</title>
-
- <para>TODO</para>
- </section>
-
- <section>
- <title>Injection JMS Resources</title>
-
- <para>TODO</para>
- </section>
-
- <section>
- <title>Routing Events over JMS</title>
-
- <para>TODO</para>
- </section>
+ <section id="injection">
+ <title>JMS Resource Injection</title>
+
+ <para>The following JMS resources are now available for injection:</para>
+
+ <itemizedlist>
+ <listitem>
+ javax.jms.Connection
+ </listitem>
+ <listitem>
+ javax.jms.Session
+ </listitem>
+ </itemizedlist>
+
+ <para>Destination-based resources:</para>
+ <itemizedlist>
+ <listitem>
+ javax.jms.Topic
+ </listitem>
+ <listitem>
+ javax.jms.Queue
+ </listitem>
+ <listitem>
+ javax.jms.TopicPublisher
+ </listitem>
+ <listitem>
+ javax.jms.QueueSender
+ </listitem>
+ <listitem>
+ javax.jms.TopicSubscriber
+ </listitem>
+ <listitem>
+ javax.jms.QueueReceiver
+ </listitem>
+ </itemizedlist>
+
+ <!-- TODO Clean up and move elsewhere
+ <tip>
+ You can use the <literal>@JmsSession</literal> qualifier when injecting <literal>javax.jms.Session</literal> to specify transacted and acknowledgement type:
+ <programlisting role="Java">
+@Inject @JmsSession(transacted=true, acknowledgementType=Session.CLIENT_ACKNOWLEDGE) Session s;
+</programlisting>
+ </tip>
+ -->
+
+ <section id="injection.destination-based">
+ <title>Destination Based Injection</title>
+
+ <para>
+ The injection of resources that are themselves a <literal>javax.jms.Destination</literal> or require one needs
+ a hint: What destination do you want to work with? This is provided by the
+ <literal>@JmsDestination</literal> annotatation.
+
+ <programlisting role="Java">
+@Inject @JmsDestination(jndiName="jms/MyTopic") Topic t;
+@Inject @JmsDestination(jndiName="jms/MyQueue") Queue q;</programlisting>
+ </para>
+
+ <para>
+ You should create your own qualifier to provide type safe injection of predefined destinations:
+ <programlisting role="Java">
+@Qualifier
+@JmsDestination(jndiName = "jms/MyTopic")
+public @interface MyTopic {}</programlisting>
+ </para>
+
+ <para>
+ You can then use it in place of the <literal>@JmsDestination</literal> qualifier anywhere it's required:
+
+ <programlisting role="Java">
+@Inject @MyTopic TopicPublisher myPub;</programlisting>
+ </para>
+ </section>
+ </section>
+
+ <section id="routing-egress">
+ <title>Routing Events over JMS</title>
+
+ <para>TODO</para>
+ </section>
</chapter>
Copied: modules/jms/trunk/docs/reference/src/main/docbook/en-US/installation.xml (from rev 12692, modules/jms/trunk/docs/reference/src/main/docbook/en-US/gettingstarted.xml)
===================================================================
--- modules/jms/trunk/docs/reference/src/main/docbook/en-US/installation.xml (rev 0)
+++ modules/jms/trunk/docs/reference/src/main/docbook/en-US/installation.xml 2010-05-07 04:54:44 UTC (rev 12695)
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
+ "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" []>
+<chapter id="installation">
+
+ <title>Installation</title>
+
+ <para>
+ Most features of Seam JMS are installed automatically by
+ including the seam-jms.jar in your application's library folder.
+ If you are using
+ <ulink
+ url="http://maven.apache.org/">Maven
+ </ulink>
+ as your build tool use the following dependency:
+ </para>
+
+ <programlisting role="XML"><![CDATA[<dependency>
+ <groupId>org.jboss.seam</groupId>
+ <artifactId>seam-jms</artifactId>
+ <version>${seam.jms.version}</version>
+</dependency>]]></programlisting>
+
+ <tip>
+ <para>Define or replace the property ${seam.jms.version} with a valid version of Seam JMS.</para>
+ </tip>
+</chapter>
Modified: modules/jms/trunk/docs/reference/src/main/docbook/en-US/intro.xml
===================================================================
--- modules/jms/trunk/docs/reference/src/main/docbook/en-US/intro.xml 2010-05-07 03:50:12 UTC (rev 12694)
+++ modules/jms/trunk/docs/reference/src/main/docbook/en-US/intro.xml 2010-05-07 04:54:44 UTC (rev 12695)
@@ -36,9 +36,9 @@
<title>Mission statement</title>
<para>
- The missing of the JMS module for Seam 3 is to provide injection
- of JMS resources and the necessary scaffolding for CDI event
- propagation over JMS.
+ The JMS module for Seam 3 is to provide injection of JMS resources
+ and the necessary scaffolding for a bidirectional propagation of
+ CDI event over JMS.
</para>
</section>
@@ -47,7 +47,7 @@
<para>
The general goals can be divided into two categories: injection
- of JMS resources and forwarding of events:
+ of JMS resources and bridging of events:
</para>
<itemizedlist>
@@ -70,12 +70,12 @@
</itemizedlist>
<itemizedlist>
- <title>Forwarding of Events</title>
+ <title>Event Bridge</title>
<listitem>
- Implicit - use a stereotype annotation when firing events
+ Egress: Routes CDI events to JMS destinations
</listitem>
<listitem>
- Explicit - events and qualifiers are registered explicitly
+ Ingress: Fires CDI events based on the reception of JMS messages
</listitem>
</itemizedlist>
</section>
Modified: modules/jms/trunk/docs/reference/src/main/docbook/en-US/master.xml
===================================================================
--- modules/jms/trunk/docs/reference/src/main/docbook/en-US/master.xml 2010-05-07 03:50:12 UTC (rev 12694)
+++ modules/jms/trunk/docs/reference/src/main/docbook/en-US/master.xml 2010-05-07 04:54:44 UTC (rev 12695)
@@ -26,5 +26,6 @@
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="book_info.xml" />
<toc />
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="intro.xml" />
+ <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="installation.xml" />
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="gettingstarted.xml" />
</book>
13 years, 11 months
Seam SVN: r12694 - in modules/jms/trunk: impl and 1 other directory.
by seam-commits@lists.jboss.org
Author: jganoff
Date: 2010-05-06 23:50:12 -0400 (Thu, 06 May 2010)
New Revision: 12694
Modified:
modules/jms/trunk/impl/pom.xml
modules/jms/trunk/pom.xml
Log:
Added slf4j dependency directly. Transitive dep was not being pulled in with mvn 2.0.10.
Modified: modules/jms/trunk/impl/pom.xml
===================================================================
--- modules/jms/trunk/impl/pom.xml 2010-05-07 03:17:44 UTC (rev 12693)
+++ modules/jms/trunk/impl/pom.xml 2010-05-07 03:50:12 UTC (rev 12694)
@@ -62,6 +62,11 @@
<version>${arquillian.version}</version>
<scope>test</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
</dependencies>
<profiles>
Modified: modules/jms/trunk/pom.xml
===================================================================
--- modules/jms/trunk/pom.xml 2010-05-07 03:17:44 UTC (rev 12693)
+++ modules/jms/trunk/pom.xml 2010-05-07 03:50:12 UTC (rev 12694)
@@ -241,6 +241,12 @@
<artifactId>seam-jms-impl</artifactId>
<version>${seam.jms.version}</version>
</dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.5.10</version>
+ </dependency>
</dependencies>
</dependencyManagement>
13 years, 11 months
Seam SVN: r12693 - in modules/jms/trunk: impl/src/main/java/org/jboss/seam/jms and 3 other directories.
by seam-commits@lists.jboss.org
Author: jganoff
Date: 2010-05-06 23:17:44 -0400 (Thu, 06 May 2010)
New Revision: 12693
Added:
modules/jms/trunk/api/src/main/java/org/jboss/seam/jms/JmsForwarding.java
modules/jms/trunk/impl/src/main/java/org/jboss/seam/jms/BridgedObserver.java
modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/bridge/
modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/
modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/Bridged.java
modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/MyForwarding.java
modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/MyTopic.java
modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/SimpleBridgedEventTest.java
Removed:
modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/
modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/Bridged.java
modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/MyForwarding.java
modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/MyTopic.java
modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/SimpleBridgedEventTest.java
Modified:
modules/jms/trunk/impl/src/main/java/org/jboss/seam/jms/Seam3JmsExtension.java
modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/Util.java
Log:
First attempt at event forwarding
Copied: modules/jms/trunk/api/src/main/java/org/jboss/seam/jms/JmsForwarding.java (from rev 12692, modules/jms/branches/simple-forwarding/api/src/main/java/org/jboss/seam/jms/JmsForwarding.java)
===================================================================
--- modules/jms/trunk/api/src/main/java/org/jboss/seam/jms/JmsForwarding.java (rev 0)
+++ modules/jms/trunk/api/src/main/java/org/jboss/seam/jms/JmsForwarding.java 2010-05-07 03:17:44 UTC (rev 12693)
@@ -0,0 +1,55 @@
+/*
+ * 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;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Set;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Named;
+import javax.jms.Destination;
+
+/**
+ * Configuration for the forwarding of events to JMS.
+ *
+ * @author Jordan Ganoff
+ */
+@Named
+@ApplicationScoped
+public interface JmsForwarding
+{
+ /**
+ * Destinations to forward events to.
+ */
+ public Set<? extends Destination> getDestinations();
+
+ /**
+ * Event type to observe and forward.
+ */
+ public Type getEventType();
+
+ /**
+ * Set of qualifiers that must exist on each event of type {@link #getEventType()}.
+ */
+ public Set<Annotation> getQualifiers();
+}
Copied: modules/jms/trunk/impl/src/main/java/org/jboss/seam/jms/BridgedObserver.java (from rev 12692, modules/jms/branches/simple-forwarding/impl/src/main/java/org/jboss/seam/jms/BridgedObserver.java)
===================================================================
--- modules/jms/trunk/impl/src/main/java/org/jboss/seam/jms/BridgedObserver.java (rev 0)
+++ modules/jms/trunk/impl/src/main/java/org/jboss/seam/jms/BridgedObserver.java 2010-05-07 03:17:44 UTC (rev 12693)
@@ -0,0 +1,110 @@
+package org.jboss.seam.jms;
+
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Set;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.event.Reception;
+import javax.enterprise.event.TransactionPhase;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.ObserverMethod;
+import javax.inject.Named;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.Session;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Observer Method to observe events and forward (bridge) them over JMS.
+ *
+ * @author Jordan Ganoff
+ */
+@Named
+@ApplicationScoped
+public class BridgedObserver implements ObserverMethod<Object>
+{
+ private Logger log = LoggerFactory.getLogger(getClass());
+
+ private BeanManager bm;
+ private JmsForwarding config;
+
+ public BridgedObserver(BeanManager bm, JmsForwarding config)
+ {
+ this.bm = bm;
+ this.config = config;
+ }
+
+ public Class<?> getBeanClass()
+ {
+ return null;
+ }
+
+ public Set<Annotation> getObservedQualifiers()
+ {
+ return config.getQualifiers();
+ }
+
+ public Type getObservedType()
+ {
+ return config.getEventType();
+ }
+
+ public Reception getReception()
+ {
+ return Reception.ALWAYS;
+ }
+
+ public TransactionPhase getTransactionPhase()
+ {
+ return TransactionPhase.AFTER_SUCCESS;
+ }
+
+ public void notify(Object evt)
+ {
+ // FIXME Include qualifiers once CDI 1.0 MR is complete and
+ // notify(Event, Set<Annotation>) is added
+ forwardEvent(evt, null);
+ }
+
+ private void forwardEvent(Object event, Set<Annotation> qualifiers)
+ {
+ Set<Bean<?>> beans = bm.getBeans(Session.class);
+ Bean<?> bean = bm.resolve(beans);
+ Session s = (Session) bm.getReference(bean, Session.class, bm.createCreationalContext(bean));
+ try
+ {
+ for (Destination d : config.getDestinations())
+ {
+ try
+ {
+ Message m = s.createObjectMessage((Serializable) event);
+ // Safe to create producers here always? In an app server these
+ // should be cached via JCA managed connection factory but what
+ // about other environments?
+ s.createProducer(d).send(m);
+ }
+ catch (JMSException ex)
+ {
+ log.error("Unable to forward event", ex);
+ }
+ }
+ }
+ finally
+ {
+ try
+ {
+ s.close();
+ }
+ catch (JMSException ex)
+ {
+ log.error("Unable to close session", ex);
+ }
+ }
+ }
+}
Modified: modules/jms/trunk/impl/src/main/java/org/jboss/seam/jms/Seam3JmsExtension.java
===================================================================
--- modules/jms/trunk/impl/src/main/java/org/jboss/seam/jms/Seam3JmsExtension.java 2010-05-07 02:25:15 UTC (rev 12692)
+++ modules/jms/trunk/impl/src/main/java/org/jboss/seam/jms/Seam3JmsExtension.java 2010-05-07 03:17:44 UTC (rev 12693)
@@ -21,11 +21,19 @@
*/
package org.jboss.seam.jms;
+import java.util.Set;
+
+import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.AfterBeanDiscovery;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
import javax.enterprise.inject.spi.Extension;
import javax.enterprise.inject.spi.ProcessAnnotatedType;
import org.jboss.seam.jms.impl.wrapper.JmsAnnotatedTypeWrapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Seam 3 JMS Portable Extension
@@ -34,8 +42,34 @@
*/
public class Seam3JmsExtension implements Extension
{
+ private static final Logger log = LoggerFactory.getLogger(Seam3JmsExtension.class);
+
+ public void afterBeanDiscovery(@Observes AfterBeanDiscovery abd, BeanManager bm)
+ {
+ Set<Bean<?>> configuration = bm.getBeans(JmsForwarding.class);
+
+ if(configuration == null || configuration.isEmpty())
+ {
+ log.info("No {} registered. Event forwarding disabled.", JmsForwarding.class.getSimpleName());
+ } else
+ {
+ for(Bean<?> c : configuration)
+ {
+ log.info("Creating {} for configuration {}", BridgedObserver.class.getSimpleName(), c);
+ CreationalContext<?> context = bm.createCreationalContext(c);
+ // TODO Verify configuration for correctness (e.g. getQualifiers() must contain only @Qualifier annotations)
+ JmsForwarding config = JmsForwarding.class.cast(bm.getReference(c, JmsForwarding.class, context));
+ BridgedObserver b = new BridgedObserver(bm, config);
+ abd.addObserverMethod(b);
+ }
+ }
+ }
+
public <X> void decorateAnnotatedType(@Observes ProcessAnnotatedType<X> pat)
{
+ /**
+ * Flatten all @Annotated that define @JmsDestinations so that they may be injected
+ */
pat.setAnnotatedType(JmsAnnotatedTypeWrapper.decorate(pat.getAnnotatedType()));
}
}
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-05-07 02:25:15 UTC (rev 12692)
+++ modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/Util.java 2010-05-07 03:17:44 UTC (rev 12693)
@@ -52,4 +52,20 @@
return archive;
}
+
+ 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));
+ }
}
Copied: modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/bridge (from rev 12692, modules/jms/branches/simple-forwarding/impl/src/test/java/org/jboss/seam/jms/test/bridge)
Copied: modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple (from rev 12692, modules/jms/branches/simple-forwarding/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple)
Deleted: modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/Bridged.java
===================================================================
--- modules/jms/branches/simple-forwarding/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/Bridged.java 2010-05-07 02:25:15 UTC (rev 12692)
+++ modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/Bridged.java 2010-05-07 03:17:44 UTC (rev 12693)
@@ -1,49 +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.jms.test.bridge.simple;
-
-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.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import javax.inject.Qualifier;
-
-/**
- * Bridged Event Qualifer that denotes the implicit forwarding over JMS
- *
- * @author Jordan Ganoff
- */
-@Qualifier
-@Documented
-@Inherited
-@Target( { FIELD, METHOD, TYPE, PARAMETER })
-@Retention(RUNTIME)
-public @interface Bridged
-{
-}
\ No newline at end of file
Copied: modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/Bridged.java (from rev 12692, modules/jms/branches/simple-forwarding/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/Bridged.java)
===================================================================
--- modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/Bridged.java (rev 0)
+++ modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/Bridged.java 2010-05-07 03:17:44 UTC (rev 12693)
@@ -0,0 +1,49 @@
+/*
+ * 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.bridge.simple;
+
+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.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+/**
+ * Bridged Event Qualifer that denotes the implicit forwarding over JMS
+ *
+ * @author Jordan Ganoff
+ */
+@Qualifier
+@Documented
+@Inherited
+@Target( { FIELD, METHOD, TYPE, PARAMETER })
+@Retention(RUNTIME)
+public @interface Bridged
+{
+}
\ No newline at end of file
Deleted: modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/MyForwarding.java
===================================================================
--- modules/jms/branches/simple-forwarding/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/MyForwarding.java 2010-05-07 02:25:15 UTC (rev 12692)
+++ modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/MyForwarding.java 2010-05-07 03:17:44 UTC (rev 12693)
@@ -1,49 +0,0 @@
-package org.jboss.seam.jms.test.bridge.simple;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
-import java.util.Collections;
-import java.util.Set;
-
-import javax.enterprise.context.ApplicationScoped;
-import javax.enterprise.inject.Instance;
-import javax.enterprise.util.AnnotationLiteral;
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.jms.Destination;
-import javax.jms.Topic;
-
-import org.jboss.seam.jms.JmsForwarding;
-import org.jboss.seam.jms.annotations.JmsDestination;
-
-@Named
-@ApplicationScoped
-public class MyForwarding implements JmsForwarding
-{
- private static final Set<Annotation> BRIDGED = Collections.<Annotation> singleton(new AnnotationLiteral<Bridged>()
- {
- private static final long serialVersionUID = 1L;
- });
-
- // Use Instance<?> here to get around problem of topic not being deployed before Weld processes
- // deployment and tries to inject topics
- @Inject
- @JmsDestination(jndiName="jms/T")
- private Instance<Topic> t;
-
- public Set<? extends Destination> getDestinations()
- {
- return Collections.singleton(t.get());
- }
-
- public Type getEventType()
- {
- return Object.class;
- }
-
- public Set<Annotation> getQualifiers()
- {
- return BRIDGED;
- }
-
-}
Copied: modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/MyForwarding.java (from rev 12692, modules/jms/branches/simple-forwarding/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/MyForwarding.java)
===================================================================
--- modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/MyForwarding.java (rev 0)
+++ modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/MyForwarding.java 2010-05-07 03:17:44 UTC (rev 12693)
@@ -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.jms.test.bridge.simple;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Collections;
+import java.util.Set;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Instance;
+import javax.enterprise.util.AnnotationLiteral;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.jms.Destination;
+import javax.jms.Topic;
+
+import org.jboss.seam.jms.JmsForwarding;
+import org.jboss.seam.jms.annotations.JmsDestination;
+
+@Named
+@ApplicationScoped
+public class MyForwarding implements JmsForwarding
+{
+ private static final Set<Annotation> BRIDGED = Collections.<Annotation> singleton(new AnnotationLiteral<Bridged>()
+ {
+ private static final long serialVersionUID = 1L;
+ });
+
+ // Use Instance<?> here to get around problem of topic not being deployed before Weld processes
+ // deployment and tries to inject topics
+ @Inject
+ @JmsDestination(jndiName="jms/T")
+ private Instance<Topic> t;
+
+ public Set<? extends Destination> getDestinations()
+ {
+ return Collections.singleton(t.get());
+ }
+
+ public Type getEventType()
+ {
+ return Object.class;
+ }
+
+ public Set<Annotation> getQualifiers()
+ {
+ return BRIDGED;
+ }
+
+}
Deleted: modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/MyTopic.java
===================================================================
--- modules/jms/branches/simple-forwarding/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/MyTopic.java 2010-05-07 02:25:15 UTC (rev 12692)
+++ modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/MyTopic.java 2010-05-07 03:17:44 UTC (rev 12693)
@@ -1,12 +0,0 @@
-package org.jboss.seam.jms.test.bridge.simple;
-
-import javax.inject.Qualifier;
-
-import org.jboss.seam.jms.annotations.JmsDestination;
-
-@Qualifier
-@JmsDestination(jndiName="jms/T")
-public @interface MyTopic
-{
-
-}
Copied: modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/MyTopic.java (from rev 12692, modules/jms/branches/simple-forwarding/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/MyTopic.java)
===================================================================
--- modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/MyTopic.java (rev 0)
+++ modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/MyTopic.java 2010-05-07 03:17:44 UTC (rev 12693)
@@ -0,0 +1,33 @@
+/*
+ * 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.bridge.simple;
+
+import javax.inject.Qualifier;
+
+import org.jboss.seam.jms.annotations.JmsDestination;
+
+@Qualifier
+@JmsDestination(jndiName="jms/T")
+public @interface MyTopic
+{
+
+}
Deleted: modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/SimpleBridgedEventTest.java
===================================================================
--- modules/jms/branches/simple-forwarding/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/SimpleBridgedEventTest.java 2010-05-07 02:25:15 UTC (rev 12692)
+++ modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/SimpleBridgedEventTest.java 2010-05-07 03:17:44 UTC (rev 12693)
@@ -1,46 +0,0 @@
-package org.jboss.seam.jms.test.bridge.simple;
-
-import javax.enterprise.event.Event;
-import javax.inject.Inject;
-import javax.jms.Connection;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.ObjectMessage;
-import javax.jms.Session;
-import javax.jms.TopicSubscriber;
-
-import org.jboss.arquillian.api.Deployment;
-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.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-(a)RunWith(Arquillian.class)
-public class SimpleBridgedEventTest
-{
- @Deployment
- public static JavaArchive createDeployment()
- {
- return Util.createDeployment(SimpleBridgedEventTest.class);
- }
-
- @Inject Connection c;
- @Inject Session s;
- @Inject @JmsDestination(jndiName="jms/T") TopicSubscriber ts;
- @Inject @Bridged Event<String> event;
-
- @Test
- public void forwardSimpleEvent() throws JMSException
- {
- String expected = "test";
- c.start();
- event.fire(expected);
- Message m = ts.receive(3000);
- Assert.assertTrue(m != null);
- Assert.assertTrue(m instanceof ObjectMessage);
- Assert.assertEquals(expected, ((ObjectMessage) m).getObject());
- }
-}
Copied: modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/SimpleBridgedEventTest.java (from rev 12692, modules/jms/branches/simple-forwarding/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/SimpleBridgedEventTest.java)
===================================================================
--- modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/SimpleBridgedEventTest.java (rev 0)
+++ modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/SimpleBridgedEventTest.java 2010-05-07 03:17:44 UTC (rev 12693)
@@ -0,0 +1,67 @@
+/*
+ * 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.bridge.simple;
+
+import javax.enterprise.event.Event;
+import javax.inject.Inject;
+import javax.jms.Connection;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.ObjectMessage;
+import javax.jms.Session;
+import javax.jms.TopicSubscriber;
+
+import org.jboss.arquillian.api.Deployment;
+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.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+(a)RunWith(Arquillian.class)
+public class SimpleBridgedEventTest
+{
+ @Deployment
+ public static JavaArchive createDeployment()
+ {
+ return Util.createDeployment(SimpleBridgedEventTest.class);
+ }
+
+ @Inject Connection c;
+ @Inject Session s;
+ @Inject @JmsDestination(jndiName="jms/T") TopicSubscriber ts;
+ @Inject @Bridged Event<String> event;
+
+ @Test
+ public void forwardSimpleEvent() throws JMSException
+ {
+ String expected = "test";
+ c.start();
+ event.fire(expected);
+ Message m = ts.receive(3000);
+ Assert.assertTrue(m != null);
+ Assert.assertTrue(m instanceof ObjectMessage);
+ Assert.assertEquals(expected, ((ObjectMessage) m).getObject());
+ }
+}
13 years, 11 months
Seam SVN: r12692 - in modules/jms/branches/simple-forwarding/impl/src: test/java/org/jboss/seam/jms/test/bridge/simple and 1 other directory.
by seam-commits@lists.jboss.org
Author: jganoff
Date: 2010-05-06 22:25:15 -0400 (Thu, 06 May 2010)
New Revision: 12692
Modified:
modules/jms/branches/simple-forwarding/impl/src/main/java/org/jboss/seam/jms/BridgedObserver.java
modules/jms/branches/simple-forwarding/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/MyForwarding.java
Log:
Minor clean up of BridgedObserver. Fixed MyForwarding test to not try to inject topic immediately (before the topic has been deployed via Arquillian).
Modified: modules/jms/branches/simple-forwarding/impl/src/main/java/org/jboss/seam/jms/BridgedObserver.java
===================================================================
--- modules/jms/branches/simple-forwarding/impl/src/main/java/org/jboss/seam/jms/BridgedObserver.java 2010-05-07 02:11:48 UTC (rev 12691)
+++ modules/jms/branches/simple-forwarding/impl/src/main/java/org/jboss/seam/jms/BridgedObserver.java 2010-05-07 02:25:15 UTC (rev 12692)
@@ -74,37 +74,37 @@
private void forwardEvent(Object event, Set<Annotation> qualifiers)
{
- log.info("Forwarding event: {}", event);
- // p.forwardEvent(event, qualifiers);
-
- // for (EventPropagator p : ServiceLoader.load(EventPropagator.class))
- // {
- // p.forwardEvent(event, null);
- // }
-
+ Set<Bean<?>> beans = bm.getBeans(Session.class);
+ Bean<?> bean = bm.resolve(beans);
+ Session s = (Session) bm.getReference(bean, Session.class, bm.createCreationalContext(bean));
try
{
- Set<Bean<?>> beans = bm.getBeans(Session.class);// , new
- // AnnotationLiteral<org.jboss.seam.jms.annotations.Session>()
- // {});
- Bean<?> bean = bm.resolve(beans);
- Session s = (Session) bm.getReference(bean, Session.class, bm.createCreationalContext(bean));
- log.info("Forwarding with session {}", s);
- log.info("To destinations {}", config.getDestinations());
- // FIXME Cache producers
- for(Destination d : config.getDestinations())
+ for (Destination d : config.getDestinations())
{
- log.info("Forwarding to destination {}", d);
- Message m = s.createObjectMessage((Serializable) event);
- s.createProducer(d).send(m);
+ try
+ {
+ Message m = s.createObjectMessage((Serializable) event);
+ // Safe to create producers here always? In an app server these
+ // should be cached via JCA managed connection factory but what
+ // about other environments?
+ s.createProducer(d).send(m);
+ }
+ catch (JMSException ex)
+ {
+ log.error("Unable to forward event", ex);
+ }
}
-// s.close();
-
-
}
- catch (JMSException ex)
+ finally
{
- log.error("Unable to forward event", ex);
+ try
+ {
+ s.close();
+ }
+ catch (JMSException ex)
+ {
+ log.error("Unable to close session", ex);
+ }
}
}
}
Modified: modules/jms/branches/simple-forwarding/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/MyForwarding.java
===================================================================
--- modules/jms/branches/simple-forwarding/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/MyForwarding.java 2010-05-07 02:11:48 UTC (rev 12691)
+++ modules/jms/branches/simple-forwarding/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/MyForwarding.java 2010-05-07 02:25:15 UTC (rev 12692)
@@ -6,6 +6,7 @@
import java.util.Set;
import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Instance;
import javax.enterprise.util.AnnotationLiteral;
import javax.inject.Inject;
import javax.inject.Named;
@@ -24,13 +25,15 @@
private static final long serialVersionUID = 1L;
});
+ // Use Instance<?> here to get around problem of topic not being deployed before Weld processes
+ // deployment and tries to inject topics
@Inject
@JmsDestination(jndiName="jms/T")
- private Topic t;
+ private Instance<Topic> t;
public Set<? extends Destination> getDestinations()
{
- return Collections.singleton(t);
+ return Collections.singleton(t.get());
}
public Type getEventType()
13 years, 11 months
Seam SVN: r12691 - in modules/jms/branches/simple-forwarding: impl and 4 other directories.
by seam-commits@lists.jboss.org
Author: jganoff
Date: 2010-05-06 22:11:48 -0400 (Thu, 06 May 2010)
New Revision: 12691
Added:
modules/jms/branches/simple-forwarding/impl/src/test/java/org/jboss/seam/jms/test/transmit/
Removed:
modules/jms/branches/simple-forwarding/impl/src/test/java/org/jboss/seam/jms/test/instance/
Modified:
modules/jms/branches/simple-forwarding/impl/pom.xml
modules/jms/branches/simple-forwarding/impl/src/main/java/org/jboss/seam/jms/impl/inject/ConnectionProducer.java
modules/jms/branches/simple-forwarding/impl/src/test/java/org/jboss/seam/jms/test/inject/InjectConnectionTest.java
modules/jms/branches/simple-forwarding/impl/src/test/java/org/jboss/seam/jms/test/transmit/SimpleTransmitMessageTest.java
modules/jms/branches/simple-forwarding/pom.xml
Log:
Merged changes from trunk @ 12690
Modified: modules/jms/branches/simple-forwarding/impl/pom.xml
===================================================================
--- modules/jms/branches/simple-forwarding/impl/pom.xml 2010-05-07 01:55:26 UTC (rev 12690)
+++ modules/jms/branches/simple-forwarding/impl/pom.xml 2010-05-07 02:11:48 UTC (rev 12691)
@@ -1,66 +1,97 @@
<?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>
+ 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</groupId>
- <artifactId>seam-jms-parent</artifactId>
- <version>3.0.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
+ <parent>
+ <groupId>org.jboss.seam</groupId>
+ <artifactId>seam-jms-parent</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
- <artifactId>seam-jms-impl</artifactId>
- <name>Seam JMS Implementation</name>
- <description>Implementation of the Seam JMS Module</description>
+ <artifactId>seam-jms-impl</artifactId>
+ <name>Seam JMS Implementation</name>
+ <description>Implementation of the Seam JMS Module</description>
- <properties>
- <arquillian.version>1.0.0.Alpha1</arquillian.version>
- </properties>
+ <properties>
+ <arquillian.version>1.0.0.Alpha1</arquillian.version>
+ </properties>
- <dependencies>
- <dependency>
- <groupId>javax.enterprise</groupId>
- <artifactId>cdi-api</artifactId>
- <scope>provided</scope>
- </dependency>
+ <dependencies>
+ <dependency>
+ <groupId>javax.enterprise</groupId>
+ <artifactId>cdi-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
- <dependency>
- <groupId>org.jboss.seam</groupId>
- <artifactId>seam-jms</artifactId>
- </dependency>
+ <dependency>
+ <groupId>org.jboss.seam</groupId>
+ <artifactId>seam-jms</artifactId>
+ </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>
- <version>4.8.1</version>
- <scope>test</scope>
- </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
- <dependency>
- <groupId>org.jboss.arquillian</groupId>
- <artifactId>arquillian-junit</artifactId>
- <version>${arquillian.version}</version>
- <scope>test</scope>
- </dependency>
+ <dependency>
+ <groupId>org.jboss.arquillian</groupId>
+ <artifactId>arquillian-junit</artifactId>
+ <version>${arquillian.version}</version>
+ <scope>test</scope>
+ </dependency>
- <dependency>
- <groupId>org.jboss.arquillian.container</groupId>
- <artifactId>arquillian-jbossas-remote-60</artifactId>
- <version>${arquillian.version}</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
+ <dependency>
+ <groupId>org.jboss.arquillian.container</groupId>
+ <artifactId>arquillian-jbossas-remote-60</artifactId>
+ <version>${arquillian.version}</version>
+ <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>
+ </profiles>
+
</project>
Modified: modules/jms/branches/simple-forwarding/impl/src/main/java/org/jboss/seam/jms/impl/inject/ConnectionProducer.java
===================================================================
--- modules/jms/branches/simple-forwarding/impl/src/main/java/org/jboss/seam/jms/impl/inject/ConnectionProducer.java 2010-05-07 01:55:26 UTC (rev 12690)
+++ modules/jms/branches/simple-forwarding/impl/src/main/java/org/jboss/seam/jms/impl/inject/ConnectionProducer.java 2010-05-07 02:11:48 UTC (rev 12691)
@@ -31,15 +31,16 @@
import org.jboss.seam.jms.annotations.Module;
-public @ApplicationScoped
-class ConnectionProducer
+public class ConnectionProducer
{
@Produces
+ @ApplicationScoped
@Module
@Resource(mappedName = "ConnectionFactory")
private ConnectionFactory cf;
@Produces
+ @ApplicationScoped
public Connection getConnection() throws Exception
{
return cf.createConnection();
Modified: modules/jms/branches/simple-forwarding/impl/src/test/java/org/jboss/seam/jms/test/inject/InjectConnectionTest.java
===================================================================
--- modules/jms/branches/simple-forwarding/impl/src/test/java/org/jboss/seam/jms/test/inject/InjectConnectionTest.java 2010-05-07 01:55:26 UTC (rev 12690)
+++ modules/jms/branches/simple-forwarding/impl/src/test/java/org/jboss/seam/jms/test/inject/InjectConnectionTest.java 2010-05-07 02:11:48 UTC (rev 12691)
@@ -46,6 +46,9 @@
@Inject
private Instance<Connection> c;
+
+ @Inject
+ private Instance<Connection> c2;
@Inject
private Instance<Session> s;
@@ -61,5 +64,11 @@
{
Assert.assertNotNull(s.get());
}
+
+ @Test
+ public void sameConnection()
+ {
+ Assert.assertEquals(c.get(), c2.get());
+ }
}
Copied: modules/jms/branches/simple-forwarding/impl/src/test/java/org/jboss/seam/jms/test/transmit (from rev 12690, modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/transmit)
Modified: modules/jms/branches/simple-forwarding/impl/src/test/java/org/jboss/seam/jms/test/transmit/SimpleTransmitMessageTest.java
===================================================================
Modified: modules/jms/branches/simple-forwarding/pom.xml
===================================================================
--- modules/jms/branches/simple-forwarding/pom.xml 2010-05-07 01:55:26 UTC (rev 12690)
+++ modules/jms/branches/simple-forwarding/pom.xml 2010-05-07 02:11:48 UTC (rev 12691)
@@ -1,97 +1,252 @@
<?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>
+ 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.weld</groupId>
- <artifactId>weld-parent</artifactId>
- <version>9</version>
- </parent>
+ <parent>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>weld-parent</artifactId>
+ <version>9</version>
+ </parent>
- <groupId>org.jboss.seam</groupId>
- <artifactId>seam-jms-parent</artifactId>
- <packaging>pom</packaging>
- <name>Seam JMS Parent</name>
- <version>3.0.0-SNAPSHOT</version>
+ <groupId>org.jboss.seam</groupId>
+ <artifactId>seam-jms-parent</artifactId>
+ <packaging>pom</packaging>
+ <name>Seam JMS Parent</name>
+ <version>3.0.0-SNAPSHOT</version>
- <url>http://sfwk.org/Seam3/JMSModule</url>
-
- <properties>
- <seam.jms.version>3.0.0-SNAPSHOT</seam.jms.version>
- <weld.api.version>1.0-SP1</weld.api.version>
- </properties>
+ <url>http://sfwk.org/Seam3/JMSModule</url>
- <modules>
- <module>api</module>
- <module>impl</module>
- <module>docs/reference</module>
- <!--
+ <properties>
+ <seam.jms.version>3.0.0-SNAPSHOT</seam.jms.version>
+ <weld.api.version>1.0-SP1</weld.api.version>
+ <emma.maven.plugin.version>1.0-alpha-2</emma.maven.plugin.version>
+ <emma4it.maven.plugin.version>1.3</emma4it.maven.plugin.version>
+ <jboss.maven.plugin.version>1.4</jboss.maven.plugin.version>
+ <maven.antrun.plugin.version>1.3</maven.antrun.plugin.version>
+ <cargo.maven2.plugin.version>1.0-beta-2</cargo.maven2.plugin.version>
+ </properties>
+
+ <modules>
+ <module>api</module>
+ <module>impl</module>
+ <module>docs/reference</module>
+ <!--
<module>examples</module>
-->
- </modules>
+ </modules>
- <!-- Only build the distribution if requested explicitly -->
- <profiles>
- <profile>
- <id>distribution</id>
- <modules>
- <module>dist</module>
- </modules>
- </profile>
- </profiles>
-
- <developers>
- <developer>
- <name>Jordan Ganoff</name>
- <email>jganoff(a)gmail.com</email>
- <timezone>EST</timezone>
- <roles>
- <role>Project Lead</role>
- </roles>
- </developer>
- </developers>
+ <!-- Only build the distribution if requested explicitly -->
+ <profiles>
+ <profile>
+ <id>distribution</id>
+ <modules>
+ <module>dist</module>
+ </modules>
+ </profile>
+ <profile>
+ <id>code-coverage</id>
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>emma-maven-plugin</artifactId>
+ <version>${emma.maven.plugin.version}</version>
+ <inherited>true</inherited>
+ <executions>
+ <execution>
+ <id>instrumentation</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>instrument</goal>
+ </goals>
+ <configuration>
+ <verbose>true</verbose>
+ </configuration>
+ </execution>
+ <execution>
+ <id>cleaning</id>
+ <phase>clean</phase>
+ <goals>
+ <goal>clean</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
- <dependencyManagement>
- <dependencies>
- <dependency>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <inherited>true</inherited>
+ <configuration>
+ <forkMode>once</forkMode>
+ <classesDirectory>${project.build.directory}/generated-classes/emma/classes</classesDirectory>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.cargo</groupId>
+ <artifactId>cargo-maven2-plugin</artifactId>
+ <version>${cargo.maven2.plugin.version}</version>
+ <executions>
+ <execution>
+ <id>start-container</id>
+ <phase>process-test-classes</phase>
+ <goals>
+ <goal>start</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>stop-container</id>
+ <phase>test</phase>
+ <goals>
+ <goal>stop</goal>
+ </goals>
+ </execution>
+ </executions>
+
+ <configuration>
+ <wait>false</wait>
+ <container>
+ <containerId>jboss5x</containerId>
+ <home>${env.JBOSS_HOME}</home>
+ <timeout>300000</timeout> <!-- 5 minutes -->
+ </container>
+ <configuration>
+ <type>existing</type>
+ <home>${env.JBOSS_HOME}/server/default</home>
+ <properties>
+ <cargo.jboss.configuration>default</cargo.jboss.configuration>
+ <cargo.rmi.port>1099</cargo.rmi.port>
+ </properties>
+ </configuration>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>${maven.antrun.plugin.version}</version>
+ <executions>
+ <execution>
+ <id>deploy-emma-jar</id>
+ <phase>process-test-sources</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <echo message="Deploying emma jar to server lib directory" />
+ <copy file="${emma.jar.file}" todir="${env.JBOSS_HOME}/server/default/lib"
+ overwrite="true" />
+ </tasks>
+ </configuration>
+ </execution>
+ <execution>
+ <id>retrieve-coverage-file</id>
+ <phase>test</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <echo
+ message="Moving coverage.ec file to current modele from parent module" />
+ <property name="coverage.file" value="${basedir}/../coverage.ec" />
+ <waitfor maxwait="30" maxwaitunit="second">
+ <available file="${coverage.file}" />
+ </waitfor>
+ <move file="${coverage.file}" todir="${basedir}"
+ failonerror="false" />
+ <delete file="${basedir}/transaction.log" failonerror="false" />
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.sonatype.maven.plugin</groupId>
+ <artifactId>emma4it-maven-plugin</artifactId>
+ <version>${emma4it.maven.plugin.version}</version>
+ <executions>
+ <execution>
+ <id>report</id>
+ <phase>test</phase>
+ <goals>
+ <goal>report</goal>
+ </goals>
+ <configuration>
+ <sourceSets>
+ <sourceSet>
+ <directory>${project.build.sourceDirectory}</directory>
+ </sourceSet>
+ </sourceSets>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+ </profile>
+ </profiles>
+
+ <developers>
+ <developer>
+ <name>Jordan Ganoff</name>
+ <email>jganoff(a)gmail.com</email>
+ <timezone>EST</timezone>
+ <roles>
+ <role>Project Lead</role>
+ </roles>
+ </developer>
+ </developers>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-api-bom</artifactId>
<version>${weld.api.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
-
- <dependency>
- <groupId>javax.jms</groupId>
- <artifactId>jms</artifactId>
- <version>1.1</version>
- </dependency>
- <dependency>
- <groupId>org.jboss.weld</groupId>
- <artifactId>weld-extensions</artifactId>
- <version>1.0.0.Alpha1</version>
- </dependency>
+ <dependency>
+ <groupId>javax.jms</groupId>
+ <artifactId>jms</artifactId>
+ <version>1.1</version>
+ </dependency>
- <!-- Modules defined again here to prevent need to explicitly specify version where used -->
- <dependency>
- <groupId>org.jboss.seam</groupId>
- <artifactId>seam-jms</artifactId>
- <version>${seam.jms.version}</version>
- </dependency>
+ <dependency>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>weld-extensions</artifactId>
+ <version>1.0.0.Alpha1</version>
+ </dependency>
- <dependency>
- <groupId>org.jboss.seam</groupId>
- <artifactId>seam-jms-impl</artifactId>
- <version>${seam.jms.version}</version>
- </dependency>
- </dependencies>
- </dependencyManagement>
+ <!--
+ Modules defined again here to prevent need to explicitly specify
+ version where used
+ -->
+ <dependency>
+ <groupId>org.jboss.seam</groupId>
+ <artifactId>seam-jms</artifactId>
+ <version>${seam.jms.version}</version>
+ </dependency>
- <scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/seam/modules/jms/trunk</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/seam/modules/jms/trunk</developerConnection>
- <url>http://fisheye.jboss.org/browse/Seam/modules/jms/trunk</url>
- </scm>
+ <dependency>
+ <groupId>org.jboss.seam</groupId>
+ <artifactId>seam-jms-impl</artifactId>
+ <version>${seam.jms.version}</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <scm>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/seam/modules/jms/trunk</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/seam/modules/jms/trunk</developerConnection>
+ <url>http://fisheye.jboss.org/browse/Seam/modules/jms/trunk</url>
+ </scm>
</project>
13 years, 11 months
Seam SVN: r12690 - in modules/jms/trunk/impl/src: test/java/org/jboss/seam/jms/test and 2 other directories.
by seam-commits@lists.jboss.org
Author: jganoff
Date: 2010-05-06 21:55:26 -0400 (Thu, 06 May 2010)
New Revision: 12690
Added:
modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/transmit/
modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/transmit/SimpleTransmitMessageTest.java
Removed:
modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/instance/
Modified:
modules/jms/trunk/impl/src/main/java/org/jboss/seam/jms/impl/inject/ConnectionProducer.java
modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/InjectConnectionTest.java
Log:
javax.jms.Connection is not produced @ApplicationScoped as intended. Simple send message tests added.
Modified: modules/jms/trunk/impl/src/main/java/org/jboss/seam/jms/impl/inject/ConnectionProducer.java
===================================================================
--- modules/jms/trunk/impl/src/main/java/org/jboss/seam/jms/impl/inject/ConnectionProducer.java 2010-05-07 00:33:56 UTC (rev 12689)
+++ modules/jms/trunk/impl/src/main/java/org/jboss/seam/jms/impl/inject/ConnectionProducer.java 2010-05-07 01:55:26 UTC (rev 12690)
@@ -31,15 +31,16 @@
import org.jboss.seam.jms.annotations.Module;
-public @ApplicationScoped
-class ConnectionProducer
+public class ConnectionProducer
{
@Produces
+ @ApplicationScoped
@Module
@Resource(mappedName = "ConnectionFactory")
private ConnectionFactory cf;
@Produces
+ @ApplicationScoped
public Connection getConnection() throws Exception
{
return cf.createConnection();
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-05-07 00:33:56 UTC (rev 12689)
+++ modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/InjectConnectionTest.java 2010-05-07 01:55:26 UTC (rev 12690)
@@ -46,6 +46,9 @@
@Inject
private Instance<Connection> c;
+
+ @Inject
+ private Instance<Connection> c2;
@Inject
private Instance<Session> s;
@@ -61,5 +64,11 @@
{
Assert.assertNotNull(s.get());
}
+
+ @Test
+ public void sameConnection()
+ {
+ Assert.assertEquals(c.get(), c2.get());
+ }
}
Added: 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 (rev 0)
+++ modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/transmit/SimpleTransmitMessageTest.java 2010-05-07 01:55:26 UTC (rev 12690)
@@ -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.jms.test.transmit;
+
+import javax.enterprise.inject.Instance;
+import javax.inject.Inject;
+import javax.jms.Connection;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+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.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+(a)RunWith(Arquillian.class)
+public class SimpleTransmitMessageTest
+{
+ @Deployment
+ public static JavaArchive createDeployment()
+ {
+ JavaArchive a = Util.createDeployment(SimpleTransmitMessageTest.class);
+ a.addPackage(InjectMessageConsumer.class.getPackage());
+ return a;
+ }
+
+ @Inject
+ private Connection c;
+
+ @Inject
+ private Session s;
+
+ @Inject
+ private Instance<InjectMessageConsumer> imc;
+
+ @Inject
+ private Instance<InjectMessageProducer> imp;
+
+ @Test
+ public void sendMessage_topic() throws JMSException
+ {
+ sendMessage(imp.get().getTp(), imc.get().getTs());
+ }
+
+ @Test
+ public void sendMessage_queue() throws JMSException
+ {
+ sendMessage(imp.get().getQs(), imc.get().getQr());
+ }
+
+ private void sendMessage(MessageProducer mp, MessageConsumer mc) throws JMSException
+ {
+ String expected = "test";
+ Message m = s.createTextMessage(expected);
+ c.start();
+ try
+ {
+ mp.send(m);
+ Message received = mc.receive(3000);
+ Assert.assertNotNull(received);
+ Assert.assertTrue(received instanceof TextMessage);
+ TextMessage tm = TextMessage.class.cast(received);
+ Assert.assertEquals(expected, tm.getText());
+ } finally
+ {
+ c.stop();
+ }
+ }
+}
13 years, 11 months
Seam SVN: r12689 - in modules/jms/branches/simple-forwarding: api/src/main/java/org/jboss/seam/jms/annotations and 2 other directories.
by seam-commits@lists.jboss.org
Author: jganoff
Date: 2010-05-06 20:33:56 -0400 (Thu, 06 May 2010)
New Revision: 12689
Added:
modules/jms/branches/simple-forwarding/api/src/main/java/org/jboss/seam/jms/JmsForwarding.java
modules/jms/branches/simple-forwarding/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/Bridged.java
modules/jms/branches/simple-forwarding/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/MyForwarding.java
Removed:
modules/jms/branches/simple-forwarding/api/src/main/java/org/jboss/seam/jms/annotations/Bridged.java
Modified:
modules/jms/branches/simple-forwarding/impl/src/main/java/org/jboss/seam/jms/BridgedObserver.java
modules/jms/branches/simple-forwarding/impl/src/main/java/org/jboss/seam/jms/Seam3JmsExtension.java
modules/jms/branches/simple-forwarding/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/SimpleBridgedEventTest.java
Log:
Ironing out bridging configuration. Does not work yet due to producer scope issues. Will fix in trunk and merge back here.
Added: modules/jms/branches/simple-forwarding/api/src/main/java/org/jboss/seam/jms/JmsForwarding.java
===================================================================
--- modules/jms/branches/simple-forwarding/api/src/main/java/org/jboss/seam/jms/JmsForwarding.java (rev 0)
+++ modules/jms/branches/simple-forwarding/api/src/main/java/org/jboss/seam/jms/JmsForwarding.java 2010-05-07 00:33:56 UTC (rev 12689)
@@ -0,0 +1,55 @@
+/*
+ * 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;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Set;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Named;
+import javax.jms.Destination;
+
+/**
+ * Configuration for the forwarding of events to JMS.
+ *
+ * @author Jordan Ganoff
+ */
+@Named
+@ApplicationScoped
+public interface JmsForwarding
+{
+ /**
+ * Destinations to forward events to.
+ */
+ public Set<? extends Destination> getDestinations();
+
+ /**
+ * Event type to observe and forward.
+ */
+ public Type getEventType();
+
+ /**
+ * Set of qualifiers that must exist on each event of type {@link #getEventType()}.
+ */
+ public Set<Annotation> getQualifiers();
+}
Deleted: modules/jms/branches/simple-forwarding/api/src/main/java/org/jboss/seam/jms/annotations/Bridged.java
===================================================================
--- modules/jms/branches/simple-forwarding/api/src/main/java/org/jboss/seam/jms/annotations/Bridged.java 2010-05-06 22:16:27 UTC (rev 12688)
+++ modules/jms/branches/simple-forwarding/api/src/main/java/org/jboss/seam/jms/annotations/Bridged.java 2010-05-07 00:33:56 UTC (rev 12689)
@@ -1,28 +0,0 @@
-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.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import javax.inject.Qualifier;
-
-/**
- * Bridged Event
- *
- * @author Jordan Ganoff
- */
-@Qualifier
-@Documented
-@Inherited
-@Target( { FIELD, METHOD, TYPE, PARAMETER })
-@Retention(RUNTIME)
-public @interface Bridged
-{
-}
\ No newline at end of file
Modified: modules/jms/branches/simple-forwarding/impl/src/main/java/org/jboss/seam/jms/BridgedObserver.java
===================================================================
--- modules/jms/branches/simple-forwarding/impl/src/main/java/org/jboss/seam/jms/BridgedObserver.java 2010-05-06 22:16:27 UTC (rev 12688)
+++ modules/jms/branches/simple-forwarding/impl/src/main/java/org/jboss/seam/jms/BridgedObserver.java 2010-05-07 00:33:56 UTC (rev 12689)
@@ -3,21 +3,20 @@
import java.io.Serializable;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
-import java.util.Collections;
import java.util.Set;
+import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.event.Reception;
import javax.enterprise.event.TransactionPhase;
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager;
import javax.enterprise.inject.spi.ObserverMethod;
-import javax.enterprise.util.AnnotationLiteral;
+import javax.inject.Named;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;
-import org.jboss.seam.jms.annotations.Bridged;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -26,22 +25,19 @@
*
* @author Jordan Ganoff
*/
+@Named
+@ApplicationScoped
public class BridgedObserver implements ObserverMethod<Object>
{
private Logger log = LoggerFactory.getLogger(getClass());
- private static final Set<Annotation> BRIDGED = Collections.<Annotation> singleton(new AnnotationLiteral<Bridged>()
- {
- private static final long serialVersionUID = 1L;
- });
-
private BeanManager bm;
- private Destination destination;
- private Set<Annotation> qualifiers;
+ private JmsForwarding config;
- public BridgedObserver(BeanManager bm)
+ public BridgedObserver(BeanManager bm, JmsForwarding config)
{
this.bm = bm;
+ this.config = config;
}
public Class<?> getBeanClass()
@@ -51,13 +47,12 @@
public Set<Annotation> getObservedQualifiers()
{
- // Note, annotation MUST be @Qualifier. No error given but will not work!
- return BRIDGED;
+ return config.getQualifiers();
}
public Type getObservedType()
{
- return Object.class;
+ return config.getEventType();
}
public Reception getReception()
@@ -79,7 +74,7 @@
private void forwardEvent(Object event, Set<Annotation> qualifiers)
{
- log.info("Forwarding event {}", event);
+ log.info("Forwarding event: {}", event);
// p.forwardEvent(event, qualifiers);
// for (EventPropagator p : ServiceLoader.load(EventPropagator.class))
@@ -95,10 +90,17 @@
Bean<?> bean = bm.resolve(beans);
Session s = (Session) bm.getReference(bean, Session.class, bm.createCreationalContext(bean));
log.info("Forwarding with session {}", s);
- log.info("To destination {}", destination);
- Message m = s.createObjectMessage((Serializable) event);
- s.createProducer(destination).send(m);
- s.close();
+ log.info("To destinations {}", config.getDestinations());
+ // FIXME Cache producers
+ for(Destination d : config.getDestinations())
+ {
+ log.info("Forwarding to destination {}", d);
+ Message m = s.createObjectMessage((Serializable) event);
+ s.createProducer(d).send(m);
+ }
+// s.close();
+
+
}
catch (JMSException ex)
{
Modified: modules/jms/branches/simple-forwarding/impl/src/main/java/org/jboss/seam/jms/Seam3JmsExtension.java
===================================================================
--- modules/jms/branches/simple-forwarding/impl/src/main/java/org/jboss/seam/jms/Seam3JmsExtension.java 2010-05-06 22:16:27 UTC (rev 12688)
+++ modules/jms/branches/simple-forwarding/impl/src/main/java/org/jboss/seam/jms/Seam3JmsExtension.java 2010-05-07 00:33:56 UTC (rev 12689)
@@ -21,13 +21,19 @@
*/
package org.jboss.seam.jms;
+import java.util.Set;
+
+import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.event.Observes;
import javax.enterprise.inject.spi.AfterBeanDiscovery;
+import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager;
import javax.enterprise.inject.spi.Extension;
import javax.enterprise.inject.spi.ProcessAnnotatedType;
import org.jboss.seam.jms.impl.wrapper.JmsAnnotatedTypeWrapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Seam 3 JMS Portable Extension
@@ -36,11 +42,27 @@
*/
public class Seam3JmsExtension implements Extension
{
+ private static final Logger log = LoggerFactory.getLogger(Seam3JmsExtension.class);
+
public void afterBeanDiscovery(@Observes AfterBeanDiscovery abd, BeanManager bm)
{
- // Temporary creation of bridged overserver (This should be changed to allow configuration from XML)
- BridgedObserver b = new BridgedObserver(bm);
- abd.addObserverMethod(b);
+ Set<Bean<?>> configuration = bm.getBeans(JmsForwarding.class);
+
+ if(configuration == null || configuration.isEmpty())
+ {
+ log.info("No {} registered. Event forwarding disabled.", JmsForwarding.class.getSimpleName());
+ } else
+ {
+ for(Bean<?> c : configuration)
+ {
+ log.info("Creating {} for configuration {}", BridgedObserver.class.getSimpleName(), c);
+ CreationalContext<?> context = bm.createCreationalContext(c);
+ // TODO Verify configuration for correctness (e.g. getQualifiers() must contain only @Qualifier annotations)
+ JmsForwarding config = JmsForwarding.class.cast(bm.getReference(c, JmsForwarding.class, context));
+ BridgedObserver b = new BridgedObserver(bm, config);
+ abd.addObserverMethod(b);
+ }
+ }
}
public <X> void decorateAnnotatedType(@Observes ProcessAnnotatedType<X> pat)
Copied: modules/jms/branches/simple-forwarding/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/Bridged.java (from rev 12682, modules/jms/branches/simple-forwarding/api/src/main/java/org/jboss/seam/jms/annotations/Bridged.java)
===================================================================
--- modules/jms/branches/simple-forwarding/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/Bridged.java (rev 0)
+++ modules/jms/branches/simple-forwarding/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/Bridged.java 2010-05-07 00:33:56 UTC (rev 12689)
@@ -0,0 +1,49 @@
+/*
+ * 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.bridge.simple;
+
+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.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+/**
+ * Bridged Event Qualifer that denotes the implicit forwarding over JMS
+ *
+ * @author Jordan Ganoff
+ */
+@Qualifier
+@Documented
+@Inherited
+@Target( { FIELD, METHOD, TYPE, PARAMETER })
+@Retention(RUNTIME)
+public @interface Bridged
+{
+}
\ No newline at end of file
Added: modules/jms/branches/simple-forwarding/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/MyForwarding.java
===================================================================
--- modules/jms/branches/simple-forwarding/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/MyForwarding.java (rev 0)
+++ modules/jms/branches/simple-forwarding/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/MyForwarding.java 2010-05-07 00:33:56 UTC (rev 12689)
@@ -0,0 +1,46 @@
+package org.jboss.seam.jms.test.bridge.simple;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Collections;
+import java.util.Set;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.util.AnnotationLiteral;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.jms.Destination;
+import javax.jms.Topic;
+
+import org.jboss.seam.jms.JmsForwarding;
+import org.jboss.seam.jms.annotations.JmsDestination;
+
+@Named
+@ApplicationScoped
+public class MyForwarding implements JmsForwarding
+{
+ private static final Set<Annotation> BRIDGED = Collections.<Annotation> singleton(new AnnotationLiteral<Bridged>()
+ {
+ private static final long serialVersionUID = 1L;
+ });
+
+ @Inject
+ @JmsDestination(jndiName="jms/T")
+ private Topic t;
+
+ public Set<? extends Destination> getDestinations()
+ {
+ return Collections.singleton(t);
+ }
+
+ public Type getEventType()
+ {
+ return Object.class;
+ }
+
+ public Set<Annotation> getQualifiers()
+ {
+ return BRIDGED;
+ }
+
+}
Modified: modules/jms/branches/simple-forwarding/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/SimpleBridgedEventTest.java
===================================================================
--- modules/jms/branches/simple-forwarding/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/SimpleBridgedEventTest.java 2010-05-06 22:16:27 UTC (rev 12688)
+++ modules/jms/branches/simple-forwarding/impl/src/test/java/org/jboss/seam/jms/test/bridge/simple/SimpleBridgedEventTest.java 2010-05-07 00:33:56 UTC (rev 12689)
@@ -5,14 +5,12 @@
import javax.jms.Connection;
import javax.jms.JMSException;
import javax.jms.Message;
-import javax.jms.MessageConsumer;
import javax.jms.ObjectMessage;
import javax.jms.Session;
-import javax.jms.Topic;
+import javax.jms.TopicSubscriber;
import org.jboss.arquillian.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.seam.jms.annotations.Bridged;
import org.jboss.seam.jms.annotations.JmsDestination;
import org.jboss.seam.jms.test.Util;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
@@ -31,24 +29,16 @@
@Inject Connection c;
@Inject Session s;
- @Inject @JmsDestination(jndiName="jms/T") Topic t;
-
+ @Inject @JmsDestination(jndiName="jms/T") TopicSubscriber ts;
@Inject @Bridged Event<String> event;
@Test
- public void a()
- {
-
- }
-
- @Test
public void forwardSimpleEvent() throws JMSException
{
String expected = "test";
- MessageConsumer mc = s.createConsumer(t);
c.start();
event.fire(expected);
- Message m = mc.receive();
+ Message m = ts.receive(3000);
Assert.assertTrue(m != null);
Assert.assertTrue(m instanceof ObjectMessage);
Assert.assertEquals(expected, ((ObjectMessage) m).getObject());
13 years, 11 months
Seam SVN: r12688 - in modules/servlet/trunk: impl/src/main/java/org/jboss/seam/servlet/http and 1 other directory.
by seam-commits@lists.jboss.org
Author: lincolnthree
Date: 2010-05-06 18:16:27 -0400 (Thu, 06 May 2010)
New Revision: 12688
Modified:
modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/http/HttpServletEnvironmentProducer.java
modules/servlet/trunk/pom.xml
Log:
Fixed Servlet Listener ordering issues - still need to fix Weld/AppServers/JavaEE
Modified: modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/http/HttpServletEnvironmentProducer.java
===================================================================
--- modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/http/HttpServletEnvironmentProducer.java 2010-05-06 22:04:23 UTC (rev 12687)
+++ modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/http/HttpServletEnvironmentProducer.java 2010-05-06 22:16:27 UTC (rev 12688)
@@ -23,6 +23,7 @@
import java.io.Serializable;
+import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.event.Observes;
import javax.enterprise.inject.Produces;
@@ -30,9 +31,7 @@
import javax.servlet.ServletRequestEvent;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
-import javax.servlet.http.HttpSessionEvent;
-import org.jboss.seam.servlet.event.qualifier.Created;
import org.jboss.seam.servlet.event.qualifier.Destroyed;
import org.jboss.seam.servlet.event.qualifier.Initialized;
import org.slf4j.Logger;
@@ -43,42 +42,41 @@
* @author Nicklas Karlsson
*
*/
-@RequestScoped
+@ApplicationScoped
public class HttpServletEnvironmentProducer implements Serializable
{
private static final long serialVersionUID = 1L;
- private HttpSession session;
- private HttpServletRequest request;
+ private final ThreadLocal<HttpSession> session = new ThreadLocal<HttpSession>();
+ private final ThreadLocal<HttpServletRequest> request = new ThreadLocal<HttpServletRequest>();
@Inject
private Logger log;
- protected void requestInitialized(@Observes @Initialized ServletRequestEvent e)
+ protected void requestInitialized(@Observes @Initialized final ServletRequestEvent e)
{
log.trace("Servlet request initialized with event #0", e);
- request = (HttpServletRequest) e.getServletRequest();
- session = request.getSession();
+ request.set((HttpServletRequest) e.getServletRequest());
+ session.set(request.get().getSession());
}
- protected void requestDestroyed(@Observes @Destroyed ServletRequestEvent e)
+ protected void requestDestroyed(@Observes @Destroyed final ServletRequestEvent e)
{
log.trace("Servlet request destroyed with event #0", e);
- request = null;
}
@Produces
@RequestScoped
protected HttpSession getSession()
{
- return session;
+ return session.get();
}
@Produces
@RequestScoped
protected HttpServletRequest getRequest()
{
- return request;
+ return request.get();
}
}
Modified: modules/servlet/trunk/pom.xml
===================================================================
--- modules/servlet/trunk/pom.xml 2010-05-06 22:04:23 UTC (rev 12687)
+++ modules/servlet/trunk/pom.xml 2010-05-06 22:16:27 UTC (rev 12688)
@@ -3,9 +3,9 @@
<modelVersion>4.0.0</modelVersion>
<parent>
- <artifactId>seam-parent</artifactId>
- <groupId>org.jboss.seam</groupId>
- <version>3.0.0-SNAPSHOT</version>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>weld-parent</artifactId>
+ <version>9</version>
</parent>
<artifactId>seam-servlet-parent</artifactId>
@@ -27,9 +27,9 @@
<properties>
<arquillian.version>1.0.0.Alpha1</arquillian.version>
- <weld.version>1.0.1-Final</weld.version>
+ <weld.api.version>1.0-SP1</weld.api.version>
<weldx.version>1.0.0-SNAPSHOT</weldx.version>
- </properties>
+ </properties>
<repositories>
<repository>
@@ -44,6 +44,18 @@
</repository>
</repositories>
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>weld-api-bom</artifactId>
+ <version>${weld.api.version}</version>
+ <scope>import</scope>
+ <type>pom</type>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
<dependencies>
<!-- Environment Dependencies -->
@@ -67,14 +79,9 @@
<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-extensions</artifactId>
- <version>${weldx.version}</version>
+ <version>${weldx.version}</version>
<scope>provided</scope>
</dependency>
- <dependency>
- <groupId>org.jboss.weld</groupId>
- <artifactId>weld-core</artifactId>
- <version>${weld.version}</version>
- </dependency>
<!-- Test Dependencies -->
<dependency>
13 years, 11 months
Seam SVN: r12687 - in modules/drools/trunk: api and 17 other directories.
by seam-commits@lists.jboss.org
Author: tsurdilovic
Date: 2010-05-06 18:04:23 -0400 (Thu, 06 May 2010)
New Revision: 12687
Added:
modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/Stateful.java
modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/Stateless.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/StatefulKnowledgeSessionWrapper.java
Modified:
modules/drools/trunk/api/pom.xml
modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/FactProvider.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/ExecutionResultsProducer.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeAgentProducer.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeBaseProducer.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeSessionProducer.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/InsertFact.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/flow/SignalEvent.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/flow/StartProcess.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/DroolsConfig.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/interceptor/InsertFactInterceptor.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/interceptor/SignalEventInterceptor.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/interceptor/StartProcessInterceptor.java
modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/utils/ConfigUtils.java
modules/drools/trunk/impl/src/main/resources/META-INF/beans.xml
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/cep/CEPTest.java
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/delegate/DelegateTest.java
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/flow/FlowTest.java
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/interceptors/InterceptorsTest.java
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/interceptors/InterceptorsTestBean.java
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kagent/KAgentTest.java
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kbase/KBaseTest.java
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/ksession/KSessionTest.java
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/query/QueryFactProvider.java
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/query/QueryTest.java
modules/drools/trunk/pom.xml
Log:
updated to weld extensions api changes. changed back to weld-parent.
Modified: modules/drools/trunk/api/pom.xml
===================================================================
--- modules/drools/trunk/api/pom.xml 2010-05-06 16:06:11 UTC (rev 12686)
+++ modules/drools/trunk/api/pom.xml 2010-05-06 22:04:23 UTC (rev 12687)
@@ -76,6 +76,10 @@
<artifactId>drools-workitems</artifactId>
</dependency>
<dependency>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-transformer-xstream</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-extensions</artifactId>
<version>1.0.0-SNAPSHOT</version>
Modified: modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/FactProvider.java
===================================================================
--- modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/FactProvider.java 2010-05-06 16:06:11 UTC (rev 12686)
+++ modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/FactProvider.java 2010-05-06 22:04:23 UTC (rev 12687)
@@ -41,4 +41,8 @@
public List<String> getQueries();
public void setQueries(List<String> queries);
+
+ public String getBatchXml();
+
+ public void setBatchXml(String batchXml);
}
Added: modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/Stateful.java
===================================================================
--- modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/Stateful.java (rev 0)
+++ modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/Stateful.java 2010-05-06 22:04:23 UTC (rev 12687)
@@ -0,0 +1,48 @@
+/*
+ * 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.drools.qualifiers;
+
+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.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+/**
+ *
+ * @author Tihomir Surdilovic
+ */
+@Qualifier
+@Target( { TYPE, METHOD, FIELD, PARAMETER })
+@Documented
+@Retention(RUNTIME)
+@Inherited
+public @interface Stateful {
+
+}
Added: modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/Stateless.java
===================================================================
--- modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/Stateless.java (rev 0)
+++ modules/drools/trunk/api/src/main/java/org/jboss/seam/drools/qualifiers/Stateless.java 2010-05-06 22:04:23 UTC (rev 12687)
@@ -0,0 +1,48 @@
+/*
+ * 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.drools.qualifiers;
+
+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.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+/**
+ *
+ * @author Tihomir Surdilovic
+ */
+@Qualifier
+@Target( { TYPE, METHOD, FIELD, PARAMETER })
+@Documented
+@Retention(RUNTIME)
+@Inherited
+public @interface Stateless {
+
+}
Modified: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/ExecutionResultsProducer.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/ExecutionResultsProducer.java 2010-05-06 16:06:11 UTC (rev 12686)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/ExecutionResultsProducer.java 2010-05-06 22:04:23 UTC (rev 12687)
@@ -35,10 +35,20 @@
import org.drools.command.CommandFactory;
import org.drools.runtime.ExecutionResults;
+import org.drools.runtime.StatefulKnowledgeSession;
import org.drools.runtime.StatelessKnowledgeSession;
+import org.drools.runtime.help.BatchExecutionHelper;
+import org.drools.runtime.pipeline.Action;
+import org.drools.runtime.pipeline.KnowledgeRuntimeCommand;
+import org.drools.runtime.pipeline.Pipeline;
+import org.drools.runtime.pipeline.PipelineFactory;
+import org.drools.runtime.pipeline.ResultHandler;
+import org.drools.runtime.pipeline.Transformer;
import org.jboss.seam.drools.bootstrap.DroolsExtension;
import org.jboss.seam.drools.qualifiers.Scanned;
-import org.jboss.weld.extensions.resources.ResourceProvider;
+import org.jboss.seam.drools.qualifiers.Stateful;
+import org.jboss.seam.drools.qualifiers.Stateless;
+import org.jboss.weld.extensions.resourceLoader.ResourceProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -62,19 +72,82 @@
@SuppressWarnings("unchecked")
@Produces
+ @Stateless
@RequestScoped
- public ExecutionResults produceExecutionResults(StatelessKnowledgeSession ksession) {
+ public ExecutionResults produceStatelessExecutionResults(StatelessKnowledgeSession ksession) {
return ksession.execute(CommandFactory.newBatchExecution(getCommandList()));
}
@SuppressWarnings("unchecked")
@Produces
+ @Stateless
@Scanned
@RequestScoped
- public ExecutionResults produceScannedExecutionResults(@Scanned StatelessKnowledgeSession ksession) {
+ public ExecutionResults produceStatelessScannedExecutionResults(@Scanned StatelessKnowledgeSession ksession) {
return ksession.execute(CommandFactory.newBatchExecution(getCommandList()));
}
+ @Produces
+ @Stateful
+ @RequestScoped
+ public ExecutionResults produceStateFulExecutionResults(StatefulKnowledgeSession ksession) {
+ ResultHandlerImpl resultsHandler = new ResultHandlerImpl();
+ Pipeline pip = getPipelineStateful(ksession);
+ Iterator<FactProvider> iter = droolsExtension.getFactProviderSet().iterator();
+ while(iter.hasNext())
+ {
+ FactProvider factProvider = iter.next();
+ if(factProvider.getBatchXml() != null) {
+ pip.insert(factProvider.getBatchXml(), resultsHandler);
+ }
+ }
+
+ return (ExecutionResults) BatchExecutionHelper.newXStreamMarshaller().fromXML((String) resultsHandler.getObject());
+ }
+
+ @Produces
+ @Stateful
+ @Scanned
+ @RequestScoped
+ public ExecutionResults produceStateFulScannedExecutionResults(@Scanned StatefulKnowledgeSession ksession) {
+ ResultHandlerImpl resultsHandler = new ResultHandlerImpl();
+ Pipeline pip = getPipelineStateful(ksession);
+ Iterator<FactProvider> iter = droolsExtension.getFactProviderSet().iterator();
+ while(iter.hasNext())
+ {
+ FactProvider factProvider = iter.next();
+ if(factProvider.getBatchXml() != null) {
+ pip.insert(factProvider.getBatchXml(), resultsHandler);
+ }
+ }
+
+ return (ExecutionResults) BatchExecutionHelper.newXStreamMarshaller().fromXML((String) resultsHandler.getObject());
+
+ }
+
+ private Pipeline getPipelineStateful(StatefulKnowledgeSession ksession)
+ {
+ Action executeResultHandler = PipelineFactory.newExecuteResultHandler();
+
+ Action assignResult = PipelineFactory.newAssignObjectAsResult();
+ assignResult.setReceiver(executeResultHandler);
+
+ Transformer outTransformer = PipelineFactory.newXStreamToXmlTransformer(BatchExecutionHelper.newXStreamMarshaller());
+ outTransformer.setReceiver(assignResult);
+
+ KnowledgeRuntimeCommand batchExecution = PipelineFactory.newCommandExecutor();
+ batchExecution.setReceiver(outTransformer);
+
+ Transformer inTransformer = PipelineFactory.newXStreamFromXmlTransformer(BatchExecutionHelper.newXStreamMarshaller());
+ inTransformer.setReceiver(batchExecution);
+
+ Pipeline pipeline = PipelineFactory.newStatefulKnowledgeSessionPipeline(ksession);
+ pipeline.setReceiver(inTransformer);
+
+ return pipeline;
+ }
+
+
@SuppressWarnings("unchecked")
private List getCommandList() {
List commandList = new ArrayList();
@@ -104,5 +177,22 @@
return commandList;
}
+ public static class ResultHandlerImpl implements ResultHandler
+ {
+ Object object;
+ public void handleResult(Object object)
+ {
+ this.object = object;
+ }
+
+ public Object getObject()
+ {
+ return this.object;
+ }
+
+ }
+
+
+
}
Modified: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeAgentProducer.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeAgentProducer.java 2010-05-06 16:06:11 UTC (rev 12686)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeAgentProducer.java 2010-05-06 22:04:23 UTC (rev 12687)
@@ -38,7 +38,7 @@
import org.jboss.seam.drools.config.DroolsConfig;
import org.jboss.seam.drools.config.RuleResources;
import org.jboss.seam.drools.qualifiers.Scanned;
-import org.jboss.weld.extensions.resources.ResourceProvider;
+import org.jboss.weld.extensions.resourceLoader.ResourceProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Modified: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeBaseProducer.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeBaseProducer.java 2010-05-06 16:06:11 UTC (rev 12686)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeBaseProducer.java 2010-05-06 22:04:23 UTC (rev 12687)
@@ -47,7 +47,7 @@
import org.jboss.seam.drools.config.RuleResources;
import org.jboss.seam.drools.events.KnowledgeBuilderErrorsEvent;
import org.jboss.seam.drools.events.RuleResourceAddedEvent;
-import org.jboss.weld.extensions.resources.ResourceProvider;
+import org.jboss.weld.extensions.resourceLoader.ResourceProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Modified: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeSessionProducer.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeSessionProducer.java 2010-05-06 16:06:11 UTC (rev 12686)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/KnowledgeSessionProducer.java 2010-05-06 22:04:23 UTC (rev 12687)
@@ -43,7 +43,7 @@
import org.jboss.seam.drools.bootstrap.DroolsExtension;
import org.jboss.seam.drools.config.DroolsConfig;
import org.jboss.seam.drools.qualifiers.Scanned;
-import org.jboss.weld.extensions.resources.ResourceProvider;
+import org.jboss.weld.extensions.resourceLoader.ResourceProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Added: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/StatefulKnowledgeSessionWrapper.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/StatefulKnowledgeSessionWrapper.java (rev 0)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/StatefulKnowledgeSessionWrapper.java 2010-05-06 22:04:23 UTC (rev 12687)
@@ -0,0 +1,328 @@
+/*
+ * 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.drools;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.Collection;
+import java.util.Map;
+
+import org.drools.KnowledgeBase;
+import org.drools.command.Command;
+import org.drools.event.process.ProcessEventListener;
+import org.drools.event.rule.AgendaEventListener;
+import org.drools.event.rule.WorkingMemoryEventListener;
+import org.drools.runtime.Environment;
+import org.drools.runtime.ExecutionResults;
+import org.drools.runtime.ExitPoint;
+import org.drools.runtime.Globals;
+import org.drools.runtime.ObjectFilter;
+import org.drools.runtime.StatefulKnowledgeSession;
+import org.drools.runtime.process.ProcessInstance;
+import org.drools.runtime.process.WorkItemManager;
+import org.drools.runtime.rule.Agenda;
+import org.drools.runtime.rule.AgendaFilter;
+import org.drools.runtime.rule.FactHandle;
+import org.drools.runtime.rule.QueryResults;
+import org.drools.runtime.rule.WorkingMemoryEntryPoint;
+import org.drools.time.SessionClock;
+
+/**
+ *
+ * @author Tihomir Surdilovic
+ */
+public class StatefulKnowledgeSessionWrapper implements StatefulKnowledgeSession, Externalizable
+{
+ private StatefulKnowledgeSession ksession;
+
+ public StatefulKnowledgeSessionWrapper(StatefulKnowledgeSession ksession)
+ {
+ this.ksession = ksession;
+ }
+
+ public StatefulKnowledgeSessionWrapper()
+ {
+
+ }
+
+ public StatefulKnowledgeSession getKsession()
+ {
+ return ksession;
+ }
+
+ public void setKsession(StatefulKnowledgeSession ksession)
+ {
+ this.ksession = ksession;
+ }
+
+ public void dispose()
+ {
+ ksession.dispose();
+ }
+
+ public int getId()
+ {
+ return ksession.getId();
+ }
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public FactHandle getFactHandle(Object object)
+ {
+ return ksession.getFactHandle(object);
+ }
+
+ public <T extends FactHandle> Collection<T> getFactHandles()
+ {
+ return ksession.getFactHandles();
+ }
+
+ public <T extends FactHandle> Collection<T> getFactHandles(ObjectFilter filter)
+ {
+ return ksession.getFactHandles(filter);
+ }
+
+ public Object getObject(FactHandle factHandle)
+ {
+ return ksession.getObject(factHandle);
+ }
+
+ public Collection<Object> getObjects()
+ {
+ return ksession.getObjects();
+ }
+
+ public Collection<Object> getObjects(ObjectFilter filter)
+ {
+ return ksession.getObjects(filter);
+ }
+
+ public FactHandle insert(Object object)
+ {
+ return ksession.insert(object);
+ }
+
+ public void retract(FactHandle handle)
+ {
+ ksession.retract(handle);
+ }
+
+ public void update(FactHandle handle, Object object)
+ {
+ ksession.update(handle, object);
+ }
+
+ public void abortProcessInstance(long id)
+ {
+ ksession.abortProcessInstance(id);
+ }
+
+ public ProcessInstance getProcessInstance(long id)
+ {
+ return ksession.getProcessInstance(id);
+ }
+
+ public Collection<ProcessInstance> getProcessInstances()
+ {
+ return ksession.getProcessInstances();
+ }
+
+ public WorkItemManager getWorkItemManager()
+ {
+ return ksession.getWorkItemManager();
+ }
+
+ public void signalEvent(String type, Object event)
+ {
+ ksession.signalEvent(type, event);
+ }
+
+ public ProcessInstance startProcess(String processId, Map<String, Object> parameters)
+ {
+ return ksession.startProcess(processId, parameters);
+ }
+
+ public ProcessInstance startProcess(String processId)
+ {
+ return ksession.startProcess(processId);
+ }
+
+ public int fireAllRules()
+ {
+ return ksession.fireAllRules();
+ }
+
+ public int fireAllRules(AgendaFilter agendaFilter)
+ {
+ return ksession.fireAllRules(agendaFilter);
+ }
+
+ public int fireAllRules(int max)
+ {
+ return ksession.fireAllRules(max);
+ }
+
+ public void fireUntilHalt()
+ {
+ ksession.fireUntilHalt();
+ }
+
+ public void fireUntilHalt(AgendaFilter agendaFilter)
+ {
+ ksession.fireUntilHalt(agendaFilter);
+ }
+
+ public Environment getEnvironment()
+ {
+ return ksession.getEnvironment();
+ }
+
+ public Object getGlobal(String identifier)
+ {
+ return ksession.getGlobal(identifier);
+ }
+
+ public Globals getGlobals()
+ {
+ return ksession.getGlobals();
+ }
+
+ public KnowledgeBase getKnowledgeBase()
+ {
+ return ksession.getKnowledgeBase();
+ }
+
+ public <T extends SessionClock> T getSessionClock()
+ {
+ // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6302954
+ return ksession.<T>getSessionClock();
+ }
+
+ public void registerExitPoint(String name, ExitPoint exitPoint)
+ {
+ ksession.registerExitPoint(name, exitPoint);
+ }
+
+ public void setGlobal(String identifier, Object object)
+ {
+ ksession.setGlobal(identifier, object);
+ }
+
+ public void unregisterExitPoint(String name)
+ {
+ ksession.unregisterExitPoint(name);
+ }
+
+ public void addEventListener(ProcessEventListener listener)
+ {
+ ksession.addEventListener(listener);
+ }
+
+ public Collection<ProcessEventListener> getProcessEventListeners()
+ {
+ return ksession.getProcessEventListeners();
+ }
+
+ public void removeEventListener(ProcessEventListener listener)
+ {
+ ksession.removeEventListener(listener);
+ }
+
+ @SuppressWarnings("unchecked")
+ public ExecutionResults execute(Command command)
+ {
+ return ksession.execute(command);
+ }
+
+ public void addEventListener(AgendaEventListener listener)
+ {
+ ksession.addEventListener(listener);
+ }
+
+ public void addEventListener(WorkingMemoryEventListener listener)
+ {
+ ksession.addEventListener(listener);
+ }
+
+ public Collection<AgendaEventListener> getAgendaEventListeners()
+ {
+ return ksession.getAgendaEventListeners();
+ }
+
+ public Collection<WorkingMemoryEventListener> getWorkingMemoryEventListeners()
+ {
+ return ksession.getWorkingMemoryEventListeners();
+ }
+
+ public void removeEventListener(AgendaEventListener listener)
+ {
+ ksession.removeEventListener(listener);
+ }
+
+ public void removeEventListener(WorkingMemoryEventListener listener)
+ {
+ ksession.removeEventListener(listener);
+ }
+
+ public Agenda getAgenda()
+ {
+ return ksession.getAgenda();
+ }
+
+ public QueryResults getQueryResults(String query, Object[] arguments)
+ {
+ return ksession.getQueryResults(query, arguments);
+ }
+
+ public QueryResults getQueryResults(String query)
+ {
+ return ksession.getQueryResults(query);
+ }
+
+ public WorkingMemoryEntryPoint getWorkingMemoryEntryPoint(String name)
+ {
+ return ksession.getWorkingMemoryEntryPoint(name);
+ }
+
+ public Collection<? extends WorkingMemoryEntryPoint> getWorkingMemoryEntryPoints()
+ {
+ return ksession.getWorkingMemoryEntryPoints();
+ }
+
+ public void halt()
+ {
+ ksession.halt();
+ }
+
+}
Modified: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/InsertFact.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/InsertFact.java 2010-05-06 16:06:11 UTC (rev 12686)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/InsertFact.java 2010-05-06 22:04:23 UTC (rev 12687)
@@ -18,7 +18,7 @@
* 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.drools.annotations;
import static java.lang.annotation.ElementType.METHOD;
@@ -43,7 +43,15 @@
@Retention(RUNTIME)
public @interface InsertFact
{
- @Nonbinding boolean fire() default false;
- @Nonbinding boolean untilHalt() default false;
- @Nonbinding String entrypoint() default "";
+ @Nonbinding
+ boolean fire() default false;
+
+ @Nonbinding
+ boolean untilHalt() default false;
+
+ @Nonbinding
+ String entrypoint() default "";
+
+ @Nonbinding
+ boolean allEntryPoints() default false;
}
Modified: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/flow/SignalEvent.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/flow/SignalEvent.java 2010-05-06 16:06:11 UTC (rev 12686)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/flow/SignalEvent.java 2010-05-06 22:04:23 UTC (rev 12687)
@@ -51,4 +51,7 @@
@Nonbinding
String processName() default "";
+
+ @Nonbinding
+ String processId() default "";
}
Modified: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/flow/StartProcess.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/flow/StartProcess.java 2010-05-06 16:06:11 UTC (rev 12686)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/annotations/flow/StartProcess.java 2010-05-06 22:04:23 UTC (rev 12687)
@@ -44,7 +44,7 @@
public @interface StartProcess
{
@Nonbinding
- String name() default "";
+ String processName() default "";
@Nonbinding
boolean fire() default false;
Modified: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/DroolsConfig.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/DroolsConfig.java 2010-05-06 16:06:11 UTC (rev 12686)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/config/DroolsConfig.java 2010-05-06 22:04:23 UTC (rev 12687)
@@ -41,7 +41,8 @@
import org.drools.io.ResourceFactory;
import org.drools.runtime.KnowledgeSessionConfiguration;
import org.jboss.seam.drools.utils.ConfigUtils;
-import org.jboss.weld.extensions.resources.ResourceProvider;
+import org.jboss.weld.extensions.resourceLoader.ResourceProvider;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Modified: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/interceptor/InsertFactInterceptor.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/interceptor/InsertFactInterceptor.java 2010-05-06 16:06:11 UTC (rev 12686)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/interceptor/InsertFactInterceptor.java 2010-05-06 22:04:23 UTC (rev 12687)
@@ -18,11 +18,12 @@
* 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.drools.interceptor;
import java.lang.annotation.Annotation;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
import javax.enterprise.inject.Any;
@@ -34,6 +35,7 @@
import javax.interceptor.InvocationContext;
import org.drools.runtime.StatefulKnowledgeSession;
+import org.drools.runtime.rule.WorkingMemoryEntryPoint;
import org.jboss.seam.drools.annotations.InsertFact;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -44,52 +46,77 @@
{
@Inject
BeanManager manager;
-
- @Inject @Any Instance<StatefulKnowledgeSession> ksessionSource;
-
+
+ @Inject
+ @Any
+ Instance<StatefulKnowledgeSession> ksessionSource;
+
private static final Logger log = LoggerFactory.getLogger(InsertFactInterceptor.class);
-
@AroundInvoke
public Object insertFact(InvocationContext ctx) throws Exception
{
boolean fire = false;
boolean untilHalt = false;
String entryPointName = null;
-
+ boolean allEntryPoints = false;
+
Annotation[] methodAnnotations = ctx.getMethod().getAnnotations();
List<Annotation> annotationTypeList = new ArrayList<Annotation>();
-
- for(Annotation nextAnnotation : methodAnnotations) {
- if(manager.isQualifier(nextAnnotation.annotationType())) {
+
+ for (Annotation nextAnnotation : methodAnnotations)
+ {
+ if (manager.isQualifier(nextAnnotation.annotationType()))
+ {
annotationTypeList.add(nextAnnotation);
}
- if(manager.isInterceptorBinding(nextAnnotation.annotationType())) {
- if(nextAnnotation instanceof InsertFact) {
+ if (manager.isInterceptorBinding(nextAnnotation.annotationType()))
+ {
+ if (nextAnnotation instanceof InsertFact)
+ {
fire = ((InsertFact) nextAnnotation).fire();
untilHalt = ((InsertFact) nextAnnotation).untilHalt();
entryPointName = ((InsertFact) nextAnnotation).entrypoint();
+ allEntryPoints = ((InsertFact) nextAnnotation).allEntryPoints();
}
}
}
-
- StatefulKnowledgeSession ksession = ksessionSource.select((Annotation[])annotationTypeList.toArray(new Annotation[annotationTypeList.size()])).get();
- if(ksession != null) {
+
+ StatefulKnowledgeSession ksession = ksessionSource.select((Annotation[]) annotationTypeList.toArray(new Annotation[annotationTypeList.size()])).get();
+ if (ksession != null)
+ {
Object retObj = ctx.proceed();
- if(entryPointName != null && entryPointName.length() > 0 ) {
+ if (entryPointName != null && entryPointName.length() > 0)
+ {
ksession.getWorkingMemoryEntryPoint(entryPointName).insert(retObj);
- } else {
+ }
+ else if (allEntryPoints)
+ {
+ Iterator<? extends WorkingMemoryEntryPoint> iter = ksession.getWorkingMemoryEntryPoints().iterator();
+ while(iter.hasNext()) {
+ WorkingMemoryEntryPoint ep = iter.next();
+ ep.insert(retObj);
+ }
+ }
+ else
+ {
ksession.insert(retObj);
}
- if(fire) {
- if(untilHalt) {
-
- } else {
+ if (fire)
+ {
+ if (untilHalt)
+ {
+ ksession.fireUntilHalt();
+ }
+ else
+ {
ksession.fireAllRules();
}
}
return retObj;
- } else {
+ }
+ else
+ {
log.info("Could not obtain StatefulKnowledgeSession.");
return ctx.proceed();
}
Modified: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/interceptor/SignalEventInterceptor.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/interceptor/SignalEventInterceptor.java 2010-05-06 16:06:11 UTC (rev 12686)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/interceptor/SignalEventInterceptor.java 2010-05-06 22:04:23 UTC (rev 12687)
@@ -61,6 +61,7 @@
public Object signalEvent(InvocationContext ctx) throws Exception
{
String processName = null;
+ String processId = null;
String type = null;
String event = null;
@@ -78,6 +79,7 @@
if (nextAnnotation instanceof SignalEvent)
{
processName = ((SignalEvent) nextAnnotation).processName();
+ processId = ((SignalEvent) nextAnnotation).processId();
type = ((SignalEvent) nextAnnotation).type();
event = ((SignalEvent) nextAnnotation).event();
}
@@ -109,6 +111,12 @@
}
}
}
+ else if(processId != null && processId.length() > 0) {
+ ProcessInstance pi = ksession.getProcessInstance(Long.parseLong(processId));
+ if(pi != null) {
+ pi.signalEvent(type, event);
+ }
+ }
else
{
if (event != null && event.length() > 0)
Modified: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/interceptor/StartProcessInterceptor.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/interceptor/StartProcessInterceptor.java 2010-05-06 16:06:11 UTC (rev 12686)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/interceptor/StartProcessInterceptor.java 2010-05-06 22:04:23 UTC (rev 12687)
@@ -65,7 +65,7 @@
}
if(manager.isInterceptorBinding(nextAnnotation.annotationType())) {
if(nextAnnotation instanceof StartProcess) {
- processName = ((StartProcess) nextAnnotation).name();
+ processName = ((StartProcess) nextAnnotation).processName();
fire = ((StartProcess) nextAnnotation).fire();
untilHalt = ((StartProcess) nextAnnotation).untilHalt();
}
Modified: modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/utils/ConfigUtils.java
===================================================================
--- modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/utils/ConfigUtils.java 2010-05-06 16:06:11 UTC (rev 12686)
+++ modules/drools/trunk/impl/src/main/java/org/jboss/seam/drools/utils/ConfigUtils.java 2010-05-06 22:04:23 UTC (rev 12687)
@@ -26,8 +26,9 @@
import java.util.Properties;
import java.util.regex.Pattern;
-import org.jboss.weld.extensions.resources.ResourceProvider;
+import org.jboss.weld.extensions.resourceLoader.ResourceProvider;
+
/**
*
* @author Tihomir Surdilovic
Modified: modules/drools/trunk/impl/src/main/resources/META-INF/beans.xml
===================================================================
--- modules/drools/trunk/impl/src/main/resources/META-INF/beans.xml 2010-05-06 16:06:11 UTC (rev 12686)
+++ modules/drools/trunk/impl/src/main/resources/META-INF/beans.xml 2010-05-06 22:04:23 UTC (rev 12687)
@@ -216,7 +216,7 @@
<d:ExecutionResultsProducer>
<s:specializes />
- <d:produceExecutionResults>
+ <d:produceStatelessExecutionResults>
<s:ApplyQualifiers />
<s:parameters>
<drools:StatelessKnowledgeSession>
@@ -224,8 +224,8 @@
<s:ApplyQualifiers />
</drools:StatelessKnowledgeSession>
</s:parameters>
- </d:produceExecutionResults>
- <d:produceScannedExecutionResults>
+ </d:produceStatelessExecutionResults>
+ <d:produceStatelessScannedExecutionResults>
<s:ApplyQualifiers />
<s:parameters>
<drools:StatelessKnowledgeSession>
@@ -233,7 +233,25 @@
<s:ApplyQualifiers />
</drools:StatelessKnowledgeSession>
</s:parameters>
- </d:produceScannedExecutionResults>
+ </d:produceStatelessScannedExecutionResults>
+ <d:produceStateFulExecutionResults>
+ <s:ApplyQualifiers />
+ <s:parameters>
+ <drools:StatefulKnowledgeSession>
+ <s:Inject />
+ <s:ApplyQualifiers />
+ </drools:StatefulKnowledgeSession>
+ </s:parameters>
+ </d:produceStateFulExecutionResults>
+ <d:produceStateFulScannedExecutionResults>
+ <s:ApplyQualifiers />
+ <s:parameters>
+ <drools:StatefulKnowledgeSession>
+ <s:Inject />
+ <s:ApplyQualifiers />
+ </drools:StatefulKnowledgeSession>
+ </s:parameters>
+ </d:produceStateFulScannedExecutionResults>
</d:ExecutionResultsProducer>
<d:QueryResultsProducer>
Modified: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/cep/CEPTest.java
===================================================================
--- modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/cep/CEPTest.java 2010-05-06 16:06:11 UTC (rev 12686)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/cep/CEPTest.java 2010-05-06 22:04:23 UTC (rev 12687)
@@ -42,7 +42,7 @@
import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
-import org.jboss.weld.extensions.resources.ResourceProvider;
+import org.jboss.weld.extensions.resourceLoader.ResourceProvider;
import org.junit.Test;
import org.junit.runner.RunWith;
Modified: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/delegate/DelegateTest.java
===================================================================
--- modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/delegate/DelegateTest.java 2010-05-06 16:06:11 UTC (rev 12686)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/delegate/DelegateTest.java 2010-05-06 22:04:23 UTC (rev 12687)
@@ -37,7 +37,7 @@
import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
-import org.jboss.weld.extensions.resources.ResourceProvider;
+import org.jboss.weld.extensions.resourceLoader.ResourceProvider;
import org.junit.Test;
import org.junit.runner.RunWith;
Modified: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/flow/FlowTest.java
===================================================================
--- modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/flow/FlowTest.java 2010-05-06 16:06:11 UTC (rev 12686)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/flow/FlowTest.java 2010-05-06 22:04:23 UTC (rev 12687)
@@ -40,7 +40,7 @@
import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
-import org.jboss.weld.extensions.resources.ResourceProvider;
+import org.jboss.weld.extensions.resourceLoader.ResourceProvider;
import org.junit.Test;
import org.junit.runner.RunWith;
Modified: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/interceptors/InterceptorsTest.java
===================================================================
--- modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/interceptors/InterceptorsTest.java 2010-05-06 16:06:11 UTC (rev 12686)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/interceptors/InterceptorsTest.java 2010-05-06 22:04:23 UTC (rev 12687)
@@ -42,7 +42,7 @@
import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
-import org.jboss.weld.extensions.resources.ResourceProvider;
+import org.jboss.weld.extensions.resourceLoader.ResourceProvider;
import org.junit.Test;
import org.junit.runner.RunWith;
Modified: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/interceptors/InterceptorsTestBean.java
===================================================================
--- modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/interceptors/InterceptorsTestBean.java 2010-05-06 16:06:11 UTC (rev 12686)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/interceptors/InterceptorsTestBean.java 2010-05-06 22:04:23 UTC (rev 12687)
@@ -56,7 +56,7 @@
return p;
}
- @StartProcess(name="interceptorstestflow", fire=true) @Default @InterceptorsTestConfig
+ @StartProcess(processName="interceptorstestflow", fire=true) @Default @InterceptorsTestConfig
public void startProcess() {
// this will start the process....
}
Modified: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kagent/KAgentTest.java
===================================================================
--- modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kagent/KAgentTest.java 2010-05-06 16:06:11 UTC (rev 12686)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kagent/KAgentTest.java 2010-05-06 22:04:23 UTC (rev 12687)
@@ -42,7 +42,7 @@
import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
-import org.jboss.weld.extensions.resources.ResourceProvider;
+import org.jboss.weld.extensions.resourceLoader.ResourceProvider;
import org.junit.Test;
import org.junit.runner.RunWith;
Modified: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kbase/KBaseTest.java
===================================================================
--- modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kbase/KBaseTest.java 2010-05-06 16:06:11 UTC (rev 12686)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/kbase/KBaseTest.java 2010-05-06 22:04:23 UTC (rev 12687)
@@ -37,7 +37,7 @@
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.formatter.Formatters;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
-import org.jboss.weld.extensions.resources.ResourceProvider;
+import org.jboss.weld.extensions.resourceLoader.ResourceProvider;
import org.junit.Test;
import org.junit.runner.RunWith;
Modified: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/ksession/KSessionTest.java
===================================================================
--- modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/ksession/KSessionTest.java 2010-05-06 16:06:11 UTC (rev 12686)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/ksession/KSessionTest.java 2010-05-06 22:04:23 UTC (rev 12687)
@@ -40,7 +40,7 @@
import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
-import org.jboss.weld.extensions.resources.ResourceProvider;
+import org.jboss.weld.extensions.resourceLoader.ResourceProvider;
import org.junit.Test;
import org.junit.runner.RunWith;
Modified: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/query/QueryFactProvider.java
===================================================================
--- modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/query/QueryFactProvider.java 2010-05-06 16:06:11 UTC (rev 12686)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/query/QueryFactProvider.java 2010-05-06 22:04:23 UTC (rev 12687)
@@ -79,6 +79,16 @@
{
}
+
+ public String getBatchXml()
+ {
+ return null;
+ }
+
+ public void setBatchXml(String batchXml)
+ {
+
+ }
Modified: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/query/QueryTest.java
===================================================================
--- modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/query/QueryTest.java 2010-05-06 16:06:11 UTC (rev 12686)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/query/QueryTest.java 2010-05-06 22:04:23 UTC (rev 12687)
@@ -35,12 +35,13 @@
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.seam.drools.KnowledgeBaseProducer;
import org.jboss.seam.drools.qualifiers.Query;
+import org.jboss.seam.drools.qualifiers.Stateless;
import org.jboss.seam.drools.qualifiers.config.DefaultConfig;
import org.jboss.seam.drools.test.DroolsModuleFilter;
import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
-import org.jboss.weld.extensions.resources.ResourceProvider;
+import org.jboss.weld.extensions.resourceLoader.ResourceProvider;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -67,7 +68,7 @@
// cannot yet move to test method arguments (ARQ-120)
@Inject @Default @DefaultConfig @Query("number of adults") QueryResults adultsQuery;
@Inject @Default @DefaultConfig @Query("number of minors") QueryResults minorsQuery;
- @Inject @Default @DefaultConfig ExecutionResults executionResults;
+ @Inject @Default @Stateless @DefaultConfig ExecutionResults executionResults;
@Test
public void testQuery() {
Modified: modules/drools/trunk/pom.xml
===================================================================
--- modules/drools/trunk/pom.xml 2010-05-06 16:06:11 UTC (rev 12686)
+++ modules/drools/trunk/pom.xml 2010-05-06 22:04:23 UTC (rev 12687)
@@ -3,9 +3,9 @@
<modelVersion>4.0.0</modelVersion>
<parent>
- <artifactId>seam-parent</artifactId>
- <groupId>org.jboss.seam</groupId>
- <version>3.0.0-SNAPSHOT</version>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>weld-parent</artifactId>
+ <version>9</version>
</parent>
<groupId>org.jboss.seam.drools</groupId>
@@ -107,6 +107,11 @@
<version>5.1.0.M1</version>
</dependency>
<dependency>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-transformer-xstream</artifactId>
+ <version>5.1.0.M1</version>
+ </dependency>
+ <dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-extensions</artifactId>
<version>1.0.0.Alpha1</version>
13 years, 11 months