geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r665933 - in /geronimo/samples/trunk/samples/customer-service: customer-service-ear/src/main/resources/META-INF/ customer-service-ejb/src/main/java/com/service/customer/ejb/ customer-service-ejb/src/main/resources/ customer-service-ejb/src/...
Date Mon, 09 Jun 2008 23:15:38 GMT
Author: djencks
Date: Mon Jun  9 16:15:38 2008
New Revision: 665933

URL: http://svn.apache.org/viewvc?rev=665933&view=rev
Log:
some basic updates

Removed:
    geronimo/samples/trunk/samples/customer-service/customer-service-ear/src/main/resources/META-INF/geronimo-application.xml
    geronimo/samples/trunk/samples/customer-service/customer-service-ejb/src/main/resources/META-INF/openejb-jar.xml
    geronimo/samples/trunk/samples/customer-service/customer-service-ejb/src/main/resources/customer.properties
    geronimo/samples/trunk/samples/customer-service/customer-service-war/src/main/webapp/WEB-INF/geronimo-web.xml
Modified:
    geronimo/samples/trunk/samples/customer-service/customer-service-ejb/src/main/java/com/service/customer/ejb/Customer.java
    geronimo/samples/trunk/samples/customer-service/customer-service-ejb/src/main/java/com/service/customer/ejb/ProcessCustomerSessionBean.java
    geronimo/samples/trunk/samples/customer-service/customer-service-war/src/main/java/com/service/customer/web/CustomerServiceJavaBean.java
    geronimo/samples/trunk/samples/customer-service/customer-service-war/src/main/webapp/WEB-INF/web.xml

Modified: geronimo/samples/trunk/samples/customer-service/customer-service-ejb/src/main/java/com/service/customer/ejb/Customer.java
URL: http://svn.apache.org/viewvc/geronimo/samples/trunk/samples/customer-service/customer-service-ejb/src/main/java/com/service/customer/ejb/Customer.java?rev=665933&r1=665932&r2=665933&view=diff
==============================================================================
--- geronimo/samples/trunk/samples/customer-service/customer-service-ejb/src/main/java/com/service/customer/ejb/Customer.java
(original)
+++ geronimo/samples/trunk/samples/customer-service/customer-service-ejb/src/main/java/com/service/customer/ejb/Customer.java
Mon Jun  9 16:15:38 2008
@@ -21,10 +21,14 @@
 
 import javax.persistence.Entity;
 import javax.persistence.Id;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
 import javax.persistence.Table;
 
 @Entity
 @Table(name = "customer")
+@NamedQueries({@NamedQuery(name = "AllCustomers", query = "SELECT c from Customer c"),
+        @NamedQuery(name = "FindCustomer", query = "SELECT c from Customer c  WHERE c.customerId=:customerId")})
 public class Customer implements Serializable {
     private String customerId;
     private String fullName;

Modified: geronimo/samples/trunk/samples/customer-service/customer-service-ejb/src/main/java/com/service/customer/ejb/ProcessCustomerSessionBean.java
URL: http://svn.apache.org/viewvc/geronimo/samples/trunk/samples/customer-service/customer-service-ejb/src/main/java/com/service/customer/ejb/ProcessCustomerSessionBean.java?rev=665933&r1=665932&r2=665933&view=diff
==============================================================================
--- geronimo/samples/trunk/samples/customer-service/customer-service-ejb/src/main/java/com/service/customer/ejb/ProcessCustomerSessionBean.java
(original)
+++ geronimo/samples/trunk/samples/customer-service/customer-service-ejb/src/main/java/com/service/customer/ejb/ProcessCustomerSessionBean.java
Mon Jun  9 16:15:38 2008
@@ -21,36 +21,28 @@
 
 import javax.ejb.Stateless;
 import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.PersistenceUnit;
+import javax.persistence.PersistenceContext;
+import javax.persistence.Query;
 
 @Stateless
 public class ProcessCustomerSessionBean implements ProcessCustomerSessionLocal {
-    @PersistenceUnit
-    protected EntityManagerFactory emf;
+    @PersistenceContext
+    protected EntityManager em;
 
     public ProcessCustomerSessionBean() {
 
     }
 
     public List<Customer> findAllCustomers() {
-        EntityManager em = emf.createEntityManager();
-        String query = "SELECT * FROM customer";
-        List<Customer> customerList =
-                (List<Customer>) em.createNativeQuery(query, Customer.class).getResultList();
-        em.close();
+        Query q = em.createNamedQuery("AllCustomers");
+        List<Customer> customerList = q.getResultList();
         return customerList;
     }
 
     public Customer findCustomer(String key) {
-        EntityManager em = emf.createEntityManager();
-        String query = "SELECT * FROM customer WHERE id='" + key + "'";
-        List<Customer> customerList =
-                (List<Customer>) em.createNativeQuery(query, Customer.class).getResultList();
-        if (customerList.size() == 1) {
-            return (Customer) customerList.get(0);
-        } else {
-            return null;
-        }
+        Query q = em.createNamedQuery("FindCustomer");
+        q.setParameter("customerId", key);
+        Customer c = (Customer) q.getSingleResult();
+        return c;
     }
 }

Modified: geronimo/samples/trunk/samples/customer-service/customer-service-war/src/main/java/com/service/customer/web/CustomerServiceJavaBean.java
URL: http://svn.apache.org/viewvc/geronimo/samples/trunk/samples/customer-service/customer-service-war/src/main/java/com/service/customer/web/CustomerServiceJavaBean.java?rev=665933&r1=665932&r2=665933&view=diff
==============================================================================
--- geronimo/samples/trunk/samples/customer-service/customer-service-war/src/main/java/com/service/customer/web/CustomerServiceJavaBean.java
(original)
+++ geronimo/samples/trunk/samples/customer-service/customer-service-war/src/main/java/com/service/customer/web/CustomerServiceJavaBean.java
Mon Jun  9 16:15:38 2008
@@ -18,8 +18,6 @@
 package com.service.customer.web;
 
 import java.util.List;
-import java.util.Locale;
-import java.util.ResourceBundle;
 
 import javax.naming.InitialContext;
 
@@ -28,24 +26,18 @@
 
 public class CustomerServiceJavaBean {
     private ProcessCustomerSessionLocal process = null;
-    private ResourceBundle bundle = null;
 
     public CustomerServiceJavaBean() {
-        InitialContext initial = null;
-
-        bundle = ResourceBundle.getBundle("customer", Locale.getDefault(), CustomerServiceJavaBean.class.getClassLoader());
-        String jndiName = bundle.getString("jndi.process.ejb");
 
         try {
-            initial = new InitialContext();
-            process = (ProcessCustomerSessionLocal) initial.lookup(jndiName.trim());
-            System.out.println("Successful looking up: '" + jndiName.trim() + "'");
-        } // end try
+            InitialContext initial = new InitialContext();
+            process = (ProcessCustomerSessionLocal) initial.lookup("java:comp/env/ejb/ProcessCustomerSessionBean");
+        }
 
         catch (Exception e) {
             e.printStackTrace();
-        } // end catch
-    } // end CustomerServiceJavaBean
+        }
+    }
 
 
     public List<Customer> getAllCustomers() {
@@ -53,11 +45,11 @@
 
         try {
             customerList = process.findAllCustomers();
-        } // end try
+        }
         catch (Exception e) {
             e.printStackTrace();
-        } // end catch
+        }
 
         return customerList;
-    } // end getAllCustomerss
-} // end CustomerServiceJavaBean
+    }
+} 

Modified: geronimo/samples/trunk/samples/customer-service/customer-service-war/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/geronimo/samples/trunk/samples/customer-service/customer-service-war/src/main/webapp/WEB-INF/web.xml?rev=665933&r1=665932&r2=665933&view=diff
==============================================================================
--- geronimo/samples/trunk/samples/customer-service/customer-service-war/src/main/webapp/WEB-INF/web.xml
(original)
+++ geronimo/samples/trunk/samples/customer-service/customer-service-war/src/main/webapp/WEB-INF/web.xml
Mon Jun  9 16:15:38 2008
@@ -17,10 +17,10 @@
    limitations under the License.
 -->
 
-<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
+<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/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
-         version="2.4">
+         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+         version="2.5">
 
     <welcome-file-list>
         <welcome-file>index.html</welcome-file>



Mime
View raw message