KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > dataregistry > VendorBean


1 /*
2  * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. U.S.
3  * Government Rights - Commercial software. Government users are subject
4  * to the Sun Microsystems, Inc. standard license agreement and
5  * applicable provisions of the FAR and its supplements. Use is subject
6  * to license terms.
7  *
8  * This distribution may include materials developed by third parties.
9  * Sun, Sun Microsystems, the Sun logo, Java and J2EE are trademarks
10  * or registered trademarks of Sun Microsystems, Inc. in the U.S. and
11  * other countries.
12  *
13  * Copyright (c) 2005 Sun Microsystems, Inc. Tous droits reserves.
14  *
15  * Droits du gouvernement americain, utilisateurs gouvernementaux - logiciel
16  * commercial. Les utilisateurs gouvernementaux sont soumis au contrat de
17  * licence standard de Sun Microsystems, Inc., ainsi qu'aux dispositions
18  * en vigueur de la FAR (Federal Acquisition Regulations) et des
19  * supplements a celles-ci. Distribue par des licences qui en
20  * restreignent l'utilisation.
21  *
22  * Cette distribution peut comprendre des composants developpes par des
23  * tierces parties. Sun, Sun Microsystems, le logo Sun, Java et J2EE
24  * sont des marques de fabrique ou des marques deposees de Sun
25  * Microsystems, Inc. aux Etats-Unis et dans d'autres pays.
26  */

27
28 package dataregistry;
29
30 import java.util.Collection JavaDoc;
31 import javax.ejb.*;
32
33 /**
34  * This is the bean class for the VendorBean enterprise bean.
35  */

36 public abstract class VendorBean implements EntityBean, VendorLocalBusiness {
37     private EntityContext context;
38     
39     // <editor-fold defaultstate="collapsed" desc="EJB infrastructure methods. Click on the + sign on the left to edit the code.">
40
// TODO Consider creating Transfer Object to encapsulate data
41
// TODO Review finder methods
42
/**
43      * @see EntityBean#setEntityContext(EntityContext)
44      */

45     public void setEntityContext(EntityContext aContext) {
46         context = aContext;
47     }
48     
49     /**
50      * @see EntityBean#ejbActivate()
51      */

52     public void ejbActivate() {
53         
54     }
55     
56     /**
57      * @see EntityBean#ejbPassivate()
58      */

59     public void ejbPassivate() {
60         
61     }
62     
63     /**
64      * @see EntityBean#ejbRemove()
65      */

66     public void ejbRemove() {
67         
68     }
69     
70     /**
71      * @see EntityBean#unsetEntityContext()
72      */

73     public void unsetEntityContext() {
74         context = null;
75     }
76     
77     /**
78      * @see EntityBean#ejbLoad()
79      */

80     public void ejbLoad() {
81         
82     }
83     
84     /**
85      * @see EntityBean#ejbStore()
86      */

87     public void ejbStore() {
88         
89     }
90     // </editor-fold>
91

92     
93     public abstract int getVendorId();
94     public abstract void setVendorId(int vendorId);
95     
96     public abstract String JavaDoc getName();
97     public abstract void setName(String JavaDoc name);
98     
99     public abstract String JavaDoc getAddress();
100     public abstract void setAddress(String JavaDoc address);
101     
102     public abstract String JavaDoc getContact();
103     public abstract void setContact(String JavaDoc contact);
104     
105     public abstract String JavaDoc getPhone();
106     public abstract void setPhone(String JavaDoc phone);
107     
108     public abstract Collection JavaDoc getVendorPartBean();
109     public abstract void setVendorPartBean(Collection JavaDoc vendorPartBean);
110     
111     
112     public VendorKey ejbCreate(int vendorId, String JavaDoc name, String JavaDoc address, String JavaDoc contact, String JavaDoc phone) throws CreateException {
113         if (name == null) {
114             throw new CreateException("The field \"name\" must not be null");
115         }
116         if (address == null) {
117             throw new CreateException("The field \"address\" must not be null");
118         }
119         if (contact == null) {
120             throw new CreateException("The field \"contact\" must not be null");
121         }
122         if (phone == null) {
123             throw new CreateException("The field \"phone\" must not be null");
124         }
125         
126         // TODO add additional validation code, throw CreateException if data is not valid
127
setVendorId(vendorId);
128         setName(name);
129         setAddress(address);
130         setContact(contact);
131         setPhone(phone);
132         
133         return null;
134     }
135     
136     public void ejbPostCreate(int vendorId, String JavaDoc name, String JavaDoc address, String JavaDoc contact, String JavaDoc phone) {
137         // TODO populate relationships here if appropriate
138

139     }
140 }
141
Popular Tags