org.picocontainer.visitors.AbstractPicoVisitor Maven / Gradle / Ivy
/*****************************************************************************
* Copyright (C) PicoContainer Organization. All rights reserved. *
* ------------------------------------------------------------------------- *
* The software in this package is published under the terms of the BSD *
* style license a copy of which has been included with this distribution in *
* the LICENSE.txt file. *
*****************************************************************************/
package org.picocontainer.visitors;
import org.picocontainer.PicoVisitor;
import org.picocontainer.PicoException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.security.AccessController;
import java.security.PrivilegedAction;
/**
* Abstract PicoVisitor implementation. A generic traverse method is implemented, that
* accepts any object with a method named "accept", that takes a
* {@link PicoVisitor} as argument and and invokes it. Additionally it provides the
* {@link #checkTraversal()} method, that throws a {@link PicoVisitorTraversalException},
* if currently no traversal is running.
*
* @author Jörg Schaible
*/
@SuppressWarnings("serial")
public abstract class AbstractPicoVisitor implements PicoVisitor {
private boolean traversal;
public Object traverse(final Object node) {
traversal = true;
Object retval =
AccessController.doPrivileged(new PrivilegedAction