KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > picocontainer > defaults > CyclicDependencyException


1 /*****************************************************************************
2  * Copyright (c) PicoContainer Organization. All rights reserved. *
3  * ------------------------------------------------------------------------- *
4  * The software in this package is published under the terms of the BSD *
5  * style license a copy of which has been included with this distribution in *
6  * the LICENSE.txt file. *
7  * *
8  * Idea by Rachel Davies, Original code by Aslak Hellesoy and Paul Hammant *
9  *****************************************************************************/

10
11 package org.picocontainer.defaults;
12
13 import org.picocontainer.PicoIntrospectionException;
14
15 import java.util.LinkedList JavaDoc;
16 import java.util.List JavaDoc;
17
18 /**
19  * @author Aslak Hellesøy
20  * @author Jörg Schaible
21  * @version $Revision: 1801 $
22  */

23 public class CyclicDependencyException extends PicoIntrospectionException {
24     private final List JavaDoc stack;
25
26     /**
27      * @since 1.1
28      */

29     public CyclicDependencyException(Class JavaDoc element) {
30         super((Throwable JavaDoc)null);
31         this.stack = new LinkedList JavaDoc();
32         push(element);
33     }
34     
35     /**
36      * @since 1.1
37      */

38     public void push(Class JavaDoc element) {
39         stack.add(element);
40     }
41
42     public Class JavaDoc[] getDependencies() {
43         return (Class JavaDoc[]) stack.toArray(new Class JavaDoc[stack.size()]);
44     }
45
46     public String JavaDoc getMessage() {
47         return "Cyclic dependency: " + stack.toString();
48     }
49 }
50
Popular Tags