Source Code Cross Referenced for ExpressionNamespace.java in  » Net » Terracotta » com » tc » aspectwerkz » expression » 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 » Net » Terracotta » com.tc.aspectwerkz.expression 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice.  All rights reserved.
003:         */
004:        package com.tc.aspectwerkz.expression;
005:
006:        import com.tc.aspectwerkz.exception.DefinitionException;
007:
008:        import java.util.HashMap;
009:        import java.util.Map;
010:        import java.util.WeakHashMap;
011:
012:        /**
013:         * The expression namespace as well as a repository for the namespaces. <p/>A namespace is usually defined by the name
014:         * of the class defining the expression.
015:         *
016:         * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
017:         */
018:        public final class ExpressionNamespace {
019:            /**
020:             * Namespace container.
021:             */
022:            private static final Map s_namespaces = new WeakHashMap();
023:
024:            /**
025:             * Map with all the expressions in the namespace, [name:expression] pairs.
026:             */
027:            private final Map m_expressions = new HashMap();
028:
029:            /**
030:             * The namespace.
031:             */
032:            private final String m_namespace;
033:
034:            /**
035:             * Creates a new expression namespace.
036:             *
037:             * @param namespace
038:             */
039:            private ExpressionNamespace(final String namespace) {
040:                m_namespace = namespace;
041:            }
042:
043:            /**
044:             * Returns the expression namespace for a specific namespace.
045:             *
046:             * @param namespace the expression namespace
047:             * @return the expression namespace abstraction
048:             */
049:            public static synchronized ExpressionNamespace getNamespace(
050:                    final String namespace) {
051:                if (!s_namespaces.containsKey(namespace)) {
052:                    s_namespaces.put(namespace, new ExpressionNamespace(
053:                            namespace));
054:                }
055:                return (ExpressionNamespace) s_namespaces.get(namespace);
056:            }
057:
058:            /**
059:             * Adds an expression info to the namespace.
060:             *
061:             * @param name           the name mapped to the expression
062:             * @param expressionInfo the expression info to add
063:             */
064:            public void addExpressionInfo(final String name,
065:                    final ExpressionInfo expressionInfo) {
066:                m_expressions.put(name, expressionInfo);
067:            }
068:
069:            /**
070:             * Returns the expression info with a specific name or null if it could not be found.
071:             *
072:             * @param name the name of the expression
073:             * @return the expression info
074:             */
075:            public ExpressionInfo getExpressionInfoOrNull(final String name) {
076:                int index = name.lastIndexOf('.');
077:                if (index != -1) {
078:                    // stay in the same CflowStack
079:                    //TODO: allow for lookup in other CflowStack providing they are in the same hierarchy
080:                    return getNamespace(name.substring(0, index))
081:                            .getExpressionInfoOrNull(
082:                                    name.substring(index + 1, name.length()));
083:                } else {
084:                    final ExpressionInfo expressionInfo = ((ExpressionInfo) m_expressions
085:                            .get(name));
086:                    //            if (expressionInfo == null) {
087:                    //                throw new DefinitionException(
088:                    //                        new StringBuffer().
089:                    //                        append("could not resolve reference to pointcut [").
090:                    //                        append(name).
091:                    //                        append("] in namespace [").
092:                    //                        append(m_namespace).
093:                    //                        append("]").toString()
094:                    //                );
095:                    //            }
096:                    return expressionInfo;
097:                }
098:            }
099:
100:            /**
101:             * Returns the expression info with a specific name or throw an exception if it could not be found.
102:             *
103:             * @param name the name of the expression
104:             * @return the expression info
105:             */
106:            public ExpressionInfo getExpressionInfo(final String name) {
107:                int index = name.lastIndexOf('.');
108:                if (index != -1) {
109:                    // stay in the same CflowStack
110:                    //TODO: allow for lookup in other CflowStack providing they are in the same hierarchy
111:                    return getNamespace(name.substring(0, index))
112:                            .getExpressionInfo(
113:                                    name.substring(index + 1, name.length()));
114:                } else {
115:                    final ExpressionInfo expressionInfo = ((ExpressionInfo) m_expressions
116:                            .get(name));
117:                    if (expressionInfo == null) {
118:                        throw new DefinitionException(
119:                                new StringBuffer()
120:                                        .append(
121:                                                "could not resolve reference to pointcut [")
122:                                        .append(name)
123:                                        .append("] in namespace [").append(
124:                                                m_namespace).append("]")
125:                                        .toString());
126:                    }
127:                    return expressionInfo;
128:                }
129:            }
130:
131:            /**
132:             * Returns the expression with a specific name.
133:             *
134:             * @param name the name of the expression
135:             * @return the expression
136:             */
137:            public ExpressionVisitor getExpression(final String name) {
138:                return getExpressionInfo(name).getExpression();
139:            }
140:
141:            /**
142:             * Returns the advised class expression with a specific name.
143:             *
144:             * @param name the name of the expression
145:             * @return the expression
146:             */
147:            public AdvisedClassFilterExpressionVisitor getAdvisedClassExpression(
148:                    final String name) {
149:                return getExpressionInfo(name)
150:                        .getAdvisedClassFilterExpression();
151:            }
152:
153:            /**
154:             * Returns the name of the namespace.
155:             *
156:             * @return the name of the namespace
157:             */
158:            public String getName() {
159:                return m_namespace;
160:            }
161:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.