You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by ec...@apache.org on 2008/03/26 08:15:01 UTC
svn commit: r641179 - in
/geronimo/samples/branches/1.0/migration-ejb-session: ./ dd/META-INF/
src/com/ src/org/ src/org/apache/ src/org/apache/geronimo/
src/org/apache/geronimo/demo/ src/org/apache/geronimo/demo/ejb/
src/org/apache/geronimo/demo/ejb/s...
Author: ecraig
Date: Wed Mar 26 00:14:58 2008
New Revision: 641179
URL: http://svn.apache.org/viewvc?rev=641179&view=rev
Log:
GERONIMO-3910
migration-ejb-session cleaned up
Added:
geronimo/samples/branches/1.0/migration-ejb-session/src/org/
geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/
geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/
geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/
geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/
geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/
geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/client/
geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/client/StatefulClient.java
geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/client/StatefulClientServlet.java
geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/client/StatelessClient.java
geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/client/StatelessClientServlet.java
geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/entity/
geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/entity/CustomerBean.java
geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/entity/CustomerHomeRemote.java
geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/entity/CustomerRemote.java
geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/session/
geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/session/stateful/
geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/session/stateful/StatefulLoanManagerBean.java
geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/session/stateful/StatefulLoanManagerHomeRemote.java
geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/session/stateful/StatefulLoanManagerRemote.java
geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/session/stateless/
geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/session/stateless/LoanManagerBean.java
geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/session/stateless/LoanManagerHomeRemote.java
geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/session/stateless/LoanManagerRemote.java
Removed:
geronimo/samples/branches/1.0/migration-ejb-session/src/com/
Modified:
geronimo/samples/branches/1.0/migration-ejb-session/dd/META-INF/ejb-jar.xml
geronimo/samples/branches/1.0/migration-ejb-session/dd/META-INF/jboss.xml
geronimo/samples/branches/1.0/migration-ejb-session/dd/META-INF/openejb-jar.xml
geronimo/samples/branches/1.0/migration-ejb-session/maven.xml
geronimo/samples/branches/1.0/migration-ejb-session/project.properties
geronimo/samples/branches/1.0/migration-ejb-session/src/webapp/WEB-INF/web.xml
Modified: geronimo/samples/branches/1.0/migration-ejb-session/dd/META-INF/ejb-jar.xml
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-ejb-session/dd/META-INF/ejb-jar.xml?rev=641179&r1=641178&r2=641179&view=diff
==============================================================================
--- geronimo/samples/branches/1.0/migration-ejb-session/dd/META-INF/ejb-jar.xml (original)
+++ geronimo/samples/branches/1.0/migration-ejb-session/dd/META-INF/ejb-jar.xml Wed Mar 26 00:14:58 2008
@@ -24,16 +24,16 @@
<entity>
<description>This bean represents customer</description>
<ejb-name>CustomerEJB</ejb-name>
- <home>com.ibm.demo.entity.CustomerHomeRemote</home>
- <remote>com.ibm.demo.entity.CustomerRemote</remote>
- <ejb-class>com.ibm.demo.entity.CustomerBean</ejb-class>
+ <home>org.apache.geronimo.demo.ejb.session.entity.CustomerHomeRemote</home>
+ <remote>org.apache.geronimo.demo.ejb.session.entity.CustomerRemote</remote>
+ <ejb-class>org.apache.geronimo.demo.ejb.session.entity.CustomerBean</ejb-class>
<persistence-type>Bean</persistence-type>
<prim-key-class>java.lang.Integer</prim-key-class>
<reentrant>False</reentrant>
<security-identity><use-caller-identity/></security-identity>
<resource-ref>
<description>DataSource for Demo Database</description>
- <res-ref-name>jdbc/ibm-demo</res-ref-name>
+ <res-ref-name>jdbc/geronimo-demo</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
@@ -42,16 +42,16 @@
<session>
<description>This bean manages the loan applications</description>
<ejb-name>LoanManagerEJB</ejb-name>
- <home>com.ibm.demo.session.stateless.LoanManagerHomeRemote</home>
- <remote>com.ibm.demo.session.stateless.LoanManagerRemote</remote>
- <ejb-class>com.ibm.demo.session.stateless.LoanManagerBean</ejb-class>
+ <home>org.apache.geronimo.demo.ejb.session.session.stateless.LoanManagerHomeRemote</home>
+ <remote>org.apache.geronimo.demo.ejb.session.session.stateless.LoanManagerRemote</remote>
+ <ejb-class>org.apache.geronimo.demo.ejb.session.session.stateless.LoanManagerBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
<ejb-ref>
<ejb-ref-name>ejb/CustomerHomeRemote</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
- <home>com.ibm.demo.entity.CustomerHomeRemote</home>
- <remote>com.ibm.demo.entity.CustomerRemote</remote>
+ <home>org.apache.geronimo.demo.ejb.session.entity.CustomerHomeRemote</home>
+ <remote>org.apache.geronimo.demo.ejb.session.entity.CustomerRemote</remote>
</ejb-ref>
<security-identity><use-caller-identity/></security-identity>
</session>
@@ -59,16 +59,16 @@
<session>
<description>This bean manages the loan applications</description>
<ejb-name>StatefulLoanManagerEJB</ejb-name>
- <home>com.ibm.demo.session.stateful.StatefulLoanManagerHomeRemote</home>
- <remote>com.ibm.demo.session.stateful.StatefulLoanManagerRemote</remote>
- <ejb-class>com.ibm.demo.session.stateful.StatefulLoanManagerBean</ejb-class>
+ <home>org.apache.geronimo.demo.ejb.session.session.stateful.StatefulLoanManagerHomeRemote</home>
+ <remote>org.apache.geronimo.demo.ejb.session.session.stateful.StatefulLoanManagerRemote</remote>
+ <ejb-class>org.apache.geronimo.demo.ejb.session.session.stateful.StatefulLoanManagerBean</ejb-class>
<session-type>Stateful</session-type>
<transaction-type>Container</transaction-type>
<ejb-ref>
<ejb-ref-name>ejb/CustomerHomeRemote</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
- <home>com.ibm.demo.entity.CustomerHomeRemote</home>
- <remote>com.ibm.demo.entity.CustomerRemote</remote>
+ <home>org.apache.geronimo.demo.ejb.session.entity.CustomerHomeRemote</home>
+ <remote>org.apache.geronimo.demo.ejb.session.entity.CustomerRemote</remote>
</ejb-ref>
<security-identity><use-caller-identity/></security-identity>
</session>
Modified: geronimo/samples/branches/1.0/migration-ejb-session/dd/META-INF/jboss.xml
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-ejb-session/dd/META-INF/jboss.xml?rev=641179&r1=641178&r2=641179&view=diff
==============================================================================
--- geronimo/samples/branches/1.0/migration-ejb-session/dd/META-INF/jboss.xml (original)
+++ geronimo/samples/branches/1.0/migration-ejb-session/dd/META-INF/jboss.xml Wed Mar 26 00:14:58 2008
@@ -28,7 +28,7 @@
<ejb-name>CustomerEJB</ejb-name>
<jndi-name>CustomerHomeRemote</jndi-name>
<resource-ref>
- <res-ref-name>jdbc/ibm-demo</res-ref-name>
+ <res-ref-name>jdbc/geronimo-demo</res-ref-name>
<jndi-name>java:/DefaultDS</jndi-name>
</resource-ref>
<configuration-name>Standard BMP EntityBean</configuration-name>
Modified: geronimo/samples/branches/1.0/migration-ejb-session/dd/META-INF/openejb-jar.xml
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-ejb-session/dd/META-INF/openejb-jar.xml?rev=641179&r1=641178&r2=641179&view=diff
==============================================================================
--- geronimo/samples/branches/1.0/migration-ejb-session/dd/META-INF/openejb-jar.xml (original)
+++ geronimo/samples/branches/1.0/migration-ejb-session/dd/META-INF/openejb-jar.xml Wed Mar 26 00:14:58 2008
@@ -28,7 +28,7 @@
<jndi-name>CustomerHomeRemote</jndi-name>
<local-jndi-name></local-jndi-name>
<resource-ref>
- <ref-name>jdbc/ibm-demo</ref-name>
+ <ref-name>jdbc/geronimo-demo</ref-name>
<resource-link>SystemDatasource</resource-link>
</resource-ref>
</entity>
Modified: geronimo/samples/branches/1.0/migration-ejb-session/maven.xml
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-ejb-session/maven.xml?rev=641179&r1=641178&r2=641179&view=diff
==============================================================================
--- geronimo/samples/branches/1.0/migration-ejb-session/maven.xml (original)
+++ geronimo/samples/branches/1.0/migration-ejb-session/maven.xml Wed Mar 26 00:14:58 2008
@@ -83,7 +83,7 @@
<goal name="run:stateful">
<!--<attainGoal name="jboss:start"/>-->
- <ant:java classname="com.ibm.demo.client.StatefulClient"
+ <ant:java classname="org.apache.geronimo.demo.ejb.session.client.StatefulClient"
fork="true"
failonerror="true"
classpathref="jboss.client.classpath">
@@ -93,7 +93,7 @@
<goal name="run:stateless">
<!--<attainGoal name="jboss:start"/>-->
- <ant:java classname="com.ibm.demo.client.StatelessClient"
+ <ant:java classname="org.apache.geronimo.demo.ejb.session.client.StatelessClient"
fork="true"
failonerror="true"
classpathref="jboss.client.classpath"/>
@@ -104,7 +104,7 @@
<ant:echo>Getting Classpath.....</ant:echo>
<ant:echo>${geronimo.client.classpath}</ant:echo>
<!--<attainGoal name="jboss:start"/>-->
- <ant:java classname="com.ibm.demo.client.StatefulClient"
+ <ant:java classname="org.apache.geronimo.demo.ejb.session.client.StatefulClient"
fork="true"
failonerror="true"
classpathref="geronimo.client.classpath">
@@ -114,7 +114,7 @@
<goal name="run-g:stateless">
<!--<attainGoal name="jboss:start"/>-->
- <ant:java classname="com.ibm.demo.client.StatelessClient"
+ <ant:java classname="org.apache.geronimo.demo.ejb.session.client.StatelessClient"
fork="true"
failonerror="true"
classpathref="geronimo.client.classpath"/>
Modified: geronimo/samples/branches/1.0/migration-ejb-session/project.properties
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-ejb-session/project.properties?rev=641179&r1=641178&r2=641179&view=diff
==============================================================================
--- geronimo/samples/branches/1.0/migration-ejb-session/project.properties (original)
+++ geronimo/samples/branches/1.0/migration-ejb-session/project.properties Wed Mar 26 00:14:58 2008
@@ -13,12 +13,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-maven.ejb.includes=com/ibm/demo/entity/**, com/ibm/demo/session/**
-maven.ejb.excludes=com/ibm/demo/client/**
+maven.ejb.includes=org/apache/geronimo/demo/ejb/session/entity/**, org/apache/geronimo/demo/ejb/session/session/**
+maven.ejb.excludes=org/apache/geronimo/demo/ejb/session/client/**
maven.ejb.src=dd
-maven.war.classes.excludes=com/ibm/demo/entity/**, com/ibm/demo/session/**
-maven.war.classes.includes=com/ibm/demo/client/**
+maven.war.classes.excludes=org/apache/geronimo/demo/ejb/session/entity/**, org/apache/geronimo/demo/ejb/session/session/**
+maven.war.classes.includes=org/apache/geronimo/demo/ejb/session/client/**
maven.jboss.home=C:/jboss-4.0.2
maven.geronimo.home=C:/geronimo-1.0
Added: geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/client/StatefulClient.java
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/client/StatefulClient.java?rev=641179&view=auto
==============================================================================
--- geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/client/StatefulClient.java (added)
+++ geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/client/StatefulClient.java Wed Mar 26 00:14:58 2008
@@ -0,0 +1,119 @@
+/*
+* 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.
+*/
+package org.apache.geronimo.demo.ejb.session.client;
+
+import java.io.*;
+import java.rmi.RemoteException;
+import java.util.Date;
+import java.util.Random;
+
+import javax.ejb.CreateException;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.rmi.PortableRemoteObject;
+
+import org.apache.geronimo.demo.ejb.session.session.stateful.StatefulLoanManagerHomeRemote;
+import org.apache.geronimo.demo.ejb.session.session.stateful.StatefulLoanManagerRemote;
+
+
+public class StatefulClient {
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+
+ Integer id = new Integer(0);
+ String name = "";
+ String sssNo = "";
+ String address = "";
+ Date birthdate = new Date();
+ Double annualSalary = new Double(0.0);
+ Double loanAmount = new Double(0.0);
+
+ int startPK = 0;
+ StatefulLoanManagerRemote loanmanager = null;
+ Random generator = new Random();
+
+ try{
+ Context jndiContext = new InitialContext();
+ Object ref = jndiContext.lookup("StatefulLoanManagerHomeRemote");
+ StatefulLoanManagerHomeRemote home = (StatefulLoanManagerHomeRemote)
+ PortableRemoteObject.narrow(ref, StatefulLoanManagerHomeRemote.class);
+ loanmanager = home.create();
+
+ } catch(CreateException ce){
+ ce.printStackTrace();
+ } catch(RemoteException re){
+ re.printStackTrace();
+ } catch(NamingException ne){
+ ne.printStackTrace();
+ }
+
+
+ //System.out.println("Please enter loan details:");
+
+ try{
+
+ startPK = loanmanager.getMaxPK();
+
+ } catch (RemoteException re){
+ re.printStackTrace();
+ }
+ for(int i=startPK + 1;i<startPK + generator.nextInt(14) + 1;i++){
+ id = new Integer(i);
+ name = "Customer" + i;
+ address = "Address" + i;
+ sssNo = "SSS:" + i;
+ birthdate = new Date();
+ annualSalary = new Double(generator.nextDouble() * 150000.0 + 20000.0);
+ loanAmount = new Double(generator.nextDouble() * 1000000.0 + 50000.0);
+
+ try{
+ loanmanager.submitLoanApplication(id, name, address, birthdate, sssNo, annualSalary, loanAmount);
+ System.out.println("Submitting new loan application...");
+ System.out.println("-> submit count is now = " + loanmanager.getSubmitCount());
+ }catch (RemoteException re){
+ re.printStackTrace();
+ }
+ }
+
+ try{
+ System.out.println(loanmanager.getSubmitCount() + " loan applications were submitted.");
+ }catch(RemoteException re){
+ re.printStackTrace();
+ }
+ }
+
+ public static String getInput(){
+ // open up standard input
+ BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
+
+ String input = null;
+ // read the user input from the command-line; need to use try/catch with the
+ // readLine() method
+ try {
+ input = br.readLine();
+ }catch (IOException ioe) {
+ System.out.println("IO error trying to read your input!");
+ System.exit(1);
+ }
+ return input;
+ }
+
+}
Added: geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/client/StatefulClientServlet.java
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/client/StatefulClientServlet.java?rev=641179&view=auto
==============================================================================
--- geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/client/StatefulClientServlet.java (added)
+++ geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/client/StatefulClientServlet.java Wed Mar 26 00:14:58 2008
@@ -0,0 +1,133 @@
+/*
+* 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.
+*/
+package org.apache.geronimo.demo.ejb.session.client;
+
+import java.io.*;
+import java.rmi.RemoteException;
+import java.util.Date;
+import java.util.Random;
+
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.ServletException;
+import javax.servlet.ServletContext;
+
+import javax.ejb.CreateException;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.rmi.PortableRemoteObject;
+
+import org.apache.geronimo.demo.ejb.session.session.stateful.StatefulLoanManagerHomeRemote;
+import org.apache.geronimo.demo.ejb.session.session.stateful.StatefulLoanManagerRemote;
+
+
+
+public class StatefulClientServlet extends HttpServlet {
+
+ private ServletContext ctx;
+ private int submitCount = 0;
+
+ private StatefulLoanManagerRemote loanmanager;
+
+ public void init() throws ServletException {
+
+ this.ctx = getServletContext();
+ loanmanager = null;
+
+ try{
+ Context jndiContext = new InitialContext();
+ Object ref = jndiContext.lookup("java:/comp/env/ejb/StatefulLoanManagerHomeRemote");
+ StatefulLoanManagerHomeRemote home = (StatefulLoanManagerHomeRemote)
+ PortableRemoteObject.narrow(ref, StatefulLoanManagerHomeRemote.class);
+
+ loanmanager = home.create();
+
+ } catch(CreateException ce){
+ ce.printStackTrace();
+ } catch(RemoteException re){
+ re.printStackTrace();
+ } catch(NamingException ne){
+ ne.printStackTrace();
+ } catch(Exception e) {
+ e.printStackTrace();
+ throw new ServletException(e);
+ }
+
+
+ }
+
+ public void destroy() {
+
+ }
+
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doGet(request, response);
+ }
+
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+
+ Integer id = new Integer(0);
+ String name = "";
+ String sssNo = "";
+ String address = "";
+ Date birthdate = new Date();
+ Double annualSalary = new Double(0.0);
+ Double loanAmount = new Double(0.0);
+
+ int startPK = 0;
+
+ Random generator = new Random();
+
+ try{
+ startPK = loanmanager.getMaxPK();
+ } catch (RemoteException re){
+ re.printStackTrace();
+ }
+ for(int i=startPK + 1;i<startPK + generator.nextInt(14) + 1;i++){
+ id = new Integer(i);
+ name = "Customer" + i;
+ address = "Address" + i;
+ sssNo = "SSS:" + i;
+ birthdate = new Date();
+ annualSalary = new Double(generator.nextDouble() * 150000.0 + 20000.0);
+ loanAmount = new Double(generator.nextDouble() * 1000000.0 + 50000.0);
+
+ try{
+ loanmanager.submitLoanApplication(id, name, address, birthdate, sssNo, annualSalary, loanAmount);
+ System.out.println("Submitting new loan application...");
+ System.out.println("-> submit count is now = " + loanmanager.getSubmitCount());
+ }catch (RemoteException re){
+ re.printStackTrace();
+ }
+ }
+
+ try{
+ submitCount = loanmanager.getSubmitCount();
+ }catch (RemoteException re){
+ re.printStackTrace();
+ }
+
+ request.setAttribute("count", new Integer(submitCount).toString());
+
+ ctx.getRequestDispatcher("/stateful.jsp").include(request, response);
+ }
+
+}
Added: geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/client/StatelessClient.java
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/client/StatelessClient.java?rev=641179&view=auto
==============================================================================
--- geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/client/StatelessClient.java (added)
+++ geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/client/StatelessClient.java Wed Mar 26 00:14:58 2008
@@ -0,0 +1,74 @@
+/*
+* 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.
+*/
+package org.apache.geronimo.demo.ejb.session.client;
+
+
+import javax.naming.InitialContext;
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.ejb.CreateException;
+import javax.rmi.PortableRemoteObject;
+
+import org.apache.geronimo.demo.ejb.session.session.stateless.LoanManagerHomeRemote;
+import org.apache.geronimo.demo.ejb.session.session.stateless.LoanManagerRemote;
+
+import java.rmi.RemoteException;
+import java.util.List;
+import java.util.Iterator;
+
+/**
+ * @author hisidro
+ *
+ */
+public class StatelessClient {
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+
+ try{
+ Context jndiContext = new InitialContext();
+ Object ref = jndiContext.lookup("LoanManagerHomeRemote");
+ LoanManagerHomeRemote home = (LoanManagerHomeRemote)
+ PortableRemoteObject.narrow(ref, LoanManagerHomeRemote.class);
+
+ LoanManagerRemote loanmanager = home.create();
+
+ // Get a list of all denied loans
+ List deniedLoans = loanmanager.deniedLoans();
+
+ if(deniedLoans!=null){
+ //CustomerRemote customer = null;
+ String customer = new String();
+ System.out.println("Customers with denied loan applications:");
+ for(Iterator i = deniedLoans.iterator();i.hasNext();){
+ customer = (String) i.next();
+ System.out.println("- " + customer);
+ }
+ }else{
+ System.out.println("There are no denied loans in the database.");
+ }
+ } catch(CreateException ce){
+ ce.printStackTrace();
+ } catch(RemoteException re){
+ re.printStackTrace();
+ } catch(NamingException ne){
+ ne.printStackTrace();
+ }
+ }
+}
Added: geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/client/StatelessClientServlet.java
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/client/StatelessClientServlet.java?rev=641179&view=auto
==============================================================================
--- geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/client/StatelessClientServlet.java (added)
+++ geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/client/StatelessClientServlet.java Wed Mar 26 00:14:58 2008
@@ -0,0 +1,98 @@
+/*
+* 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.
+*/
+package org.apache.geronimo.demo.ejb.session.client;
+
+
+import javax.naming.InitialContext;
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.ejb.CreateException;
+import javax.rmi.PortableRemoteObject;
+
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.ServletException;
+import javax.servlet.ServletContext;
+
+import org.apache.geronimo.demo.ejb.session.session.stateless.LoanManagerHomeRemote;
+import org.apache.geronimo.demo.ejb.session.session.stateless.LoanManagerRemote;
+
+import java.io.IOException;
+import java.rmi.RemoteException;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * @author hisidro
+ *
+ */
+public class StatelessClientServlet extends HttpServlet {
+
+ private ServletContext ctx;
+ private List deniedLoans = new ArrayList();
+ private LoanManagerRemote loanmanager;
+
+ public void init() throws ServletException {
+ try{
+ this.ctx = getServletContext();
+
+ Context jndiContext = new InitialContext();
+ Object ref = jndiContext.lookup("java:/comp/env/ejb/LoanManagerHomeRemote");
+ LoanManagerHomeRemote home = (LoanManagerHomeRemote)
+ PortableRemoteObject.narrow(ref, LoanManagerHomeRemote.class);
+
+ loanmanager = home.create();
+
+ } catch(CreateException ce){
+ ce.printStackTrace();
+ } catch(RemoteException re){
+ re.printStackTrace();
+ } catch(NamingException ne){
+ ne.printStackTrace();
+ } catch(Exception e) {
+ e.printStackTrace();
+ throw new ServletException(e);
+ }
+ }
+
+ public void destroy() {
+
+ }
+
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ doGet(request, response);
+ }
+
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+
+ // Get a list of all denied loans
+ deniedLoans = loanmanager.deniedLoans();
+
+ if(deniedLoans==null){
+ System.out.println("No denied loans");
+ deniedLoans.add("No denied loan applications.");
+ }
+
+ request.setAttribute("customers", deniedLoans);
+
+ ctx.getRequestDispatcher("/stateless.jsp").include(request, response);
+ }
+
+}
Added: geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/entity/CustomerBean.java
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/entity/CustomerBean.java?rev=641179&view=auto
==============================================================================
--- geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/entity/CustomerBean.java (added)
+++ geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/entity/CustomerBean.java Wed Mar 26 00:14:58 2008
@@ -0,0 +1,501 @@
+/*
+* 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.
+*/
+/*
+ * Created on Sep 26, 2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.apache.geronimo.demo.ejb.session.entity;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Date;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBException;
+import javax.ejb.EntityBean;
+import javax.ejb.EntityContext;
+import javax.ejb.FinderException;
+import javax.ejb.ObjectNotFoundException;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.sql.DataSource;
+
+/**
+ * @author cpineda
+ *
+ * TODO To change the template for this generated type comment go to Window -
+ * Preferences - Java - Code Style - Code Templates
+ */
+public class CustomerBean implements EntityBean {
+
+ public Integer id;
+
+ public String name;
+
+ public String address;
+
+ public Date birthdate;
+
+ public String sssNo;
+
+ public Double annualSalary;
+
+ public Double loanAmount;
+
+ public EntityContext context;
+
+ /**
+ *
+ * @param id
+ * @param name
+ * @param sssNo
+ * @param address
+ * @param birthdate
+ * @param annualSalary
+ * @param loanAmount
+ * @return @throws
+ * CreateException
+ */
+ public Integer ejbCreate(Integer id, String name, String sssNo,
+ String address, Date birthdate, Double annualSalary,
+ Double loanAmount) throws CreateException {
+ String insertQuery = "INSERT INTO CUSTOMER "
+ + "(ID,NAME,SSS_NO,BIRTHDATE,ADDRESS,ANNUAL_SALARY,LOAN_AMOUNT)"
+ + " VALUES (?,?,?,?,?,?,?)";
+ this.id = id;
+ this.name = name;
+ this.birthdate = birthdate;
+ this.sssNo = sssNo;
+ this.address = address;
+ this.annualSalary = annualSalary;
+ this.loanAmount = loanAmount;
+ Connection conn = null;
+ PreparedStatement ps = null;
+ try {
+ conn = this.getConnection();
+ ps = conn.prepareStatement(insertQuery);
+ ps.setInt(1, id.intValue());
+ ps.setString(2, name);
+ ps.setString(3, sssNo);
+ ps.setDate(4, new java.sql.Date(birthdate.getTime()));
+ ps.setString(5, address);
+ ps.setDouble(6, annualSalary.doubleValue());
+ ps.setDouble(7, loanAmount.doubleValue());
+ if (ps.executeUpdate() != 1) {
+ throw new CreateException("Failed to Add Customer");
+ }
+ } catch (SQLException se) {
+ throw new EJBException(se);
+ } finally {
+ try {
+ ps.close();
+ } catch (Exception e) {
+ }
+ try {
+ conn.close();
+ } catch (Exception e) {
+ }
+ }
+ return id;
+ }
+
+ /**
+ *
+ * @param id
+ * @return @throws
+ * CreateException
+ */
+ public Integer ejbCreate(Integer id) throws CreateException {
+ String insertQuery = "INSERT INTO CUSTOMER " + "(ID)" + " VALUES (?)";
+ this.id = id;
+ Connection conn = null;
+ PreparedStatement ps = null;
+ try {
+ conn = this.getConnection();
+ ps = conn.prepareStatement(insertQuery);
+ ps.setInt(1, id.intValue());
+ if (ps.executeUpdate() != 1) {
+ throw new CreateException("Failed to Add Customer");
+ }
+ } catch (SQLException se) {
+ se.printStackTrace();
+ throw new EJBException(se);
+ } finally {
+ try {
+ ps.close();
+ } catch (Exception e) {
+ }
+ try {
+ conn.close();
+ } catch (Exception e) {
+ }
+ }
+ return id;
+ }
+
+ /**
+ *
+ * @param id
+ * @param name
+ * @param sssNo
+ * @param address
+ * @param birthdate
+ * @param annualSalary
+ * @param loanAmount
+ */
+ public void ejbPostCreate(Integer id, String name, String sssNo,
+ String address, Date birthdate, Double annualSalary,
+ Double loanAmount) {
+
+ }
+
+ /**
+ *
+ * @param id
+ */
+ public void ejbPostCreate(Integer id) {
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.ejb.EntityBean#setEntityContext(javax.ejb.EntityContext)
+ */
+ public void setEntityContext(EntityContext context) {
+ this.context = context;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.ejb.EntityBean#unsetEntityContext()
+ */
+ public void unsetEntityContext() {
+ this.context = null;
+ }
+
+ /**
+ *
+ * @param primaryKey
+ * @return @throws
+ * FinderException
+ */
+ public Integer ejbFindByPrimaryKey(Integer primaryKey)
+ throws FinderException {
+ Connection conn = null;
+ PreparedStatement ps = null;
+ ResultSet result = null;
+ String query = "SELECT ID FROM CUSTOMER WHERE ID=?";
+
+ try {
+ conn = this.getConnection();
+ ps = conn.prepareStatement(query);
+ ps.setInt(1, primaryKey.intValue());
+ result = ps.executeQuery();
+ if (!result.next()) {
+ throw new ObjectNotFoundException(
+ "Customer not found with ID: " + primaryKey);
+ }
+ } catch (SQLException se) {
+ throw new EJBException(se);
+ } finally {
+ try {
+ result.close();
+ } catch (Exception e) {
+ }
+ try {
+ ps.close();
+ } catch (Exception e) {
+ }
+ try {
+ conn.close();
+ } catch (Exception e) {
+ }
+ }
+ return primaryKey;
+ }
+
+ /**
+ *
+ * @param sssNo
+ * @return @throws
+ * FinderException
+ */
+ public Integer ejbFindBySssNo(String sssNo) throws FinderException {
+ Connection conn = null;
+ PreparedStatement ps = null;
+ ResultSet result = null;
+ String query = "SELECT ID FROM CUSTOMER WHERE SSS_NO=?";
+ int customerId;
+
+ try {
+ conn = this.getConnection();
+ ps = conn.prepareStatement(query);
+ ps.setString(1, sssNo);
+ result = ps.executeQuery();
+ if (!result.next()) {
+ throw new ObjectNotFoundException(
+ "Customer not found with SSS_NO:" + sssNo);
+ } else {
+ customerId = result.getInt(1);
+ }
+ if (result.next()) {
+ //Invalid state duplicate entry for unique index
+ throw new SQLException(
+ "Invalid database state.Duplicate entries for unique index SSS_NO");
+ }
+ } catch (SQLException se) {
+ throw new EJBException(se);
+ } finally {
+ try {
+ result.close();
+ } catch (Exception e) {
+ }
+ try {
+ ps.close();
+ } catch (Exception e) {
+ }
+ try {
+ conn.close();
+ } catch (Exception e) {
+ }
+ }
+ return new Integer(customerId);
+ }
+
+ public void ejbActivate() {
+ // Not implemented.
+ }
+
+ public void ejbPassivate() {
+ // Not implemented.
+ }
+
+ public void ejbLoad() {
+
+ Integer primaryKey = (Integer) context.getPrimaryKey();
+ Connection conn = null;
+ PreparedStatement ps = null;
+ ResultSet result = null;
+ String query = "SELECT NAME,BIRTHDATE,SSS_NO,ADDRESS,ANNUAL_SALARY,LOAN_AMOUNT"
+ + " FROM CUSTOMER WHERE ID=?";
+ try {
+ conn = this.getConnection();
+ ps= conn.prepareStatement(query);
+ ps.setInt(1, primaryKey.intValue());
+ result = ps.executeQuery();
+
+ if (result.next()) {
+ this.id = primaryKey;
+ this.name = result.getString(1);
+ this.birthdate = new Date(result.getDate(2).getTime());
+ this.sssNo = result.getString(3);
+ this.address = result.getString(4);
+ this.annualSalary = new Double(result.getDouble(5));
+ this.loanAmount = new Double(result.getDouble(6));
+
+ } else {
+ throw new EJBException();
+ }
+ } catch (SQLException se) {
+ throw new EJBException(se);
+ } finally {
+ try {
+ result.close();
+ } catch (Exception e) {
+ }
+ try {
+ ps.close();
+ } catch (Exception e) {
+ }
+ try {
+ conn.close();
+ } catch (Exception e) {
+ }
+ }
+ }
+
+ public void ejbStore() {
+ String updateQuery = "UPDATE CUSTOMER SET NAME=?, BIRTHDATE=?, SSS_NO=?, ADDRESS=?,ANNUAL_SALARY=?,LOAN_AMOUNT=? WHERE ID=?";
+ Connection conn = null;
+ PreparedStatement ps = null;
+ try {
+ conn = this.getConnection();
+ ps = conn.prepareStatement(updateQuery);
+ ps.setString(1, name);
+ ps.setDate(2, new java.sql.Date(birthdate.getTime()));
+ ps.setString(3, sssNo);
+ ps.setString(4, address);
+ ps.setDouble(5, annualSalary.doubleValue());
+ ps.setDouble(6, loanAmount.doubleValue());
+ ps.setInt(7, id.intValue());
+ ps.executeUpdate();
+ /*if (ps.executeUpdate() != 1) {
+ throw new EJBException("ejbStore unable to update table");
+ }*/
+ } catch (SQLException se) {
+ throw new EJBException(se);
+ } finally {
+ try {
+ ps.close();
+ } catch (Exception e) {
+ }
+ try {
+ conn.close();
+ } catch (Exception e) {
+ }
+ }
+ }
+
+ public void ejbRemove() {
+ String deleteQuery = "DELETE FROM CUSTOMER WHERE ID=?";
+ Connection conn = null;
+ PreparedStatement ps = null;
+ try {
+ conn = this.getConnection();
+ ps = conn.prepareStatement(deleteQuery);
+ ps.setInt(1, id.intValue());
+ if (ps.executeUpdate() != 1) {
+ throw new EJBException("ejbStore unable to update table");
+ }
+ } catch (SQLException se) {
+ throw new EJBException(se);
+ } finally {
+ try {
+ ps.close();
+ } catch (Exception e) {
+ }
+ try {
+ conn.close();
+ } catch (Exception e) {
+ }
+ }
+ }
+
+ /**
+ *
+ * @return @throws
+ * SQLException
+ */
+ private Connection getConnection() throws SQLException {
+ try {
+ Context jndiCntx = new InitialContext();
+ DataSource ds = (DataSource) jndiCntx
+ .lookup("java:comp/env/jdbc/geronimo-demo");
+ return ds.getConnection();
+ } catch (NamingException ne) {
+ ne.printStackTrace();
+ throw new EJBException(ne);
+ }
+ }
+
+ /**
+ * @return Returns the address.
+ */
+ public String getAddress() {
+ return address;
+ }
+
+ /**
+ * @param address
+ * The address to set.
+ */
+ public void setAddress(String address) {
+ this.address = address;
+ }
+
+ /**
+ * @return Returns the annualSalary.
+ */
+ public Double getAnnualSalary() {
+ return annualSalary;
+ }
+
+ /**
+ * @param annualSalary
+ * The annualSalary to set.
+ */
+ public void setAnnualSalary(Double annualSalary) {
+ this.annualSalary = annualSalary;
+ }
+
+ /**
+ * @return Returns the birthdate.
+ */
+ public Date getBirthdate() {
+ return birthdate;
+ }
+
+ /**
+ * @param birthdate
+ * The birthdate to set.
+ */
+ public void setBirthdate(Date birthdate) {
+ this.birthdate = birthdate;
+ }
+
+ /**
+ * @return Returns the loanAmount.
+ */
+ public Double getLoanAmount() {
+ return loanAmount;
+ }
+
+ /**
+ * @param loanAmount
+ * The loanAmount to set.
+ */
+ public void setLoanAmount(Double loanAmount) {
+ this.loanAmount = loanAmount;
+ }
+
+ /**
+ * @return Returns the name.
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name
+ * The name to set.
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * @return Returns the sssNo.
+ */
+ public String getSssNo() {
+ return sssNo;
+ }
+
+ /**
+ * @param sssNo
+ * The sssNo to set.
+ */
+ public void setSssNo(String sssNo) {
+ this.sssNo = sssNo;
+ }
+}
\ No newline at end of file
Added: geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/entity/CustomerHomeRemote.java
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/entity/CustomerHomeRemote.java?rev=641179&view=auto
==============================================================================
--- geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/entity/CustomerHomeRemote.java (added)
+++ geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/entity/CustomerHomeRemote.java Wed Mar 26 00:14:58 2008
@@ -0,0 +1,85 @@
+/*
+* 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.
+*/
+/*
+ * Created on Sep 26, 2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.apache.geronimo.demo.ejb.session.entity;
+
+import java.rmi.RemoteException;
+import java.util.Date;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBHome;
+import javax.ejb.FinderException;
+
+/**
+ * @author cpineda
+ *
+ * TODO To change the template for this generated type comment go to Window -
+ * Preferences - Java - Code Style - Code Templates
+ */
+public interface CustomerHomeRemote extends EJBHome {
+
+ /**
+ *
+ * @param id
+ * @param name
+ * @param sssNo
+ * @param address
+ * @param birthdate
+ * @param annualSalary
+ * @param loanAmount
+ * @return
+ * @throws CreateException
+ * @throws RemoteException
+ */
+ public CustomerRemote create(Integer id,String name,String sssNo,String address,Date birthdate,
+ Double annualSalary,Double loanAmount) throws CreateException,RemoteException;
+
+ /**
+ *
+ * @param primaryKey
+ * @return
+ * @throws CreateException
+ * @throws RemoteException
+ */
+ public CustomerRemote create(Integer primaryKey)throws CreateException,RemoteException;
+
+ /**
+ *
+ * @param pk
+ * @return @throws
+ * FinderException
+ * @throws RemoteException
+ */
+ public CustomerRemote findByPrimaryKey(Integer pk) throws FinderException,
+ RemoteException;
+
+ /**
+ *
+ * @param sssNo
+ * @return @throws
+ * FinderException
+ * @throws RemoteException
+ */
+ public CustomerRemote findBySssNo(String sssNo) throws FinderException,
+ RemoteException;
+
+}
\ No newline at end of file
Added: geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/entity/CustomerRemote.java
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/entity/CustomerRemote.java?rev=641179&view=auto
==============================================================================
--- geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/entity/CustomerRemote.java (added)
+++ geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/entity/CustomerRemote.java Wed Mar 26 00:14:58 2008
@@ -0,0 +1,58 @@
+/*
+* 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.
+*/
+/*
+ * Created on Sep 26, 2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.apache.geronimo.demo.ejb.session.entity;
+
+import java.util.Date;
+
+import javax.ejb.EJBObject;
+import java.rmi.RemoteException;
+
+/**
+ * @author cpineda
+ *
+ * TODO To change the template for this generated type comment go to Window -
+ * Preferences - Java - Code Style - Code Templates
+ */
+public interface CustomerRemote extends EJBObject {
+
+
+ public void setName(String name) throws RemoteException;
+ public String getName() throws RemoteException;
+
+ public void setSssNo(String sssNo) throws RemoteException;
+ public String getSssNo() throws RemoteException;
+
+ public void setAddress(String address) throws RemoteException;
+ public String getAddress() throws RemoteException;
+
+ public void setBirthdate(Date birthdate) throws RemoteException;
+ public Date getBirthdate() throws RemoteException;
+
+ public void setAnnualSalary(Double annualSalary) throws RemoteException;
+ public Double getAnnualSalary() throws RemoteException;
+
+ public void setLoanAmount(Double loanAmount) throws RemoteException;
+ public Double getLoanAmount() throws RemoteException;
+
+
+}
\ No newline at end of file
Added: geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/session/stateful/StatefulLoanManagerBean.java
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/session/stateful/StatefulLoanManagerBean.java?rev=641179&view=auto
==============================================================================
--- geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/session/stateful/StatefulLoanManagerBean.java (added)
+++ geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/session/stateful/StatefulLoanManagerBean.java Wed Mar 26 00:14:58 2008
@@ -0,0 +1,124 @@
+/*
+* 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.
+*/
+package org.apache.geronimo.demo.ejb.session.session.stateful;
+
+import javax.ejb.*;
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.InitialContext;
+import javax.rmi.PortableRemoteObject;
+
+import org.apache.geronimo.demo.ejb.session.entity.CustomerHomeRemote;
+import org.apache.geronimo.demo.ejb.session.entity.CustomerRemote;
+
+import java.rmi.RemoteException;
+import java.util.Date;
+
+
+/**
+ * @author hisidro
+ *
+ */
+public class StatefulLoanManagerBean implements SessionBean{
+
+ private int submit_count;
+
+ public void ejbCreate(){
+ this.submit_count = 0;
+ }
+
+ public void ejbRemove(){}
+ public void ejbActivate(){}
+ public void ejbPassivate(){}
+ public void setSessionContext(SessionContext ctx){}
+
+ /**
+ * @param id
+ * @param name
+ * @param address
+ * @param birthdate
+ * @param sssNo
+ * @param annualSalary
+ * @param loanAmount
+ */
+ public void submitLoanApplication(Integer id, String name, String address, Date birthdate,
+ String sssNo, Double annualSalary, Double loanAmount) {
+
+ CustomerHomeRemote customerHome = null;
+ CustomerRemote customer = null;
+
+ try{
+ Context jndiContext = new InitialContext();
+ Object obj = jndiContext.lookup("java:comp/env/ejb/CustomerHomeRemote");
+
+ customerHome = (CustomerHomeRemote) PortableRemoteObject.narrow(obj, CustomerHomeRemote.class);
+ } catch (NamingException ne){
+ System.out.println("Naming Exception: " + ne.getMessage());
+ }
+
+ try{
+ customer = customerHome.create(id, name, sssNo, address, birthdate, annualSalary, loanAmount);
+ submit_count++;
+ } catch(RemoteException re){
+ System.out.println("Remote Exception: " + re.getMessage());
+ } catch(CreateException ce){
+ System.out.println("Create Exception: " + ce.getMessage());
+ }
+ }
+
+ /**
+ * @return
+ */
+ public int getSubmitCount(){
+ return submit_count;
+ }
+
+ /**
+ * @return
+ */
+ public int getMaxPK(){
+ int maxPK = 0;
+
+ CustomerHomeRemote customerHome = null;
+ CustomerRemote customer = null;
+
+ try{
+ Context jndiContext = new InitialContext();
+ Object obj = jndiContext.lookup("java:comp/env/ejb/CustomerHomeRemote");
+
+ customerHome = (CustomerHomeRemote) PortableRemoteObject.narrow(obj, CustomerHomeRemote.class);
+ } catch (NamingException ne){
+ System.out.println("Naming Exception: " + ne.getMessage());
+ }
+
+ for(int pk = 1;;pk++){
+ try{
+ customer = customerHome.findByPrimaryKey(new Integer(pk));
+ } catch(FinderException fe){
+ System.out.println("Find Exception: " + fe.getMessage());
+ maxPK = pk - 1;
+ break;
+ } catch(RemoteException re){
+ System.out.println("Remote Exception: " + re.getMessage());
+ break;
+ }
+ }
+
+ return maxPK;
+ }
+
+}
\ No newline at end of file
Added: geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/session/stateful/StatefulLoanManagerHomeRemote.java
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/session/stateful/StatefulLoanManagerHomeRemote.java?rev=641179&view=auto
==============================================================================
--- geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/session/stateful/StatefulLoanManagerHomeRemote.java (added)
+++ geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/session/stateful/StatefulLoanManagerHomeRemote.java Wed Mar 26 00:14:58 2008
@@ -0,0 +1,34 @@
+/*
+* 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.
+*/
+package org.apache.geronimo.demo.ejb.session.session.stateful;
+
+import javax.ejb.*;
+import java.rmi.RemoteException;
+
+/**
+ * @author hisidro
+ *
+ */
+public interface StatefulLoanManagerHomeRemote extends EJBHome {
+
+ /**
+ * @return
+ * @throws RemoteException
+ * @throws CreateException
+ */
+ public StatefulLoanManagerRemote create() throws RemoteException, CreateException;
+}
\ No newline at end of file
Added: geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/session/stateful/StatefulLoanManagerRemote.java
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/session/stateful/StatefulLoanManagerRemote.java?rev=641179&view=auto
==============================================================================
--- geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/session/stateful/StatefulLoanManagerRemote.java (added)
+++ geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/session/stateful/StatefulLoanManagerRemote.java Wed Mar 26 00:14:58 2008
@@ -0,0 +1,53 @@
+/*
+* 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.
+*/
+package org.apache.geronimo.demo.ejb.session.session.stateful;
+
+import javax.ejb.*;
+import java.rmi.RemoteException;
+import java.util.Date;
+
+/**
+ * @author hisidro
+ *
+ */
+public interface StatefulLoanManagerRemote extends EJBObject{
+
+ /**
+ * @param id
+ * @param name
+ * @param address
+ * @param birthdate
+ * @param sssNo
+ * @param annualSalary
+ * @param loanAmount
+ * @throws RemoteException
+ */
+ public void submitLoanApplication(Integer id, String name, String address, Date birthdate,
+ String sssNo, Double annualSalary, Double loanAmount) throws RemoteException;
+
+ /**
+ * @return
+ * @throws RemoteException
+ */
+ public int getSubmitCount() throws RemoteException;
+
+ /**
+ * @return
+ * @throws RemoteException
+ */
+ public int getMaxPK() throws RemoteException;
+}
\ No newline at end of file
Added: geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/session/stateless/LoanManagerBean.java
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/session/stateless/LoanManagerBean.java?rev=641179&view=auto
==============================================================================
--- geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/session/stateless/LoanManagerBean.java (added)
+++ geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/session/stateless/LoanManagerBean.java Wed Mar 26 00:14:58 2008
@@ -0,0 +1,89 @@
+/*
+* 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.
+*/
+package org.apache.geronimo.demo.ejb.session.session.stateless;
+
+import javax.ejb.*;
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.InitialContext;
+import javax.rmi.PortableRemoteObject;
+
+import org.apache.geronimo.demo.ejb.session.entity.CustomerHomeRemote;
+import org.apache.geronimo.demo.ejb.session.entity.CustomerRemote;
+
+import java.rmi.RemoteException;
+import java.util.List;
+import java.util.ArrayList;
+
+
+/**
+ * @author hisidro
+ *
+ */
+public class LoanManagerBean implements SessionBean{
+
+ public void ejbCreate(){}
+ public void ejbRemove(){}
+ public void ejbActivate(){}
+ public void ejbPassivate(){}
+ public void setSessionContext(SessionContext ctx){}
+
+ /**
+ * @return
+ */
+ public List deniedLoans() {
+
+ CustomerHomeRemote customerHome = null;
+
+ try{
+ Context jndiContext = new InitialContext();
+ Object obj = jndiContext.lookup("java:comp/env/ejb/CustomerHomeRemote");
+
+ customerHome = (CustomerHomeRemote) PortableRemoteObject.narrow(obj, CustomerHomeRemote.class);
+ } catch (NamingException ne){
+ System.out.println("Naming Exception: " + ne.getMessage());
+ }
+
+ List granted = new ArrayList();
+
+ //loop through all customers
+ CustomerRemote customer = null;
+ for (int i = 1; ; i++){
+ Integer pk = new Integer(i);
+ try{
+ customer = customerHome.findByPrimaryKey(pk);
+ } catch(FinderException fe){
+ System.out.println("Find Exception: " + fe.getMessage());
+ break;
+ } catch(RemoteException re){
+ System.out.println("Remote Exception: " + re.getMessage());
+ break;
+ }
+ // Check to see if the annualSalary to loanAmount ratio is not acceptable (<0.1)
+
+ try{
+ double ratio = customer.getAnnualSalary().doubleValue() / customer.getLoanAmount().doubleValue();
+ if((customer != null)&&(ratio < 0.1)){
+ granted.add(customer.getName());
+ }
+ }catch (RemoteException re){
+ System.out.println("Remote Exception: " + re.getMessage());
+ }
+ }
+ return granted;
+ }
+}
\ No newline at end of file
Added: geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/session/stateless/LoanManagerHomeRemote.java
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/session/stateless/LoanManagerHomeRemote.java?rev=641179&view=auto
==============================================================================
--- geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/session/stateless/LoanManagerHomeRemote.java (added)
+++ geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/session/stateless/LoanManagerHomeRemote.java Wed Mar 26 00:14:58 2008
@@ -0,0 +1,34 @@
+/*
+* 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.
+*/
+package org.apache.geronimo.demo.ejb.session.session.stateless;
+
+import javax.ejb.*;
+import java.rmi.RemoteException;
+
+/**
+ * @author hisidro
+ *
+ */
+public interface LoanManagerHomeRemote extends EJBHome {
+
+ /**
+ * @return
+ * @throws RemoteException
+ * @throws CreateException
+ */
+ public LoanManagerRemote create() throws RemoteException, CreateException;
+}
\ No newline at end of file
Added: geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/session/stateless/LoanManagerRemote.java
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/session/stateless/LoanManagerRemote.java?rev=641179&view=auto
==============================================================================
--- geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/session/stateless/LoanManagerRemote.java (added)
+++ geronimo/samples/branches/1.0/migration-ejb-session/src/org/apache/geronimo/demo/ejb/session/session/stateless/LoanManagerRemote.java Wed Mar 26 00:14:58 2008
@@ -0,0 +1,34 @@
+/*
+* 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.
+*/
+package org.apache.geronimo.demo.ejb.session.session.stateless;
+
+import javax.ejb.*;
+import java.rmi.RemoteException;
+import java.util.List;
+
+/**
+ * @author hisidro
+ *
+ */
+public interface LoanManagerRemote extends EJBObject{
+
+ /**
+ * @return
+ * @throws RemoteException
+ */
+ public List deniedLoans() throws RemoteException;
+}
\ No newline at end of file
Modified: geronimo/samples/branches/1.0/migration-ejb-session/src/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-ejb-session/src/webapp/WEB-INF/web.xml?rev=641179&r1=641178&r2=641179&view=diff
==============================================================================
--- geronimo/samples/branches/1.0/migration-ejb-session/src/webapp/WEB-INF/web.xml (original)
+++ geronimo/samples/branches/1.0/migration-ejb-session/src/webapp/WEB-INF/web.xml Wed Mar 26 00:14:58 2008
@@ -33,13 +33,13 @@
<servlet>
<display-name>stateless</display-name>
<servlet-name>stateless</servlet-name>
- <servlet-class>com.ibm.demo.client.StatelessClientServlet</servlet-class>
+ <servlet-class>org.apache.geronimo.demo.ejb.session.client.StatelessClientServlet</servlet-class>
</servlet>
<servlet>
<display-name>stateful</display-name>
<servlet-name>stateful</servlet-name>
- <servlet-class>com.ibm.demo.client.StatefulClientServlet</servlet-class>
+ <servlet-class>org.apache.geronimo.demo.ejb.session.client.StatefulClientServlet</servlet-class>
</servlet>
<servlet-mapping>
@@ -59,14 +59,14 @@
<ejb-ref>
<ejb-ref-name>ejb/LoanManagerHomeRemote</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
- <home>com.ibm.demo.session.stateless.LoanManagerHomeRemote</home>
- <remote>com.ibm.demo.session.stateless.LoanManagerRemote</remote>
+ <home>org.apache.geronimo.demo.ejb.session.session.stateless.LoanManagerHomeRemote</home>
+ <remote>org.apache.geronimo.demo.ejb.session.session.stateless.LoanManagerRemote</remote>
</ejb-ref>
<ejb-ref>
<ejb-ref-name>ejb/StatefulLoanManagerHomeRemote</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
- <home>com.ibm.demo.session.stateful.StatefulLoanManagerHomeRemote</home>
- <remote>com.ibm.demo.session.stateful.StatefulLoanManagerRemote</remote>
+ <home>org.apache.geronimo.demo.ejb.session.session.stateful.StatefulLoanManagerHomeRemote</home>
+ <remote>org.apache.geronimo.demo.ejb.session.session.stateful.StatefulLoanManagerRemote</remote>
</ejb-ref>
</web-app>