Source Code Cross Referenced for RDBMPropertyStore.java in  » Portal » uPortal_rel-2-6-1-GA » org » jasig » portal » services » entityproperties » 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.entityproperties 
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.entityproperties;
007:
008:        import java.sql.Connection;
009:        import java.sql.PreparedStatement;
010:        import java.sql.ResultSet;
011:        import java.sql.Timestamp;
012:
013:        import org.apache.commons.logging.Log;
014:        import org.apache.commons.logging.LogFactory;
015:        import org.jasig.portal.EntityIdentifier;
016:        import org.jasig.portal.RDBMServices;
017:        import org.jasig.portal.services.EntityPropertyRegistry;
018:
019:        /**
020:         * A portal RDBM based entity property store implementation
021:         *
022:         * @author Alex Vigdor av317@columbia.edu
023:         * @version $Revision: 35492 $
024:         */
025:        public class RDBMPropertyStore implements  IEntityPropertyStore {
026:
027:            private static final Log log = LogFactory
028:                    .getLog(RDBMPropertyStore.class);
029:
030:            protected static Class propsType = null;
031:            protected final static String TABLE_NAME = "UP_ENTITY_PROP";
032:            protected final static String TYPE_COL = "ENTITY_TYPE_ID";
033:            protected final static String KEY_COL = "ENTITY_KEY";
034:            protected final static String NAME_COL = "PROPERTY_NAME";
035:            protected final static String VALUE_COL = "PROPERTY_VALUE";
036:            protected final static String DATE_COL = "LAST_MODIFIED";
037:            protected final static String selectProperties = "SELECT "
038:                    + NAME_COL + ", " + VALUE_COL + " FROM " + TABLE_NAME
039:                    + " WHERE " + TYPE_COL + "=? AND " + KEY_COL + "=?";
040:            protected final static String deleteProperty = "DELETE FROM "
041:                    + TABLE_NAME + " WHERE " + TYPE_COL + "=? AND " + KEY_COL
042:                    + "=? AND " + NAME_COL + "=?";
043:            protected final static String insertProperty = "INSERT INTO "
044:                    + TABLE_NAME + " VALUES (?,?,?,?,?)";
045:
046:            public RDBMPropertyStore() {
047:                try {
048:                    if (propsType == null) {
049:                        propsType = Class
050:                                .forName("org.jasig.portal.services.entityproperties.EntityProperties");
051:                    }
052:                } catch (Exception e) {
053:                    log
054:                            .error(
055:                                    "RDBMPropertyStore.Constructor Unable to create propstype",
056:                                    e);
057:                }
058:            }
059:
060:            public String[] getPropertyNames(EntityIdentifier entityID) {
061:                String[] propNames = null;
062:                EntityProperties ep = getCachedProperties(entityID);
063:                if (ep != null) {
064:                    propNames = ep.getPropertyNames();
065:                }
066:                return propNames;
067:            }
068:
069:            public String getProperty(EntityIdentifier entityID, String name) {
070:                String propVal = null;
071:                EntityProperties ep = getCachedProperties(entityID);
072:                if (ep != null) {
073:                    propVal = ep.getProperty(name);
074:                }
075:                return propVal;
076:            }
077:
078:            public void storeProperty(EntityIdentifier entityID, String name,
079:                    String value) {
080:                this .unStoreProperty(entityID, name);
081:                Connection conn = null;
082:                PreparedStatement ps = null;
083:                try {
084:                    conn = this .getConnection();
085:                    ps = conn.prepareStatement(insertProperty);
086:                    ps.clearParameters();
087:                    ps.setInt(1, org.jasig.portal.EntityTypes.getEntityTypeID(
088:                            entityID.getType()).intValue());
089:                    ps.setString(2, entityID.getKey());
090:                    ps.setString(3, name);
091:                    ps.setString(4, value);
092:                    ps.setTimestamp(5,
093:                            new Timestamp(System.currentTimeMillis()));
094:                    ps.executeUpdate();
095:                    ps.close();
096:                    clearCache(entityID);
097:                } catch (Exception e) {
098:                    log.error("RDBMPropertyStore.storeProperty " + ps, e);
099:                } finally {
100:                    this .releaseConnection(conn);
101:                }
102:            }
103:
104:            public void unStoreProperty(EntityIdentifier entityID, String name) {
105:                Connection conn = null;
106:                PreparedStatement ps = null;
107:                try {
108:                    conn = this .getConnection();
109:                    ps = conn.prepareStatement(deleteProperty);
110:                    ps.clearParameters();
111:                    ps.setInt(1, org.jasig.portal.EntityTypes.getEntityTypeID(
112:                            entityID.getType()).intValue());
113:                    ps.setString(2, entityID.getKey());
114:                    ps.setString(3, name);
115:                    ps.executeUpdate();
116:                    ps.close();
117:                    clearCache(entityID);
118:                } catch (Exception e) {
119:                    log.error("RDBMPropertyStore.unStoreProperty " + ps, e);
120:                } finally {
121:                    this .releaseConnection(conn);
122:                }
123:            }
124:
125:            protected Connection getConnection() {
126:                return RDBMServices.getConnection();
127:            }
128:
129:            protected void releaseConnection(Connection conn) {
130:                RDBMServices.releaseConnection(conn);
131:            }
132:
133:            protected EntityProperties getCachedProperties(
134:                    EntityIdentifier entityID) {
135:                EntityProperties ep = EntityPropertyRegistry.instance()
136:                        .getCachedProperties(entityID);
137:                if (ep == null) {
138:                    ep = new EntityProperties(entityID.getKey());
139:                    Connection conn = null;
140:                    PreparedStatement ps = null;
141:                    try {
142:                        conn = this .getConnection();
143:                        ps = conn.prepareStatement(selectProperties);
144:                        ps.clearParameters();
145:                        ps
146:                                .setInt(1, org.jasig.portal.EntityTypes
147:                                        .getEntityTypeID(entityID.getType())
148:                                        .intValue());
149:                        ps.setString(2, entityID.getKey());
150:                        ResultSet rs = ps.executeQuery();
151:                        while (rs.next()) {
152:                            ep.setProperty(rs.getString(NAME_COL), rs
153:                                    .getString(VALUE_COL));
154:                        }
155:                        addToCache(ep);
156:                        rs.close();
157:                        ps.close();
158:                    } catch (Exception e) {
159:                        log.error("RDBMPropertyStore.getPropertyNames: " + ps,
160:                                e);
161:                    } finally {
162:                        this .releaseConnection(conn);
163:                    }
164:                }
165:                return ep;
166:            }
167:
168:            protected void clearCache(EntityIdentifier entityID) {
169:                EntityPropertyRegistry.instance().clearCache(entityID);
170:            }
171:
172:            protected void addToCache(EntityProperties ep) {
173:                EntityPropertyRegistry.instance().addToCache(ep);
174:            }
175:
176:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.