geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pra...@apache.org
Subject svn commit: r499591 - in /geronimo/samples/trunk/calculator-stateless-pojo: calculator-stateless-ear/ calculator-stateless-war/src/main/java/org/apache/geronimo/samples/calculator/ calculator-stateless-war/src/main/webapp/ calculator-stateless-war/src/...
Date Wed, 24 Jan 2007 22:11:16 GMT
Author: prasad
Date: Wed Jan 24 14:11:14 2007
New Revision: 499591

URL: http://svn.apache.org/viewvc?view=rev&rev=499591
Log:
* use geronimo-application.xml plan with deploy
* change action in jsp form
* commented code put for jndi lookup of ejb for jetty container
* commented code put for <ejb-ref> in web.xml

Modified:
    geronimo/samples/trunk/calculator-stateless-pojo/calculator-stateless-ear/pom.xml
    geronimo/samples/trunk/calculator-stateless-pojo/calculator-stateless-war/src/main/java/org/apache/geronimo/samples/calculator/CalculatorServlet.java
    geronimo/samples/trunk/calculator-stateless-pojo/calculator-stateless-war/src/main/webapp/WEB-INF/web.xml
    geronimo/samples/trunk/calculator-stateless-pojo/calculator-stateless-war/src/main/webapp/sample-docu.jsp

Modified: geronimo/samples/trunk/calculator-stateless-pojo/calculator-stateless-ear/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/samples/trunk/calculator-stateless-pojo/calculator-stateless-ear/pom.xml?view=diff&rev=499591&r1=499590&r2=499591
==============================================================================
--- geronimo/samples/trunk/calculator-stateless-pojo/calculator-stateless-ear/pom.xml (original)
+++ geronimo/samples/trunk/calculator-stateless-pojo/calculator-stateless-ear/pom.xml Wed
Jan 24 14:11:14 2007
@@ -91,6 +91,9 @@
                     <plugin>
                         <groupId>org.apache.geronimo.plugins</groupId>
                         <artifactId>geronimo-maven-plugin</artifactId>
+                        <configuration>
+                            <modulePlan>${project.build.directory}/classes/META-INF/geronimo-application.xml</modulePlan>
+                        </configuration>
                     </plugin>
                 </plugins>
             </build>

Modified: geronimo/samples/trunk/calculator-stateless-pojo/calculator-stateless-war/src/main/java/org/apache/geronimo/samples/calculator/CalculatorServlet.java
URL: http://svn.apache.org/viewvc/geronimo/samples/trunk/calculator-stateless-pojo/calculator-stateless-war/src/main/java/org/apache/geronimo/samples/calculator/CalculatorServlet.java?view=diff&rev=499591&r1=499590&r2=499591
==============================================================================
--- geronimo/samples/trunk/calculator-stateless-pojo/calculator-stateless-war/src/main/java/org/apache/geronimo/samples/calculator/CalculatorServlet.java
(original)
+++ geronimo/samples/trunk/calculator-stateless-pojo/calculator-stateless-war/src/main/java/org/apache/geronimo/samples/calculator/CalculatorServlet.java
Wed Jan 24 14:11:14 2007
@@ -23,6 +23,9 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
 import org.apache.geronimo.samples.slsb.calculator.CalculatorLocal;
 
 // A stateful session bean must be declared at the type level
@@ -31,12 +34,32 @@
 
 public class CalculatorServlet extends HttpServlet {
 
+
     // the ejb container will route every request to different bean instances. 
     @EJB
-    private CalculatorLocal calc;
+    private CalculatorLocal calc = null;
 
     public void doGet(HttpServletRequest req, HttpServletResponse resp)
-            throws ServletException, IOException {
+    throws ServletException, IOException {
+
+        /*
+        Context initialContext = null;
+        try {
+            initialContext = new InitialContext();
+        }
+        catch ( Exception e ) {
+            System.out.print("Cannot get initial context for JNDI: " + e.getMessage());
+            return;
+        }
+
+        try {
+            calc = (CalculatorLocal) initialContext.lookup("java:comp/env/ejb/Calculator");
+        }
+        catch ( Exception e ) {
+            System.out.println("Cannot lookup java:comp/env/ejb/Calculator: " + e);
+            return;
+        }
+        */
 
         try {
             String firstNumber = req.getParameter("firstNumber");
@@ -46,16 +69,19 @@
             int firstInt = (firstNumber == null) ? 1 : Integer.valueOf(firstNumber).intValue();
             int secondInt = (secondNumber == null) ? 1 : Integer.valueOf(secondNumber).intValue();
 
-            if ("multiply".equals(operation) ) {
+            if ( "multiply".equals(operation) ) {
                 req.setAttribute("result", calc.multiply(firstInt, secondInt));
             }
-            else if ("add".equals(operation) ) {
+            else if ( "add".equals(operation) ) {
                 req.setAttribute("result", calc.sum(firstInt, secondInt));
             }
 
-            getServletContext().getRequestDispatcher("/").forward(req, resp);
+            System.out.println("Result is " + req.getAttribute("result"));
+
+            getServletContext().getRequestDispatcher("/sample-docu.jsp").forward(req, resp);
 
-        } catch (Exception e) {
+        }
+        catch ( Exception e ) {
             e.printStackTrace();
             throw new ServletException(e);
         }

Modified: geronimo/samples/trunk/calculator-stateless-pojo/calculator-stateless-war/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/geronimo/samples/trunk/calculator-stateless-pojo/calculator-stateless-war/src/main/webapp/WEB-INF/web.xml?view=diff&rev=499591&r1=499590&r2=499591
==============================================================================
--- geronimo/samples/trunk/calculator-stateless-pojo/calculator-stateless-war/src/main/webapp/WEB-INF/web.xml
(original)
+++ geronimo/samples/trunk/calculator-stateless-pojo/calculator-stateless-war/src/main/webapp/WEB-INF/web.xml
Wed Jan 24 14:11:14 2007
@@ -36,4 +36,18 @@
         <welcome-file>index.html</welcome-file>
     </welcome-file-list>
 
+    <!--
+    <ejb-ref>
+        <ejb-ref-name>ejb/Calculator</ejb-ref-name>
+        <ejb-ref-type>Session</ejb-ref-type>
+        <remote>org.apache.geronimo.samples.slsb.calculator.CalculatorRemote</remote>
+    </ejb-ref>
+
+    <ejb-local-ref>
+        <ejb-ref-name>ejb/Calculator</ejb-ref-name>
+        <ejb-ref-type>Session</ejb-ref-type>
+        <local>org.apache.geronimo.samples.slsb.calculator.CalculatorLocal</local>
+    </ejb-local-ref>
+    -->
+
 </web-app>

Modified: geronimo/samples/trunk/calculator-stateless-pojo/calculator-stateless-war/src/main/webapp/sample-docu.jsp
URL: http://svn.apache.org/viewvc/geronimo/samples/trunk/calculator-stateless-pojo/calculator-stateless-war/src/main/webapp/sample-docu.jsp?view=diff&rev=499591&r1=499590&r2=499591
==============================================================================
--- geronimo/samples/trunk/calculator-stateless-pojo/calculator-stateless-war/src/main/webapp/sample-docu.jsp
(original)
+++ geronimo/samples/trunk/calculator-stateless-pojo/calculator-stateless-war/src/main/webapp/sample-docu.jsp
Wed Jan 24 14:11:14 2007
@@ -28,12 +28,19 @@
 
 <BODY>
   <font face="Verdana, Helvetica, Arial">
-<FORM ACTION="/calculator" method="get">
+<FORM ACTION="calculator" method="get">
   <h2>A Stateless Session Sample</H2>
   <H3>Calculator</h2>
   <font style="font-size:12px">
   <p>
   This sample shows an EJB 3.0 Stateless session bean.
+  <%
+      String result = String.valueOf(request.getAttribute("result"));
+      result = ("null".equals(result)) ? "0" : result;
+      request.setAttribute("result", null);
+      request.removeAttribute("result");
+  %>
+
   </p>
   <table cols="4" border="3" id="mainTable" cellpadding="0">
     <thead id="mainTableHead">
@@ -46,17 +53,17 @@
     </thead>
     <tr>
       <td class="cell">
-        <INPUT TYPE="text" name="firstNumber" value="1">
+        <INPUT TYPE="text" name="firstNumber" value="0">
       </td>
       <td class="cell">
-        <INPUT TYPE="text" name="secondNumber" value="1">
+        <INPUT TYPE="text" name="secondNumber" value="0">
       </td>
       <td class="cell">
         <INPUT TYPE="submit" name="operation" value="add">
         <BR>
         <INPUT TYPE="submit" name="operation" value="multiply">
       </td>
-      <td class="cell"><%=request.getAttribute("result")%></td>
+      <td class="cell"><%=result%></td>
     </tr>
   </table>
 </FORM>



Mime
View raw message