/** Create a ChargeCodeBean with the specified parameters. This Æ
is never called directly. */
public ChargeCodePK ejbCreate(long id, String name, String description,
ProjectLocal project) throws CreateException
{
setId(id);
setName(name);
setDescription(description);
return null;
}
/** Actions performed after creation. This is never called directly. */
public void ejbPostCreate(long id, String name, String description,
ProjectLocal project)
{
setProject(project);
}
}
10 ChargeCodeEntityBean
267783 WS02.qxd 5/5/03 9:17 AM Page 10
11
ClientInt.java
ClientInt.java is the local Business interface for the Client entity bean. It defines all of
the locally accessible methods for the Client entity bean.
package com.wiley.compBooks.EJwithUML.TimeCardDomain;
import java.util.*;
import javax.ejb.*;
/**
* The ClientInt is the interface that ties the Bean with the Remote
* interface to provide compile time type checking.
*/
public interface ClientInt
{
/** Answers the name of this Client. */
public String getName();
/** Answers the description of this Client. */
public String getDescription();
/** Answers all the projects of this Client. */
ClientEntityBean
267783 WS03.qxd 5/5/03 9:17 AM Page 11
public Collection getProjects();
}
ClientLocal.java
ClientLocal.java is the local EJB interface for the Client entity bean that inherits from
ClientInt.
package com.wiley.compBooks.EJwithUML.TimeCardDomain;
import java.util.*;
import javax.ejb.*;
/**
* The Client bean holds descriptive information about a client.
* ClientLocal is the local interface through which local clients access
* the underlying entity bean.
*/
public interface ClientLocal extends EJBLocalObject, ClientInt
{
}
ClientLocalHome.java
ClientLocalHome.java is the Home interface for the Client entity bean. It defines the
methods for finding and creating Client entity beans.
package com.wiley.compBooks.EJwithUML.TimeCardDomain;
import java.util.*;
import javax.ejb.*;
/**
* The Client bean holds descriptive information about a client.
* ClientLocalHome is the local interface through which local clients
* find and create the underlying entity beans.
*/
public interface ClientLocalHome extends EJBLocalHome
{
/** Answers a Collection that holds references to all of the Client Æ
beans. */
public Collection findAll() throws FinderException;
/**
* Answers a Collection that holds references to all of the Client
* beans that match the name parameter.
*/
public Collection findByName(String name) throws FinderException;
/** Answers a local reference to the Client bean, if it exists. */
12 ClientEntityBean
267783 WS03.qxd 5/5/03 9:17 AM Page 12
public ClientLocal findByPrimaryKey(ClientPK key) throws FinderException;
/** Answers a local reference to the newly created Client bean. */
public ClientLocal create(long id, String name, String description) Æ
throws CreateException;
}
ClientBean.java
ClientBean.java is the implementation class for the Client entity bean. It contains the
data and logic for the bean.
package com.wiley.compBooks.EJwithUML.TimeCardDomain;
import com.wiley.compBooks.EJwithUML.Base.EjbUtil.*;
import java.util.*;
import java.rmi.*;
import javax.ejb.*;
import javax.naming.*;
/**
* The Client bean holds descriptive information about a client.
* ClientBean is the actual entity bean implementation.
*/
public abstract class ClientBean extends BasicEntityBean implements Æ
ClientInt
{
/** CMP fields */
public abstract long getId();
public abstract void setId(long id);
public abstract String getName();
public abstract void setName(String name);
public abstract String getDescription();
public abstract void setDescription(String desc);
/** CMR fields */
public abstract Collection getProjects();
public abstract void setProjects(Collection projects);
public ClientBean()
{
}
/** Create a ClientBean with the specified parameters. This is Æ
never called directly. */
public ClientPK ejbCreate(long id, String name, String description) Æ
throws CreateException
{
setId(id);
setName(name);
ClientEntityBean 13
267783 WS03.qxd 5/5/03 9:17 AM Page 13
setDescription(description);
return null;
}
/** Actions performed after creation. This is never called directly. */
public void ejbPostCreate(long id, String name, String description)
{
}
}
14 ClientEntityBean
267783 WS03.qxd 5/5/03 9:17 AM Page 14
15
ProjectInt.java
ProjectInt.java is the local Business interface for the Project entity bean. It defines the
locally accessible methods for the Project entity bean.
package com.wiley.compBooks.EJwithUML.TimeCardDomain;
import java.util.*;
import javax.ejb.*;
/**
* The ProjectInt is the interface that ties the Bean with the Remote
* interface to provide compile time type checking.
*/
public interface ProjectInt
{
/** Answers the name of this Project. */
public String getName();
/** Answers the description of this Project. */
public String getDescription();
/** Answers the parent Client of this Project. */
ProjectEntityBean
267783 WS04.qxd 5/5/03 9:18 AM Page 15
public ClientLocal getClient();
/** Answers all the charge codes for this Project. */
public Collection getChargeCodes();
}
ProjectLocal.java
ProjectLocal.java is the local EJB interface for the Project entity bean that inherits from
ProjectInt.
package com.wiley.compBooks.EJwithUML.TimeCardDomain;
import java.util.*;
import javax.ejb.*;
/**
* The Project bean holds descriptive information about a project.
* ProjectLocal is the local interface through which local clients
* access the underlying entity bean.
*/
public interface ProjectLocal extends EJBLocalObject, ProjectInt
{
}
ProjectLocalHome.java
ProjectLocalHome.java is the Home interface for the Project entity bean. It defines the
methods for finding and creating Project entity beans.
package com.wiley.compBooks.EJwithUML.TimeCardDomain;
import java.util.*;
import javax.ejb.*;
/**
* The Project bean holds descriptive information about a project.
* ProjectLocalHome is the local interface through which local clients
* find and create the underlying entity beans.
*/
public interface ProjectLocalHome extends EJBLocalHome
{
/** Answers a Collection that contains references to all Projects
associated with the specified client. */
public Collection findByClientId(long clientId) throws FinderException;
/** Answers a Collection that contains references to all Project beans
16 ProjectEntityBean
267783 WS04.qxd 5/5/03 9:18 AM Page 16
that have the specified name. Should be unique. */
public Collection findProject(long clientId, String name) throws Æ
FinderException;
/** Answer a local reference to the Project if it exists. */
public ProjectLocal findByPrimaryKey(ProjectPK key) throws
FinderException;
/** Answer a local reference to the newly created Project. */
public ProjectLocal create(long id, String name, String description,
ClientLocal client) throws CreateException;
}
ProjectBean.java
ProjectBean.java is the implementation class for the Project entity bean. It holds the
data and logic for the bean.
package com.wiley.compBooks.EJwithUML.TimeCardDomain;
import com.wiley.compBooks.EJwithUML.Base.EjbUtil.*;
import java.util.*;
import java.rmi.*;
import javax.ejb.*;
import javax.naming.*;
/**
* The Project bean holds descriptive information about a project.
* ProjectBean is the actual entity bean implementation.
*/
public abstract class ProjectBean extends BasicEntityBean implements Æ
ProjectInt
{
/** CMP fields */
public abstract long getId();
public abstract void setId(long id);
public abstract String getName();
public abstract void setName(String name);
public abstract String getDescription();
public abstract void setDescription(String desc);
/** CMR fields*/
public abstract ClientLocal getClient();
public abstract void setClient(ClientLocal client);
public abstract Collection getChargeCodes();
public abstract void setChargeCodes(Collection chargeCodes);
public ProjectBean()
{
ProjectEntityBean 17
267783 WS04.qxd 5/5/03 9:18 AM Page 17
}
/** Create a ProjectBean with the specified parameters. This is Æ
never called directly. */
public ProjectPK ejbCreate(long id, String name, String description,
ClientLocal client) throws CreateException
{
setId(id);
setName(name);
setDescription(description);
return null;
}
/** Actions performed after creation. This is never called directly. */
public void ejbPostCreate(long id, String name, String description,
ClientLocal client) throws CreateException
{
setClient(client);
}
}
18 ProjectEntityBean
267783 WS04.qxd 5/5/03 9:18 AM Page 18
19
RecordTimeServlet.java
The RecordTimeServlet uses the RecordTimeWorkflow to retrieve and update time-
cards. If no entry or new charge code is specified, the RecordTimeServlet retrieves the
current timecard and builds an entry form. If an entry is submitted, the RecordTime-
Servlet first updates the timecard through the RecordTimeWorkflow and then builds
an entry form. If a new charge code is specified, then the RecordTimeServlet creates
new zero hour entries for the charge code, updates the timecard, and then builds an
entry form.
package com.wiley.compBooks.EJwithUML.TimecardUI;
import javax.servlet.http.*;
import javax.servlet.*;
import javax.naming.*;
import javax.ejb.*;
import java.rmi.*;
import javax.rmi.PortableRemoteObject;
import javax.servlet.http.*;
import javax.servlet.*;
import javax.naming.*;
RecordTimeServletjava
267783 WS05.qxd 5/5/03 9:18 AM Page 19