KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > xdoclet > PhoneBean


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999-2004 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: PhoneBean.java,v 1.9 2004/12/01 13:38:37 camillej Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package xdoclet;
27
28 import javax.ejb.EntityContext;
29 import java.util.Date;
30 import javax.naming.InitialContext;
31 import javax.naming.NamingException;
32 /**
33  * PhoneBean is an entity bean with "container managed persistence version 2".
34  * The state of an instance is stored into a relational database.
35  *
36  * @ejb.bean
37  * name="PhoneBean"
38  * description="Deployment descriptor for the PhoneBean bean with CMP2 JOnAS example"
39  * type="CMP"
40  * view-type="local"
41  * jndi-name="PhoneBeanHome"
42  * cmp-version="2.x"
43  * reentrant="false"
44  * @ejb.home
45  * local-class="xdoclet.PhoneHomeLocal"
46  * @ejb.interface
47  * local-class="xdoclet.PhoneLocal"
48  * @ejb:pk
49  * class="java.lang.Object"
50  * @jonas.jdbc-mapping
51  * automatic-pk-field-name="pkphone"
52  * @ejb:finder
53  * signature= "java.util.Collection findAllPhones()"
54  * query ="SELECT OBJECT(o) FROM PhoneBean o"
55  * @jonas.session-timeout
56  * session-timeout="60"
57  * @ejb:transaction type="Required"
58  */

59
60 public abstract class PhoneBean implements javax.ejb.EntityBean {
61     
62     /**
63      * EJBCREATE
64      * @return pk primary key set to null
65      *
66      * @ejb.create-method
67      */

68     public Object ejbCreate( String number, byte type) throws javax.ejb.CreateException {
69     setNumber(number);
70     setType(type);
71     return null;
72     }
73
74     public void ejbPostCreate(String number, byte type) {
75     System.out.println("PhoneBean ejbPostCreate number= "+number);
76     }
77
78         
79     
80     /**
81      * @ejb.persistent-field
82      * @ejb.interface-method
83      * @jonas.cmp-field-jdbc-mapping
84      * field-name="number"
85      * jdbc-field-name="PhoneNumber"
86      */

87     public abstract String getNumber();
88     /**
89      * @ejb.persistent-field
90      * @ejb.interface-method
91      */

92     public abstract void setNumber(String number);
93     /**
94      * @ejb.persistent-field
95      * @ejb.interface-method
96      */

97     public abstract byte getType();
98    /**
99      * @ejb.persistent-field
100      * @ejb.interface-method
101     */

102     public abstract void setType(byte type);
103
104     // standard call back methods
105

106     public void setEntityContext(EntityContext ec){}
107     public void unsetEntityContext(){}
108     public void ejbLoad(){}
109     public void ejbStore(){}
110     public void ejbActivate(){}
111     public void ejbPassivate(){}
112     public void ejbRemove() throws javax.ejb.RemoveException{}
113
114 }
115
Popular Tags