Source Code Cross Referenced for ComponentNode.java in  » Inversion-of-Control » nanocontainer » org » nanocontainer » script » groovy » buildernodes » 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 » Inversion of Control » nanocontainer » org.nanocontainer.script.groovy.buildernodes 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*****************************************************************************
002:         * Copyright (C) NanoContainer Organization. All rights reserved.            *
003:         * ------------------------------------------------------------------------- *
004:         * The software in this package is published under the terms of the BSD      *
005:         * style license a copy of which has been included with this distribution in *
006:         * the LICENSE.txt file.                                                     *
007:         *                                                                           *
008:         * Original code by James Strachan                                           *
009:         *****************************************************************************/package org.nanocontainer.script.groovy.buildernodes;
010:
011:        import java.util.List;
012:        import java.util.Map;
013:
014:        import org.nanocontainer.NanoContainer;
015:        import org.nanocontainer.script.NodeBuilderDecorationDelegate;
016:        import org.nanocontainer.script.ComponentElementHelper;
017:        import org.picocontainer.MutablePicoContainer;
018:        import org.picocontainer.Parameter;
019:        import org.picocontainer.defaults.ConstantParameter;
020:
021:        /**
022:         *
023:         * @author James Strachan
024:         * @author Paul Hammant
025:         * @author Aslak Hellesøy
026:         * @author Michael Rimov
027:         * @author Mauro Talevi
028:         * @version $Revision: 2695 $
029:         */
030:        public class ComponentNode extends AbstractBuilderNode {
031:
032:            public static final String NODE_NAME = "component";
033:
034:            /**
035:             * Attributes 'key'
036:             */
037:            public static final String KEY = "key";
038:
039:            /**
040:             * Class attribute.
041:             */
042:            private static final String CLASS = "class";
043:
044:            /**
045:             * Class Name Key Attribute.
046:             */
047:            private static final String CLASS_NAME_KEY = "classNameKey";
048:
049:            /**
050:             * Instance attribute name.
051:             */
052:            private static final String INSTANCE = "instance";
053:
054:            /**
055:             * Parameters attribute name.
056:             */
057:            private static final String PARAMETERS = "parameters";
058:
059:            private final NodeBuilderDecorationDelegate delegate;
060:
061:            public ComponentNode(NodeBuilderDecorationDelegate builderDelegate) {
062:                super (NODE_NAME);
063:
064:                this .delegate = builderDelegate;
065:
066:                //Supported attributes.
067:                this .addAttribute(KEY).addAttribute(CLASS).addAttribute(
068:                        CLASS_NAME_KEY).addAttribute(INSTANCE).addAttribute(
069:                        PARAMETERS);
070:            }
071:
072:            /**
073:             * Execute the handler for the given node builder.
074:             * TODO - wrong Javadoc
075:             * @param name Object the parent object.
076:             * @param value The Node value. This is almost never used, but it kept
077:             *   in for consistency with the Groovy Builder API. Normally set to
078:             *   null.
079:             * @param current The current node.
080:             * @param attributes Map attributes specified in the groovy script for
081:             *   the builder node.
082:             * @return Object
083:             */
084:            public Object createNewNode(final Object current,
085:                    final Map attributes) {
086:                delegate.rememberComponentKey(attributes);
087:                Object key = attributes.remove(KEY);
088:                Object cnkey = attributes.remove(CLASS_NAME_KEY);
089:                Object classValue = attributes.remove(CLASS);
090:                Object instance = attributes.remove(INSTANCE);
091:                List parameters = (List) attributes.remove(PARAMETERS);
092:
093:                ComponentElementHelper.makeComponent(cnkey, key,
094:                        getParameters(parameters), classValue,
095:                        (NanoContainer) current, instance);
096:
097:                return this .getNodeName();
098:            }
099:
100:            private static Parameter[] getParameters(List paramsList) {
101:                if (paramsList == null) {
102:                    return null;
103:                }
104:                int n = paramsList.size();
105:                Parameter[] parameters = new Parameter[n];
106:                for (int i = 0; i < n; ++i) {
107:                    parameters[i] = toParameter(paramsList.get(i));
108:                }
109:                return parameters;
110:            }
111:
112:            private static Parameter toParameter(Object obj) {
113:                return obj instanceof  Parameter ? (Parameter) obj
114:                        : new ConstantParameter(obj);
115:            }
116:
117:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.