View Javadoc

1   /***
2    *  Copyright 2003-2010 Terracotta, Inc.
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   */
16  package net.sf.ehcache.writer.writebehind.operations;
17  
18  import net.sf.ehcache.writer.CacheWriter;
19  
20  import java.util.List;
21  
22  /***
23   * Interface to implement single operations that are performed with write-behind
24   *
25   * @author Geert Bevin
26   * @version $Id: SingleOperation.html 13146 2011-08-01 17:12:39Z oletizi $
27   */
28  public interface SingleOperation extends KeyBasedOperation {
29      /***
30       * Perform this operation as a single execution with the provided cache writer
31       *
32       * @param cacheWriter the cache writer this operation should be performed upon
33       */
34      public void performSingleOperation(CacheWriter cacheWriter);
35  
36      /***
37       * Creates a batch operation that corresponds to the operation type of this single operation.
38       * <p/>
39       * This batch operation will not be stored in the queue anymore and is solely used for structuring.
40       * The data from the single operation will already be processed in the final form that will be expected by the
41       * {@code CacheWriter} that will be used to execute the batch operation.
42       *
43       * @param operations the single operations that need to be regrouped in the batch operation
44       * @return the created batch operation
45       */
46      public BatchOperation createBatchOperation(List<SingleOperation> operations);
47  
48      /***
49       * Returns a stable identifier for the type this operation can be classified in. This is used to group and order
50       * batched operations.
51       *
52       * @return the identifier for this operation type
53       */
54      public SingleOperationType getType();
55  }