Source Code Cross Referenced for AbstractXmlApplicationContext.java in  » J2EE » spring-framework-2.5 » org » springframework » context » support » 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 » J2EE » spring framework 2.5 » org.springframework.context.support 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2002-2007 the original author or authors.
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *      http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:
017:        package org.springframework.context.support;
018:
019:        import java.io.IOException;
020:
021:        import org.springframework.beans.BeansException;
022:        import org.springframework.beans.factory.support.DefaultListableBeanFactory;
023:        import org.springframework.beans.factory.xml.ResourceEntityResolver;
024:        import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
025:        import org.springframework.context.ApplicationContext;
026:        import org.springframework.core.io.Resource;
027:
028:        /**
029:         * Convenient base class for {@link org.springframework.context.ApplicationContext}
030:         * implementations, drawing configuration from XML documents containing bean definitions
031:         * understood by an {@link org.springframework.beans.factory.xml.XmlBeanDefinitionReader}.
032:         *
033:         * <p>Subclasses just have to implement the {@link #getConfigResources} and/or
034:         * the {@link #getConfigLocations} method. Furthermore, they might override
035:         * the {@link #getResourceByPath} hook to interpret relative paths in an
036:         * environment-specific fashion, and/or {@link #getResourcePatternResolver}
037:         * for extended pattern resolution.
038:         *
039:         * @author Rod Johnson
040:         * @author Juergen Hoeller
041:         * @see #getConfigResources
042:         * @see #getConfigLocations
043:         * @see org.springframework.beans.factory.xml.XmlBeanDefinitionReader
044:         */
045:        public abstract class AbstractXmlApplicationContext extends
046:                AbstractRefreshableApplicationContext {
047:
048:            /**
049:             * Create a new AbstractXmlApplicationContext with no parent.
050:             */
051:            public AbstractXmlApplicationContext() {
052:            }
053:
054:            /**
055:             * Create a new AbstractXmlApplicationContext with the given parent context.
056:             * @param parent the parent context
057:             */
058:            public AbstractXmlApplicationContext(ApplicationContext parent) {
059:                super (parent);
060:            }
061:
062:            /**
063:             * Loads the bean definitions via an XmlBeanDefinitionReader.
064:             * @see org.springframework.beans.factory.xml.XmlBeanDefinitionReader
065:             * @see #initBeanDefinitionReader
066:             * @see #loadBeanDefinitions
067:             */
068:            protected void loadBeanDefinitions(
069:                    DefaultListableBeanFactory beanFactory) throws IOException {
070:                // Create a new XmlBeanDefinitionReader for the given BeanFactory.
071:                XmlBeanDefinitionReader beanDefinitionReader = new XmlBeanDefinitionReader(
072:                        beanFactory);
073:
074:                // Configure the bean definition reader with this context's
075:                // resource loading environment.
076:                beanDefinitionReader.setResourceLoader(this );
077:                beanDefinitionReader
078:                        .setEntityResolver(new ResourceEntityResolver(this ));
079:
080:                // Allow a subclass to provide custom initialization of the reader,
081:                // then proceed with actually loading the bean definitions.
082:                initBeanDefinitionReader(beanDefinitionReader);
083:                loadBeanDefinitions(beanDefinitionReader);
084:            }
085:
086:            /**
087:             * Initialize the bean definition reader used for loading the bean
088:             * definitions of this context. Default implementation is empty.
089:             * <p>Can be overridden in subclasses, e.g. for turning off XML validation
090:             * or using a different XmlBeanDefinitionParser implementation.
091:             * @param beanDefinitionReader the bean definition reader used by this context
092:             * @see org.springframework.beans.factory.xml.XmlBeanDefinitionReader#setDocumentReaderClass
093:             */
094:            protected void initBeanDefinitionReader(
095:                    XmlBeanDefinitionReader beanDefinitionReader) {
096:            }
097:
098:            /**
099:             * Load the bean definitions with the given XmlBeanDefinitionReader.
100:             * <p>The lifecycle of the bean factory is handled by the {@link #refreshBeanFactory}
101:             * method; hence this method is just supposed to load and/or register bean definitions.
102:             * @param reader the XmlBeanDefinitionReader to use
103:             * @throws BeansException in case of bean registration errors
104:             * @throws IOException if the required XML document isn't found
105:             * @see #refreshBeanFactory
106:             * @see #getConfigLocations
107:             * @see #getResources
108:             * @see #getResourcePatternResolver
109:             */
110:            protected void loadBeanDefinitions(XmlBeanDefinitionReader reader)
111:                    throws BeansException, IOException {
112:                Resource[] configResources = getConfigResources();
113:                if (configResources != null) {
114:                    reader.loadBeanDefinitions(configResources);
115:                }
116:                String[] configLocations = getConfigLocations();
117:                if (configLocations != null) {
118:                    reader.loadBeanDefinitions(configLocations);
119:                }
120:            }
121:
122:            /**
123:             * Return an array of Resource objects, referring to the XML bean definition
124:             * files that this context should be built with.
125:             * <p>The default implementation returns <code>null</code>. Subclasses can override
126:             * this to provide pre-built Resource objects rather than location Strings.
127:             * @return an array of Resource objects, or <code>null</code> if none
128:             * @see #getConfigLocations()
129:             */
130:            protected Resource[] getConfigResources() {
131:                return null;
132:            }
133:
134:            /**
135:             * Return an array of resource locations, referring to the XML bean definition
136:             * files that this context should be built with. Can also include location
137:             * patterns, which will get resolved via a ResourcePatternResolver.
138:             * <p>The default implementation returns <code>null</code>. Subclasses can override
139:             * this to provide a set of resource locations to load bean definitions from.
140:             * @return an array of resource locations, or <code>null</code> if none
141:             * @see #getResources
142:             * @see #getResourcePatternResolver
143:             */
144:            protected String[] getConfigLocations() {
145:                return null;
146:            }
147:
148:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.