01: /*
02: * Copyright 2006-2007, Unitils.org
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.unitils.spring.util;
17:
18: import org.springframework.context.ConfigurableApplicationContext;
19: import org.springframework.context.support.ClassPathXmlApplicationContext;
20:
21: import java.util.List;
22:
23: /**
24: * An {@link ApplicationContextFactory} that creates an instance of
25: * the type <code>ClassPathXmlApplicationContext</code>.
26: *
27: * @author Tim Ducheyne
28: * @author Filip Neven
29: */
30: public class ClassPathXmlApplicationContextFactory implements
31: ApplicationContextFactory {
32:
33: /**
34: * Create an <code>ClassPathXmlApplicationContext</code> for the given locations on which refresh has not
35: * yet been called
36: *
37: * @param locations The configuration file locations, not null
38: * @return A context, on which the <code>refresh()</code> method hasn't been called yet
39: */
40: public ConfigurableApplicationContext createApplicationContext(
41: List<String> locations) {
42: return new ClassPathXmlApplicationContext(locations
43: .toArray(new String[locations.size()]), false);
44: }
45: }
|