001    package org.shiftone.jrat.util;
002    
003    import org.shiftone.jrat.core.JRatException;
004    
005    
006    /**
007     * @author jeff@shiftone.org (Jeff Drost)
008     */
009    public class Command {
010    
011        /**
012         * implement this method if you DO NOT want to return something
013         */
014        protected void run() throws Exception {
015        }
016    
017    
018        /**
019         * implement this method if you want to return something
020         */
021        protected Object call() throws Exception {
022    
023            run();
024    
025            return null;
026        }
027    
028    
029        public Object execute() {
030    
031            try {
032                return call();
033            }
034            catch (RuntimeException e) {
035                throw e;
036            }
037            catch (Throwable e) {
038                throw new JRatException("command failed", e);
039            }
040        }
041    }