Source Code Cross Referenced for ExpressionNamespace.java in  » Aspect-oriented » aspectwerkz-2.0 » org » codehaus » 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 » Aspect oriented » aspectwerkz 2.0 » org.codehaus.aspectwerkz.expression 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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