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