/[svn]/jsampler/trunk/src/org/jsampler/task/EnhancedTask.java
ViewVC logotype

Diff of /jsampler/trunk/src/org/jsampler/task/EnhancedTask.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1866 by iliev, Wed Oct 8 22:38:15 2008 UTC revision 1867 by iliev, Mon Mar 16 22:12:32 2009 UTC
# Line 1  Line 1 
1  /*  /*
2   *   JSampler - a java front-end for LinuxSampler   *   JSampler - a java front-end for LinuxSampler
3   *   *
4   *   Copyright (C) 2005-2006 Grigor Iliev <grigor@grigoriliev.com>   *   Copyright (C) 2005-2009 Grigor Iliev <grigor@grigoriliev.com>
5   *   *
6   *   This file is part of JSampler.   *   This file is part of JSampler.
7   *   *
# Line 22  Line 22 
22    
23  package org.jsampler.task;  package org.jsampler.task;
24    
25    import java.util.logging.Level;
26    
27  import net.sf.juife.AbstractTask;  import net.sf.juife.AbstractTask;
28    
29    import org.jsampler.CC;
30    import org.jsampler.HF;
31    
32  import org.linuxsampler.lscp.LSException;  import org.linuxsampler.lscp.LSException;
33    
34    import static org.jsampler.JSI18n.i18n;
35    
36    
37  /**  /**
38   * This class extends <code>AbstractTask</code> to add new features.   * This class extends <code>AbstractTask</code> to add new features.
39   * @author Grigor Iliev   * @author Grigor Iliev
40   */   */
41  public abstract class EnhancedTask<R> extends AbstractTask<R> {  public abstract class EnhancedTask<R> extends AbstractTask<R> {
42            public static final int SOCKET_ERROR = 1;
43          private boolean stopped = false;          private boolean stopped = false;
44          private boolean silent = false;          private boolean silent = false;
45            private boolean showErrorDetails;
46            
47            public
48            EnhancedTask() { this(false); }
49    
50            public
51            EnhancedTask(boolean showErrorDetails) {
52                    this.showErrorDetails = showErrorDetails;
53            }
54    
55            public void
56            run() {
57                    try { exec(); }
58                    catch(java.net.SocketException x) {
59                            setErrorCode(SOCKET_ERROR);
60                            setErrorMessage(i18n.getError("SOCKET_ERROR"));
61                            CC.getLogger().log(Level.FINE, getErrorMessage(), x);
62                    } catch(Exception x) {
63                            setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x));
64                            if(showErrorDetails) setErrorDetails(x);
65                            CC.getLogger().log(Level.FINE, getErrorMessage(), x);
66                            onError(x);
67                    }
68            }
69    
70            public void
71            exec() throws Exception { }
72    
73            public void
74            onError(Exception e) { }
75                    
76          /**          /**
77           * Marks that the execution of this task was interrupted.           * Marks that the execution of this task was interrupted.

Legend:
Removed from v.1866  
changed lines
  Added in v.1867

  ViewVC Help
Powered by ViewVC