alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Spring Framework example source code file (ContextConfiguration.java)

This example Spring Framework source code file (ContextConfiguration.java) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Spring Framework tags/keywords

annotation, class, class, contextconfiguration, contextloader, documented, documented, inherited, inherited, string, string

The Spring Framework ContextConfiguration.java source code

/*
 * Copyright 2002-2007 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.test.context;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * <p>
 * ContextConfiguration defines class-level metadata which can be used to
 * instruct client code with regard to how to load and configure an
 * {@link org.springframework.context.ApplicationContext ApplicationContext}.
 * </p>
 *
 * @author Sam Brannen
 * @since 2.5
 * @see ContextLoader
 * @see org.springframework.context.ApplicationContext
 */
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Inherited
@Documented
public @interface ContextConfiguration {

	/**
	 * <p>
	 * The resource locations to use for loading an
	 * {@link org.springframework.context.ApplicationContext ApplicationContext}.
	 * </p>
	 */
	String[] locations() default {};

	/**
	 * <p>
	 * Whether or not {@link #locations() resource locations} from superclasses
	 * should be <em>inherited.
	 * </p>
	 * <p>
	 * The default value is <code>true, which means that an annotated
	 * class will <em>inherit the resource locations defined by an
	 * annotated superclass. Specifically, the resource locations for an
	 * annotated class will be appended to the list of resource locations
	 * defined by an annotated superclass. Thus, subclasses have the option of
	 * <em>extending the list of resource locations. In the following
	 * example, the
	 * {@link org.springframework.context.ApplicationContext ApplicationContext}
	 * for <code>ExtendedTest will be loaded from
	 * "base-context.xml" <strong>and
	 * "extended-context.xml", in that order. Beans defined in
	 * "extended-context.xml" may therefore override those defined in
	 * "base-context.xml".
	 * </p>
	 *
	 * <pre class="code">
	 * {@link ContextConfiguration @ContextConfiguration}(locations={"base-context.xml"})
	 * public class BaseTest {
	 *     // ...
	 * }
	 * {@link ContextConfiguration @ContextConfiguration}(locations={"extended-context.xml"})
	 * public class ExtendedTest extends BaseTest {
	 *     // ...
	 * }
	 * </pre>
	 *
	 * <p>
	 * If <code>inheritLocations is set to false, the
	 * resource locations for the annotated class will <em>shadow and
	 * effectively replace any resource locations defined by a superclass.
	 * </p>
	 */
	boolean inheritLocations() default true;

	/**
	 * <p>
	 * The {@link Class type} of {@link ContextLoader} to use for loading an
	 * {@link org.springframework.context.ApplicationContext ApplicationContext}.
	 * </p>
	 */
	Class<? extends ContextLoader> loader() default ContextLoader.class;

}

Other Spring Framework examples (source code examples)

Here is a short list of links related to this Spring Framework ContextConfiguration.java source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.