Cluster mgr to remove caches when container is destroyed
[controller.git] / opendaylight / clustering / services_implementation / src / main / java / org / opendaylight / controller / clustering / services_implementation / internal / GetUpdatesContainer.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.controller.clustering.services_implementation.internal;
10
11 import org.opendaylight.controller.clustering.services.IGetUpdates;
12 import org.opendaylight.controller.clustering.services.ICacheUpdateAware;
13
14 public class GetUpdatesContainer<K,V> implements IGetUpdates<K,V> {
15     private ICacheUpdateAware<K,V> toBeUpdated;
16     private String containerName;
17     private String cacheName;
18
19     public GetUpdatesContainer(ICacheUpdateAware<K,V> i, String containerName,
20                                String cacheName) {
21         this.toBeUpdated = i;
22         this.containerName = containerName;
23         this.cacheName = cacheName;
24     }
25
26     public ICacheUpdateAware<K,V> whichListener() {
27         return this.toBeUpdated;
28     }
29
30     @Override
31     public void entryCreated(K key, String containerName, String cacheName,
32                              boolean local) {
33         if (this.toBeUpdated != null) {
34             this.toBeUpdated.entryCreated(key, cacheName, local);
35         }
36     }
37
38     @Override
39     public void entryUpdated(K key, V new_value, String containerName,
40                              String cacheName,
41                              boolean local) {
42         if (this.toBeUpdated != null) {
43             this.toBeUpdated.entryUpdated(key, new_value, cacheName, local);
44         }
45     }
46
47     @Override
48     public void entryDeleted(K key, String containerName, String cacheName,
49                              boolean local) {
50         if (this.toBeUpdated != null) {
51             this.toBeUpdated.entryDeleted(key, cacheName, local);
52         }
53     }
54 }