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


001:        package org.andromda.cartridges.spring;
002:
003:        import java.util.Collection;
004:        import java.util.LinkedHashSet;
005:        import java.util.List;
006:        import java.util.ArrayList;
007:        import java.util.Iterator;
008:        import java.util.LinkedHashMap;
009:        import java.util.Map;
010:
011:        import org.andromda.cartridges.spring.metafacades.SpringService;
012:        import org.andromda.metafacades.uml.Service;
013:        import org.andromda.metafacades.uml.ModelElementFacade;
014:        import org.apache.commons.collections.Closure;
015:        import org.apache.commons.collections.CollectionUtils;
016:        import org.apache.commons.collections.Predicate;
017:
018:        /**
019:         * Contains utilities used within the Spring cartridge.
020:         *
021:         * @author Chad Brandon
022:         * @author Joel Kozikowski
023:         */
024:        public class SpringUtils {
025:            /**
026:             * Retrieves all roles from the given <code>services</code> collection.
027:             *
028:             * @param services the collection services.
029:             * @return all roles from the collection.
030:             */
031:            public Collection getAllRoles(Collection services) {
032:                final Collection allRoles = new LinkedHashSet();
033:                CollectionUtils.forAllDo(services, new Closure() {
034:                    public void execute(Object object) {
035:                        if (object != null
036:                                && Service.class.isAssignableFrom(object
037:                                        .getClass())) {
038:                            allRoles.addAll(((Service) object).getAllRoles());
039:                        }
040:                    }
041:                });
042:                return allRoles;
043:            }
044:
045:            /**
046:             * Indicates if any remote EJBs are present in the collection
047:             * of services.
048:             *
049:             * @param services the collection of services to check.
050:             * @return true/false.
051:             */
052:            public boolean remoteEjbsPresent(final Collection services) {
053:                boolean present = services != null && !services.isEmpty();
054:                if (present) {
055:                    present = CollectionUtils.find(services, new Predicate() {
056:                        public boolean evaluate(final Object object) {
057:                            boolean valid = false;
058:                            if (object instanceof  SpringService) {
059:                                final SpringService service = (SpringService) object;
060:                                valid = service.isEjbRemoteView();
061:                            }
062:                            return valid;
063:                        }
064:                    }) != null;
065:                }
066:                return present;
067:            }
068:
069:            /**
070:             * Indicates if any local EJBs are present in the collection
071:             * of services.
072:             *
073:             * @param services the collection of services to check.
074:             * @return true/false.
075:             */
076:            public boolean localEjbsPresent(final Collection services) {
077:                boolean present = services != null && !services.isEmpty();
078:                if (present) {
079:                    present = CollectionUtils.find(services, new Predicate() {
080:                        public boolean evaluate(final Object object) {
081:                            boolean valid = false;
082:                            if (object instanceof  SpringService) {
083:                                final SpringService service = (SpringService) object;
084:                                valid = service.isEjbLocalView();
085:                            }
086:                            return valid;
087:                        }
088:                    }) != null;
089:                }
090:                return present;
091:            }
092:
093:            /**
094:             * Indicates if any Spring remotable services are present.
095:             *
096:             * @param services the collection of services to check.
097:             * @return true/false.
098:             */
099:            public boolean remotableServicesPresent(final Collection services) {
100:                boolean present = services != null && !services.isEmpty();
101:                if (present) {
102:                    present = CollectionUtils.find(services, new Predicate() {
103:                        public boolean evaluate(final Object object) {
104:                            boolean valid = false;
105:                            if (object instanceof  SpringService) {
106:                                final SpringService service = (SpringService) object;
107:                                valid = service.isRemotable();
108:                            }
109:                            return valid;
110:                        }
111:                    }) != null;
112:                }
113:                return present;
114:            }
115:
116:            /**
117:             * Based on the given <code>value</code>, this method will return
118:             * a formatted Spring property (including the handling of 'null').
119:             *
120:             * @param value the value from which to create the spring value.
121:             * @return the spring value.
122:             */
123:            public String getSpringPropertyValue(final String value) {
124:                String propertyValue = "";
125:                if (value != null) {
126:                    if ("null".equalsIgnoreCase(value)) {
127:                        propertyValue = "<null/>";
128:                    } else {
129:                        propertyValue = "<value>" + value + "</value>";
130:                    }
131:                }
132:                return propertyValue;
133:            }
134:
135:            /**
136:             * Removes generics from string. Currently used to strip generics 
137:             * from ejb-jar.xml method parameters.
138:             * 
139:             * @param String containing generics
140:             * @return String with generics stripped
141:             */
142:            public String removeGenerics(final String parameter) {
143:                int position = parameter.indexOf("<");
144:                String result = parameter;
145:                if (position != -1) {
146:                    result = result.substring(0, position);
147:                }
148:                return result;
149:            }
150:
151:            /**
152:             * Are we generating code for a rich client?
153:             */
154:            private boolean richClient = false;
155:
156:            /**
157:             * Sets if code is being generated for a rich client.
158:             */
159:            public void setRichClient(final boolean richClientProperty) {
160:                this .richClient = richClientProperty;
161:            }
162:
163:            /**
164:             * Returns TRUE if code is being generated for a rich client environment 
165:             */
166:            public boolean isRichClient() {
167:                return this .richClient;
168:            }
169:
170:            /**
171:             * Returns the class name part of a fully qualified name
172:             * @param fullyQualifiedName
173:             * @return just the "class name" part of the fully qualified name
174:             */
175:            public String getClassName(String fullyQualifiedName) {
176:                String className;
177:                if (fullyQualifiedName != null
178:                        && fullyQualifiedName.length() > 0) {
179:                    int lastDot = fullyQualifiedName.lastIndexOf('.');
180:                    if (lastDot >= 0)
181:                        className = fullyQualifiedName.substring(lastDot + 1);
182:                    else
183:                        className = fullyQualifiedName;
184:                } else
185:                    className = "";
186:
187:                return className;
188:            }
189:
190:            /**
191:             * Returns the package name part of a fully qualified name
192:             * @param fullyQualifiedName
193:             * @return just the "package" part of the fully qualified name
194:             */
195:            public String getPackageName(String fullyQualifiedName) {
196:                String packageName;
197:                if (fullyQualifiedName != null
198:                        && fullyQualifiedName.length() > 0) {
199:                    int lastDot = fullyQualifiedName.lastIndexOf('.');
200:                    if (lastDot >= 0)
201:                        packageName = fullyQualifiedName.substring(0, lastDot);
202:                    else
203:                        packageName = "";
204:                } else
205:                    packageName = "";
206:
207:                return packageName;
208:            }
209:
210:            /**
211:             * Returns an ordered set containing the argument model elements, model elements with a name that is already
212:             * used by another model element in the argument collection will not be returned.
213:             * The first operation with a name not already encountered will be returned, the order inferred by the
214:             * argument's iterator will determine the order of the returned list.
215:             *
216:             * @param modelElements a collection of model elements, elements that are not model elements will be ignored
217:             * @return the argument model elements without, elements with a duplicate name will only be recorded once
218:             */
219:            public List filterUniqueByName(Collection modelElements) {
220:                final Map filteredElements = new LinkedHashMap();
221:
222:                for (final Iterator elementIterator = modelElements.iterator(); elementIterator
223:                        .hasNext();) {
224:                    final Object object = elementIterator.next();
225:                    if (object instanceof  ModelElementFacade) {
226:                        final ModelElementFacade modelElement = (ModelElementFacade) object;
227:                        if (!filteredElements.containsKey(modelElement
228:                                .getName())) {
229:                            filteredElements.put(modelElement.getName(),
230:                                    modelElement);
231:                        }
232:                    }
233:                }
234:
235:                return new ArrayList(filteredElements.values());
236:            }
237:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.