Source Code Cross Referenced for MetafacadeCache.java in  » UML » AndroMDA-3.2 » org » andromda » core » metafacade » 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 » UML » AndroMDA 3.2 » org.andromda.core.metafacade 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.andromda.core.metafacade;
002:
003:        import java.util.HashMap;
004:        import java.util.Map;
005:
006:        /**
007:         * A global cache for metafacades. Used by the {@link MetafacadeFactory}when constructing or retrieving metafacade
008:         * instances. If the cache constains the metafacade it should not be constructed again.
009:         *
010:         * @author Chad Brandon
011:         */
012:        public final class MetafacadeCache {
013:            /**
014:             * Constructs a new instance of this class.
015:             *
016:             * @return the new instance
017:             */
018:            public static MetafacadeCache newInstance() {
019:                return new MetafacadeCache();
020:            }
021:
022:            private MetafacadeCache() {
023:                // don't allow instantiation
024:            }
025:
026:            /**
027:             * The namespace to which the cache currently applies
028:             */
029:            private String namespace;
030:
031:            /**
032:             * Sets the namespace to which the cache currently applies.
033:             *
034:             * @param namespace the current namespace.
035:             */
036:            public final void setNamespace(final String namespace) {
037:                this .namespace = namespace;
038:            }
039:
040:            /**
041:             * The cache for already created metafacades.
042:             */
043:            private final Map metafacadeCache = new HashMap();
044:
045:            /**
046:             * <p/>
047:             * Returns the metafacade from the metafacade cache. The Metafacades are cached first by according to its
048:             * <code>mappingObject</code>, next the <code>metafacadeClass</code>, and finally by the current namespace. </p>
049:             * <p/>
050:             * Metafacades must be cached in order to keep track of the state of its validation. If we keep creating a new one
051:             * each time, we can never tell whether or not a metafacade has been previously validated. Not to mention tremendous
052:             * performance gains. </p>
053:             *
054:             * @param mappingObject   the object to which the mapping applies
055:             * @param metafacadeClass the class of the metafacade.
056:             * @return MetafacadeBase stored in the cache.
057:             */
058:            public final MetafacadeBase get(final Object mappingObject,
059:                    final Class metafacadeClass) {
060:                MetafacadeBase metafacade = null;
061:                final Map namespaceMetafacadeCache = (Map) this .metafacadeCache
062:                        .get(mappingObject);
063:                if (namespaceMetafacadeCache != null) {
064:                    final Map metafacadeCache = (Map) namespaceMetafacadeCache
065:                            .get(metafacadeClass);
066:                    if (metafacadeCache != null) {
067:                        metafacade = (MetafacadeBase) metafacadeCache
068:                                .get(this .namespace);
069:                    }
070:                }
071:                return metafacade;
072:            }
073:
074:            /**
075:             * Adds the <code>metafacade</code> to the cache according to first <code>mappingObject</code>, second the
076:             * <code>metafacade</code>, and finally by the current <code>namespace</code>.
077:             *
078:             * @param mappingObject the mappingObject for which to cache the metafacade.
079:             * @param metafacade the metafacade to cache.
080:             */
081:            public final void add(final Object mappingObject,
082:                    final MetafacadeBase metafacade) {
083:                Map namespaceMetafacadeCache = (Map) this .metafacadeCache
084:                        .get(mappingObject);
085:                if (namespaceMetafacadeCache == null) {
086:                    namespaceMetafacadeCache = new HashMap();
087:                    this .metafacadeCache.put(mappingObject,
088:                            namespaceMetafacadeCache);
089:                }
090:                Map metafacadeCache = (Map) namespaceMetafacadeCache
091:                        .get(metafacade.getClass());
092:                if (metafacadeCache == null) {
093:                    metafacadeCache = new HashMap();
094:                    namespaceMetafacadeCache.put(metafacade.getClass(),
095:                            metafacadeCache);
096:                }
097:                metafacadeCache.put(this .namespace, metafacade);
098:            }
099:
100:            /**
101:             * Clears the cache of any metafacades
102:             */
103:            public final void clear() {
104:                this .metafacadeCache.clear();
105:            }
106:
107:            /**
108:             * @see java.lang.Object#toString()
109:             */
110:            public String toString() {
111:                return this.metafacadeCache.toString();
112:            }
113:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.