001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.test.foedeployer.ejb.m2mb;
023:
024: import javax.ejb.EntityBean;
025: import javax.ejb.EntityContext;
026: import javax.ejb.FinderException;
027: import javax.ejb.NoSuchEntityException;
028: import javax.ejb.ObjectNotFoundException;
029: import javax.ejb.RemoveException;
030: import javax.ejb.CreateException;
031: import javax.ejb.DuplicateKeyException;
032: import javax.ejb.EJBException;
033:
034: import javax.sql.DataSource;
035: import javax.naming.InitialContext;
036: import javax.naming.NamingException;
037:
038: import java.sql.Connection;
039: import java.sql.Statement;
040: import java.sql.ResultSet;
041: import java.sql.SQLException;
042:
043: import java.util.Collection;
044:
045: import org.apache.log4j.Category;
046:
047: /**
048: * Models a project.
049: *
050: * @ejb.bean
051: * name="Project"
052: * generate="true"
053: * view-type="local"
054: * type="CMP"
055: * local-jndi-name="ProjectEJB.ProjectHome"
056: * reentrant="False"
057: * cmp-version="2.x"
058: * primkey-field="name"
059: *
060: * @ejb.pk
061: * class="java.lang.String"
062: * generate="false"
063: *
064: * @@ejb.finder signature="Collection findAll()"
065: *
066: * @ejb.transaction type="Required"
067: *
068: * @@ejb.persistence table-name="project"
069: * @weblogic:table-name project
070: *
071: * @jboss.create-table "${jboss.create.table}"
072: * @jboss.remove-table "${jboss.remove.table}"
073: *
074: * @author <a href="mailto:aloubyansky@hotmail.com">Alex Loubyansky</a>
075: */
076: public abstract class ProjectBean implements EntityBean {
077: // Constants -----------------------------------------------------
078: static Category log = Category.getInstance(ProjectBean.class);
079:
080: // Attributes ----------------------------------------------------
081: private EntityContext ctx;
082:
083: // CMP
084:
085: /**
086: * Project name: primary key field
087: *
088: * @ejb.pk-field
089: * @ejb.persistent-field
090: * @ejb.interface-method
091: *
092: * xdoclet needs update
093: * @@ejb.persistence
094: * column-name="name"
095: * jdbc-type="VARCHAR"
096: * sql-type="VARCHAR(50)"
097: *
098: * @weblogic:dbms-column name
099: */
100: public abstract String getName();
101:
102: public abstract void setName(String name);
103:
104: // CMR
105:
106: /**
107: * Developers: m2m bidirectional CMR
108: *
109: * @ejb.interface-method
110: *
111: * @ejb.relation
112: * name="Developer-Project"
113: * role-name="Project-Has-Developers"
114: *
115: * @jboss.relation-table
116: * table-name="developer_project"
117: * create-table="${jboss.create.table}"
118: * remove-table="${jboss.remove.table}"
119: * @jboss.relation
120: * fk-contraint="false"
121: * related-pk-field="name"
122: * fk-column="developer"
123: *
124: * @weblogic.relation join-table-name="developer_project"
125: * @weblogic.column-map
126: * foreign-key-column="project"
127: * key-column="name"
128: */
129: public abstract Collection getDevelopers();
130:
131: /**
132: * @ejb.interface-method
133: */
134: public abstract void setDevelopers(Collection developer);
135:
136: // EntityBean Implementation -------------------------------------
137: /**
138: * @ejb.create-method
139: */
140: public String ejbCreate(String name) throws CreateException {
141: setName(name);
142: return null; // See 9.4.2 of the EJB 1.1 specification
143: }
144:
145: public void ejbPostCreate(String name) {
146: }
147:
148: public void ejbRemove() throws RemoveException {
149: log.debug("removed: " + ctx.getPrimaryKey());
150: }
151:
152: public void setEntityContext(EntityContext ctx) {
153: this .ctx = ctx;
154: }
155:
156: public void unsetEntityContext() {
157: ctx = null;
158: }
159:
160: public void ejbActivate() {
161: }
162:
163: public void ejbPassivate() {
164: }
165:
166: public void ejbLoad() {
167: }
168:
169: public void ejbStore() {
170: }
171: }
|