View Javadoc

    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    *
    9    *     http://www.apache.org/licenses/LICENSE-2.0
    10   *
    11   * Unless required by applicable law or agreed to in writing, software
    12   * distributed under the License is distributed on an "AS IS" BASIS,
    13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14   * See the License for the specific language governing permissions and
    15   * limitations under the License.
    16   */
    17
    18  /*
    19   * DataStoreCache.java
    20   *
    21   */
    22
    23  package javax.jdo.datastore;
    24
    25  import java.util.Collection;
    26
    27
    28  /**
    29   * Many JDO implementations allow instances to be cached in a
    30   * second-level cache, and allow direct management of the cache by
    31   * knowledgeable applications. This interface standardizes this
    32   * behavior.
    33   * @since 2.0
    34   * @version 2.0
    35   */
    36  public interface DataStoreCache {
    37
    38      /** Evict the parameter instance from the second-level cache.
    39       * @param oid the object id of the instance to evict.
    40       * @since 2.0
    41       */
    42      void evict (Object oid);
    43
    44      /** Evict the parameter instances from the second-level cache.
    45       * All instances in the PersistenceManager's cache are evicted
    46       * from the second-level cache.
    47       * @since 2.0
    48       */
    49      void evictAll ();
    50
    51      /** Evict the parameter instances from the second-level cache.
    52       * @param oids the object ids of the instance to evict.
    53       * @since 2.0
    54       */
    55      void evictAll (Object... oids);
    56
    57      /** Evict the parameter instances from the second-level cache.
    58       * @param oids the object ids of the instance to evict.
    59       * @since 2.0
    60       */
    61      void evictAll (Collection oids);
    62
    63      /** Evict the parameter instances from the second-level cache.
    64       * @param pcClass the class of instances to evict
    65       * @param subclasses if true, evict instances of subclasses also
    66       * @since 2.0
    67       * @deprecated use evictAll (boolean subclasses, Class pcClass)
    68       */
    69      void evictAll (Class pcClass, boolean subclasses);
    70
    71      /** Evict the parameter instances from the second-level cache.
    72       * @param pcClass the class of instances to evict
    73       * @param subclasses if true, evict instances of subclasses also
    74       * @since 2.1
    75       */
    76      void evictAll (boolean subclasses, Class pcClass);
    77
    78      /** Pin the parameter instance in the second-level cache.
    79       * @param oid the object id of the instance to pin.
    80       * @since 2.0
    81       */
    82      void pin (Object oid);
    83
    84      /** Pin the parameter instances in the second-level cache.
    85       * @param oids the object ids of the instances to pin.
    86       * @since 2.0
    87       */
    88      void pinAll (Collection oids);
    89
    90      /** Pin the parameter instances in the second-level cache.
    91       * @param oids the object ids of the instances to pin.
    92       * @since 2.0
    93       */
    94      void pinAll (Object... oids);
    95
    96      /** Pin instances in the second-level cache.
    97       * @param pcClass the class of instances to pin
    98       * @param subclasses if true, pin instances of subclasses also
    99       * @since 2.0
    100      * @deprecated use pinAll (boolean subclasses, Class pcClass)
    101      */
    102     void pinAll (Class pcClass, boolean subclasses);
    103
    104     /** Pin instances in the second-level cache.
    105      * @param pcClass the class of instances to pin
    106      * @param subclasses if true, pin instances of subclasses also
    107      * @since 2.1
    108      */
    109     void pinAll (boolean subclasses, Class pcClass);
    110
    111     /** Unpin the parameter instance from the second-level cache.
    112      * @param oid the object id of the instance to unpin.
    113      * @since 2.0
    114      */
    115     void unpin(Object oid);
    116
    117     /** Unpin the parameter instances from the second-level cache.
    118      * @param oids the object ids of the instance to evict.
    119      * @since 2.0
    120      */
    121     void unpinAll(Collection oids);
    122
    123     /** Unpin the parameter instance from the second-level cache.
    124      * @param oids the object id of the instance to evict.
    125      * @since 2.0
    126      */
    127     void unpinAll(Object... oids);
    128
    129     /** Unpin instances from the second-level cache.
    130      * @param pcClass the class of instances to unpin
    131      * @param subclasses if true, unpin instances of subclasses also
    132      * @since 2.0
    133      * @deprecated use unpinAll(boolean subclasses, Class pcClass)
    134      */
    135     void unpinAll(Class pcClass, boolean subclasses);
    136
    137     /** Unpin instances from the second-level cache.
    138      * @param pcClass the class of instances to unpin
    139      * @param subclasses if true, unpin instances of subclasses also
    140      * @since 2.1
    141      */
    142     void unpinAll(boolean subclasses, Class pcClass);
    143
    144     /**
    145      * This class is an empty implementation of the DataStoreCache
    146      * interface. It can be used by an implementation that does not
    147      * support a second-level cache.
    148      * @since 2.0
    149      */
    150     public class EmptyDataStoreCache implements DataStoreCache {
    151
    152         public EmptyDataStoreCache() {
    153         }
    154
    155         public void evict(Object oid) {
    156         }
    157
    158         public void evictAll() {
    159         }
    160
    161         public void evictAll(Object... oids) {
    162         }
    163
    164         public void evictAll(Collection oids) {
    165         }
    166
    167         public void evictAll(Class pcClass, boolean subclasses) {
    168         }
    169
    170         public void evictAll(boolean subclasses, Class pcClass) {
    171         }
    172
    173         public void pin(Object oid) {
    174         }
    175
    176         public void pinAll(Object... oids) {
    177         }
    178
    179         public void pinAll(Collection oids) {
    180         }
    181
    182         public void pinAll(Class pcClass, boolean subclasses) {
    183         }
    184
    185         public void pinAll(boolean subclasses, Class pcClass) {
    186         }
    187
    188         public void unpin(Object oid) {
    189         }
    190
    191         public void unpinAll(Object... oids) {
    192         }
    193
    194         public void unpinAll(Collection oids) {
    195         }
    196
    197         public void unpinAll(Class pcClass, boolean subclasses) {
    198         }
    199
    200         public void unpinAll(boolean subclasses, Class pcClass) {
    201         }
    202     }
    203 }