View Javadoc

1   /**
2    *  Copyright 2003-2006 Greg Luck
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  
17  package net.sf.ehcache.distribution;
18  
19  import net.sf.ehcache.Element;
20  
21  import java.io.Serializable;
22  import java.rmi.Remote;
23  import java.rmi.RemoteException;
24  import java.util.List;
25  
26  /**
27   * An interface for a cache peer to which updates are made remotely. The distribution mechanism
28   * is meant to be pluggable. The requirements of RMI force this interface to exten Remote and
29   * throw RemoteException.
30   * <p/>
31   * It is acknowledged that not all implementations will use Remote. Remote is just a marker interface like Serializable,
32   * so nothing specific is required.
33   * <p/>
34   * Non-RMI implementations should be able to use this interface.
35   * Implementations not using RMI should
36   *
37   * @author Greg Luck
38   * @version $Id: CachePeer.java 52 2006-04-24 14:50:03Z gregluck $
39   */
40  public interface CachePeer extends Remote {
41  
42  
43      /**
44       * Put an element in the cache.
45       * <p/>
46       * Resets the access statistics on the element, which would be the case if it has previously been
47       * gotten from a cache, and is now being put back.
48       *
49       * @param element
50       * @throws IllegalStateException    if the cache is not {@link net.sf.ehcache.Status#STATUS_ALIVE}
51       * @throws IllegalArgumentException if the element is null
52       */
53      void put(Element element) throws IllegalArgumentException, IllegalStateException, RemoteException;
54  
55      /**
56       * Removes an {@link net.sf.ehcache.Element} from the Cache. This also removes it from any
57       * stores it may be in.
58       *
59       * @param key
60       * @return true if the element was removed, false if it was not found in the cache
61       * @throws IllegalStateException if the cache is not {@link net.sf.ehcache.Status#STATUS_ALIVE}
62       * @noinspection UnneededThrows,UnusedReturnValue
63       */
64      boolean remove(Serializable key) throws IllegalStateException, RemoteException;
65  
66      /**
67       * Removes all cached items.
68       *
69       * @throws IllegalStateException if the cache is not {@link net.sf.ehcache.Status#STATUS_ALIVE}
70       */
71      void removeAll() throws RemoteException, IllegalStateException;
72  
73  
74      /**
75       * Send the cache peer with an ordered list of {@link EventMessage}s.
76       * <p/>
77       * This enables multiple messages to be delivered in one network invocation.
78       * @param eventMessages a list of type {@link EventMessage}
79       */
80      void send(List eventMessages) throws RemoteException;
81  
82      /**
83       * Gets the cache name.
84       * @noinspection UnneededThrows
85       */
86      String getName() throws RemoteException;
87  
88      /**
89       * Gets the globally unique id for the underlying <code>Cache</code> instance.
90       * @return a String representation of the GUID
91       * @throws RemoteException
92       * @noinspection UnneededThrows
93       */
94      String getGuid() throws RemoteException;
95  
96      /**
97       * The URL for the remote replicator to connect. The value will only have meaning
98       * for a specific implementation of replicator and remote peer.
99       * <p/>
100      * This method is not meant to be used remotely. The replicator already needs to know this. It has
101      * to throw RemoteException to comply with RMI requirements
102      * @return the URL as a string
103      * @noinspection UnneededThrows
104      */
105     String getUrl() throws RemoteException;
106 
107 
108     /**
109      * The URL base for the remote replicator to connect. The value will have meaning
110      * only to a specific implementation of replicator and remote peer.
111      * @noinspection UnneededThrows
112      */
113      String getUrlBase() throws RemoteException;
114 
115 
116 
117 
118 }