ServiceProcess.java
001 /* This file is part of the project "Hilbert II" - http://www.qedeq.org
002  *
003  * Copyright 2000-2013,  Michael Meyling <mime@qedeq.org>.
004  *
005  * "Hilbert II" is free software; you can redistribute
006  * it and/or modify it under the terms of the GNU General Public
007  * License as published by the Free Software Foundation; either
008  * version 2 of the License, or (at your option) any later version.
009  *
010  * This program is distributed in the hope that it will be useful,
011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
013  * GNU General Public License for more details.
014  */
015 
016 package org.qedeq.kernel.bo.common;
017 
018 
019 /**
020  * Process info for a kernel service.
021  *
022  @author  Michael Meyling
023  */
024 public interface ServiceProcess extends Comparable {
025 
026     /**
027      * Get currently running plugin call.
028      *
029      @return  Plugin call.
030      */
031     public PluginCall getPluginCall();
032 
033     /**
034      * Plugin execution.
035      *
036      @param   call    Execute this plugin call.
037      */
038     public void setPluginCall(final PluginCall call);
039 
040     /**
041      * Get thread the service runs within.
042      *
043      @return  Service thread.
044      */
045     public Thread getThread();
046 
047     /**
048      * Get currently processed QedeqBo.
049      *
050      @return  QEDEQ module. Might be <code>null</code>.
051      */
052     public QedeqBo getQedeq();
053 
054     /**
055      * Get name of currently processed QedeqBo.
056      *
057      @return  Name of QEDEQ module. Might be empty string.
058      */
059     public String getQedeqName();
060 
061     /**
062      * Get URL of currently processed QedeqBo.
063      *
064      @return  URL of QEDEQ module. Might be empty string.
065      */
066     public String getQedeqUrl();
067 
068     /**
069      * Get timestamp for service start.
070      *
071      @return  Service start timestamp.
072      */
073     public long getStart();
074 
075     /**
076      * Get timestamp for service stop.
077      *
078      @return  Service stop timestamp.
079      */
080     public long getStop();
081 
082     /**
083      * Is the process still running?
084      *
085      @return  The process is still running. (But it might be blocked.)
086      */
087     public boolean isRunning();
088 
089     /**
090      * Is the process running, but is blocked?
091      *
092      @return  Process is running and blocked.
093      */
094     public boolean isBlocked();
095 
096     /**
097      * Has the process normally ended?
098      *
099      @return  Has the process normally ended?
100      */
101     public boolean wasSuccess();
102 
103     /**
104      * Has the process been canceled?
105      *
106      @return  The process has been canceled.
107      */
108     public boolean wasFailure();
109 
110     /**
111      * Interrupt running thread. Usually because of user canceling. This should initiate a
112      {@link org.qedeq.kernel.se.visitor.InterruptException} when {@link Thread.interrupted()}
113      * is <code>true</code>.
114      */
115     public void interrupt();
116 
117     /**
118      * Get action name. This is what the process mainly does.
119      *
120      @return  Action name.
121      */
122     public String getActionName();
123 
124     /**
125      * Get percentage of currently running execution.
126      *
127      @return  Number between 0 and 100.
128      */
129     public double getExecutionPercentage();
130 
131     /**
132      * Get description of currently taken action.
133      *
134      @return  We are doing this currently.
135      */
136     public String getExecutionActionDescription();
137 
138     /**
139      * Get {@link QedeqModule}s blocked by this process.
140      *
141      @return  Blocked QEDEQ modules.
142      */
143     public QedeqBoSet getBlockedModules();
144 
145     /**
146      * Get process id.
147      *
148      @return  Process identifying number.
149      */
150     public long getId();
151 
152 }