[jboss-svn-commits] JBL Code SVN: r37155 - in labs/jbosstm/trunk/ArjunaJTA/examples/integration/src/main: java/org/jboss/narayana/examples and 4 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Jun 24 14:10:53 EDT 2011
Author: tomjenkinson
Date: 2011-06-24 14:10:53 -0400 (Fri, 24 Jun 2011)
New Revision: 37155
Added:
labs/jbosstm/trunk/ArjunaJTA/examples/integration/src/main/java/org/jboss/narayana/examples/mdb/
labs/jbosstm/trunk/ArjunaJTA/examples/integration/src/main/java/org/jboss/narayana/examples/mdb/SimpleMDB.java
labs/jbosstm/trunk/ArjunaJTA/examples/integration/src/main/java/org/jboss/narayana/examples/servlet/
labs/jbosstm/trunk/ArjunaJTA/examples/integration/src/main/java/org/jboss/narayana/examples/servlet/SimpleServlet.java
labs/jbosstm/trunk/ArjunaJTA/examples/integration/src/main/webapp/
labs/jbosstm/trunk/ArjunaJTA/examples/integration/src/main/webapp/WEB-INF/
labs/jbosstm/trunk/ArjunaJTA/examples/integration/src/main/webapp/WEB-INF/web.xml
Log:
JBTM-854 updated to be a bit more complex
Added: labs/jbosstm/trunk/ArjunaJTA/examples/integration/src/main/java/org/jboss/narayana/examples/mdb/SimpleMDB.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/examples/integration/src/main/java/org/jboss/narayana/examples/mdb/SimpleMDB.java (rev 0)
+++ labs/jbosstm/trunk/ArjunaJTA/examples/integration/src/main/java/org/jboss/narayana/examples/mdb/SimpleMDB.java 2011-06-24 18:10:53 UTC (rev 37155)
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat 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.
+ */
+package org.jboss.narayana.examples.mdb;
+
+import javax.ejb.ActivationConfigProperty;
+import javax.ejb.MessageDriven;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.TextMessage;
+
+import org.jboss.ejb3.annotation.ResourceAdapter;
+
+ at MessageDriven(name = "MDB_BMTExample", activationConfig = {
+ @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
+ @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/testQueue") })
+ at ResourceAdapter("jms-ra.rar")
+public class SimpleMDB implements MessageListener {
+ public void onMessage(final Message message) {
+ TextMessage textMessage = (TextMessage) message;
+ try {
+ String text = textMessage.getText();
+ System.out.println("message " + text + " received");
+ } catch (JMSException e) {
+ System.err.println("Something went wrong");
+ e.printStackTrace();
+ }
+ }
+}
\ No newline at end of file
Added: labs/jbosstm/trunk/ArjunaJTA/examples/integration/src/main/java/org/jboss/narayana/examples/servlet/SimpleServlet.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/examples/integration/src/main/java/org/jboss/narayana/examples/servlet/SimpleServlet.java (rev 0)
+++ labs/jbosstm/trunk/ArjunaJTA/examples/integration/src/main/java/org/jboss/narayana/examples/servlet/SimpleServlet.java 2011-06-24 18:10:53 UTC (rev 37155)
@@ -0,0 +1,89 @@
+package org.jboss.narayana.examples.servlet;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.ejb.EJB;
+import javax.naming.InitialContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.transaction.UserTransaction;
+
+import org.jboss.narayana.examples.ejb.SimpleEJB;
+
+public class SimpleServlet extends HttpServlet {
+
+ @EJB
+ private SimpleEJB simpleEJB;
+
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+
+ response.setContentType("text/html");
+ PrintWriter out = response.getWriter();
+ out.println("<html>");
+ out.println("<head><title>Rocking out with Openshift</title></head>");
+ out.println("<body>");
+ String operation = request.getParameter("operation");
+ if (operation != null) {
+ if (operation.equals("list")) {
+ out.println(listCustomers());
+ } else if (operation.equals("create")) {
+ String name = request.getParameter("name");
+ if (name != null) {
+ out.println(createCustomer(name));
+ } else {
+ out.println(error("Requires name parameter"));
+ }
+ } else {
+ out.println(error("Unknown operation: " + operation));
+ }
+ } else {
+ out.println(error("Requires operation"));
+ }
+ out.println("</body>");
+ out.println("</html>");
+ }
+
+ private String error(String error) {
+ StringBuffer toWrite = new StringBuffer();
+ toWrite.append("<h1>Invalid parameters</h1>\n");
+ toWrite.append("<p>" + error + "</p>");
+ return toWrite.toString();
+ }
+
+ public String listCustomers() {
+ StringBuffer toWrite = new StringBuffer();
+ toWrite.append("<h1>List of customer Ids</h1>\n");
+
+ try {
+ UserTransaction tx = (UserTransaction) new InitialContext()
+ .lookup("java:comp/UserTransaction");
+ tx.begin();
+ toWrite.append("<p>" + simpleEJB.listIds() + "</p>");
+ tx.commit();
+ } catch (Throwable e) {
+ throw new RuntimeException(e);
+ }
+ return toWrite.toString();
+ }
+
+ public String createCustomer(String name) {
+ StringBuffer toWrite = new StringBuffer();
+ toWrite.append("<h1>Update summary</h1>\n");
+
+ try {
+ UserTransaction tx = (UserTransaction) new InitialContext()
+ .lookup("java:comp/UserTransaction");
+ tx.begin();
+ simpleEJB.createCustomer(name);
+ toWrite.append("<p>Created: " + name + "</p>");
+ tx.commit();
+ } catch (Throwable e) {
+ throw new RuntimeException(e);
+ }
+ return toWrite.toString();
+ }
+}
Added: labs/jbosstm/trunk/ArjunaJTA/examples/integration/src/main/webapp/WEB-INF/web.xml
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/examples/integration/src/main/webapp/WEB-INF/web.xml (rev 0)
+++ labs/jbosstm/trunk/ArjunaJTA/examples/integration/src/main/webapp/WEB-INF/web.xml 2011-06-24 18:10:53 UTC (rev 37155)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<web-app version="2.5" 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">
+ <servlet>
+ <servlet-name>hello</servlet-name>
+ <servlet-class>org.jboss.narayana.examples.servlet.SimpleServlet</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>hello</servlet-name>
+ <url-pattern>/hello</url-pattern>
+ </servlet-mapping>
+</web-app>
More information about the jboss-svn-commits
mailing list