Source Code Cross Referenced for ComponentTypeHandler.java in  » Inversion-of-Control » carbon » org » sape » carbon » core » config » type » handlers » 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 » carbon » org.sape.carbon.core.config.type.handlers 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The contents of this file are subject to the Sapient Public License
003:         * Version 1.0 (the "License"); you may not use this file except in compliance
004:         * with the License. You may obtain a copy of the License at
005:         * http://carbon.sf.net/License.html.
006:         *
007:         * Software distributed under the License is distributed on an "AS IS" basis,
008:         * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
009:         * the specific language governing rights and limitations under the License.
010:         *
011:         * The Original Code is The Carbon Component Framework.
012:         *
013:         * The Initial Developer of the Original Code is Sapient Corporation
014:         *
015:         * Copyright (C) 2003 Sapient Corporation. All Rights Reserved.
016:         */
017:
018:        package org.sape.carbon.core.config.type.handlers;
019:
020:        import org.sape.carbon.core.component.Component;
021:        import org.sape.carbon.core.component.ComponentConfiguration;
022:        import org.sape.carbon.core.component.Lookup;
023:        import org.sape.carbon.core.config.Configuration;
024:        import org.sape.carbon.core.config.interceptor.ConfigurationInterceptor;
025:        import org.sape.carbon.core.config.type.ComplexConfigurationTypeHandler;
026:        import org.sape.carbon.core.config.type.NonCacheableTypeHandler;
027:        import org.sape.carbon.core.config.type.TypeConversionException;
028:
029:        /**
030:         * <P>Parses and formats between Configurations and Components.</P>
031:         *
032:         * Copyright 2002 Sapient
033:         * @since carbon 1.0
034:         * @author Douglas Voet, September 2002
035:         * @version $Revision: 1.19 $($Author: dvoet $ / $Date: 2003/07/29 19:54:45 $)
036:         */
037:        public class ComponentTypeHandler implements 
038:                ComplexConfigurationTypeHandler, NonCacheableTypeHandler {
039:
040:            /**
041:             * <P>Formats a Component into a Configuration object.</P>
042:             *
043:             * @param objectValue the Component to be formatted
044:             * @return the configuration for the given component
045:             * @throws ClassCastException when past an object other than a Component
046:             * @throws TypeConversionException if the Component does not have
047:             * a <code>ConfigurationInterceptor</code>
048:             */
049:            public Configuration toConfiguration(Object objectValue)
050:                    throws TypeConversionException {
051:                // assume that objectValue is a component and a ConfigurationInterceptor
052:                // is configured
053:
054:                try {
055:                    ConfigurationInterceptor assistantView = (ConfigurationInterceptor) objectValue;
056:
057:                    return assistantView.getLiveConfiguration();
058:
059:                } catch (ClassCastException cce) {
060:                    throw new TypeConversionException(
061:                            this .getClass(),
062:                            "Component ["
063:                                    + ((Component) objectValue)
064:                                            .getComponentName()
065:                                    + "] does not have a ConfigurationInterceptor, "
066:                                    + "one must be configured in its component template "
067:                                    + "in order to set Component types in Configurations",
068:                            cce);
069:                }
070:
071:            }
072:
073:            /**
074:             * <P>Parses a Configuration object into a Component object.</P>
075:             *
076:             * @param returnType the type of the object that should be returned
077:             * @param configuration the config object holding the data to be used in
078:             *   creating the object.
079:             * @return Component specified in the configuration
080:             * @throws TypeConversionException when the string does not represent
081:             *   a valid Component
082:             */
083:            public Object toObject(Class returnType, Configuration configuration)
084:                    throws TypeConversionException {
085:
086:                Component component = null;
087:
088:                if (configuration != null) {
089:                    component = Lookup.getInstance().fetchComponent(
090:                            configuration.getConfigurationName());
091:
092:                    if (!returnType.isAssignableFrom(component.getClass())) {
093:                        throw new TypeConversionException(
094:                                this .getClass(),
095:                                "Component defined by configuraion ["
096:                                        + configuration.getConfigurationName()
097:                                        + "] was incorrect type: expected ["
098:                                        + returnType.getName()
099:                                        + "], actual FunctionalInterface: ["
100:                                        + ((ComponentConfiguration) configuration)
101:                                                .getFunctionalInterface()
102:                                                .getName() + "].");
103:                    }
104:                }
105:
106:                return component;
107:
108:            }
109:
110:            /**
111:             * @see org.sape.carbon.core.config.type.ComplexConfigurationTypeHandler#getRequiredConfigurationInterface()
112:             */
113:            public Class getRequiredConfigurationInterface() {
114:                return ComponentConfiguration.class;
115:            }
116:
117:        }
ww__w__._j___a__va__2s___.___c_o___m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.