001: package org.objectweb.jonas.jtests.beans.ejbql;
002:
003: import java.util.ArrayList;
004: import java.util.Collection;
005: import java.util.Iterator;
006:
007: import javax.ejb.EntityContext;
008: import javax.ejb.FinderException;
009: import javax.naming.InitialContext;
010:
011: public abstract class AddressBean implements javax.ejb.EntityBean {
012:
013: private SequenceSessionLocalHome seqHome = null;
014: private SequenceSessionLocal seqLocal = null;
015:
016: public Integer ejbCreateAddress(String street, String city,
017: String state, String zip) throws javax.ejb.CreateException {
018: setStreet(street);
019: setCity(city);
020: setState(state);
021: setZip(zip);
022: int id = seqLocal.getNextNumberInSequence("Address");
023: setId(new Integer(id));
024: return null;
025: }
026:
027: public void ejbPostCreateAddress(String street, String city,
028: String state, String zip) {
029: }
030:
031: // persistent fields
032: public abstract Integer getId();
033:
034: public abstract void setId(Integer id);
035:
036: public abstract String getStreet();
037:
038: public abstract void setStreet(String street);
039:
040: public abstract String getCity();
041:
042: public abstract void setCity(String city);
043:
044: public abstract String getState();
045:
046: public abstract void setState(String state);
047:
048: public abstract String getZip();
049:
050: public abstract void setZip(String zip);
051:
052: // abstract ejbSelect() methods
053: public abstract long ejbSelectCountOfCities()
054: throws FinderException;
055:
056: public abstract long ejbSelectCountOfDistinctCities()
057: throws FinderException;
058:
059: public abstract Collection ejbSelectCities() throws FinderException;
060:
061: public abstract Collection ejbSelectCreditCompanies()
062: throws FinderException;
063:
064: public abstract Collection ejbSelectCreditCompanyNames()
065: throws FinderException;
066:
067: public abstract Collection ejbSelectCreditCompanyIds()
068: throws FinderException;
069:
070: public abstract Collection ejbSelectCreditCompanyNums()
071: throws FinderException;
072:
073: // Public Home method required to test the private ejbSelectXXXX method
074: public long ejbHomeGetCountOfCities() throws FinderException {
075: return this .ejbSelectCountOfCities();
076: }
077:
078: public long ejbHomeGetCountOfDistinctCities()
079: throws FinderException {
080: return this .ejbSelectCountOfDistinctCities();
081: }
082:
083: public Collection ejbHomeGetAllCities() throws FinderException {
084: return this .ejbSelectCities();
085: }
086:
087: public Collection ejbHomeGetAllCreditCompanies()
088: throws FinderException {
089: Collection ccs = this .ejbSelectCreditCompanies();
090: Iterator iCCs = ccs.iterator();
091: ArrayList ccsId = new ArrayList();
092: while (iCCs.hasNext()) {
093: CreditCompanyLocal cclb = (CreditCompanyLocal) iCCs.next();
094: if (cclb != null) {
095: ccsId.add(cclb.getId());
096: }
097: }
098: return ccsId;
099: }
100:
101: public Collection ejbHomeGetAllCreditCompanyNames()
102: throws FinderException {
103: return this .ejbSelectCreditCompanyNames();
104: }
105:
106: public Collection ejbHomeGetAllCreditCompanyIds()
107: throws FinderException {
108: return this .ejbSelectCreditCompanyIds();
109: }
110:
111: public Collection ejbHomeGetAllCreditCompanyNums()
112: throws FinderException {
113: return this .ejbSelectCreditCompanyNums();
114: }
115:
116: // standard call back methods
117: public void setEntityContext(EntityContext ec) {
118: try {
119: InitialContext cntx = new InitialContext();
120: SequenceSessionLocalHome seqHome = (SequenceSessionLocalHome) cntx
121: .lookup("java:comp/env/ejb/SequenceSessionLocalHome");
122: seqLocal = seqHome.create();
123: } catch (Exception e) {
124: throw new javax.ejb.EJBException(e);
125: }
126:
127: }
128:
129: public void unsetEntityContext() {
130: }
131:
132: public void ejbLoad() {
133: }
134:
135: public void ejbStore() {
136: }
137:
138: public void ejbActivate() {
139: }
140:
141: public void ejbPassivate() {
142: }
143:
144: public void ejbRemove() throws javax.ejb.RemoveException {
145: }
146:
147: }
|