Source Code Cross Referenced for DeploymentModel.java in  » Net » Terracotta » com » tc » aspectwerkz » 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 
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;
005:
006:        import com.tc.aspectwerkz.perx.PerObjectAspect;
007:
008:        /**
009:         * Enum containing the different deployment model types.
010:         * <p/>
011:         * Note: equals does not check for pointcut equality for perthis/pertarget but
012:         * does only checks for types
013:         *
014:         * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
015:         */
016:        public class DeploymentModel {
017:
018:            public static final DeploymentModel PER_JVM = new DeploymentModel(
019:                    "perJVM");
020:            public static final DeploymentModel PER_CLASS = new DeploymentModel(
021:                    "perClass");
022:            public static final DeploymentModel PER_INSTANCE = new DeploymentModel(
023:                    "perInstance");
024:
025:            public static final DeploymentModel PER_TARGET = new DeploymentModel(
026:                    "perTarget");
027:            public static final DeploymentModel PER_THIS = new DeploymentModel(
028:                    "perThis");
029:            public static final DeploymentModel PER_CFLOW = new DeploymentModel(
030:                    "perCflow");
031:            public static final DeploymentModel PER_CFLOWBELOW = new DeploymentModel(
032:                    "perCflowbelow");
033:
034:            private static final String THIS_POINTCUT = "this("
035:                    + PerObjectAspect.ADVICE_ARGUMENT_NAME + ")";
036:            private static final String TARGET_POINTCUT = "target("
037:                    + PerObjectAspect.ADVICE_ARGUMENT_NAME + ")";
038:
039:            protected final String m_name;
040:
041:            DeploymentModel(String name) {
042:                m_name = name;
043:            }
044:
045:            public String toString() {
046:                return m_name;
047:            }
048:
049:            public boolean equals(Object o) {
050:                if (this  == o) {
051:                    return true;
052:                }
053:                if (!(o instanceof  DeploymentModel)) {
054:                    return false;
055:                }
056:                final DeploymentModel adviceType = (DeploymentModel) o;
057:                if ((m_name != null) ? (!m_name.equals(adviceType.m_name))
058:                        : (adviceType.m_name != null)) {
059:                    return false;
060:                }
061:                return true;
062:            }
063:
064:            public int hashCode() {
065:                return ((m_name != null) ? m_name.hashCode() : 0);
066:            }
067:
068:            public static DeploymentModel getDeploymentModelFor(
069:                    final String deploymentModelAsString) {
070:                if (deploymentModelAsString == null
071:                        || deploymentModelAsString.equals("")) {
072:                    return PER_JVM; // default is PER_JVM
073:                }
074:                if (deploymentModelAsString
075:                        .equalsIgnoreCase(PER_JVM.toString())) {
076:                    return PER_JVM;
077:                } else if (deploymentModelAsString.equalsIgnoreCase(PER_CLASS
078:                        .toString())) {
079:                    return PER_CLASS;
080:                } else if (deploymentModelAsString
081:                        .equalsIgnoreCase(PER_INSTANCE.toString())) {
082:                    return PER_INSTANCE;
083:                } else if (deploymentModelAsString.equalsIgnoreCase(PER_CFLOW
084:                        .toString())) {
085:                    return PER_CFLOW;
086:                } else if (deploymentModelAsString
087:                        .equalsIgnoreCase(PER_CFLOWBELOW.toString())) {
088:                    return PER_CFLOWBELOW;
089:                } else if (deploymentModelAsString.equalsIgnoreCase(PER_THIS
090:                        .toString())) {
091:                    return PER_THIS;
092:                } else if (deploymentModelAsString.equalsIgnoreCase(PER_TARGET
093:                        .toString())) {
094:                    return PER_TARGET;
095:                    // below support for more advanced schemes.
096:                } else if (deploymentModelAsString.toLowerCase().startsWith(
097:                        PER_THIS.m_name.toLowerCase())) {
098:                    return new PointcutControlledDeploymentModel(
099:                            PER_THIS.m_name, getDeploymentExpression(
100:                                    deploymentModelAsString, THIS_POINTCUT));
101:                } else if (deploymentModelAsString.toLowerCase().startsWith(
102:                        PER_TARGET.m_name.toLowerCase())) {
103:                    return new PointcutControlledDeploymentModel(
104:                            PER_TARGET.m_name, getDeploymentExpression(
105:                                    deploymentModelAsString, TARGET_POINTCUT));
106:                } else {
107:                    System.out
108:                            .println("AW::WARNING - no such deployment model ["
109:                                    + deploymentModelAsString
110:                                    + "] using default (perJVM)");
111:                    return PER_JVM; // falling back to default - PER_JVM
112:                }
113:            }
114:
115:            /**
116:             * @param deploymentModelAsString
117:             * @return
118:             */
119:            private static String getDeploymentExpression(
120:                    String deploymentModelAsString, final String pointcut) {
121:                int startIndex = deploymentModelAsString.indexOf('(');
122:                int endIndex = deploymentModelAsString.lastIndexOf(')');
123:
124:                if (startIndex == -1 || endIndex == -1
125:                        || startIndex >= endIndex) {
126:                    System.out
127:                            .println("AW::ERROR - wrong deployment model definition ["
128:                                    + deploymentModelAsString + "]");
129:
130:                    return "";
131:                }
132:
133:                return deploymentModelAsString.substring(startIndex + 1,
134:                        endIndex).trim()
135:                        + " && " + pointcut;
136:            }
137:
138:            /**
139:             * perthis.. pertarget.. deployment model depends on a pointcut expression
140:             */
141:            public static final class PointcutControlledDeploymentModel extends
142:                    DeploymentModel {
143:
144:                private String m_expression;
145:
146:                PointcutControlledDeploymentModel(String name, String expression) {
147:                    super (name);
148:                    m_expression = expression;
149:                }
150:
151:                public String getDeploymentExpression() {
152:                    return m_expression;
153:                }
154:
155:                public String toString() {
156:                    // returns only the name, not the expression
157:                    return m_name;
158:                }
159:
160:                public boolean equals(Object o) {
161:                    return super .equals(o);
162:                }
163:
164:                public int hashCode() {
165:                    return super.hashCode();
166:                }
167:            }
168:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.