KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > foedeployer > ejb > m2mb > DeveloperBean


1 /*
2 * JBoss, the OpenSource EJB server
3 *
4 * Distributable under LGPL license.
5 * See terms of license at gnu.org.
6 */

7 package org.jboss.test.foedeployer.ejb.m2mb;
8
9 import javax.ejb.EntityBean JavaDoc;
10 import javax.ejb.EntityContext JavaDoc;
11 import javax.ejb.FinderException JavaDoc;
12 import javax.ejb.NoSuchEntityException JavaDoc;
13 import javax.ejb.ObjectNotFoundException JavaDoc;
14 import javax.ejb.RemoveException JavaDoc;
15 import javax.ejb.CreateException JavaDoc;
16 import javax.ejb.DuplicateKeyException JavaDoc;
17 import javax.ejb.EJBException JavaDoc;
18
19 import javax.sql.DataSource JavaDoc;
20 import javax.naming.InitialContext JavaDoc;
21 import javax.naming.NamingException JavaDoc;
22
23 import java.sql.Connection JavaDoc;
24 import java.sql.Statement JavaDoc;
25 import java.sql.ResultSet JavaDoc;
26 import java.sql.SQLException JavaDoc;
27
28 import java.util.Collection JavaDoc;
29
30 import org.apache.log4j.Category;
31
32 /**
33  * Models a developer.
34  *
35  * @ejb.bean
36  * name="Developer"
37  * generate="true"
38  * view-type="local"
39  * type="CMP"
40  * local-jndi-name="DeveloperEJB.DeveloperHome"
41  * reentrant="False"
42  * cmp-version="2.x"
43  * primkey-field="name"
44  *
45  * @ejb.pk
46  * class="java.lang.String"
47  * generate="false"
48  *
49  * @ejb.transaction type="Required"
50  *
51  * @@ejb:finder signature="Collection findAll()"
52  *
53  * @@ejb.persistence table-name="developer"
54  * @weblogic:table-name developer
55  *
56  * @jboss.create-table "${jboss.create.table}"
57  * @jboss.remove-table "${jboss.remove.table}"
58  *
59  * @author <a HREF="mailto:loubyansky@hotmail.com">Alex Loubyansky</a>
60  */

61 public abstract class DeveloperBean
62    implements EntityBean JavaDoc
63 {
64    // Constants -----------------------------------------------------
65
static Category log = Category.getInstance( DeveloperBean.class );
66
67    // Attributes ----------------------------------------------------
68
private EntityContext JavaDoc ctx;
69
70    // CMP
71

72    /**
73     * Developer's name: primary key field
74     *
75     * @ejb.pk-field
76     * @ejb.persistent-field
77     * @ejb.interface-method
78     *
79     * xdoclet needs update
80     * @@ejb.persistence
81     * column-name="name"
82     * jdbc-type="VARCHAR"
83     * sql-type="VARCHAR(50)"
84     *
85     * @weblogic:dbms-column name
86     */

87    public abstract String JavaDoc getName();
88    public abstract void setName(String JavaDoc name);
89
90    
91    // CMR
92

93    /**
94     * Projects: m2m bidirectional CMR
95     *
96     * @ejb.interface-method
97     *
98     * @ejb.relation
99     * name="Developer-Project"
100     * role-name="Developer-Has-Projects"
101     *
102     * @jboss.relation-table
103     * table-name="developer_project"
104     * create-table="${jboss.create.table}"
105     * remove-table="${jboss.remove.table}"
106     * @jboss.relation
107     * fk-contraint="false"
108     * related-pk-field="name"
109     * fk-column="project"
110     *
111     * @weblogic.relation join-table-name="developer_project"
112     * @weblogic.column-map
113     * foreign-key-column="developer"
114     * key-column="name"
115     */

116    public abstract Collection JavaDoc getProjects();
117    /**
118     * @ejb.interface-method
119     */

120    public abstract void setProjects(Collection JavaDoc projects);
121
122    // EntityBean Implementation -------------------------------------
123
/**
124     * @ejb.create-method
125     */

126    public String JavaDoc ejbCreate( String JavaDoc name )
127       throws CreateException JavaDoc
128    {
129       setName(name);
130       return null; // See 9.4.2 of the EJB 1.1 specification
131
}
132
133    public void ejbPostCreate( String JavaDoc name ) { }
134
135    public void ejbRemove()
136       throws RemoveException JavaDoc
137    {
138       log.debug("removed: " + ctx.getPrimaryKey() );
139    }
140    
141    public void setEntityContext(EntityContext JavaDoc ctx)
142    {
143       this.ctx = ctx;
144    }
145    
146    public void unsetEntityContext()
147    {
148       ctx = null;
149    }
150    
151    public void ejbActivate() { }
152    public void ejbPassivate() { }
153    public void ejbLoad() { }
154    public void ejbStore() { }
155 }
156
Popular Tags