KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > tutorial > callback > client > Client


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.tutorial.callback.client;
8
9 import org.jboss.tutorial.callback.bean.Customer;
10 import org.jboss.tutorial.callback.bean.CustomerDAO;
11
12 import javax.naming.InitialContext JavaDoc;
13
14 import java.util.List JavaDoc;
15
16
17 public class Client
18 {
19    public static void main(String JavaDoc[] args) throws Exception JavaDoc
20    {
21       InitialContext JavaDoc ctx = new InitialContext JavaDoc();
22       CustomerDAO dao = (CustomerDAO) ctx.lookup(CustomerDAO.class.getName());
23
24       System.out.println("Create Bill Burke and Monica Smith");
25       dao.create("Bill", "Burke", "1 Boston Road", "Boston", "MA", "02115");
26       int moId = dao.create("Monica", "Smith", "1 Boston Road", "Boston", "MA", "02115");
27
28       System.out.println("Bill and Monica get married");
29       Customer monica = dao.find(moId);
30       monica.setLast("Burke");
31       dao.merge(monica);
32
33       System.out.println("Get all the Burkes");
34       List JavaDoc burkes = dao.findByLastName("Burke");
35       System.out.println("There are now " + burkes.size() + " Burkes");
36
37       System.out.println("Bill and Monica are moving abroad");
38       dao.delete(burkes);
39    }
40 }
41
Popular Tags