001    package org.apache.ojb.broker;
002    
003    /* Copyright 2002-2005 The Apache Software Foundation
004     *
005     * Licensed under the Apache License, Version 2.0 (the "License");
006     * you may not use this file except in compliance with the License.
007     * You may obtain a copy of the License at
008     *
009     *     http://www.apache.org/licenses/LICENSE-2.0
010     *
011     * Unless required by applicable law or agreed to in writing, software
012     * distributed under the License is distributed on an "AS IS" BASIS,
013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     * See the License for the specific language governing permissions and
015     * limitations under the License.
016     */
017    
018    
019    /**
020     * Exception that is thrown if a violation of an optimistic lock was detected.
021     * 
022     * @author Thomas Mahler
023     * @version $Id: OptimisticLockException.java,v 1.1 2007-08-24 22:17:35 ewestfal Exp $
024     */
025    public class OptimisticLockException extends PersistenceBrokerException
026    {
027        /** The violating object. */
028            private Object sourceObject;
029            
030        /**
031         * Creates a new exception instance.
032         */
033        public OptimisticLockException()
034        {
035            super();
036        }
037    
038        /**
039         * Creates a new exception instance.
040         * 
041         * @param msg The exception message
042         */
043        public OptimisticLockException(String msg)
044        {
045            super(msg);
046        }
047        
048        /**
049         * Creates a new exception instance.
050         * 
051         * @param msg    The exception message
052         * @param source The violating object
053         */
054        public OptimisticLockException(String msg, Object source)
055        {
056            super(msg);
057            sourceObject = source;
058        }    
059    
060        /**
061         * Creates a new exception instance.
062         * 
063         * @param cause The base exception
064         */
065        public OptimisticLockException(Throwable cause)
066        {
067            super(cause);
068        }
069    
070        /**
071         * Gets the violating object.
072         * 
073         * @return The object
074         */
075        public Object getSourceObject()
076        {
077            return sourceObject;
078        }
079    
080        /**
081         * Sets the violating object.
082         * 
083         * @param sourceObject The object
084         */
085        public void setSourceObject(Object sourceObject)
086        {
087            this.sourceObject = sourceObject;
088        }
089    
090    }