Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 91728 invoked from network); 22 Mar 2008 22:11:25 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 22 Mar 2008 22:11:25 -0000 Received: (qmail 38134 invoked by uid 500); 22 Mar 2008 22:11:23 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 38121 invoked by uid 500); 22 Mar 2008 22:11:23 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 38110 invoked by uid 99); 22 Mar 2008 22:11:23 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 22 Mar 2008 15:11:23 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 22 Mar 2008 22:10:52 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id D9FF21A9832; Sat, 22 Mar 2008 15:11:03 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r640093 - in /geronimo/samples/branches/1.0/migration-ejb-bmp/src/org/apache/geronimo: demo/ demo/entity/ demo/entity/bmp/ demo/entity/client/ demo/entity/servlet/ entity/ Date: Sat, 22 Mar 2008 22:11:03 -0000 To: scm@geronimo.apache.org From: ecraig@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080322221103.D9FF21A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: ecraig Date: Sat Mar 22 15:11:02 2008 New Revision: 640093 URL: http://svn.apache.org/viewvc?rev=640093&view=rev Log: Forgot the .demo context.... Added: geronimo/samples/branches/1.0/migration-ejb-bmp/src/org/apache/geronimo/demo/ geronimo/samples/branches/1.0/migration-ejb-bmp/src/org/apache/geronimo/demo/entity/ geronimo/samples/branches/1.0/migration-ejb-bmp/src/org/apache/geronimo/demo/entity/bmp/ geronimo/samples/branches/1.0/migration-ejb-bmp/src/org/apache/geronimo/demo/entity/bmp/CustomerBean.java (with props) geronimo/samples/branches/1.0/migration-ejb-bmp/src/org/apache/geronimo/demo/entity/bmp/CustomerHomeRemote.java (with props) geronimo/samples/branches/1.0/migration-ejb-bmp/src/org/apache/geronimo/demo/entity/bmp/CustomerRemote.java (with props) geronimo/samples/branches/1.0/migration-ejb-bmp/src/org/apache/geronimo/demo/entity/client/ geronimo/samples/branches/1.0/migration-ejb-bmp/src/org/apache/geronimo/demo/entity/client/EntityBeanClient.java (with props) geronimo/samples/branches/1.0/migration-ejb-bmp/src/org/apache/geronimo/demo/entity/servlet/ geronimo/samples/branches/1.0/migration-ejb-bmp/src/org/apache/geronimo/demo/entity/servlet/PublisherServlet.java (with props) Removed: geronimo/samples/branches/1.0/migration-ejb-bmp/src/org/apache/geronimo/entity/ Added: geronimo/samples/branches/1.0/migration-ejb-bmp/src/org/apache/geronimo/demo/entity/bmp/CustomerBean.java URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-ejb-bmp/src/org/apache/geronimo/demo/entity/bmp/CustomerBean.java?rev=640093&view=auto ============================================================================== --- geronimo/samples/branches/1.0/migration-ejb-bmp/src/org/apache/geronimo/demo/entity/bmp/CustomerBean.java (added) +++ geronimo/samples/branches/1.0/migration-ejb-bmp/src/org/apache/geronimo/demo/entity/bmp/CustomerBean.java Sat Mar 22 15:11:02 2008 @@ -0,0 +1,543 @@ +/* + * 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.entity.bmp; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Date; +import java.util.Collection; +import java.util.ArrayList; + +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); + } + + /** + * + * @return + * @throws FinderException + */ + public Collection ejbFindAll() throws FinderException { + Collection ret = new ArrayList(); + Connection conn = null; + PreparedStatement ps = null; + ResultSet result = null; + String query = "SELECT ID FROM CUSTOMER"; + + try { + conn = this.getConnection(); + ps = conn.prepareStatement(query); + result = ps.executeQuery(); + while (result.next()) { + ret.add(new Integer(result.getInt(1))); + } + } 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 ret; + } + + 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) { + se.printStackTrace(); + 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 Propchange: geronimo/samples/branches/1.0/migration-ejb-bmp/src/org/apache/geronimo/demo/entity/bmp/CustomerBean.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/samples/branches/1.0/migration-ejb-bmp/src/org/apache/geronimo/demo/entity/bmp/CustomerBean.java ------------------------------------------------------------------------------ svn:keywords = Date Revision Propchange: geronimo/samples/branches/1.0/migration-ejb-bmp/src/org/apache/geronimo/demo/entity/bmp/CustomerBean.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: geronimo/samples/branches/1.0/migration-ejb-bmp/src/org/apache/geronimo/demo/entity/bmp/CustomerHomeRemote.java URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-ejb-bmp/src/org/apache/geronimo/demo/entity/bmp/CustomerHomeRemote.java?rev=640093&view=auto ============================================================================== --- geronimo/samples/branches/1.0/migration-ejb-bmp/src/org/apache/geronimo/demo/entity/bmp/CustomerHomeRemote.java (added) +++ geronimo/samples/branches/1.0/migration-ejb-bmp/src/org/apache/geronimo/demo/entity/bmp/CustomerHomeRemote.java Sat Mar 22 15:11:02 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. +*/ +/* + * 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.entity.bmp; + +import java.rmi.RemoteException; +import java.util.Date; +import java.util.Collection; + +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; + + public Collection findAll() throws FinderException, + RemoteException; + + /** + * + * @param sssNo + * @return @throws + * FinderException + * @throws RemoteException + */ + public CustomerRemote findBySssNo(String sssNo) throws FinderException, + RemoteException; + +} \ No newline at end of file Propchange: geronimo/samples/branches/1.0/migration-ejb-bmp/src/org/apache/geronimo/demo/entity/bmp/CustomerHomeRemote.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/samples/branches/1.0/migration-ejb-bmp/src/org/apache/geronimo/demo/entity/bmp/CustomerHomeRemote.java ------------------------------------------------------------------------------ svn:keywords = Date Revision Propchange: geronimo/samples/branches/1.0/migration-ejb-bmp/src/org/apache/geronimo/demo/entity/bmp/CustomerHomeRemote.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: geronimo/samples/branches/1.0/migration-ejb-bmp/src/org/apache/geronimo/demo/entity/bmp/CustomerRemote.java URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-ejb-bmp/src/org/apache/geronimo/demo/entity/bmp/CustomerRemote.java?rev=640093&view=auto ============================================================================== --- geronimo/samples/branches/1.0/migration-ejb-bmp/src/org/apache/geronimo/demo/entity/bmp/CustomerRemote.java (added) +++ geronimo/samples/branches/1.0/migration-ejb-bmp/src/org/apache/geronimo/demo/entity/bmp/CustomerRemote.java Sat Mar 22 15:11:02 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.entity.bmp; + +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 Propchange: geronimo/samples/branches/1.0/migration-ejb-bmp/src/org/apache/geronimo/demo/entity/bmp/CustomerRemote.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/samples/branches/1.0/migration-ejb-bmp/src/org/apache/geronimo/demo/entity/bmp/CustomerRemote.java ------------------------------------------------------------------------------ svn:keywords = Date Revision Propchange: geronimo/samples/branches/1.0/migration-ejb-bmp/src/org/apache/geronimo/demo/entity/bmp/CustomerRemote.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: geronimo/samples/branches/1.0/migration-ejb-bmp/src/org/apache/geronimo/demo/entity/client/EntityBeanClient.java URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-ejb-bmp/src/org/apache/geronimo/demo/entity/client/EntityBeanClient.java?rev=640093&view=auto ============================================================================== --- geronimo/samples/branches/1.0/migration-ejb-bmp/src/org/apache/geronimo/demo/entity/client/EntityBeanClient.java (added) +++ geronimo/samples/branches/1.0/migration-ejb-bmp/src/org/apache/geronimo/demo/entity/client/EntityBeanClient.java Sat Mar 22 15:11:02 2008 @@ -0,0 +1,93 @@ +/* +* 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 27, 2005 + * + * TODO To change the template for this generated file go to + * Window - Preferences - Java - Code Style - Code Templates + */ +package org.apache.geronimo.demo.entity.client; + +/** + * @author cpineda + * + * TODO To change the template for this generated type comment go to Window - + * Preferences - Java - Code Style - Code Templates + */ +import java.rmi.RemoteException; +import java.util.Date; + +import javax.naming.InitialContext; +import javax.naming.Context; +import javax.naming.NamingException; +import javax.rmi.PortableRemoteObject; + +import org.apache.geronimo.demo.entity.bmp.*; + +public class EntityBeanClient { + + public static void main(String[] arg) { + try { + Context jndiContext = getInitialContext(); + + String name = "CustomerHomeRemote"; + + Object ref = jndiContext.lookup(name); + CustomerHomeRemote home = (CustomerHomeRemote) PortableRemoteObject + .narrow(ref, CustomerHomeRemote.class); + CustomerRemote customerRemote = null; + System.out.println("creating customer..."); + try{ + customerRemote = home.create(new Integer(1),"Customer 1","2323232","NO INFO",new Date(),new Double(0.0),new Double(0.0)); + }catch(Exception e){/* this will most likely be because the customer already exists in the database. */ } + System.out.print("done."); + + System.out.println("findByPrimaryKeyTest... 1"); + customerRemote = null; + customerRemote = home.findByPrimaryKey(new Integer(1)); + System.out.println("customer name: "+customerRemote.getName()); + System.out.println("customer sss no: "+customerRemote.getSssNo()); + System.out.println("customer loan amount: "+customerRemote.getLoanAmount()); + System.out.println("customer annual salary: "+customerRemote.getAnnualSalary()); + System.out.println("customer birthdate: "+customerRemote.getBirthdate()); + + System.out.println("updating ejb..."); + customerRemote.setName("Customer 2"); + System.out.print("done."); + + System.out.println("findBySssNoTest... 2323232"); + customerRemote = null; + customerRemote = home.findBySssNo("2323232"); + System.out.println("customer name: "+customerRemote.getName()); + System.out.println("customer sss no: "+customerRemote.getSssNo()); + System.out.println("customer loan amount: "+customerRemote.getLoanAmount()); + System.out.println("customer annual salary: "+customerRemote.getAnnualSalary()); + System.out.println("customer birthdate: "+customerRemote.getBirthdate()); + + customerRemote.remove(); + + } catch (Exception e) { + e.printStackTrace(); + } + + } + + public static Context getInitialContext() + throws javax.naming.NamingException { + return new javax.naming.InitialContext(); + } +} \ No newline at end of file Propchange: geronimo/samples/branches/1.0/migration-ejb-bmp/src/org/apache/geronimo/demo/entity/client/EntityBeanClient.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/samples/branches/1.0/migration-ejb-bmp/src/org/apache/geronimo/demo/entity/client/EntityBeanClient.java ------------------------------------------------------------------------------ svn:keywords = Date Revision Propchange: geronimo/samples/branches/1.0/migration-ejb-bmp/src/org/apache/geronimo/demo/entity/client/EntityBeanClient.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: geronimo/samples/branches/1.0/migration-ejb-bmp/src/org/apache/geronimo/demo/entity/servlet/PublisherServlet.java URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-ejb-bmp/src/org/apache/geronimo/demo/entity/servlet/PublisherServlet.java?rev=640093&view=auto ============================================================================== --- geronimo/samples/branches/1.0/migration-ejb-bmp/src/org/apache/geronimo/demo/entity/servlet/PublisherServlet.java (added) +++ geronimo/samples/branches/1.0/migration-ejb-bmp/src/org/apache/geronimo/demo/entity/servlet/PublisherServlet.java Sat Mar 22 15:11:02 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.entity.servlet; + + +import javax.servlet.ServletException; +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletContext; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.naming.InitialContext; +import javax.rmi.PortableRemoteObject; + +import org.apache.geronimo.demo.entity.bmp.*; + +import java.text.SimpleDateFormat; + +import java.io.IOException; + +/** + * Created by IntelliJ IDEA. + * User: simon + * Date: Nov 13, 2004 + * Time: 10:07:03 AM + * To change this template use File | Settings | File Templates. + */ +public class PublisherServlet extends javax.servlet.http.HttpServlet { + + private ServletContext ctx; + + public void init() throws ServletException { + + this.ctx = getServletContext(); + } + + + public void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + doGet(request, response); + } + + public void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + + RequestDispatcher rd = null; + + try { + InitialContext jndiContext = new InitialContext(); + + String name = "java:comp/env/ejb/CustomerHome"; + + Object ref = jndiContext.lookup(name); + CustomerHomeRemote home = (CustomerHomeRemote) PortableRemoteObject.narrow(ref, CustomerHomeRemote.class); + CustomerRemote customerRemote = null; + System.out.println("creating customer..."); + try{ + Integer customerID = new Integer(request.getParameter("clientID")); + String customerName = request.getParameter("clientName"); + String customerSSS = request.getParameter("clientSSS"); + String customerAddress = request.getParameter("clientSSS"); + String birthdate = request.getParameter("clientBirthdate"); + Double customerSalary = new Double(request.getParameter("clientSalary")); + Double customerLoan = new Double(request.getParameter("loanAmt")); + + customerRemote = home.create(customerID,customerName,customerSSS,customerAddress,new SimpleDateFormat("mm/dd/yyyy").parse(birthdate),customerSalary,customerLoan); + }catch(Exception e){/* this will most likely be because the customer already exists in the database. */ } + + rd = ctx.getRequestDispatcher("/list.jsp"); + rd.forward(request, response); + } + catch(Exception e) { + throw new ServletException(e); + } + } +} Propchange: geronimo/samples/branches/1.0/migration-ejb-bmp/src/org/apache/geronimo/demo/entity/servlet/PublisherServlet.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/samples/branches/1.0/migration-ejb-bmp/src/org/apache/geronimo/demo/entity/servlet/PublisherServlet.java ------------------------------------------------------------------------------ svn:keywords = Date Revision Propchange: geronimo/samples/branches/1.0/migration-ejb-bmp/src/org/apache/geronimo/demo/entity/servlet/PublisherServlet.java ------------------------------------------------------------------------------ svn:mime-type = text/plain