001    package org.nanocontainer.persistence;
002    
003    /**
004     * Factory component used by ExceptionHandler in order to create exceptions.
005     * 
006     * @version $Revision: $
007     */
008    public interface ExceptionFactory {
009    
010            /**
011             * Creates an instance of the persistence exception. 
012         * You should return <code>cause</code> if it is already an
013             * instance of Persistence's exception.
014             * 
015             * @param cause Original exception.
016             * @return The desired exception instance.
017             */
018            public RuntimeException createPersistenceException(Throwable cause);
019    
020            /**
021             * Creates an instance of the exception which indicates concurrency failure.
022             * 
023             * @param cause Original exception.
024             * @return The desired exception instance.
025             */
026            public RuntimeException createConcurrencyFailureException(Throwable cause);
027    
028            /**
029             * Creates an instance of the exception which indicates that the version number or timestamp check failed or try
030             * delete or update a row that does not exist anymore. It should be subclass of the one which indicates concurrency
031             * failure.
032             * 
033             * @param cause Original exception.
034             * @param type A string which indicate which entity it has happened or null if it can't be determined.
035             * @param id The id representation of its object or null if it can't be determined.
036             * @return The desired exception instance.
037             */
038            public RuntimeException createStaleObjectStateException(Throwable cause, String type, Object id);
039    
040            /**
041             * Creates an instance of the exception which indicates that an object retrieval failure happens.
042             * 
043             * @param cause Original exception.
044             * @param type A string which indicate which entity it has happened or null if it can't be determined.
045             * @param id The id representation of its object or null if it can't be determined.
046             * @return The desired exception instance.
047             */
048            public RuntimeException createObjectRetrievalFailureException(Throwable cause, String type, Object id);
049    
050            /**
051             * Creates an instance of the exception which indicates that a transaction could not be begun, committed or rolled
052             * back.
053             * 
054             * @param cause Original exception.
055             * @return The desired exception instance.
056             */
057            public RuntimeException createTransactionException(Throwable cause);
058    
059    }