01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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: package org.apache.jetspeed.components.portletregistry;
18:
19: import org.apache.jetspeed.cache.CacheElement;
20: import org.apache.jetspeed.cache.DistributedCacheObject;
21: import org.apache.ojb.broker.Identity;
22:
23: /**
24: * OJB cache
25: *
26: * @author dtaylor
27: *
28: */
29: public class RegistryCacheObjectWrapper implements
30: DistributedCacheObject {
31: /** The serial uid. */
32: private static final long serialVersionUID = 1853381807991868844L;
33: Identity id = null;
34: String key = null;;
35:
36: public RegistryCacheObjectWrapper(Identity id, String key) {
37: //System.out.println(this.getClass().getName() + "-" + "NodeCache - fullpath=" + fullpath);
38: this .key = key;
39: this .id = id;
40: }
41:
42: public Identity getId() {
43: //System.out.println(this.getClass().getName() + "-" +"getNode=" + node.getFullPath());
44: return id;
45: }
46:
47: public void setIdentity(Identity id) {
48: // System.out.println(this.getClass().getName() + "-" +"setFullpath=" + node.getFullPath());
49: this .id = id;
50: }
51:
52: public boolean equals(Object obj) {
53: if (obj != null && obj instanceof RegistryCacheObjectWrapper) {
54: RegistryCacheObjectWrapper other = (RegistryCacheObjectWrapper) obj;
55: return getKey().equals(other.getKey());
56: }
57: return false;
58: }
59:
60: public int hashCode() {
61: return getKey().hashCode();
62: }
63:
64: public String getCacheKey() {
65: return getKey();
66: }
67:
68: public String getKey() {
69: return key;
70: }
71:
72: public void notifyChange(int action) {
73:
74: switch (action) {
75: case CacheElement.ActionAdded:
76: // System.out.println("CacheObjectAdded =" + this.getKey());
77: break;
78: case CacheElement.ActionChanged:
79: // System.out.println("CacheObjectChanged =" + this.getKey());
80: break;
81: case CacheElement.ActionRemoved:
82: // System.out.println("CacheObjectRemoved =" + this.getKey());
83: break;
84: case CacheElement.ActionEvicted:
85: // System.out.println("CacheObjectEvicted =" + this.getKey());
86: break;
87: case CacheElement.ActionExpired:
88: // System.out.println("CacheObjectExpired =" + this.getKey());
89: break;
90: default:
91: System.out.println("CacheObject -UNKOWN OPRERATION ="
92: + this.getKey());
93: return;
94: }
95: return;
96: }
97: }
|