KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portal > server > impl > user > UserContextImpl


1 /*****************************************
2  * *
3  * JBoss Portal: The OpenSource Portal *
4  * *
5  * Distributable under LGPL license. *
6  * See terms of license at gnu.org. *
7  * *
8  *****************************************/

9 package org.jboss.portal.server.impl.user;
10
11 import java.io.IOException JavaDoc;
12 import java.io.ObjectInputStream JavaDoc;
13 import java.io.ObjectOutputStream JavaDoc;
14 import java.io.Serializable JavaDoc;
15 import java.util.HashMap JavaDoc;
16 import java.util.Map JavaDoc;
17
18 import org.apache.log4j.Logger;
19 import org.jboss.portal.server.ServerObject;
20 import org.jboss.portal.server.plugins.preferences.AbstractPreferenceStore;
21 import org.jboss.portal.server.plugins.preferences.PreferenceStore;
22 import org.jboss.portal.server.user.ServerObjectContext;
23 import org.jboss.portal.server.user.UserContext;
24
25 /**
26  * A simple implementation.
27  *
28  * @author <a HREF="mailto:julien@jboss.org">Julien Viet</a>
29  * @version $Revision: 1.3 $
30  */

31 public class UserContextImpl implements UserContext, Serializable JavaDoc
32 {
33
34    private static final Logger log = Logger.getLogger(UserContextImpl.class);
35
36    private Map JavaDoc contexts;
37    private Map JavaDoc informations;
38    private PreferenceStore store;
39
40    public UserContextImpl()
41    {
42       this.contexts = new HashMap JavaDoc();
43       this.informations = new HashMap JavaDoc();
44       this.store = new AbstractPreferenceStore();
45       informations.put("user.name.given", "given");
46       informations.put("user.name.family", "family");
47    }
48
49    public ServerObjectContext getContext(ServerObject serverObject)
50    {
51       ServerObjectContext ctx = (ServerObjectContext)contexts.get(serverObject.getID());
52       if (ctx == null)
53       {
54          ctx = serverObject.createContext();
55          contexts.put(serverObject.getID(), ctx);
56       }
57       return ctx;
58    }
59
60    public PreferenceStore getPreferenceStore()
61    {
62       return store;
63    }
64
65    public Map JavaDoc getInformations()
66    {
67       return informations;
68    }
69
70    private void readObject(ObjectInputStream JavaDoc in) throws ClassNotFoundException JavaDoc, IOException JavaDoc
71    {
72       if (log.isDebugEnabled())
73       {
74          log.debug("Read object");
75       }
76       in.defaultReadObject();
77    }
78
79    private void writeObject(ObjectOutputStream JavaDoc out) throws IOException JavaDoc
80    {
81       if (log.isDebugEnabled())
82       {
83          log.debug("Write object");
84       }
85       out.defaultWriteObject();
86    }
87 }
88
Popular Tags