KickJava   Java API By Example, From Geeks To Geeks.

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


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 project.
34  *
35  * @ejb.bean
36  * name="Project"
37  * generate="true"
38  * view-type="local"
39  * type="CMP"
40  * local-jndi-name="ProjectEJB.ProjectHome"
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.finder signature="Collection findAll()"
50  *
51  * @ejb.transaction type="Required"
52  *
53  * @@ejb.persistence table-name="project"
54  * @weblogic:table-name project
55  *
56  * @jboss.create-table "${jboss.create.table}"
57  * @jboss.remove-table "${jboss.remove.table}"
58  *
59  * @author <a HREF="mailto:aloubyansky@hotmail.com">Alex Loubyansky</a>
60  */

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

72    /**
73     * Project 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    // CMR
91

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

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

119    public abstract void setDevelopers(Collection JavaDoc developer);
120
121    // EntityBean Implementation -------------------------------------
122
/**
123     * @ejb.create-method
124     */

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