001: /*
002: * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. U.S.
003: * Government Rights - Commercial software. Government users are subject
004: * to the Sun Microsystems, Inc. standard license agreement and
005: * applicable provisions of the FAR and its supplements. Use is subject
006: * to license terms.
007: *
008: * This distribution may include materials developed by third parties.
009: * Sun, Sun Microsystems, the Sun logo, Java and J2EE are trademarks
010: * or registered trademarks of Sun Microsystems, Inc. in the U.S. and
011: * other countries.
012: *
013: * Copyright (c) 2005 Sun Microsystems, Inc. Tous droits reserves.
014: *
015: * Droits du gouvernement americain, utilisateurs gouvernementaux - logiciel
016: * commercial. Les utilisateurs gouvernementaux sont soumis au contrat de
017: * licence standard de Sun Microsystems, Inc., ainsi qu'aux dispositions
018: * en vigueur de la FAR (Federal Acquisition Regulations) et des
019: * supplements a celles-ci. Distribue par des licences qui en
020: * restreignent l'utilisation.
021: *
022: * Cette distribution peut comprendre des composants developpes par des
023: * tierces parties. Sun, Sun Microsystems, le logo Sun, Java et J2EE
024: * sont des marques de fabrique ou des marques deposees de Sun
025: * Microsystems, Inc. aux Etats-Unis et dans d'autres pays.
026: */
027:
028: package dataregistry;
029:
030: import java.util.Collection;
031: import javax.ejb.*;
032:
033: /**
034: * This is the bean class for the VendorBean enterprise bean.
035: */
036: public abstract class VendorBean implements EntityBean,
037: VendorLocalBusiness {
038: private EntityContext context;
039:
040: // <editor-fold defaultstate="collapsed" desc="EJB infrastructure methods. Click on the + sign on the left to edit the code.">
041: // TODO Consider creating Transfer Object to encapsulate data
042: // TODO Review finder methods
043: /**
044: * @see EntityBean#setEntityContext(EntityContext)
045: */
046: public void setEntityContext(EntityContext aContext) {
047: context = aContext;
048: }
049:
050: /**
051: * @see EntityBean#ejbActivate()
052: */
053: public void ejbActivate() {
054:
055: }
056:
057: /**
058: * @see EntityBean#ejbPassivate()
059: */
060: public void ejbPassivate() {
061:
062: }
063:
064: /**
065: * @see EntityBean#ejbRemove()
066: */
067: public void ejbRemove() {
068:
069: }
070:
071: /**
072: * @see EntityBean#unsetEntityContext()
073: */
074: public void unsetEntityContext() {
075: context = null;
076: }
077:
078: /**
079: * @see EntityBean#ejbLoad()
080: */
081: public void ejbLoad() {
082:
083: }
084:
085: /**
086: * @see EntityBean#ejbStore()
087: */
088: public void ejbStore() {
089:
090: }
091:
092: // </editor-fold>
093:
094: public abstract int getVendorId();
095:
096: public abstract void setVendorId(int vendorId);
097:
098: public abstract String getName();
099:
100: public abstract void setName(String name);
101:
102: public abstract String getAddress();
103:
104: public abstract void setAddress(String address);
105:
106: public abstract String getContact();
107:
108: public abstract void setContact(String contact);
109:
110: public abstract String getPhone();
111:
112: public abstract void setPhone(String phone);
113:
114: public abstract Collection getVendorPartBean();
115:
116: public abstract void setVendorPartBean(Collection vendorPartBean);
117:
118: public VendorKey ejbCreate(int vendorId, String name,
119: String address, String contact, String phone)
120: throws CreateException {
121: if (name == null) {
122: throw new CreateException(
123: "The field \"name\" must not be null");
124: }
125: if (address == null) {
126: throw new CreateException(
127: "The field \"address\" must not be null");
128: }
129: if (contact == null) {
130: throw new CreateException(
131: "The field \"contact\" must not be null");
132: }
133: if (phone == null) {
134: throw new CreateException(
135: "The field \"phone\" must not be null");
136: }
137:
138: // TODO add additional validation code, throw CreateException if data is not valid
139: setVendorId(vendorId);
140: setName(name);
141: setAddress(address);
142: setContact(contact);
143: setPhone(phone);
144:
145: return null;
146: }
147:
148: public void ejbPostCreate(int vendorId, String name,
149: String address, String contact, String phone) {
150: // TODO populate relationships here if appropriate
151:
152: }
153: }
|