001    /*
002     * (c) 2010 ThoughtWorks Ltd
003     * All rights reserved.
004     *
005     * The software in this package is published under the terms of the BSD
006     * style license a copy of which has been included with this distribution in
007     * the LICENSE.txt file.
008     * 
009     * Created on 19-03-2010.
010     */
011    package com.thoughtworks.proxy.toys.privilege;
012    
013    import java.security.PrivilegedActionException;
014    import java.security.PrivilegedExceptionAction;
015    
016    /**
017     * Direct execution of a {@link PrivilegedExceptionAction}.
018     * 
019     * @author Jörg Schaible
020     * @since 1.0
021     */
022    public class DirectExecutor implements ActionExecutor
023    {
024        public Object execute(PrivilegedExceptionAction<Object> action) throws PrivilegedActionException
025        {
026            try {
027                return action.run();
028            } catch (Exception e) {
029                throw new PrivilegedActionException(e);
030            }
031        }
032    }