ServiceProcess.java
001 /* This file is part of the project "Hilbert II" - http://www.qedeq.org
002  *
003  * Copyright 2000-2011,  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 import java.util.Map;
019 
020 import org.qedeq.kernel.se.common.Plugin;
021 
022 
023 /**
024  * Process info for a service.
025  *
026  @author  Michael Meyling
027  */
028 public interface ServiceProcess {
029 
030     /**
031      * Get service.
032      *
033      @return  service
034      */
035     public Plugin getService();
036 
037     /**
038      * Get thread the service runs within.
039      *
040      @return  Service thread.
041      */
042     public Thread getThread();
043 
044     /**
045      * Get service.
046      *
047      @return  service
048      */
049     public QedeqBo getQedeq();
050 
051     /**
052      * Get service parameter.
053      *
054      @return  Service parameter.
055      */
056     public Map getParameters();
057 
058     /**
059      * Get associated executor.
060      *
061      @return  Associated executor. Might be <code>null</code>.
062      */
063     public PluginExecutor getExecutor();
064 
065     /**
066      * Set associated executor.
067      *
068      @param   executor    Associated executor.
069      */
070     public void setExecutor(final PluginExecutor executor);
071 
072     /**
073      * Get service parameter. Filters only for parameters that are explicitly for this plugin.
074      *
075      @return  Service parameter.
076      */
077     public String getParameterString();
078 
079     /**
080      * Get timestamp for service start.
081      *
082      @return  Service start timestamp.
083      */
084     public long getStart();
085 
086     /**
087      * Get timestamp for service stop.
088      *
089      @return  Service stop timestamp.
090      */
091     public long getStop();
092 
093     /**
094      * Mark that thread execution was has normally ended.
095      */
096     public void setSuccessState();
097 
098     /**
099      * Mark that thread execution was canceled.
100      */
101     public void setFailureState();
102 
103     /**
104      * Is the process still running?
105      *
106      @return  The process is still running. (But it might be blocked.)
107      */
108     public boolean isRunning();
109 
110     /**
111      * Is the process running, but is blocked?
112      *
113      @return  Process is running and blocked.
114      */
115     public boolean isBlocked();
116 
117     /**
118      * Set blocked state.
119      *
120      @param   blocked Blocked state.
121      */
122     public void setBlocked(final boolean blocked);
123 
124     /**
125      * Has the process normally ended?
126      *
127      @return  Has the process normally ended?
128      */
129     public boolean wasSuccess();
130 
131     /**
132      * Has the process been canceled?
133      *
134      @return  The process has been canceled.
135      */
136     public boolean wasFailure();
137 
138     /**
139      * Interrupt running thread. Usually because of user canceling.
140      */
141     public void interrupt();
142 
143     /**
144      * Get percentage of currently running plugin execution.
145      *
146      @return  Number between 0 and 100.
147      */
148     public double getExecutionPercentage();
149 
150     /**
151      * Get description of currently taken action.
152      *
153      @return  We are doing this currently.
154      */
155     public String getExecutionActionDescription();
156 
157 }