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  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 DistributedCacheObject
30  {
31      /*** The serial uid. */
32      private static final long serialVersionUID = 1853381807991868844L;
33      Identity id = null;
34      String key = null;;
35  
36  
37      public RegistryCacheObjectWrapper(Identity id, String key)
38      {
39          //System.out.println(this.getClass().getName() + "-" + "NodeCache - fullpath=" + fullpath);
40          this.key = key;
41          this.id = id;
42      }
43  
44  
45      public Identity getId()
46      {
47          //System.out.println(this.getClass().getName() + "-" +"getNode=" + node.getFullPath());
48          return id;
49      }
50  
51      public void setIdentity(Identity id)
52      {
53          // System.out.println(this.getClass().getName() + "-" +"setFullpath=" + node.getFullPath());
54          this.id = id;
55      }
56  
57  
58      public boolean equals(Object obj)
59      {
60          if (obj != null && obj instanceof RegistryCacheObjectWrapper)
61          {
62              RegistryCacheObjectWrapper other = (RegistryCacheObjectWrapper) obj;
63              return getKey().equals(other.getKey());
64          }
65          return false;
66      }
67  
68      public int hashCode()
69      {
70          return getKey().hashCode();
71      }
72  
73      public String getCacheKey()
74      {
75          return getKey();
76      }
77  
78      public String getKey()
79      {
80          return key;
81      }
82  
83      
84      public void notifyChange(int action)
85      {
86  
87          switch (action)
88          {
89              case CacheElement.ActionAdded:
90  //              System.out.println("CacheObjectAdded =" + this.getKey());
91                  break;
92              case CacheElement.ActionChanged:
93  //              System.out.println("CacheObjectChanged =" + this.getKey());
94                  break;
95              case CacheElement.ActionRemoved:
96  //              System.out.println("CacheObjectRemoved =" + this.getKey());
97                  break;
98              case CacheElement.ActionEvicted:
99  //              System.out.println("CacheObjectEvicted =" + this.getKey());
100                 break;
101             case CacheElement.ActionExpired:
102 //              System.out.println("CacheObjectExpired =" + this.getKey());
103                 break;
104             default:
105                 System.out.println("CacheObject -UNKOWN OPRERATION =" + this.getKey());
106                 return;
107         }
108         return;
109     }
110 }