View Javadoc

1   /*
2    * Copyright 2003,2004 The Apache Software Foundation.
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  
18   */
19  
20  package org.apache.pluto.portalImpl.om.common;
21  
22  import java.util.HashSet;
23  import java.util.Iterator;
24  
25  public abstract class AbstractSupportSet extends HashSet implements java.io.Serializable, Support {
26  
27      public AbstractSupportSet()
28      {
29      }
30  
31  
32      // support implemenation.
33      public void postLoad(Object parameter) throws Exception
34      {
35          dispatch(parameter, POST_LOAD);
36      }
37  
38      public void preBuild(Object parameter) throws Exception
39      {
40          dispatch(parameter, PRE_BUILD);
41      }
42      
43      public void postBuild(Object parameter) throws Exception
44      {
45          dispatch(parameter, POST_BUILD);
46      }
47  
48      public void preStore(Object parameter) throws Exception
49      {
50          dispatch(parameter, PRE_STORE);
51      }
52  
53      public void postStore(Object parameter) throws Exception
54      {
55          dispatch(parameter, POST_STORE);
56      }
57  
58      // additional methods.
59      protected void dispatch(Object parameter, int id) throws Exception
60      {
61          Iterator iterator = this.iterator();
62          while (iterator.hasNext()) {
63              Support support = (Support)iterator.next();
64              switch (id) {
65                  case POST_LOAD : support.postLoad(parameter);  break;
66                  case PRE_BUILD : support.preBuild(parameter);  break;
67                  case POST_BUILD: support.postBuild(parameter); break;
68                  case PRE_STORE : support.preStore(parameter);  break;
69                  case POST_STORE: support.postStore(parameter); break;
70              }
71          }
72      }
73  }