Source Code Cross Referenced for EntityCachingService.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 2002 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.IBasicEntity;
012:        import org.jasig.portal.concurrency.CachingException;
013:        import org.jasig.portal.concurrency.IEntityCachingService;
014:        import org.jasig.portal.concurrency.IEntityCachingServiceFactory;
015:        import org.jasig.portal.properties.PropertiesManager;
016:
017:        /**
018:         * This class presents a facade for the IEntityCachingService implementation
019:         * that lets clients cache and retrieve <code>IBasicEntities</code>.  It
020:         * hides such details as the physical structure of the cache and whether
021:         * it is running in a multi- or single-JVM environment.
022:         * <p>
023:         * An <code>IBasicEntity</code> can answer its type and key.  (See
024:         * org.jasig.portal.groups.EntityTypes).
025:         * <p>
026:         * Caching consists of asking the service to add, retrieve, update and
027:         * remove elements from the cache, e.g.,
028:         * <p>
029:         * <code>
030:         *       // Retrieve the entity from its store:<br>
031:         *       Class type = getEntityClass();<br>
032:         *       String key = getEntityKey();<br>
033:         *       IBasicEntity ent = findEntity(key); <br>
034:         *        ... <br>
035:         *       // Cache the entity:<br>
036:         *       EntityCachingService.add(ent);<br>
037:         *        ... <br>
038:         *       // Retrieve the entity from the cache:<br>
039:         *       IEntity aCopy = EntityCachingService.get(type, key);<br>
040:         *        ...<br>
041:         *       // Update the entity and then:<br>
042:         *       EntityCachingService..update(aCopy);    // notifies peer caches.<br>
043:         *        ...<br>
044:         *       // Or delete the entity and:<br>
045:         *       EntityCachingService.remove(type, key); // notifies peer caches.<br>
046:         * </code>
047:         * <p>
048:         * @author  Dan Ellentuck
049:         * @version $Revision: 35418 $
050:         */
051:
052:        public class EntityCachingService {
053:
054:            private static final Log log = LogFactory
055:                    .getLog(EntityCachingService.class);
056:            // Singleton instance of the bootstrap class:
057:            private static EntityCachingService instance = null;
058:            // The caching service:
059:            private IEntityCachingService cache = null;
060:
061:            /** Creates new EntityLockService */
062:            private EntityCachingService() throws CachingException {
063:                super ();
064:                initialize();
065:            }
066:
067:            /**
068:             * Adds the entity to the cache.
069:             * @param ent org.jasig.portal.IBasicEntity
070:             * @exception org.jasig.portal.concurrency.CachingException
071:             */
072:            public void add(IBasicEntity ent) throws CachingException {
073:                cache.add(ent);
074:            }
075:
076:            /**
077:             * Returns the cached entity identified by type and key.
078:             * @param type Class
079:             * @param key String
080:             * @return IBasicEntity entity
081:             * @exception org.jasig.portal.concurrency.CachingException
082:             */
083:            public IBasicEntity get(Class type, String key)
084:                    throws CachingException {
085:                return cache.get(type, key);
086:            }
087:
088:            /**
089:             * Returns the cached entity referred to by entityID.
090:             * @param entityID entity identifier
091:             * @return IBasicEntity entity
092:             * @exception org.jasig.portal.concurrency.CachingException
093:             */
094:            public IBasicEntity get(EntityIdentifier entityID)
095:                    throws CachingException {
096:                return cache.get(entityID.getType(), entityID.getKey());
097:            }
098:
099:            /**
100:             * @exception org.jasig.portal.concurrency.CachingException
101:             */
102:            private void initialize() throws CachingException {
103:                String eMsg = null;
104:                String factoryName = PropertiesManager
105:                        .getProperty("org.jasig.portal.concurrency.IEntityCachingServiceFactory");
106:
107:                if (factoryName == null) {
108:                    eMsg = "EntityCachingService.initialize(): No entry for org.jasig.portal.concurrency.caching.IEntityCachingServiceFactory in portal.properties.";
109:                    log.error(eMsg);
110:                    throw new CachingException(eMsg);
111:                }
112:
113:                try {
114:                    IEntityCachingServiceFactory cachingServiceFactory = (IEntityCachingServiceFactory) Class
115:                            .forName(factoryName).newInstance();
116:                    cache = cachingServiceFactory.newCachingService();
117:                } catch (Exception e) {
118:                    eMsg = "EntityCachingService.initialize(): Problem creating entity caching service...";
119:                    log.error(eMsg, e);
120:                    throw new CachingException(eMsg, e);
121:                }
122:            }
123:
124:            public static synchronized EntityCachingService instance()
125:                    throws CachingException {
126:                if (instance == null) {
127:                    instance = new EntityCachingService();
128:                }
129:                return instance;
130:            }
131:
132:            /**
133:             * Removes the entity identified by type and key from the cache and notifies
134:             * peer caches.
135:             * @param type Class
136:             * @param key String
137:             * @exception org.jasig.portal.concurrency.CachingException
138:             */
139:            public void remove(Class type, String key) throws CachingException {
140:                cache.remove(type, key);
141:            }
142:
143:            /**
144:             * Removes the entity referred to by entityID from the cache and notifies peer
145:             * caches.
146:             * @param entityID
147:             * @exception org.jasig.portal.concurrency.CachingException
148:             */
149:            public void remove(EntityIdentifier entityID)
150:                    throws CachingException {
151:                remove(entityID.getType(), entityID.getKey());
152:            }
153:
154:            /**
155:             * Removes the <code>IBasicEntity</code> from the cache and notifies peer
156:             * caches.
157:             * @param ent org.jasig.portal.IBasicEntity
158:             * @exception org.jasig.portal.concurrency.CachingException
159:             */
160:            public void remove(IBasicEntity ent) throws CachingException {
161:                remove(ent.getEntityIdentifier());
162:            }
163:
164:            public static synchronized EntityCachingService start()
165:                    throws CachingException {
166:                return instance();
167:            }
168:
169:            /**
170:             * Updates the entity in the cache and notifies peer caches.
171:             * @param ent org.jasig.portal.concurrency.IBasicEntity
172:             * @exception org.jasig.portal.concurrency.CachingException
173:             */
174:            public void update(IBasicEntity ent) throws CachingException {
175:                cache.update(ent);
176:            }
177:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.