Source Code Cross Referenced for EntityPropertyRegistry.java in  » Portal » uPortal_rel-2-6-1-GA » org » jasig » portal » services » 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 » Portal » uPortal_rel 2 6 1 GA » org.jasig.portal.services 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Copyright 2001 The JA-SIG Collaborative.  All rights reserved.
002:         *  See license distributed with this file and
003:         *  available online at http://www.uportal.org/license.html
004:         */
005:
006:        package org.jasig.portal.services;
007:
008:        import org.apache.commons.logging.Log;
009:        import org.apache.commons.logging.LogFactory;
010:        import org.jasig.portal.EntityIdentifier;
011:        import org.jasig.portal.concurrency.CachingException;
012:        import org.jasig.portal.services.entityproperties.EntityProperties;
013:        import org.jasig.portal.services.entityproperties.IEntityPropertyFinder;
014:        import org.jasig.portal.services.entityproperties.IEntityPropertyStore;
015:        import org.jasig.portal.utils.ResourceLoader;
016:        import org.w3c.dom.Document;
017:        import org.w3c.dom.Element;
018:        import org.w3c.dom.NodeList;
019:
020:        /**
021:         * A Service to allow the querying and storing of properties relating
022:         * to portal entities.  Configured using /properties/EntityPropertyRegistry.xml
023:         *
024:         * see dtds/EntityPropertyRegistry.dtd for configuration file grammar
025:         *
026:         * @author Alex Vigdor av317@columbia.edu
027:         * @version $Revision: 34943 $
028:         *
029:         * @author Don Fracapane df7@columbia.edu
030:         * Removed caching from this class and delegated it to the finder classes. Each
031:         * finder can choose the method of caching if caching is appropriate.
032:         */
033:        public class EntityPropertyRegistry {
034:
035:            private static final Log log = LogFactory
036:                    .getLog(EntityPropertyRegistry.class);
037:
038:            protected static EntityPropertyRegistry _instance;
039:            protected IEntityPropertyStore store;
040:            protected int storePrecedence;
041:            protected IEntityPropertyFinder[] finders;
042:            protected Object[] finderTypes;
043:            protected Class propsType;
044:
045:            protected EntityPropertyRegistry() {
046:            }
047:
048:            protected void init() throws Exception {
049:                Document def = ResourceLoader.getResourceAsDocument(this 
050:                        .getClass(), "/properties/EntityPropertyRegistry.xml");
051:                NodeList ss = def.getElementsByTagName("store");
052:                if (ss.getLength() == 1) {
053:                    Element s = (Element) ss.item(0);
054:                    this .store = (IEntityPropertyStore) Class.forName(
055:                            s.getAttribute("impl")).newInstance();
056:                    this .storePrecedence = Integer.parseInt(s
057:                            .getAttribute("precedence"));
058:                }
059:                NodeList ff = def.getElementsByTagName("finder");
060:                int top = storePrecedence;
061:                for (int i = 0; i < ff.getLength(); i++) {
062:                    Element f = (Element) ff.item(i);
063:                    int test = Integer.parseInt(f.getAttribute("precedence"));
064:                    if (test > storePrecedence) {
065:                        top = test;
066:                    }
067:                }
068:                finders = new IEntityPropertyFinder[top + 1];
069:                finderTypes = new Object[top + 1];
070:                for (int i = 0; i < ff.getLength(); i++) {
071:                    Element f = (Element) ff.item(i);
072:                    int p = Integer.parseInt(f.getAttribute("precedence"));
073:                    finders[p] = (IEntityPropertyFinder) Class.forName(
074:                            f.getAttribute("impl")).newInstance();
075:                    String type = f.getAttribute("type");
076:                    if (type.equals("*")) {
077:                        finderTypes[p] = type;
078:                    } else {
079:                        finderTypes[p] = Class.forName(type);
080:                    }
081:                }
082:                propsType = Class
083:                        .forName("org.jasig.portal.services.entityproperties.EntityProperties");
084:            }
085:
086:            public synchronized static EntityPropertyRegistry instance() {
087:                if (_instance == null) {
088:                    try {
089:                        _instance = new EntityPropertyRegistry();
090:                        _instance.init();
091:                    } catch (Exception e) {
092:                        _instance = null;
093:                        log.error(
094:                                "Could not initialize EntityPropertyRegistry",
095:                                e);
096:                    }
097:                }
098:                return _instance;
099:            }
100:
101:            public static String[] getPropertyNames(EntityIdentifier entityID) {
102:                return instance().getProperties(entityID).getPropertyNames();
103:            }
104:
105:            public static String getProperty(EntityIdentifier entityID,
106:                    String name) {
107:                return instance().getProperties(entityID).getProperty(name);
108:            }
109:
110:            public static void storeProperty(EntityIdentifier entityID,
111:                    String name, String value) {
112:                instance().store.storeProperty(entityID, name, value);
113:            }
114:
115:            public static void unStoreProperty(EntityIdentifier entityID,
116:                    String name) {
117:                instance().store.unStoreProperty(entityID, name);
118:            }
119:
120:            protected String getPropKey(EntityIdentifier entityID) {
121:                String key = org.jasig.portal.EntityTypes.getEntityTypeID(
122:                        entityID.getType()).toString()
123:                        + "." + entityID.getKey();
124:                return key;
125:            }
126:
127:            protected EntityProperties getProperties(EntityIdentifier entityID) {
128:                EntityProperties ep = null;
129:                ep = new EntityProperties(getPropKey(entityID));
130:                for (int i = 0; i < finders.length; i++) {
131:                    IEntityPropertyFinder finder;
132:                    if (i == storePrecedence) {
133:                        finder = store;
134:                    } else {
135:                        if ((finderTypes[i] != null)
136:                                && (finderTypes[i].equals("*") || entityID
137:                                        .getType().equals(finderTypes[i]))) {
138:                            finder = finders[i];
139:                        } else {
140:                            finder = null;
141:                        }
142:                    }
143:                    if (finder != null) {
144:                        String[] names = finder.getPropertyNames(entityID);
145:                        for (int j = 0; j < names.length; j++) {
146:                            ep.setProperty(names[j], finder.getProperty(
147:                                    entityID, names[j]));
148:                        }
149:                    }
150:                }
151:                return ep;
152:            }
153:
154:            public void clearCache(EntityIdentifier entityID) {
155:                try {
156:                    EntityCachingService.instance().remove(propsType,
157:                            getPropKey(entityID));
158:                } catch (CachingException e) {
159:                    log.error("Error clearing cache for entity ID [" + entityID
160:                            + "]", e);
161:                }
162:            }
163:
164:            public void addToCache(EntityProperties ep) {
165:                try {
166:                    EntityCachingService.instance().add(ep);
167:                } catch (CachingException e) {
168:                    log.error("Error adding entity properties [" + ep
169:                            + "] to the cache", e);
170:                }
171:            }
172:
173:            public EntityProperties getCachedProperties(
174:                    EntityIdentifier entityID) {
175:                EntityProperties ep = null;
176:                try {
177:                    ep = (EntityProperties) EntityCachingService.instance()
178:                            .get(propsType, entityID.getKey());
179:                } catch (CachingException e) {
180:                    log.error("Error getting cached properties for entity ["
181:                            + entityID + "]", e);
182:                }
183:                return ep;
184:            }
185:
186:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.