KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > jtests > beans > ejbql > AddressBean


1 package org.objectweb.jonas.jtests.beans.ejbql;
2
3 import java.util.ArrayList JavaDoc;
4 import java.util.Collection JavaDoc;
5 import java.util.Iterator JavaDoc;
6
7 import javax.ejb.EntityContext JavaDoc;
8 import javax.ejb.FinderException JavaDoc;
9 import javax.naming.InitialContext JavaDoc;
10
11
12 public abstract class AddressBean implements javax.ejb.EntityBean JavaDoc {
13     
14     private SequenceSessionLocalHome seqHome = null;
15     private SequenceSessionLocal seqLocal = null;
16
17     public Integer JavaDoc ejbCreateAddress(String JavaDoc street, String JavaDoc city, String JavaDoc state, String JavaDoc zip )
18     throws javax.ejb.CreateException JavaDoc {
19     setStreet(street);
20     setCity(city);
21     setState(state);
22     setZip(zip);
23         int id = seqLocal.getNextNumberInSequence("Address");
24     setId(new Integer JavaDoc(id));
25     return null;
26     }
27
28     public void ejbPostCreateAddress (String JavaDoc street, String JavaDoc city,String JavaDoc state, String JavaDoc zip){
29     }
30
31     // persistent fields
32
public abstract Integer JavaDoc getId();
33     public abstract void setId(Integer JavaDoc id);
34     public abstract String JavaDoc getStreet();
35     public abstract void setStreet(String JavaDoc street);
36     public abstract String JavaDoc getCity();
37     public abstract void setCity(String JavaDoc city);
38     public abstract String JavaDoc getState();
39     public abstract void setState(String JavaDoc state);
40     public abstract String JavaDoc getZip();
41     public abstract void setZip(String JavaDoc zip);
42
43     // abstract ejbSelect() methods
44
public abstract long ejbSelectCountOfCities() throws FinderException JavaDoc;
45     public abstract long ejbSelectCountOfDistinctCities() throws FinderException JavaDoc;
46     public abstract Collection JavaDoc ejbSelectCities() throws FinderException JavaDoc;
47     public abstract Collection JavaDoc ejbSelectCreditCompanies() throws FinderException JavaDoc;
48     public abstract Collection JavaDoc ejbSelectCreditCompanyNames() throws FinderException JavaDoc;
49     public abstract Collection JavaDoc ejbSelectCreditCompanyIds() throws FinderException JavaDoc;
50     public abstract Collection JavaDoc ejbSelectCreditCompanyNums() throws FinderException JavaDoc;
51
52     // Public Home method required to test the private ejbSelectXXXX method
53
public long ejbHomeGetCountOfCities() throws FinderException JavaDoc {
54         return this.ejbSelectCountOfCities();
55     }
56     public long ejbHomeGetCountOfDistinctCities() throws FinderException JavaDoc {
57         return this.ejbSelectCountOfDistinctCities();
58     }
59     public Collection JavaDoc ejbHomeGetAllCities() throws FinderException JavaDoc {
60         return this.ejbSelectCities();
61     }
62     public Collection JavaDoc ejbHomeGetAllCreditCompanies() throws FinderException JavaDoc {
63         Collection JavaDoc ccs = this.ejbSelectCreditCompanies();
64         Iterator JavaDoc iCCs = ccs.iterator();
65         ArrayList JavaDoc ccsId = new ArrayList JavaDoc();
66         while (iCCs.hasNext()) {
67             CreditCompanyLocal cclb = (CreditCompanyLocal) iCCs.next();
68             if (cclb != null) {
69                 ccsId.add(cclb.getId());
70             }
71         }
72         return ccsId;
73     }
74     public Collection JavaDoc ejbHomeGetAllCreditCompanyNames() throws FinderException JavaDoc {
75         return this.ejbSelectCreditCompanyNames();
76     }
77     public Collection JavaDoc ejbHomeGetAllCreditCompanyIds() throws FinderException JavaDoc {
78         return this.ejbSelectCreditCompanyIds();
79     }
80     public Collection JavaDoc ejbHomeGetAllCreditCompanyNums() throws FinderException JavaDoc {
81         return this.ejbSelectCreditCompanyNums();
82     }
83
84     // standard call back methods
85
public void setEntityContext(EntityContext JavaDoc ec){
86     try {
87         InitialContext JavaDoc cntx = new InitialContext JavaDoc( );
88         SequenceSessionLocalHome seqHome =
89             (SequenceSessionLocalHome)cntx.lookup("java:comp/env/ejb/SequenceSessionLocalHome");
90         seqLocal = seqHome.create();
91     } catch(Exception JavaDoc e) {
92         throw new javax.ejb.EJBException JavaDoc(e);
93     }
94         
95     }
96
97     public void unsetEntityContext(){}
98     public void ejbLoad(){}
99     public void ejbStore(){}
100     public void ejbActivate(){}
101     public void ejbPassivate(){}
102     public void ejbRemove() throws javax.ejb.RemoveException JavaDoc{}
103
104 }
105
Popular Tags