01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2006, GeoTools Project Managment Committee (PMC)
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation;
09: * version 2.1 of the License.
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: package org.geotools.factory;
17:
18: // Geotools dependencies
19: import org.geotools.resources.Utilities;
20: import org.geotools.resources.i18n.Errors;
21: import org.geotools.resources.i18n.ErrorKeys;
22:
23: /**
24: * Thrown when {@link FactoryRegistry} is invoked recursively for the same category. This exception
25: * is often the result of a programming error. It happen typically when an implementation of some
26: * {@code FooFactory} interface queries in their constructor, directly or indirectly,
27: * {@link FactoryRegistry#getServiceProvider getServiceProvider} for the same category (namely
28: * {@code FooFactory.class}). Factories implemented as wrappers around other factories of the same
29: * kind are the most likely to fall in this canvas. If this {@code RecursiveSearchException}
30: * was not throw, the application would typically dies with a {@link StackOverflowError}.
31: * <p>
32: * A workaround for this exception is to invoke {@code getServiceProvider} outside the constuctor,
33: * when a method first need it.
34: *
35: * @since 2.3
36: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/metadata/src/main/java/org/geotools/factory/RecursiveSearchException.java $
37: * @version $Id: RecursiveSearchException.java 22443 2006-10-27 20:47:22Z desruisseaux $
38: * @author Martin Desruisseaux
39: */
40: public class RecursiveSearchException extends FactoryRegistryException {
41: /**
42: * For cross-version compatibility.
43: */
44: private static final long serialVersionUID = -2028654588882874110L;
45:
46: /**
47: * Creates a new exception with a default message determined from the specified category.
48: */
49: public RecursiveSearchException(final Class category) {
50: super (Errors.format(ErrorKeys.RECURSIVE_CALL_$1, Utilities
51: .getShortName(category)));
52: }
53:
54: /**
55: * Creates a new exception with the specified detail message.
56: */
57: public RecursiveSearchException(final String message) {
58: super(message);
59: }
60: }
|