1 package org.apache.commons.jcs3.utils.access;
2
3 /*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21
22 /**
23 * Interface for doing a piece of work which is expected to be cached. This is
24 * meant to be used in conjunction with JCSWorker.
25 * <p>
26 * Implement doWork() to return the work being done. isFinished() should return
27 * false until setFinished(true) is called, after which time it should return
28 * true.
29 * </p>
30 */
31 public interface JCSWorkerHelper<V>
32 {
33 /**
34 * Tells us whether or not the work has been completed. This will be called
35 * automatically by JCSWorker. You should not call it yourself.
36 * <p>
37 * @return True if the work has already been done, otherwise false.
38 */
39 boolean isFinished();
40
41 /**
42 * Sets whether or not the work has been done.
43 * <p>
44 * @param isFinished
45 * True if the work has already been done, otherwise false.
46 */
47 void setFinished( boolean isFinished );
48
49 /**
50 * The method to implement to do the work that should be cached. JCSWorker
51 * will call this itself! You should not call this directly.
52 * <p>
53 * @return The result of doing the work to be cached.
54 * @throws Exception
55 * If anything goes wrong while doing the work, an Exception
56 * should be thrown.
57 */
58 V doWork() throws Exception;
59 }