Source Code Cross Referenced for ClassPathXmlApplicationContext.java in  » J2EE » spring-framework-2.0.6 » 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.0.6 » 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 org.springframework.beans.BeansException;
020:        import org.springframework.context.ApplicationContext;
021:        import org.springframework.core.io.ClassPathResource;
022:        import org.springframework.core.io.Resource;
023:        import org.springframework.util.Assert;
024:
025:        /**
026:         * Standalone XML application context, taking the context definition files
027:         * from the class path, interpreting plain paths as class path resource names
028:         * that include the package path (e.g. "mypackage/myresource.txt"). Useful for
029:         * test harnesses as well as for application contexts embedded within JARs.
030:         *
031:         * <p>The config location defaults can be overridden via {@link #getConfigLocations},
032:         * Config locations can either denote concrete files like "/myfiles/context.xml"
033:         * or Ant-style patterns like "/myfiles/*-context.xml" (see the
034:         * {@link org.springframework.util.AntPathMatcher} javadoc for pattern details).
035:         *
036:         * <p>Note: In case of multiple config locations, later bean definitions will
037:         * override ones defined in earlier loaded files. This can be leveraged to
038:         * deliberately override certain bean definitions via an extra XML file.
039:         *
040:         * <p><b>This is a simple, one-stop shop convenience ApplicationContext.
041:         * Consider using the {@link GenericApplicationContext} class in combination
042:         * with an {@link org.springframework.beans.factory.xml.XmlBeanDefinitionReader}
043:         * for more flexible context setup.</b>
044:         *
045:         * @author Rod Johnson
046:         * @author Juergen Hoeller
047:         * @see #getResource
048:         * @see #getResourceByPath
049:         * @see GenericApplicationContext
050:         */
051:        public class ClassPathXmlApplicationContext extends
052:                AbstractXmlApplicationContext {
053:
054:            private Resource[] configResources;
055:
056:            private String[] configLocations;
057:
058:            /**
059:             * Create a new ClassPathXmlApplicationContext, loading the definitions
060:             * from the given XML file and automatically refreshing the context.
061:             * @param configLocation resource location
062:             * @throws BeansException if context creation failed
063:             */
064:            public ClassPathXmlApplicationContext(String configLocation)
065:                    throws BeansException {
066:                this (new String[] { configLocation });
067:            }
068:
069:            /**
070:             * Create a new ClassPathXmlApplicationContext, loading the definitions
071:             * from the given XML files and automatically refreshing the context.
072:             * @param configLocations array of resource locations
073:             * @throws BeansException if context creation failed
074:             */
075:            public ClassPathXmlApplicationContext(String[] configLocations)
076:                    throws BeansException {
077:                this (configLocations, (ApplicationContext) null);
078:            }
079:
080:            /**
081:             * Create a new ClassPathXmlApplicationContext with the given parent,
082:             * loading the definitions from the given XML files and automatically
083:             * refreshing the context.
084:             * @param configLocations array of resource locations
085:             * @param parent the parent context
086:             * @throws BeansException if context creation failed
087:             */
088:            public ClassPathXmlApplicationContext(String[] configLocations,
089:                    ApplicationContext parent) throws BeansException {
090:
091:                super (parent);
092:                this .configLocations = configLocations;
093:                refresh();
094:            }
095:
096:            /**
097:             * Create a new ClassPathXmlApplicationContext, loading the definitions
098:             * from the given XML files.
099:             * @param configLocations array of resource locations
100:             * @param refresh whether to automatically refresh the context,
101:             * loading all bean definitions and creating all singletons.
102:             * Alternatively, call refresh manually after further configuring the context.
103:             * @throws BeansException if context creation failed
104:             * @see #refresh()
105:             */
106:            public ClassPathXmlApplicationContext(String[] configLocations,
107:                    boolean refresh) throws BeansException {
108:                this (configLocations, refresh, null);
109:            }
110:
111:            /**
112:             * Create a new ClassPathXmlApplicationContext with the given parent,
113:             * loading the definitions from the given XML files.
114:             * @param configLocations array of resource locations
115:             * @param refresh whether to automatically refresh the context,
116:             * loading all bean definitions and creating all singletons.
117:             * Alternatively, call refresh manually after further configuring the context.
118:             * @param parent the parent context
119:             * @throws BeansException if context creation failed
120:             * @see #refresh()
121:             */
122:            public ClassPathXmlApplicationContext(String[] configLocations,
123:                    boolean refresh, ApplicationContext parent)
124:                    throws BeansException {
125:
126:                super (parent);
127:                this .configLocations = configLocations;
128:                if (refresh) {
129:                    refresh();
130:                }
131:            }
132:
133:            /**
134:             * Create a new ClassPathXmlApplicationContext, loading the definitions
135:             * from the given XML file and automatically refreshing the context.
136:             * <p>This is a convenience method to load class path resources relative to a
137:             * given Class. For full flexibility, consider using a GenericApplicationContext
138:             * with an XmlBeanDefinitionReader and a ClassPathResource argument.
139:             * @param path relative (or absolute) path within the class path
140:             * @param clazz the class to load resources with (basis for the given paths)
141:             * @throws BeansException if context creation failed
142:             * @see org.springframework.core.io.ClassPathResource#ClassPathResource(String, Class)
143:             * @see org.springframework.context.support.GenericApplicationContext
144:             * @see org.springframework.beans.factory.xml.XmlBeanDefinitionReader
145:             */
146:            public ClassPathXmlApplicationContext(String path, Class clazz)
147:                    throws BeansException {
148:                this (new String[] { path }, clazz);
149:            }
150:
151:            /**
152:             * Create a new ClassPathXmlApplicationContext, loading the definitions
153:             * from the given XML files and automatically refreshing the context.
154:             * @param paths array of relative (or absolute) paths within the class path
155:             * @param clazz the class to load resources with (basis for the given paths)
156:             * @throws BeansException if context creation failed
157:             * @see org.springframework.core.io.ClassPathResource#ClassPathResource(String, Class)
158:             * @see org.springframework.context.support.GenericApplicationContext
159:             * @see org.springframework.beans.factory.xml.XmlBeanDefinitionReader
160:             */
161:            public ClassPathXmlApplicationContext(String[] paths, Class clazz)
162:                    throws BeansException {
163:                this (paths, clazz, null);
164:            }
165:
166:            /**
167:             * Create a new ClassPathXmlApplicationContext with the given parent,
168:             * loading the definitions from the given XML files and automatically
169:             * refreshing the context.
170:             * @param paths array of relative (or absolute) paths within the class path
171:             * @param clazz the class to load resources with (basis for the given paths)
172:             * @param parent the parent context
173:             * @throws BeansException if context creation failed
174:             * @see org.springframework.core.io.ClassPathResource#ClassPathResource(String, Class)
175:             * @see org.springframework.context.support.GenericApplicationContext
176:             * @see org.springframework.beans.factory.xml.XmlBeanDefinitionReader
177:             */
178:            public ClassPathXmlApplicationContext(String[] paths, Class clazz,
179:                    ApplicationContext parent) throws BeansException {
180:
181:                super (parent);
182:                Assert.notNull(paths, "Path array must not be null");
183:                Assert.notNull(clazz, "Class argument must not be null");
184:                this .configResources = new Resource[paths.length];
185:                for (int i = 0; i < paths.length; i++) {
186:                    this .configResources[i] = new ClassPathResource(paths[i],
187:                            clazz);
188:                }
189:                refresh();
190:            }
191:
192:            protected Resource[] getConfigResources() {
193:                return this .configResources;
194:            }
195:
196:            protected String[] getConfigLocations() {
197:                return this.configLocations;
198:            }
199:
200:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.