001 /*
002 * jDTAUS Core API
003 * Copyright (c) 2005 Christian Schulte
004 *
005 * Christian Schulte, Haldener Strasse 72, 58095 Hagen, Germany
006 * <schulte2005@users.sourceforge.net> (+49 2331 3543887)
007 *
008 * This library is free software; you can redistribute it and/or
009 * modify it under the terms of the GNU Lesser General Public
010 * License as published by the Free Software Foundation; either
011 * version 2.1 of the License, or any later version.
012 *
013 * This library is distributed in the hope that it will be useful,
014 * but WITHOUT ANY WARRANTY; without even the implied warranty of
015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
016 * Lesser General Public License for more details.
017 *
018 * You should have received a copy of the GNU Lesser General Public
019 * License along with this library; if not, write to the Free Software
020 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
021 *
022 */
023 package org.jdtaus.core.container;
024
025 import java.util.Locale;
026
027 /**
028 * Gets thrown when an implementation fails to operate.
029 *
030 * @author <a href="mailto:schulte2005@users.sourceforge.net">Christian Schulte</a>
031 * @version $Id: ImplementationException.java 8044 2009-07-02 01:29:05Z schulte2005 $
032 */
033 public class ImplementationException extends IllegalStateException
034 {
035 //--Constants---------------------------------------------------------------
036
037 /** Serial version UID for backwards compatibility with 1.0.x classes. */
038 private static final long serialVersionUID = -3001627267463476552L;
039
040 //---------------------------------------------------------------Constants--
041 //--Constructors------------------------------------------------------------
042
043 /**
044 * Creates a new instance of {@code ImplementationException} taking
045 * meta-data of the failing implementation.
046 *
047 * @param implementation the failing implementation.
048 *
049 * @throws NullPointerException if {@code implementation} is {@code null}.
050 */
051 public ImplementationException( final Implementation implementation )
052 {
053 super( ImplementationExceptionBundle.getInstance().
054 getImplementationExceptionMessage(
055 Locale.getDefault(), implementation.getIdentifier(),
056 implementation.getVersion(), implementation.getModuleName(),
057 "" ) );
058
059 this.implementation = implementation;
060 }
061
062 /**
063 * Creates a new instance of {@code ImplementationException} taking a
064 * causing {@code Throwable}.
065 *
066 * @param implementation the failing implementation.
067 * @param cause the causing throwable.
068 *
069 * @throws NullPointerException if either {@code implementation} or
070 * {@code cause} is {@code null}.
071 */
072 public ImplementationException( final Implementation implementation,
073 final Throwable cause )
074 {
075 super( ImplementationExceptionBundle.getInstance().
076 getImplementationExceptionMessage(
077 Locale.getDefault(), implementation.getIdentifier(),
078 implementation.getVersion(), implementation.getModuleName(),
079 cause.getMessage() ) );
080
081 this.initCause( cause );
082 this.implementation = implementation;
083 }
084
085 /**
086 * Creates a new instance of {@code ImplementationException} taking a
087 * message.
088 *
089 * @param implementation the failing implementation.
090 * @param msg the message describing the error.
091 *
092 * @throws NullPointerException if {@code implementation} is {@code null}.
093 */
094 public ImplementationException( final Implementation implementation,
095 final String msg )
096 {
097 super( ImplementationExceptionBundle.getInstance().
098 getImplementationExceptionMessage(
099 Locale.getDefault(), implementation.getIdentifier(),
100 implementation.getVersion(), implementation.getModuleName(),
101 msg ) );
102
103 this.implementation = implementation;
104 }
105
106 //------------------------------------------------------------Constructors--
107 //--ImplementationException-------------------------------------------------
108
109 /**
110 * The failing implementation.
111 * @serial
112 */
113 private Implementation implementation;
114
115 /**
116 * Gets the failing implementation.
117 *
118 * @return the failing implementation or {@code null}.
119 */
120 public Implementation getImplementation()
121 {
122 return this.implementation;
123 }
124
125 //-------------------------------------------------ImplementationException--
126 }