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