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 for cyclic dependency graphs. 027 * 028 * @author <a href="mailto:cs@schulte.it">Christian Schulte</a> 029 * @version $JDTAUS: DependencyCycleException.java 8743 2012-10-07 03:06:20Z schulte $ 030 */ 031public class DependencyCycleException extends IllegalStateException 032{ 033 //--Constants--------------------------------------------------------------- 034 035 /** Serial version UID for backwards compatibility with 1.5.x classes. */ 036 private static final long serialVersionUID = 8471828485552467121L; 037 038 //---------------------------------------------------------------Constants-- 039 //--Constructors------------------------------------------------------------ 040 041 /** 042 * Creates a new {@code DependencyCycleException} taking the involved 043 * implementations. 044 * 045 * @param impl1 the implementation the cycle was detected for. 046 * @param impl2 the implementation introducing the cycle to {@code impl1}. 047 * 048 * @throws NullPointerException if either {@code impl1} or {@code impl2} 049 * is {@code null}. 050 */ 051 public DependencyCycleException( final Implementation impl1, 052 final Implementation impl2 ) 053 { 054 super( DependencyCycleExceptionBundle.getInstance(). 055 getDependencyCycleMessage( Locale.getDefault(), 056 impl1.getIdentifier(), 057 impl2.getIdentifier() ) ); 058 059 this.implementations = new Implementation[] 060 { 061 impl1, impl2 062 }; 063 } 064 065 /** 066 * Creates a new {@code DependencyCycleException} taking identifiers of the 067 * involved implementations. 068 * 069 * @param identifier1 the identifier of the implementation the cycle was 070 * detected for. 071 * @param identifier2 the identifier of the implementation introducing the 072 * cycle. 073 * 074 * @throws NullPointerException if either {@code identifier1} or 075 * {@code identifier2} is {@code null}. 076 */ 077 public DependencyCycleException( final String identifier1, 078 final String identifier2 ) 079 { 080 super( DependencyCycleExceptionBundle.getInstance(). 081 getDependencyCycleMessage( Locale.getDefault(), 082 identifier1, 083 identifier2 ) ); 084 085 this.implementations = null; 086 } 087 088 //------------------------------------------------------------Constructors-- 089 //--DependencyCycleException------------------------------------------------ 090 091 /** 092 * The implementations introducing a cycle. 093 * @serial 094 */ 095 private final Implementation[] implementations; 096 097 /** 098 * Gets the implementation introducing a cycle. 099 * 100 * @return the implementations introducing a cycle. 101 */ 102 public Implementation[] getImplementations() 103 { 104 return this.implementations; 105 } 106 107 //------------------------------------------------DependencyCycleException-- 108}