Source Code Cross Referenced for AbstractUserAttributeStore.java in  » EJB-Server-resin-3.1.5 » resin » com » caucho » portal » generic » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » EJB Server resin 3.1.5 » resin » com.caucho.portal.generic 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The Apache Software License, Version 1.1
003:         *
004:         * Copyright (c) 2001-2004 Caucho Technology, Inc.  All rights reserved.
005:         *
006:         * Redistribution and use in source and binary forms, with or without
007:         * modification, are permitted provided that the following conditions
008:         * are met:
009:         *
010:         * 1. Redistributions of source code must retain the above copyright
011:         *    notice, this list of conditions and the following disclaimer.
012:         *
013:         * 2. Redistributions in binary form must reproduce the above copyright
014:         *    notice, this list of conditions and the following disclaimer in
015:         *    the documentation and/or other materials provided with the
016:         *    distribution.
017:         *
018:         * 3. The end-user documentation included with the redistribution, if
019:         *    any, must include the following acknowlegement:
020:         *       "This product includes software developed by the
021:         *        Caucho Technology (http://www.caucho.com/)."
022:         *    Alternately, this acknowlegement may appear in the software itself,
023:         *    if and wherever such third-party acknowlegements normally appear.
024:         *
025:         * 4. The names "Hessian", "Resin", and "Caucho" must not be used to
026:         *    endorse or promote products derived from this software without prior
027:         *    written permission. For written permission, please contact
028:         *    info@caucho.com.
029:         *
030:         * 5. Products derived from this software may not be called "Resin"
031:         *    nor may "Resin" appear in their names without prior written
032:         *    permission of Caucho Technology.
033:         *
034:         * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
035:         * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
036:         * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
037:         * DISCLAIMED.  IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS
038:         * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
039:         * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
040:         * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
041:         * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
042:         * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
043:         * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
044:         * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
045:         *
046:         * @author Sam
047:         */
048:
049:        package com.caucho.portal.generic;
050:
051:        import javax.portlet.PortletRequest;
052:        import java.io.IOException;
053:        import java.util.HashMap;
054:        import java.util.LinkedHashMap;
055:        import java.util.Map;
056:        import java.util.Set;
057:
058:        /**
059:         * Abstract base class for implementations that load user attributes.
060:         */
061:        abstract public class AbstractUserAttributeStore implements 
062:                UserAttributeStore {
063:            protected static String DELETE = "<delete>";
064:
065:            private Map<String, String> _defaultMap;
066:            private Map<String, String> _nameLinkMap;
067:            private Map<String, String> _reverseNameLinkMap;
068:
069:            /**
070:             * Load the user attributes, called once for each connection.
071:             * Implementing classes use the <i>request</i> to determine the identity
072:             * of the user.
073:             *
074:             * @return a Map<String, String> of all the user attribute names that are
075:             * available for the user identified by <i>request</i>, null
076:             * if no attributes are available.
077:             */
078:            abstract protected Map<String, String> load(PortletRequest request)
079:                    throws IOException;
080:
081:            /**
082:             * Called just before unload() if the attributes have been updated.
083:             * The updateMap contains only entries that have changed.  Entries with a
084:             * value of DELETE are meant to be deleted from the store. 
085:             *
086:             * @param storeMap the map returned by load()
087:             *
088:             * @param updateMap the map containing the updates
089:             *
090:             * @throws UnsupportedOperationException if the implementation does not
091:             * support updates to user attributes. 
092:             */
093:            abstract protected void save(Map<String, String> storeMap,
094:                    Map<String, String> updateMap) throws IOException;
095:
096:            /**
097:             * Called when the connection is complete.
098:             * 
099:             * A call to unload() is not guaranteed to occur for every connection,
100:             * if an error occurs when processing a request unload() may never be called.
101:             *
102:             * @param isModified true if the map has been changed
103:             */
104:            abstract protected void unload(Map<String, String> map);
105:
106:            public void addDefault(String name, String value) {
107:                if (_defaultMap == null)
108:                    _defaultMap = new LinkedHashMap<String, String>();
109:
110:                _defaultMap.put(name, value);
111:            }
112:
113:            public void addDefault(NameValuePair nameValuePair) {
114:                addDefault(nameValuePair.getName(), nameValuePair.getValue());
115:            }
116:
117:            /**
118:             * Add a link such that when the portlet uses the attribute<i>name</i>, the
119:             * name that is used with the store is <i>link</i>.
120:             */
121:            public void addNameLink(String name, String link) {
122:                if (_nameLinkMap == null)
123:                    _nameLinkMap = new HashMap<String, String>();
124:
125:                _nameLinkMap.put(name, link);
126:            }
127:
128:            public void addNameLink(NameLink nameLink) {
129:                addNameLink(nameLink.getName(), nameLink.getLink());
130:            }
131:
132:            public Map<String, String> getUserAttributeMap(
133:                    PortletRequest request, Set<String> names)
134:                    throws IOException {
135:                Map<String, String> storeMap = load(request);
136:
137:                StoreUpdateMap<String, String> map = new StoreUpdateMap<String, String>();
138:
139:                if (_nameLinkMap != null) {
140:                    synchronized (_nameLinkMap) {
141:                        if (_reverseNameLinkMap == null)
142:                            _reverseNameLinkMap = KeyLinkMap
143:                                    .<String> getReverseKeyLinkMap(_nameLinkMap);
144:                    }
145:                }
146:
147:                map.start(_nameLinkMap, _reverseNameLinkMap, _defaultMap,
148:                        storeMap, names, DELETE);
149:
150:                return map;
151:            }
152:
153:            public void finish(Map<String, String> userAttributeMap)
154:                    throws IOException {
155:                StoreUpdateMap<String, String> map = (StoreUpdateMap<String, String>) userAttributeMap;
156:
157:                Map<String, String> storeMap = map.getStoreMap();
158:                Map<String, String> updateMap = map.getUpdateMap();
159:
160:                map.finish();
161:
162:                if (updateMap != null)
163:                    save(storeMap, updateMap);
164:
165:                unload(storeMap);
166:            }
167:
168:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.