| 1 | /* |
| 2 | * jDTAUS Core API |
| 3 | * Copyright (C) 2005 Christian Schulte |
| 4 | * <cs@schulte.it> |
| 5 | * |
| 6 | * This library is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU Lesser General Public |
| 8 | * License as published by the Free Software Foundation; either |
| 9 | * version 2.1 of the License, or any later version. |
| 10 | * |
| 11 | * This library is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * Lesser General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU Lesser General Public |
| 17 | * License along with this library; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 19 | * |
| 20 | */ |
| 21 | package org.jdtaus.core.container; |
| 22 | |
| 23 | import java.util.Locale; |
| 24 | |
| 25 | /** |
| 26 | * Gets thrown when an implementation fails to operate. |
| 27 | * |
| 28 | * @author <a href="mailto:cs@schulte.it">Christian Schulte</a> |
| 29 | * @version $JDTAUS: ImplementationException.java 8743 2012-10-07 03:06:20Z schulte $ |
| 30 | */ |
| 31 | public class ImplementationException extends IllegalStateException |
| 32 | { |
| 33 | //--Constants--------------------------------------------------------------- |
| 34 | |
| 35 | /** Serial version UID for backwards compatibility with 1.0.x classes. */ |
| 36 | private static final long serialVersionUID = -3001627267463476552L; |
| 37 | |
| 38 | //---------------------------------------------------------------Constants-- |
| 39 | //--Constructors------------------------------------------------------------ |
| 40 | |
| 41 | /** |
| 42 | * Creates a new instance of {@code ImplementationException} taking |
| 43 | * meta-data of the failing implementation. |
| 44 | * |
| 45 | * @param implementation the failing implementation. |
| 46 | * |
| 47 | * @throws NullPointerException if {@code implementation} is {@code null}. |
| 48 | */ |
| 49 | public ImplementationException( final Implementation implementation ) |
| 50 | { |
| 51 | super( ImplementationExceptionBundle.getInstance(). |
| 52 | getImplementationExceptionMessage( |
| 53 | Locale.getDefault(), implementation.getIdentifier(), |
| 54 | implementation.getVersion(), implementation.getModuleName(), |
| 55 | "" ) ); |
| 56 | |
| 57 | this.implementation = implementation; |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Creates a new instance of {@code ImplementationException} taking a |
| 62 | * causing {@code Throwable}. |
| 63 | * |
| 64 | * @param implementation the failing implementation. |
| 65 | * @param cause the causing throwable. |
| 66 | * |
| 67 | * @throws NullPointerException if either {@code implementation} or |
| 68 | * {@code cause} is {@code null}. |
| 69 | */ |
| 70 | public ImplementationException( final Implementation implementation, |
| 71 | final Throwable cause ) |
| 72 | { |
| 73 | super( ImplementationExceptionBundle.getInstance(). |
| 74 | getImplementationExceptionMessage( |
| 75 | Locale.getDefault(), implementation.getIdentifier(), |
| 76 | implementation.getVersion(), implementation.getModuleName(), |
| 77 | cause.getMessage() ) ); |
| 78 | |
| 79 | this.initCause( cause ); |
| 80 | this.implementation = implementation; |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * Creates a new instance of {@code ImplementationException} taking a |
| 85 | * message. |
| 86 | * |
| 87 | * @param implementation the failing implementation. |
| 88 | * @param msg the message describing the error. |
| 89 | * |
| 90 | * @throws NullPointerException if {@code implementation} is {@code null}. |
| 91 | */ |
| 92 | public ImplementationException( final Implementation implementation, |
| 93 | final String msg ) |
| 94 | { |
| 95 | super( ImplementationExceptionBundle.getInstance(). |
| 96 | getImplementationExceptionMessage( |
| 97 | Locale.getDefault(), implementation.getIdentifier(), |
| 98 | implementation.getVersion(), implementation.getModuleName(), |
| 99 | msg ) ); |
| 100 | |
| 101 | this.implementation = implementation; |
| 102 | } |
| 103 | |
| 104 | //------------------------------------------------------------Constructors-- |
| 105 | //--ImplementationException------------------------------------------------- |
| 106 | |
| 107 | /** |
| 108 | * The failing implementation. |
| 109 | * @serial |
| 110 | */ |
| 111 | private final Implementation implementation; |
| 112 | |
| 113 | /** |
| 114 | * Gets the failing implementation. |
| 115 | * |
| 116 | * @return the failing implementation or {@code null}. |
| 117 | */ |
| 118 | public Implementation getImplementation() |
| 119 | { |
| 120 | return this.implementation; |
| 121 | } |
| 122 | |
| 123 | //-------------------------------------------------ImplementationException-- |
| 124 | } |