KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > portal > aspect > impl > MemoryAspectDataStore


1 /*
2  * Copyright 1999-2002,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 package org.apache.cocoon.portal.aspect.impl;
17
18 import java.util.HashMap JavaDoc;
19 import java.util.Map JavaDoc;
20
21 import org.apache.avalon.framework.component.Component;
22 import org.apache.avalon.framework.logger.AbstractLogEnabled;
23 import org.apache.avalon.framework.thread.ThreadSafe;
24 import org.apache.cocoon.portal.aspect.AspectDataStore;
25 import org.apache.cocoon.portal.aspect.Aspectalizable;
26
27 /**
28  * An aspect data store that holds the aspects in memory.
29  *
30  * @author <a HREF="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
31  *
32  * @version CVS $Id: MemoryAspectDataStore.java 30932 2004-07-29 17:35:38Z vgritsenko $
33  */

34 public class MemoryAspectDataStore
35     extends AbstractLogEnabled
36     implements Component, ThreadSafe, AspectDataStore {
37     
38     protected final Map JavaDoc objectMap = new HashMap JavaDoc();
39     
40     /**
41      * Get the aspect map for an object
42      */

43     protected Map JavaDoc getMap(Aspectalizable owner) {
44         Map JavaDoc result = (Map JavaDoc)this.objectMap.get(owner);
45         if ( result == null ) {
46             result = new HashMap JavaDoc();
47             this.objectMap.put(owner, result);
48         }
49         return result;
50     }
51     
52     /* (non-Javadoc)
53      * @see org.apache.cocoon.portal.aspect.AspectDataStore#getAspectData(org.apache.cocoon.portal.aspect.Aspectalizable, java.lang.String)
54      */

55     public Object JavaDoc getAspectData(Aspectalizable owner, String JavaDoc aspectName) {
56         return this.getMap(owner).get( aspectName );
57     }
58     
59     /* (non-Javadoc)
60      * @see org.apache.cocoon.portal.aspect.AspectDataStore#setAspectData(org.apache.cocoon.portal.aspect.Aspectalizable, java.lang.String, java.lang.Object)
61      */

62     public void setAspectData(Aspectalizable owner, String JavaDoc aspectName, Object JavaDoc data) {
63         this.getMap(owner).put(aspectName, data);
64     }
65
66     /* (non-Javadoc)
67      * @see org.apache.cocoon.portal.aspect.AspectDataStore#isPersistent()
68      */

69     public boolean isPersistent() {
70         return false;
71     }
72     
73 }
74
Popular Tags