Source Code Cross Referenced for AspectModelManager.java in  » Net » Terracotta » com » tc » aspectwerkz » transform » inlining » 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.transform.inlining 
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.transform.inlining;
005:
006:        import com.tc.aspectwerkz.definition.AspectDefinition;
007:        import com.tc.aspectwerkz.exception.DefinitionException;
008:        import com.tc.aspectwerkz.transform.inlining.model.AopAllianceAspectModel;
009:        import com.tc.aspectwerkz.transform.inlining.model.AspectWerkzAspectModel;
010:        import com.tc.aspectwerkz.transform.inlining.model.SpringAspectModel;
011:        import com.tc.aspectwerkz.transform.inlining.spi.AspectModel;
012:        import com.tc.aspectwerkz.util.ContextClassLoader;
013:        import com.tc.aspectwerkz.reflect.ClassInfo;
014:
015:        import java.util.ArrayList;
016:        import java.util.Iterator;
017:        import java.util.List;
018:        import java.util.StringTokenizer;
019:
020:        /**
021:         * Manages the different aspect model implementations that is registered.
022:         *
023:         * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
024:         */
025:        public class AspectModelManager {
026:
027:            public static final String ASPECT_MODELS_VM_OPTION = "aspectwerkz.extension.aspectmodels";
028:            private static final String DELIMITER = ":";
029:
030:            /**
031:             * The aspects models that are registered
032:             */
033:            private static List ASPECT_MODELS = new ArrayList(1);
034:
035:            static {
036:                ASPECT_MODELS.add(new AspectWerkzAspectModel());
037:                ASPECT_MODELS.add(new AopAllianceAspectModel());
038:                ASPECT_MODELS.add(new SpringAspectModel());
039:                registerCustomAspectModels(System.getProperty(
040:                        ASPECT_MODELS_VM_OPTION, null));
041:
042:            }
043:
044:            /**
045:             * Returns an array with all the aspect models that has been registered.
046:             *
047:             * @return an array with the aspect models
048:             */
049:            public static AspectModel[] getModels() {
050:                return (AspectModel[]) ASPECT_MODELS
051:                        .toArray(new AspectModel[] {});
052:            }
053:
054:            /**
055:             * Returns the advice model for a specific aspect model type id.
056:             *
057:             * @param type the aspect model type id
058:             * @return the aspect model
059:             */
060:            public static AspectModel getModelFor(String type) {
061:                for (Iterator iterator = ASPECT_MODELS.iterator(); iterator
062:                        .hasNext();) {
063:                    AspectModel aspectModel = (AspectModel) iterator.next();
064:                    if (aspectModel.getAspectModelType().equals(type)) {
065:                        return aspectModel;
066:                    }
067:                }
068:                return null;
069:            }
070:
071:            /**
072:             * Let all aspect models try to define the aspect (only one should succeed).
073:             *
074:             * @param aspectClassInfo
075:             * @param aspectDef
076:             * @param loader
077:             */
078:            public static void defineAspect(final ClassInfo aspectClassInfo,
079:                    final AspectDefinition aspectDef, final ClassLoader loader) {
080:                for (Iterator iterator = ASPECT_MODELS.iterator(); iterator
081:                        .hasNext();) {
082:                    AspectModel aspectModel = (AspectModel) iterator.next();
083:                    aspectModel
084:                            .defineAspect(aspectClassInfo, aspectDef, loader);
085:                }
086:            }
087:
088:            /**
089:             * Registers aspect models.
090:             *
091:             * @param aspectModels the class names of the aspect models to register concatenated and separated with a ':'.
092:             */
093:            public static void registerCustomAspectModels(
094:                    final String aspectModels) {
095:                if (aspectModels != null) {
096:                    StringTokenizer tokenizer = new StringTokenizer(
097:                            aspectModels, DELIMITER);
098:                    while (tokenizer.hasMoreTokens()) {
099:                        final String className = tokenizer.nextToken();
100:                        try {
101:                            final Class modelClass = ContextClassLoader
102:                                    .forName(className);
103:                            ASPECT_MODELS.add(modelClass.newInstance());
104:                        } catch (ClassNotFoundException e) {
105:                            throw new DefinitionException(
106:                                    "aspect model implementation class not found ["
107:                                            + className + "]: " + e.toString());
108:                        } catch (Exception e) {
109:                            throw new DefinitionException(
110:                                    "aspect model implementation class could not be instantiated ["
111:                                            + className
112:                                            + "] - make sure it has a default no argument constructor: "
113:                                            + e.toString());
114:                        }
115:                    }
116:                }
117:            }
118:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.