catalog.model.service.impl
Class CachedCatalogServiceImpl

java.lang.Object
  extended bycatalog.model.service.impl.CachedCatalogServiceImpl
All Implemented Interfaces:
CatalogService

public class CachedCatalogServiceImpl
extends java.lang.Object
implements CatalogService

The implementation of the CatalogService.

Spring Framework is used to manage this service bean. Since this class is not dependend on Spring API, it can be used outside the Spring IOC container.

Read/write caches for products and categories are implemented inside this class. It will be configured as a singleton in the Spring container. So the caches are in the application scope.

Author:
Derek Y. Shen
See Also:
CatalogService

Constructor Summary
CachedCatalogServiceImpl()
          Default constructor.
 
Method Summary
 void deleteProduct(Product product)
          Delete product.
 java.util.List getAllCategories()
          Get all categories.
 java.util.List getAllProducts()
          Get all products.
 Category getCategory(java.lang.String id)
          Get category by id.
 Product getProduct(java.lang.String id)
          Get product by product id.
 void init()
           
 Product saveProduct(Product product)
          Save the product.
 void setCatalogDao(CatalogDao newCatalogDao)
          Set the CatalogDao.
 void updateProduct(Product product)
          Update product.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CachedCatalogServiceImpl

public CachedCatalogServiceImpl()
                         throws CatalogException
Default constructor.

Throws:
CatalogException - If internal error occurs while populates the caches
Method Detail

setCatalogDao

public void setCatalogDao(CatalogDao newCatalogDao)
Set the CatalogDao.

It can be used by the Spring IOC container.

Parameters:
newCatalogDao - the CatalogDao to be set

saveProduct

public Product saveProduct(Product product)
                    throws CatalogException
Description copied from interface: CatalogService
Save the product.

Specified by:
saveProduct in interface CatalogService
Parameters:
product - the product to be saved
Returns:
the product saved
Throws:
CatalogException
See Also:
CatalogService.saveProduct(Product)

updateProduct

public void updateProduct(Product product)
                   throws CatalogException
Description copied from interface: CatalogService
Update product.

Specified by:
updateProduct in interface CatalogService
Parameters:
product - the product to be updated
Throws:
CatalogException
See Also:
CatalogService.updateProduct(Product)

deleteProduct

public void deleteProduct(Product product)
                   throws CatalogException
Description copied from interface: CatalogService
Delete product.

Specified by:
deleteProduct in interface CatalogService
Parameters:
product - the product to be deleted
Throws:
CatalogException
See Also:
CatalogService.deleteProduct(Product)

getProduct

public Product getProduct(java.lang.String id)
Description copied from interface: CatalogService
Get product by product id.

Specified by:
getProduct in interface CatalogService
Parameters:
id - the product id
Returns:
the product associated with the product id
See Also:
CatalogService.getProduct(String)

getCategory

public Category getCategory(java.lang.String id)
Description copied from interface: CatalogService
Get category by id.

Specified by:
getCategory in interface CatalogService
Parameters:
id - the category id
Returns:
the category associated with the category id
See Also:
CatalogService.getCategory(String)

getAllProducts

public java.util.List getAllProducts()
Description copied from interface: CatalogService
Get all products.

Specified by:
getAllProducts in interface CatalogService
Returns:
a list with all products
See Also:
CatalogService.getAllProducts()

getAllCategories

public java.util.List getAllCategories()
Description copied from interface: CatalogService
Get all categories.

Specified by:
getAllCategories in interface CatalogService
Returns:
a list with all categories

init

public void init()
          throws CatalogException
Throws:
CatalogException


Copyright (c) 2004 The JCatalog Project.