This is an automated email from the ASF dual-hosted git repository.

jgallimore pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomee.git

commit 3a0508cc058f6c2f12ba8aff307f02cc6b0604d6
Author: Jonathan Gallimore <[email protected]>
AuthorDate: Wed Dec 2 21:30:53 2020 +0000

    New example
---
 examples/rest-sse-example/README.adoc              | 605 +++++++++++++++++++++
 examples/rest-sse-example/pom.xml                  | 130 +++++
 .../org/superbiz/rest/service/JmsResource.java     |  42 ++
 .../org/superbiz/rest/service/TopicListener.java   |  23 +
 .../src/main/resources/META-INF/beans.xml          |  18 +
 .../src/main/resources/META-INF/resources.xml      |  31 ++
 .../src/main/webapp/WEB-INF/beans.xml              |  17 +
 .../src/main/webapp/WEB-INF/web.xml                |  25 +
 8 files changed, 891 insertions(+)

diff --git a/examples/rest-sse-example/README.adoc 
b/examples/rest-sse-example/README.adoc
new file mode 100644
index 0000000..47e14f6
--- /dev/null
+++ b/examples/rest-sse-example/README.adoc
@@ -0,0 +1,605 @@
+:index-group: REST
+:jbake-type: page
+:jbake-status: status=published
+= REST Example
+
+_Help us document this example! Click the blue pencil icon in the upper
+right to edit this page._
+
+== CommentDAO
+
+[source,java]
+----
+package org.superbiz.rest.dao;
+
+import org.superbiz.rest.model.Comment;
+import org.superbiz.rest.model.Post;
+
+import javax.ejb.EJB;
+import javax.ejb.Stateless;
+import java.util.Collections;
+import java.util.List;
+
+@Stateless
+public class CommentDAO extends DAO {
+    @EJB
+    private DAO dao;
+
+    public List<Comment> list(long postId) {
+        Post post = dao.find(Post.class, postId);
+        if (post == null) {
+            throw new IllegalArgumentException("post with id " + postId + " 
not found");
+        }
+        return Collections.unmodifiableList(post.getComments());
+    }
+
+    public Comment create(String author, String content, long postId) {
+        Post post = dao.find(Post.class, postId);
+        if (post == null) {
+            throw new IllegalArgumentException("post with id " + postId + " 
not found");
+        }
+
+        Comment comment = new Comment();
+        comment.setAuthor(author);
+        comment.setContent(content);
+        dao.create(comment);
+        comment.setPost(post);
+        return comment;
+    }
+
+    public void delete(long id) {
+        dao.delete(Comment.class, id);
+    }
+
+    public Comment update(long id, String author, String content) {
+        Comment comment = dao.find(Comment.class, id);
+        if (comment == null) {
+            throw new IllegalArgumentException("comment with id " + id + " not 
found");
+        }
+
+        comment.setAuthor(author);
+        comment.setContent(content);
+        return dao.update(comment);
+    }
+}
+----
+
+== DAO
+
+[source,java]
+----
+package org.superbiz.rest.dao;
+
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.Query;
+import java.util.List;
+
+/**
+ * Simply maps the entitymanager.
+ * It simplifies refactoring (unitName change) and wraps some logic (limited 
queries).
+ *
+ */
+@Stateless
+public class DAO {
+    @PersistenceContext(unitName = "blog")
+    private EntityManager em;
+
+    public <E> E create(E e) {
+        em.persist(e);
+        return e;
+    }
+
+    public <E> E update(E e) {
+        return em.merge(e);
+    }
+
+    public <E> void delete(Class<E> clazz, long id) {
+        em.remove(em.find(clazz, id));
+    }
+
+    public <E> E find(Class<E> clazz, long id) {
+        return em.find(clazz, id);
+    }
+
+    public <E> List<E> find(Class<E> clazz, String query, int min, int max) {
+        return queryRange(em.createQuery(query, clazz), min, 
max).getResultList();
+    }
+
+    public <E> List<E> namedFind(Class<E> clazz, String query, int min, int 
max) {
+        return queryRange(em.createNamedQuery(query, clazz), min, 
max).getResultList();
+    }
+
+    private static Query queryRange(Query query, int min, int max) {
+        if (max >= 0) {
+            query.setMaxResults(max);
+        }
+        if (min >= 0) {
+            query.setFirstResult(min);
+        }
+        return query;
+    }
+}
+----
+
+== PostDAO
+
+[source,java]
+----
+package org.superbiz.rest.dao;
+
+import org.superbiz.rest.model.Post;
+import org.superbiz.rest.model.User;
+
+import javax.ejb.EJB;
+import javax.ejb.Stateless;
+import java.util.List;
+
+@Stateless
+public class PostDAO {
+    @EJB
+    private DAO dao;
+
+    public Post create(String title, String content, long userId) {
+        User user = dao.find(User.class, userId);
+        Post post = new Post();
+        post.setTitle(title);
+        post.setContent(content);
+        post.setUser(user);
+        return dao.create(post);
+    }
+
+    public Post find(long id) {
+        return dao.find(Post.class, id);
+    }
+
+    public List<Post> list(int first, int max) {
+        return dao.namedFind(Post.class, "post.list", first, max);
+    }
+
+    public void delete(long id) {
+        dao.delete(Post.class, id);
+    }
+
+    public Post update(long id, long userId, String title, String content) {
+        User user = dao.find(User.class, userId);
+        if (user == null) {
+            throw new IllegalArgumentException("user id " + id + " not found");
+        }
+
+        Post post = dao.find(Post.class, id);
+        if (post == null) {
+            throw new IllegalArgumentException("post id " + id + " not found");
+        }
+
+        post.setTitle(title);
+        post.setContent(content);
+        post.setUser(user);
+        return dao.update(post);
+    }
+}
+----
+
+== UserDAO
+
+[source,java]
+----
+package org.superbiz.rest.dao;
+
+import org.superbiz.rest.model.User;
+
+import javax.ejb.EJB;
+import javax.ejb.Stateless;
+import java.util.List;
+
+@Stateless
+public class UserDAO {
+    @EJB
+    private DAO dao;
+
+    public User create(String name, String pwd, String mail) {
+        User user = new User();
+        user.setFullname(name);
+        user.setPassword(pwd);
+        user.setEmail(mail);
+        return dao.create(user);
+    }
+
+    public List<User> list(int first, int max) {
+        return dao.namedFind(User.class, "user.list", first, max);
+    }
+
+    public User find(long id) {
+        return dao.find(User.class, id);
+    }
+
+    public void delete(long id) {
+        dao.delete(User.class, id);
+    }
+
+    public User update(long id, String name, String pwd, String mail) {
+        User user = dao.find(User.class, id);
+        if (user == null) {
+            throw new IllegalArgumentException("setUser id " + id + " not 
found");
+        }
+
+        user.setFullname(name);
+        user.setPassword(pwd);
+        user.setEmail(mail);
+        return dao.update(user);
+    }
+}
+----
+
+== Comment
+
+[source,java]
+----
+package org.superbiz.rest.model;
+
+import javax.persistence.Entity;
+import javax.persistence.JoinColumn;
+import javax.persistence.Lob;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+
+@Entity
+@NamedQueries({
+        @NamedQuery(name = "comment.list", query = "select c from Comment c")
+}
+----
+
+== DatedModel
+
+[source,java]
+----
+package org.superbiz.rest.model;
+
+import javax.persistence.MappedSuperclass;
+import javax.persistence.PrePersist;
+import java.util.Date;
+
+@MappedSuperclass
+public abstract class DatedModel extends Model {
+    private Date created;
+
+    @PrePersist
+    public void create() {
+        created = new Date();
+    }
+
+    public Date getCreated() {
+        return created;
+    }
+
+    public void setCreated(Date created) {
+        this.created = created;
+    }
+}
+----
+
+== Model
+
+[source,java]
+----
+package org.superbiz.rest.model;
+
+import javax.persistence.Access;
+import javax.persistence.AccessType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.MappedSuperclass;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+
+@MappedSuperclass
+@Access(AccessType.FIELD)
+@XmlAccessorType(XmlAccessType.FIELD)
+public abstract class Model {
+
+    @Id
+    @GeneratedValue
+    protected long id;
+
+    public long getId() {
+        return id;
+    }
+
+    public void setId(long id) {
+        this.id = id;
+    }
+}
+----
+
+== Post
+
+[source,java]
+----
+package org.superbiz.rest.model;
+
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Lob;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToMany;
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.util.ArrayList;
+import java.util.List;
+
+@Entity
+@NamedQueries({
+        @NamedQuery(name = "post.list", query = "select p from Post p")
+}
+----
+
+== User
+
+[source,java]
+----
+package org.superbiz.rest.model;
+
+import javax.persistence.Entity;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Pattern;
+import javax.validation.constraints.Size;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@Entity
+@NamedQueries({
+        @NamedQuery(name = "user.list", query = "select u from User u")
+}
+----
+
+== CommentService
+
+[source,java]
+----
+package org.superbiz.rest.service;
+
+import org.superbiz.rest.dao.CommentDAO;
+import org.superbiz.rest.model.Comment;
+
+import javax.ejb.EJB;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import java.util.List;
+
+@Path("/api/comment")
+@Produces({"text/xml", "application/json"})
+public class CommentService {
+    @EJB
+    private CommentDAO commentDao;
+
+    @Path("/create")
+    @PUT
+    public Comment create(@QueryParam("author") String author,
+                          @QueryParam("content") String content,
+                          @QueryParam("postId") long postId) {
+        return commentDao.create(author, content, postId);
+    }
+
+    @Path("/list/{postId}")
+    @GET
+    public List<Comment> list(@PathParam("postId") long postId) {
+        return commentDao.list(postId);
+    }
+
+    @Path("/delete/{id}")
+    @DELETE
+    public void delete(@PathParam("id") long id) {
+        commentDao.delete(id);
+    }
+
+    @Path("/update/{id}")
+    @POST
+    public Comment update(@PathParam("id") long id,
+                          @QueryParam("author") String author,
+                          @QueryParam("content") String content) {
+        return commentDao.update(id, author, content);
+    }
+}
+----
+
+== PostService
+
+[source,java]
+----
+package org.superbiz.rest.service;
+
+import org.superbiz.rest.dao.PostDAO;
+import org.superbiz.rest.model.Post;
+
+import javax.ejb.EJB;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import java.util.List;
+
+@Path("/api/post")
+@Produces({"text/xml", "application/json"})
+public class PostService {
+    @EJB
+    private PostDAO dao;
+
+    @Path("/create")
+    @PUT
+    public Post create(@QueryParam("title") String title,
+                       @QueryParam("content") String content,
+                       @QueryParam("userId") long userId) {
+        return dao.create(title, content, userId);
+    }
+
+    @Path("/list")
+    @GET
+    public List<Post> list(@QueryParam("first") @DefaultValue("0") int first,
+                           @QueryParam("max") @DefaultValue("20") int max) {
+        return dao.list(first, max);
+    }
+
+    @Path("/show/{id}")
+    @GET
+    public Post show(@PathParam("id") long id) {
+        return dao.find(id);
+    }
+
+    @Path("/delete/{id}")
+    @DELETE
+    public void delete(@PathParam("id") long id) {
+        dao.delete(id);
+    }
+
+    @Path("/update/{id}")
+    @POST
+    public Post update(@PathParam("id") long id,
+                       @QueryParam("userId") long userId,
+                       @QueryParam("title") String title,
+                       @QueryParam("content") String content) {
+        return dao.update(id, userId, title, content);
+    }
+}
+----
+
+== UserService
+
+[source,java]
+----
+package org.superbiz.rest.service;
+
+import org.superbiz.rest.dao.UserDAO;
+import org.superbiz.rest.model.User;
+
+import javax.ejb.EJB;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import java.util.List;
+
+@Path("/api/user")
+@Produces({"text/xml", "application/json"})
+public class UserService {
+    @EJB
+    private UserDAO dao;
+
+    @Path("/create")
+    @PUT
+    public User create(@QueryParam("name") String name,
+                       @QueryParam("pwd") String pwd,
+                       @QueryParam("mail") String mail) {
+        return dao.create(name, pwd, mail);
+    }
+
+    @Path("/list")
+    @GET
+    public List<User> list(@QueryParam("first") @DefaultValue("0") int first,
+                           @QueryParam("max") @DefaultValue("20") int max) {
+        return dao.list(first, max);
+    }
+
+    @Path("/show/{id}")
+    @GET
+    public User show(@PathParam("id") long id) {
+        return dao.find(id);
+    }
+
+    @Path("/delete/{id}")
+    @DELETE
+    public void delete(@PathParam("id") long id) {
+        dao.delete(id);
+    }
+
+    @Path("/update/{id}")
+    @POST
+    public User update(@PathParam("id") long id,
+                       @QueryParam("name") String name,
+                       @QueryParam("pwd") String pwd,
+                       @QueryParam("mail") String mail) {
+        return dao.update(id, name, pwd, mail);
+    }
+}
+----
+
+== persistence.xml
+
+[source,xml]
+----
+<persistence version="2.0"
+             xmlns="http://java.sun.com/xml/ns/persistence";
+             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+             xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
+                       
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd";>
+  <persistence-unit name="blog">
+    <jta-data-source>My DataSource</jta-data-source>
+    <non-jta-data-source>My Unmanaged DataSource</non-jta-data-source>
+    <class>org.superbiz.rest.model.User</class>
+    <class>org.superbiz.rest.model.Post</class>
+    <class>org.superbiz.rest.model.Comment</class>
+    <class>org.superbiz.rest.model.Model</class>
+    <class>org.superbiz.rest.model.DatedModel</class>
+    <properties>
+      <property name="openjpa.jdbc.SynchronizeMappings" 
value="buildSchema(ForeignKeys=true)"/>
+    </properties>
+  </persistence-unit>
+</persistence>
+----
+
+== web.xml
+
+[source,xml]
+----
+<web-app xmlns="http://java.sun.com/xml/ns/javaee";
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd";
+         metadata-complete="false"
+         version="2.5">
+
+  <display-name>OpenEJB REST Example</display-name>
+</web-app>
+----
+
+== UserDaoTest
+
+[source,java]
+----
+packagenull
+}
+----
+
+== UserServiceTest
+
+[source,java]
+----
+packagenull
+}
+----
diff --git a/examples/rest-sse-example/pom.xml 
b/examples/rest-sse-example/pom.xml
new file mode 100644
index 0000000..1745b4f
--- /dev/null
+++ b/examples/rest-sse-example/pom.xml
@@ -0,0 +1,130 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<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>
+  <groupId>org.superbiz</groupId>
+  <artifactId>rest-sse-example</artifactId>
+  <packaging>war</packaging>
+  <version>8.0.6-SNAPSHOT</version>
+  <name>TomEE :: Web Examples :: REST SSE Example</name>
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <tomee.version>8.0.6-SNAPSHOT</tomee.version>
+    <version.openjpa>3.0.0</version.openjpa>
+  </properties>
+  <repositories>
+    <repository>
+      <id>apache-m2-snapshot</id>
+      <name>Apache Snapshot Repository</name>
+      <url>https://repository.apache.org/content/groups/snapshots</url>
+    </repository>
+  </repositories>
+  <pluginRepositories>
+    <pluginRepository>
+      <id>apache-m2-snapshot</id>
+      <name>Apache Snapshot Repository</name>
+      <url>https://repository.apache.org/content/groups/snapshots</url>
+    </pluginRepository>
+  </pluginRepositories>
+  <build>
+    <finalName>${project.artifactId}</finalName>
+    <defaultGoal>package</defaultGoal>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>3.5.1</version>
+        <configuration>
+          <source>1.8</source>
+          <target>1.8</target>
+        </configuration>
+      </plugin>
+      <plugin>
+        <artifactId>maven-war-plugin</artifactId>
+        <version>3.1.0</version>
+        <configuration>
+          <packagingExcludes>WEB-INF/web.xml</packagingExcludes>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <version>2.22.1</version>
+        <configuration>
+          <argLine>-Djdk.attach.allowAttachSelf</argLine>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.tomee.maven</groupId>
+        <artifactId>tomee-maven-plugin</artifactId>
+        <version>${tomee.version}</version>
+        <configuration>
+          <simpleLog>true</simpleLog>
+          <tomeeVersion>${tomee.version}</tomeeVersion>
+          <tomeeClassifier>plus</tomeeClassifier>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.tomitribe.transformer</groupId>
+        <artifactId>org.eclipse.transformer.maven</artifactId>
+        <version>0.1.1a</version>
+        <configuration>
+          <classifier>jakartaee9</classifier>
+        </configuration>
+        <executions>
+          <execution>
+            <goals>
+              <goal>run</goal>
+            </goals>
+            <phase>package</phase>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.tomee</groupId>
+      <artifactId>javaee-api</artifactId>
+      <version>[8.0,)</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.12</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+  <!--
+  This section allows you to configure where to publish libraries for sharing.
+  It is not required and may be deleted.  For more information see:
+  http://maven.apache.org/plugins/maven-deploy-plugin/
+  -->
+  <distributionManagement>
+    <repository>
+      <id>local-release-repo</id>
+      <url>file://${project.build.outputDirectory}/repo/</url>
+    </repository>
+    <snapshotRepository>
+      <id>local-snapshot-repo</id>
+      <url>file://${project.build.outputDirectory}/repo/</url>
+    </snapshotRepository>
+  </distributionManagement>
+</project>
diff --git 
a/examples/rest-sse-example/src/main/java/org/superbiz/rest/service/JmsResource.java
 
b/examples/rest-sse-example/src/main/java/org/superbiz/rest/service/JmsResource.java
new file mode 100644
index 0000000..e9e0e8e
--- /dev/null
+++ 
b/examples/rest-sse-example/src/main/java/org/superbiz/rest/service/JmsResource.java
@@ -0,0 +1,42 @@
+package org.superbiz.rest.service;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.event.Observes;
+import javax.jms.Message;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.sse.OutboundSseEvent;
+import javax.ws.rs.sse.Sse;
+import javax.ws.rs.sse.SseBroadcaster;
+import javax.ws.rs.sse.SseEventSink;
+
+@Path("jms")
+@ApplicationScoped
+public class JmsResource {
+
+    private SseBroadcaster broadcaster;
+    private OutboundSseEvent.Builder builder;
+
+    @GET
+    @Produces(MediaType.SERVER_SENT_EVENTS)
+    public void stats(final @Context SseEventSink sink) {
+        broadcaster.register(sink);
+    }
+
+    @Context
+    public void setSse(final Sse sse) {
+        this.broadcaster = sse.newBroadcaster();
+        this.builder = sse.newEventBuilder();
+    }
+
+    public void onMessage(final @Observes Message message) {
+        if (broadcaster == null) {
+            return;
+        }
+
+        broadcaster.broadcast(builder.data(Message.class, 
message).mediaType(MediaType.APPLICATION_JSON_TYPE).build());
+    }
+}
diff --git 
a/examples/rest-sse-example/src/main/java/org/superbiz/rest/service/TopicListener.java
 
b/examples/rest-sse-example/src/main/java/org/superbiz/rest/service/TopicListener.java
new file mode 100644
index 0000000..ea28788
--- /dev/null
+++ 
b/examples/rest-sse-example/src/main/java/org/superbiz/rest/service/TopicListener.java
@@ -0,0 +1,23 @@
+package org.superbiz.rest.service;
+
+import javax.ejb.ActivationConfigProperty;
+import javax.ejb.MessageDriven;
+import javax.enterprise.event.Event;
+import javax.inject.Inject;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+
+@MessageDriven(activationConfig = {
+        @ActivationConfigProperty(propertyName = "destinationType", 
propertyValue = "javax.jms.Topic"),
+        @ActivationConfigProperty(propertyName = "destination", propertyValue 
= "EVENT"),
+})
+public class TopicListener implements MessageListener {
+
+    @Inject
+    private Event<Message> messageReceivedEvent;
+
+    @Override
+    public void onMessage(final Message message) {
+        messageReceivedEvent.fire(message);
+    }
+}
diff --git a/examples/rest-sse-example/src/main/resources/META-INF/beans.xml 
b/examples/rest-sse-example/src/main/resources/META-INF/beans.xml
new file mode 100644
index 0000000..9b0b74f
--- /dev/null
+++ b/examples/rest-sse-example/src/main/resources/META-INF/beans.xml
@@ -0,0 +1,18 @@
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<beans/>
diff --git 
a/examples/rest-sse-example/src/main/resources/META-INF/resources.xml 
b/examples/rest-sse-example/src/main/resources/META-INF/resources.xml
new file mode 100644
index 0000000..c98e634
--- /dev/null
+++ b/examples/rest-sse-example/src/main/resources/META-INF/resources.xml
@@ -0,0 +1,31 @@
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<resources>
+  <Resource id="MyJmsResourceAdapter" type="ActiveMQResourceAdapter">
+    BrokerXmlConfig =  broker:(tcp://127.0.0.01:61616)
+    ServerUrl       =  tcp://localhost:61616
+  </Resource>
+
+  <Resource id="MyJmsConnectionFactory" type="javax.jms.ConnectionFactory">
+    ResourceAdapter = MyJmsResourceAdapter
+  </Resource>
+
+  <Container id="MyJmsMdbContainer" ctype="MESSAGE">
+    ResourceAdapter = MyJmsResourceAdapter
+  </Container>
+</resources>
diff --git a/examples/rest-sse-example/src/main/webapp/WEB-INF/beans.xml 
b/examples/rest-sse-example/src/main/webapp/WEB-INF/beans.xml
new file mode 100644
index 0000000..bbc3399
--- /dev/null
+++ b/examples/rest-sse-example/src/main/webapp/WEB-INF/beans.xml
@@ -0,0 +1,17 @@
+<!--
+     Licensed to the Apache Software Foundation (ASF) under one or more
+     contributor license agreements.  See the NOTICE file distributed with
+     this work for additional information regarding copyright ownership.
+     The ASF licenses this file to You under the Apache License, Version 2.0
+     (the "License"); you may not use this file except in compliance with
+     the License.  You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+  -->
+<beans/>
diff --git a/examples/rest-sse-example/src/main/webapp/WEB-INF/web.xml 
b/examples/rest-sse-example/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..17930cf
--- /dev/null
+++ b/examples/rest-sse-example/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+     Licensed to the Apache Software Foundation (ASF) under one or more
+     contributor license agreements.  See the NOTICE file distributed with
+     this work for additional information regarding copyright ownership.
+     The ASF licenses this file to You under the Apache License, Version 2.0
+     (the "License"); you may not use this file except in compliance with
+     the License.  You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+  -->
+<web-app xmlns="http://java.sun.com/xml/ns/javaee";
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd";
+         metadata-complete="false"
+         version="2.5">
+
+  <display-name>SSE Example</display-name>
+</web-app>

Reply via email to