edu.rice.rubis.beans
Class CategoryBean

java.lang.Object
  |
  +--edu.rice.rubis.beans.CategoryBean
All Implemented Interfaces:
javax.ejb.EnterpriseBean, javax.ejb.EntityBean, java.io.Serializable

public class CategoryBean
extends java.lang.Object
implements javax.ejb.EntityBean

CategoryBean is an entity bean with "bean managed persistence". The state of an instance is stored into a relational database. The following table should exist:

 CREATE TABLE categories (
    id   INTEGER UNSIGNED NOT NULL UNIQUE
    name VARCHAR(50),
    PRIMARY KEY(id)
 );
 

Version:
1.0
Author:
Emmanuel Cecchet and Julie Marguerite
See Also:
Serialized Form

Field Summary
 java.lang.Integer id
           
 java.lang.String name
           
 
Constructor Summary
CategoryBean()
           
 
Method Summary
 void ejbActivate()
          Mandatory methods
 CategoryPK ejbCreate(java.lang.String categoryName)
          This method is used to create a new Category Bean.
 java.util.Collection ejbFindAllCategories()
          This method is used to retrieve all categories from the database!
 CategoryPK ejbFindByName(java.lang.String categoryName)
          This method is used to retrieve a Category Bean from its name.
 CategoryPK ejbFindByPrimaryKey(CategoryPK id)
          This method is used to retrieve a Category Bean from its primary key, that is to say its id.
 void ejbLoad()
          Read the reccord from the database and update the bean.
 void ejbPassivate()
           
 void ejbPostCreate(java.lang.String categoryName)
          This method does currently nothing
 void ejbRemove()
          This method delete the record from the database.
 void ejbStore()
          Update the record.
 java.sql.Connection getConnection()
          Retrieve a connection..
 java.lang.Integer getId()
          Get category's id.
 java.lang.String getName()
          Get the category name.
 java.lang.String printCategory()
          Display category information for the BrowseCategories servlet
 java.lang.String printCategoryByRegion(int regionId)
          Display category information for the BrowseCategories servlet
 java.lang.String printCategoryToSellItem(int userId)
          Display category information for the BrowseCategories servlet
 void setEntityContext(javax.ejb.EntityContext context)
          Sets the associated entity context.
 void setName(java.lang.String newName)
          Set category's name
 void unsetEntityContext()
          Unsets the associated entity context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

id

public java.lang.Integer id

name

public java.lang.String name
Constructor Detail

CategoryBean

public CategoryBean()
Method Detail

getId

public java.lang.Integer getId()
                        throws java.rmi.RemoteException
Get category's id.
Returns:
category id
Throws:
java.rmi.RemoteException - if an error occurs

getName

public java.lang.String getName()
                         throws java.rmi.RemoteException
Get the category name.
Returns:
category name
Throws:
java.rmi.RemoteException - if an error occurs

setName

public void setName(java.lang.String newName)
             throws java.rmi.RemoteException
Set category's name
Parameters:
newName - category name
Throws:
java.rmi.RemoteException - if an error occurs

getConnection

public java.sql.Connection getConnection()
                                  throws java.lang.Exception
Retrieve a connection..
Returns:
connection
Throws:
java.lang.Exception - if an error occurs

ejbFindByPrimaryKey

public CategoryPK ejbFindByPrimaryKey(CategoryPK id)
                               throws javax.ejb.FinderException,
                                      java.rmi.RemoteException
This method is used to retrieve a Category Bean from its primary key, that is to say its id.
Parameters:
id - Region id (primary key)
Returns:
the primary key of the category if found else null
Throws:
javax.ejb.FinderException - if an error occurs
java.rmi.RemoteException - if an error occurs

ejbFindByName

public CategoryPK ejbFindByName(java.lang.String categoryName)
                         throws javax.ejb.FinderException,
                                java.rmi.RemoteException
This method is used to retrieve a Category Bean from its name.
Parameters:
categoryName - Category name
Returns:
the primary key of the category if found else null
Throws:
javax.ejb.FinderException - if an error occurs
java.rmi.RemoteException - if an error occurs

ejbFindAllCategories

public java.util.Collection ejbFindAllCategories()
                                          throws java.rmi.RemoteException,
                                                 javax.ejb.FinderException
This method is used to retrieve all categories from the database!
Returns:
Collection of primary keys (eventually empty)
Throws:
java.rmi.RemoteException - if an error occurs
javax.ejb.FinderException - if an error occurs

ejbCreate

public CategoryPK ejbCreate(java.lang.String categoryName)
                     throws javax.ejb.CreateException,
                            java.rmi.RemoteException,
                            javax.ejb.RemoveException
This method is used to create a new Category Bean. Note that the category id is automatically generated by the database (AUTO_INCREMENT) on the primary key.
Parameters:
categoryName - Category name
Returns:
pk primary key set to null
Throws:
javax.ejb.CreateException - if an error occurs
java.rmi.RemoteException - if an error occurs
javax.ejb.RemoveException - if an error occurs

ejbPostCreate

public void ejbPostCreate(java.lang.String categoryName)
This method does currently nothing

ejbActivate

public void ejbActivate()
                 throws java.rmi.RemoteException
Mandatory methods
Specified by:
ejbActivate in interface javax.ejb.EntityBean

ejbPassivate

public void ejbPassivate()
                  throws java.rmi.RemoteException
Specified by:
ejbPassivate in interface javax.ejb.EntityBean

ejbRemove

public void ejbRemove()
               throws java.rmi.RemoteException,
                      javax.ejb.RemoveException
This method delete the record from the database.
Specified by:
ejbRemove in interface javax.ejb.EntityBean
Throws:
java.rmi.RemoteException - if an error occurs
javax.ejb.RemoveException - if an error occurs

ejbStore

public void ejbStore()
              throws java.rmi.RemoteException
Update the record.
Specified by:
ejbStore in interface javax.ejb.EntityBean
Throws:
java.rmi.RemoteException - if an error occurs

ejbLoad

public void ejbLoad()
             throws java.rmi.RemoteException
Read the reccord from the database and update the bean.
Specified by:
ejbLoad in interface javax.ejb.EntityBean
Throws:
java.rmi.RemoteException - if an error occurs

setEntityContext

public void setEntityContext(javax.ejb.EntityContext context)
                      throws java.rmi.RemoteException
Sets the associated entity context. The container invokes this method on an instance after the instance has been created. This method is called in an unspecified transaction context.
Specified by:
setEntityContext in interface javax.ejb.EntityBean
Parameters:
context - - An EntityContext interface for the instance. The instance should store the reference to the context in an instance variable.
Throws:
javax.ejb.EJBException - Thrown by the method to indicate a failure caused by a system-level error.
java.rmi.RemoteException - - This exception is defined in the method signature to provide backward compatibility for enterprise beans written for the EJB 1.0 specification. Enterprise beans written for the EJB 1.1 and higher specification should throw the javax.ejb.EJBException instead of this exception.

unsetEntityContext

public void unsetEntityContext()
                        throws java.rmi.RemoteException
Unsets the associated entity context. The container calls this method before removing the instance. This is the last method that the container invokes on the instance. The Java garbage collector will eventually invoke the finalize() method on the instance. This method is called in an unspecified transaction context.
Specified by:
unsetEntityContext in interface javax.ejb.EntityBean
Throws:
javax.ejb.EJBException - Thrown by the method to indicate a failure caused by a system-level error.
java.rmi.RemoteException - - This exception is defined in the method signature to provide backward compatibility for enterprise beans written for the EJB 1.0 specification. Enterprise beans written for the EJB 1.1 and higher specification should throw the javax.ejb.EJBException instead of this exception.

printCategory

public java.lang.String printCategory()
                               throws java.rmi.RemoteException
Display category information for the BrowseCategories servlet
Returns:
a String containing HTML code
Throws:
java.rmi.RemoteException - if an error occurs
Since:
1.0

printCategoryByRegion

public java.lang.String printCategoryByRegion(int regionId)
                                       throws java.rmi.RemoteException
Display category information for the BrowseCategories servlet
Parameters:
regionId - an int value
Returns:
a String containing HTML code
Throws:
java.rmi.RemoteException - if an error occurs
Since:
1.0

printCategoryToSellItem

public java.lang.String printCategoryToSellItem(int userId)
                                         throws java.rmi.RemoteException
Display category information for the BrowseCategories servlet
Parameters:
userId - an int value
Returns:
a String containing HTML code
Throws:
java.rmi.RemoteException - if an error occurs
Since:
1.0


Copyright © 2003 - ObjectWeb Consortium - All Rights Reserved.