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


001:        package org.andromda.cartridges.spring.metafacades;
002:
003:        import org.andromda.cartridges.spring.SpringProfile;
004:        import org.andromda.core.common.ExceptionUtils;
005:        import org.andromda.metafacades.uml.ClassifierFacade;
006:        import org.andromda.metafacades.uml.ModelElementFacade;
007:        import org.andromda.metafacades.uml.OperationFacade;
008:        import org.andromda.metafacades.uml.UMLProfile;
009:        import org.apache.commons.collections.CollectionUtils;
010:        import org.apache.commons.collections.Predicate;
011:        import org.apache.commons.lang.StringUtils;
012:
013:        /**
014:         * Contains utilities specific to dealing with the Spring cartridge metafacades.
015:         *
016:         * @author Chad Brandon
017:         * @author Peter Friese
018:         */
019:        class SpringMetafacadeUtils {
020:            /**
021:             * Creates a fully qualified name from the given <code>packageName</code>, <code>name</code>, and
022:             * <code>suffix</code>.
023:             *
024:             * @param packageName the name of the model element package.
025:             * @param name        the name of the model element.
026:             * @param suffix      the suffix to append.
027:             * @return the new fully qualified name.
028:             */
029:            static String getFullyQualifiedName(String packageName,
030:                    String name, String suffix) {
031:                StringBuffer fullyQualifiedName = new StringBuffer(StringUtils
032:                        .trimToEmpty(packageName));
033:                if (StringUtils.isNotBlank(packageName)) {
034:                    fullyQualifiedName.append(".");
035:                }
036:                fullyQualifiedName.append(StringUtils.trimToEmpty(name));
037:                if (StringUtils.isNotEmpty(suffix)) {
038:                    fullyQualifiedName.append(StringUtils.trimToEmpty(suffix));
039:                }
040:                return fullyQualifiedName.toString();
041:            }
042:
043:            /**
044:             * Creates a fully qualified name from the given <code>packageName</code>, <code>name</code>, and
045:             * <code>suffix</code>.
046:             *
047:             * @param packageName the name of the model element package.
048:             * @param name        the name of the model element.
049:             * @return the new fully qualified name.
050:             */
051:            static String getFullyQualifiedName(String packageName, String name) {
052:                return getFullyQualifiedName(packageName, name, null);
053:            }
054:
055:            /**
056:             * Gets the remoting type for the passed in <code>classifier</code>. If the remoting type can be retrieved from the
057:             * <code>classifier</code>, then that is used, otherwise the <code>defaultRemotingType</code> is returned.
058:             *
059:             * @return String the remoting type name.
060:             */
061:            static String getServiceRemotingType(ClassifierFacade classifier,
062:                    String defaultServiceRemotingType) {
063:                ExceptionUtils.checkNull("classifer", classifier);
064:                String remotingType = null;
065:                if (classifier.hasStereotype(UMLProfile.STEREOTYPE_SERVICE)) {
066:                    String remotingTypeValue = (String) classifier
067:                            .findTaggedValue(SpringProfile.TAGGEDVALUE_SPRING_SERVICE_REMOTING_TYPE);
068:                    // if the remoting type wasn't found, search all super classes
069:                    if (StringUtils.isEmpty(remotingTypeValue)) {
070:                        remotingType = (String) CollectionUtils.find(classifier
071:                                .getAllGeneralizations(), new Predicate() {
072:                            public boolean evaluate(Object object) {
073:                                return ((ModelElementFacade) object)
074:                                        .findTaggedValue(SpringProfile.TAGGEDVALUE_SPRING_SERVICE_REMOTING_TYPE) != null;
075:                            }
076:                        });
077:                    }
078:                    if (StringUtils.isNotEmpty(remotingTypeValue)) {
079:                        remotingType = remotingTypeValue;
080:                    }
081:                }
082:                if (StringUtils.isEmpty(remotingType)) {
083:                    remotingType = defaultServiceRemotingType;
084:                }
085:                return remotingType.toLowerCase().trim();
086:            }
087:
088:            /**
089:             * Get the interceptors for the passed in <code>classifier</code>. If the interceptors can be retrieved from the
090:             * <code>classifier</code>, then these will be used, otherwise the <code>defaultInterceptors</code> are
091:             * returned.
092:             *
093:             * @param classifier the classifier whose interceptors we are looking for.
094:             * @param defaultInterceptors a list of interceptors to use if the classifier itself has no explicit interceptors.
095:             *
096:             * @return String[] the interceptors.
097:             */
098:            static String[] getServiceInterceptors(ClassifierFacade classifier,
099:                    String[] defaultInterceptors) {
100:                ExceptionUtils.checkNull("classifier", classifier);
101:                String[] interceptors = null;
102:                if (classifier.hasStereotype(UMLProfile.STEREOTYPE_SERVICE)) {
103:                    String interceptorsValue = (String) classifier
104:                            .findTaggedValue(SpringProfile.TAGGEDVALUE_SPRING_SERVICE_INTERCEPTORS);
105:                    // if the interceptors weren't found, search all super classes
106:                    if (StringUtils.isEmpty(interceptorsValue)) {
107:                        interceptorsValue = (String) CollectionUtils.find(
108:                                classifier.getAllGeneralizations(),
109:                                new Predicate() {
110:                                    public boolean evaluate(Object object) {
111:                                        return ((ModelElementFacade) object)
112:                                                .findTaggedValue(SpringProfile.TAGGEDVALUE_SPRING_SERVICE_INTERCEPTORS) != null;
113:                                    }
114:                                });
115:                    }
116:                    // interceptors are a comma-separated list of strings, go and split the list
117:                    if (StringUtils.isNotEmpty(interceptorsValue)) {
118:                        interceptors = interceptorsValue.split(",");
119:                    }
120:                }
121:                if (interceptors == null || interceptors.length == 0) {
122:                    interceptors = defaultInterceptors;
123:                }
124:                return interceptors;
125:            }
126:
127:            /**
128:             * Gets the remote service port for the passed in <code>classifier</code>. If the remote service
129:             * port can be retrieved from the <code>classifier</code>, then that is used, otherwise the
130:             * <code>defaultRemoteServicePort</code> is returned.
131:             *
132:             * @return String the remote service port.
133:             */
134:            static String getServiceRemotePort(ClassifierFacade classifier,
135:                    String defaultRemoteServicePort) {
136:                ExceptionUtils.checkNull("classifer", classifier);
137:                String remoteServicePort = null;
138:                if (classifier.hasStereotype(UMLProfile.STEREOTYPE_SERVICE)) {
139:                    String remoteServicePortValue = (String) classifier
140:                            .findTaggedValue(SpringProfile.TAGGEDVALUE_SPRING_SERVICE_REMOTE_PORT);
141:                    // if the remote service port wasn't found, search all super classes
142:                    if (StringUtils.isEmpty(remoteServicePortValue)) {
143:                        remoteServicePort = (String) CollectionUtils.find(
144:                                classifier.getAllGeneralizations(),
145:                                new Predicate() {
146:                                    public boolean evaluate(Object object) {
147:                                        return ((ModelElementFacade) object)
148:                                                .findTaggedValue(SpringProfile.TAGGEDVALUE_SPRING_SERVICE_REMOTE_PORT) != null;
149:                                    }
150:                                });
151:                    }
152:                    if (StringUtils.isNotEmpty(remoteServicePortValue)) {
153:                        remoteServicePort = remoteServicePortValue;
154:                    }
155:                }
156:                if (StringUtils.isEmpty(remoteServicePort)) {
157:                    remoteServicePort = defaultRemoteServicePort;
158:                }
159:                return remoteServicePort.toLowerCase().trim();
160:            }
161:
162:            /**
163:             * Checks whether the passed in operation is a query and should be using named parameters.
164:             *
165:             * @param operation the operation.
166:             * @param defaultUseNamedParameters the default value.
167:             * @return whether named parameters should be used.
168:             */
169:            static boolean getUseNamedParameters(OperationFacade operation,
170:                    boolean defaultUseNamedParameters) {
171:                ExceptionUtils.checkNull("operation", operation);
172:                boolean useNamedParameters = defaultUseNamedParameters;
173:                if (operation.isQuery()) {
174:                    String useNamedParametersValue = StringUtils
175:                            .trimToEmpty((String) operation
176:                                    .findTaggedValue(SpringProfile.TAGGEDVALUE_HIBERNATE_USE_NAMED_PARAMETERS));
177:                    if (StringUtils.isNotEmpty(useNamedParametersValue)) {
178:                        useNamedParameters = Boolean.valueOf(
179:                                useNamedParametersValue).booleanValue();
180:                    }
181:                }
182:                return useNamedParameters;
183:            }
184:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.