Source Code Cross Referenced for DeploymentHandle.java in  » Aspect-oriented » aspectwerkz-2.0 » org » codehaus » aspectwerkz » transform » inlining » deployer » 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.transform.inlining.deployer 
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.transform.inlining.deployer;
008:
009:        import java.util.Map;
010:        import java.util.HashMap;
011:        import java.util.Iterator;
012:        import java.util.Set;
013:        import java.lang.ref.WeakReference;
014:
015:        import org.codehaus.aspectwerkz.util.UuidGenerator;
016:        import org.codehaus.aspectwerkz.definition.AdviceDefinition;
017:        import org.codehaus.aspectwerkz.definition.SystemDefinitionContainer;
018:        import org.codehaus.aspectwerkz.definition.SystemDefinition;
019:        import org.codehaus.aspectwerkz.definition.AspectDefinition;
020:        import org.codehaus.aspectwerkz.expression.ExpressionInfo;
021:
022:        /**
023:         * Universal Unique IDentifier (UUID) for a deployment event.
024:         * <p/>
025:         * Can be stored by the user to allow access to a specific deployment event.
026:         * <p/>
027:         * Visibility for all methods are package private, user should only use it as a handle.
028:         *
029:         * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
030:         */
031:        public final class DeploymentHandle {
032:
033:            private final String UUID;
034:            private final Map m_definitionChangeElements = new HashMap();
035:            private final WeakReference m_loaderRef;
036:            private final WeakReference m_classRef;
037:
038:            /**
039:             * Creates a new handle.
040:             *
041:             * @param clazz the class of the entity being deployed
042:             */
043:            DeploymentHandle(final Class clazz, final ClassLoader loader) {
044:                if (clazz == null) {
045:                    throw new IllegalArgumentException("class can not be null");
046:                }
047:                if (loader == null) {
048:                    throw new IllegalArgumentException("loader can not be null");
049:                }
050:                UUID = UuidGenerator.generate(clazz);
051:                m_loaderRef = new WeakReference(loader);
052:                m_classRef = new WeakReference(clazz);
053:            }
054:
055:            void registerDefinitionChange(final AdviceDefinition adviceDef,
056:                    final ExpressionInfo oldExpression) {
057:                m_definitionChangeElements.put(adviceDef.getQualifiedName(),
058:                        new DefinitionChangeElement(adviceDef, oldExpression));
059:            }
060:
061:            Class getAspectClass() {
062:                return (Class) m_classRef.get();
063:            }
064:
065:            Map getDefintionChangeElements() {
066:                return m_definitionChangeElements;
067:            }
068:
069:            void revertChanges() {
070:                final ClassLoader loader = (ClassLoader) m_loaderRef.get();
071:                // hotdeployment is done thru the virtual system, so reverts changes as well
072:                SystemDefinition systemDef = SystemDefinitionContainer
073:                        .getVirtualDefinitionAt(loader);
074:                for (Iterator it2 = systemDef.getAspectDefinitions().iterator(); it2
075:                        .hasNext();) {
076:                    AspectDefinition aspectDef = (AspectDefinition) it2.next();
077:                    for (Iterator it3 = aspectDef.getAfterAdviceDefinitions()
078:                            .iterator(); it3.hasNext();) {
079:                        AdviceDefinition adviceDef = (AdviceDefinition) it3
080:                                .next();
081:                        DefinitionChangeElement changeElement = (DefinitionChangeElement) m_definitionChangeElements
082:                                .get(adviceDef.getQualifiedName());
083:                        if (changeElement != null) {
084:                            changeElement.getAdviceDef().setExpressionInfo(
085:                                    changeElement.getOldExpression());
086:                        }
087:                    }
088:                }
089:            }
090:
091:            public String toString() {
092:                return new StringBuffer().append("DeploymentHandle [").append(
093:                        UUID.toString()).append(',').append(
094:                        ((Class) m_classRef.get()).getName()).append(',')
095:                        .append((ClassLoader) m_loaderRef.get()).append(']')
096:                        .toString();
097:            }
098:
099:            public int hashCode() {
100:                return UUID.hashCode();
101:            }
102:
103:            public boolean equals(Object o) {
104:                return ((DeploymentHandle) o).UUID.equals(UUID);
105:            }
106:
107:            /**
108:             * Holds the definition change of one advice.
109:             *
110:             * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
111:             */
112:            static class DefinitionChangeElement {
113:                private final AdviceDefinition m_adviceDef;
114:                private final ExpressionInfo m_oldExpression;
115:
116:                public DefinitionChangeElement(
117:                        final AdviceDefinition adviceDef,
118:                        final ExpressionInfo oldExpression) {
119:                    m_adviceDef = adviceDef;
120:                    m_oldExpression = oldExpression;
121:                }
122:
123:                public ExpressionInfo getOldExpression() {
124:                    return m_oldExpression;
125:                }
126:
127:                public AdviceDefinition getAdviceDef() {
128:                    return m_adviceDef;
129:                }
130:            }
131:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.