org.opensubsystems.core.persist
Interface DataFactory

All Known Subinterfaces:
BasicDataFactory, ModifiableDataFactory

public interface DataFactory

Base interface for all data factories responsible for loading and persisting data. Data factory is here to implement Data Access Object pattern as described in http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html or more generically the Abstract Factory pattern as described in http://homepage.mac.com/loeffler/java/patterns/absfac.html by GoF95 http://homepage.mac.com/loeffler/java/patterns.html. It's main purpose is to persist, retrieve and change the persisted data objects in the underlying persistence store without exposing any persistence store dependent information to the rest of the application. This interface doesn't dictate implementation therefore it is possible to have FileDataFactory, DatabaseDataFactory, etc.

Version:
$Id: DataFactory.java,v 1.8 2007/01/28 06:54:51 bastafidli Exp $
Author:
Miro Halas
Code reviewer:
Miro Halas
Code reviewed:
1.5 2005/03/26 03:49:48 bastafidli

Method Summary
 DataObject get(int iId, int iDomainId)
          Get specific data object identified by its id from the persistence store.
 int getDataType()
          Get data type code for DataObject derived class managed by the data factory which implements this interface.
 

Method Detail

getDataType

int getDataType()
Get data type code for DataObject derived class managed by the data factory which implements this interface.

Returns:
int - unique data type code

get

DataObject get(int iId,
               int iDomainId)
               throws OSSException
Get specific data object identified by its id from the persistence store. Every data factory has to support this method otherwise we wouldn't have any way hot to load and test existence of the data.

Parameters:
iId - - id of the data object to get, if the id is NEW_ID a new data object initialized to default values
iDomainId - - if the data object exists in a domain then by specifying the domain id it allows the persistance store to limit the data that will be searched and also possibly enforce in what domain the id can possibly exist. This allows to enforce security on the persistance layer that by ensuring that if the data object doesn't exist in the domain where it is expected to exist, it will not be even retrieved. If the data object doesnt exist in the domain, you can pass DataObject.NEW_ID here since it won't be used.
Returns:
DataObject - specified data object or null if it couldn't be retrieved
Throws:
OSSException - - an error while getting data


Copyright © 2003 - 2006 OpenSubsystems s.r.o.