[demo] / insanejava / trunk / rest-demo / src / main / java / no / brodwall / insanejava / rest / Repository.java Repository:
ViewVC logotype

View of /insanejava/trunk/rest-demo/src/main/java/no/brodwall/insanejava/rest/Repository.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 187 - (download) (as text) (annotate)
Thu Aug 30 22:15:18 2007 UTC (3 years ago) by johannes
File size: 1696 byte(s)
Decreased use of generics
package no.brodwall.insanejava.rest;

import java.io.Serializable;

/**
 * Encapsulates the creation, storage and maintenance of a
 * specific entity type.
 */
public interface Repository {

    /** After insert has been called, retrieve with the resulting key should always
     *  return an equal object.
     */
    Serializable insert(Object entity);

    /** Retrieves the entity with the specified key, or null, if it doesn't
     * exist. retrieve should always return the same object instance until
     * discardChanges or writeChanges is called.
     */
    public Object retrieve(Serializable key);

    /** Update an existing entity in the repository. If there is no entity with the
     * specified key, an exception is thrown.
     */
    void update(Serializable key, Object entity);

    /** Delete an existing entity in the repository. If there is no entity with
     * the specified key, the method returns normally.
     */
    void delete(Serializable key);

    /** After this method is called, any unwritten changes are flushed to the
     * underlying structure. After writeChanges() has been called, retrieve
     * should never return an object instance that has been returned, updated
     * or inserted with this repository.
     */
    public void writeChanges();

    /** After this method is called, any changes since the last discardChanges
     * or writeChanges will be discarded. After this method is called retrieve
     * will never return an object instance that has been returned, updated,
     * or inserted with this repository.
     */
    void discardChanges();


    Serializable getKey(Object entity);
}

Johannes Brodwall
ViewVC Help
Powered by ViewVC 1.0.0