Source Code Cross Referenced for PropertyFactory.java in  » Content-Management-System » harmonise » org » openharmonise » rm » resources » metadata » properties » 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 » Content Management System » harmonise » org.openharmonise.rm.resources.metadata.properties 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The contents of this file are subject to the 
003:         * Mozilla Public License Version 1.1 (the "License"); 
004:         * you may not use this file except in compliance with the License. 
005:         * You may obtain a copy of the License at http://www.mozilla.org/MPL/
006:         *
007:         * Software distributed under the License is distributed on an "AS IS"
008:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. 
009:         * See the License for the specific language governing rights and 
010:         * limitations under the License.
011:         *
012:         * The Initial Developer of the Original Code is Simulacra Media Ltd.
013:         * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
014:         *
015:         * All Rights Reserved.
016:         *
017:         * Contributor(s):
018:         */
019:        package org.openharmonise.rm.resources.metadata.properties;
020:
021:        import java.sql.*;
022:        import java.util.*;
023:        import java.util.logging.*;
024:
025:        import org.openharmonise.commons.cache.*;
026:        import org.openharmonise.commons.dsi.*;
027:        import org.openharmonise.commons.dsi.dml.SelectStatement;
028:        import org.openharmonise.rm.DataAccessException;
029:        import org.openharmonise.rm.factory.*;
030:        import org.openharmonise.rm.resources.AbstractObject;
031:        import org.openharmonise.rm.resources.lifecycle.*;
032:
033:        /**
034:         * <code>PropertyFactory</code> provides a method of obtaining <code>Property</code> 
035:         * objects from a name rather than an id.
036:         * 
037:         * @author Michael Bell
038:         * @version $Revision: 1.2 $
039:         *
040:         */
041:        public class PropertyFactory implements  EditEventListener {
042:
043:            /**
044:             * <code>Map</code> of names to <code>CachePointer</code>s to 
045:             * <code>Property</code> used to cache the data and reduce database queries.
046:             */
047:            private static Map NAME_2_PROP_MAP = new Hashtable();
048:
049:            /**
050:             * Logger for this class
051:             */
052:            private static final Logger m_logger = Logger
053:                    .getLogger(PropertyFactory.class.getName());
054:
055:            /**
056:             * Constructs a new <code>PropertyFactory</code>.
057:             * 
058:             * Note: This constructor is <code>private</code> and can therefore not
059:             * be executed
060:             */
061:            private PropertyFactory() {
062:                super ();
063:            }
064:
065:            /**
066:             * Returns the <code>Property</code> with the specified name.
067:             * 
068:             * @param dsi the data store inteface
069:             * @param sPropName the name of the <code>Property</code> to return
070:             * @return the <code>Property</code> with the specified name
071:             * @throws HarmoniseFactoryException if an error occurs 
072:             */
073:            public static Property getPropertyFromName(
074:                    AbstractDataStoreInterface dsi, String sPropName)
075:                    throws HarmoniseFactoryException {
076:                Property prop = null;
077:
078:                try {
079:
080:                    CachePointer propPtr = (CachePointer) NAME_2_PROP_MAP
081:                            .get(sPropName.intern());
082:
083:                    if (propPtr == null) {
084:                        //double checked synchronized block to avoid concurrency problems
085:                        synchronized (NAME_2_PROP_MAP) {
086:                            propPtr = (CachePointer) NAME_2_PROP_MAP
087:                                    .get(sPropName.intern());
088:
089:                            if (propPtr == null) {
090:                                SelectStatement select = new SelectStatement();
091:
092:                                select.addSelectColumn(AbstractObject
093:                                        .getColumnRef(Property.class.getName(),
094:                                                AbstractObject.ATTRIB_ID));
095:                                select.addSelectColumn(AbstractObject
096:                                        .getColumnRef(Property.class.getName(),
097:                                                AbstractObject.ATTRIB_TYPE));
098:                                select.addWhereCondition(AbstractObject
099:                                        .getColumnRef(Property.class.getName(),
100:                                                AbstractObject.TAG_NAME), "=",
101:                                        sPropName);
102:
103:                                ResultSet rs = dsi.execute(select);
104:
105:                                if (rs.next()) {
106:                                    int nId = rs.getInt(1);
107:                                    String sClass = rs.getString(2);
108:
109:                                    prop = (Property) HarmoniseObjectFactory
110:                                            .instantiateHarmoniseObject(dsi,
111:                                                    sClass, nId);
112:                                    try {
113:                                        propPtr = CacheHandler.getInstance(dsi)
114:                                                .getCachePointer(prop);
115:                                    } catch (CacheException e) {
116:                                        throw new HarmoniseFactoryException(e);
117:                                    }
118:
119:                                    NAME_2_PROP_MAP.put(sPropName.intern(),
120:                                            propPtr);
121:                                }
122:
123:                                rs.close();
124:                            }
125:                        }
126:
127:                    } else {
128:                        try {
129:                            prop = (Property) propPtr.getObject();
130:
131:                            if (prop.exists() == false) {
132:                                prop = null;
133:                                NAME_2_PROP_MAP.remove(sPropName);
134:                            }
135:                        } catch (CacheException e) {
136:                            throw new HarmoniseFactoryException(e);
137:                        }
138:                    }
139:
140:                } catch (DataStoreException e) {
141:                    throw new HarmoniseFactoryException("ds error", e);
142:                } catch (SQLException e) {
143:                    throw new HarmoniseFactoryException("sql error", e);
144:                }
145:
146:                return prop;
147:            }
148:
149:            /* (non-Javadoc)
150:             * @see org.openharmonise.rm.resources.lifecycle.EditEventListener#workflowObjectSaved(org.openharmonise.rm.resources.lifecycle.EditEvent)
151:             */
152:            public void workflowObjectSaved(EditEvent event) {
153:                // nothing to do
154:
155:            }
156:
157:            /* (non-Javadoc)
158:             * @see org.openharmonise.rm.resources.lifecycle.EditEventListener#workflowObjectStatusChanged(org.openharmonise.rm.resources.lifecycle.EditEvent)
159:             */
160:            public void workflowObjectStatusChanged(EditEvent event) {
161:                // nothing to do
162:
163:            }
164:
165:            /* (non-Javadoc)
166:             * @see org.openharmonise.rm.resources.lifecycle.EditEventListener#workflowObjectArchived(org.openharmonise.rm.resources.lifecycle.EditEvent)
167:             */
168:            public void workflowObjectArchived(EditEvent event) {
169:                Property prop = (Property) event.getSource();
170:                String sName;
171:                try {
172:                    sName = prop.getName();
173:
174:                } catch (DataAccessException e) {
175:                    m_logger.log(Level.WARNING, e.getLocalizedMessage(), e);
176:                }
177:
178:            }
179:
180:            /* (non-Javadoc)
181:             * @see org.openharmonise.rm.resources.lifecycle.EditEventListener#workflowObjectReactivated(org.openharmonise.rm.resources.lifecycle.EditEvent)
182:             */
183:            public void workflowObjectReactivated(EditEvent event) {
184:                // nothing to do
185:
186:            }
187:
188:            /* (non-Javadoc)
189:             * @see org.openharmonise.rm.resources.lifecycle.EditEventListener#workflowObjectLocked(org.openharmonise.rm.resources.lifecycle.EditEvent)
190:             */
191:            public void workflowObjectLocked(EditEvent event) {
192:                // nothing to do
193:
194:            }
195:
196:            /* (non-Javadoc)
197:             * @see org.openharmonise.rm.resources.lifecycle.EditEventListener#workflowObjectUnlocked(org.openharmonise.rm.resources.lifecycle.EditEvent)
198:             */
199:            public void workflowObjectUnlocked(EditEvent event) {
200:                // nothing to do
201:
202:            }
203:
204:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.