Spring Framework GenericXmlContextLoader - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework GenericXmlContextLoader class.

This code example shows how to use the following methods:
import org.springframework.test.context.support.GenericXmlContextLoader;
 
/** 
 * @author Gunnar Hillert 
 */ 
public class CustomTestContextLoader extends GenericXmlContextLoader {
 
	private static final Logger LOGGER = Logger.getLogger(CustomTestContextLoader.class);
 
	@Override 
	protected void loadBeanDefinitions(GenericApplicationContext context,
			MergedContextConfiguration mergedConfig) {
 
		int availableServerSocket = SocketUtils.findAvailableServerSocket(5678);
 
		final Map<String, Object> sockets = new HashMap<String, Object>();
		sockets.put("availableServerSocket", availableServerSocket);
 
		if (LOGGER.isInfoEnabled()) {
			LOGGER.info("Available server socket: " + availableServerSocket);
5
CodeRank
This code example shows how to use the following methods:
package com.googlecode.gwt.test.spring; 
 
import org.springframework.beans.factory.support.BeanDefinitionReader;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.test.context.support.GenericXmlContextLoader;
 
import com.googlecode.gwt.test.internal.GwtFactory; 
 
public class GwtTestContextLoader extends GenericXmlContextLoader {
 
   @Override 
   protected BeanDefinitionReader createBeanDefinitionReader(GenericApplicationContext context) {
      XmlBeanDefinitionReader beanDefinitionReader = new XmlBeanDefinitionReader(context);
      beanDefinitionReader.setResourceLoader(new DefaultResourceLoader(
               GwtFactory.get().getClassLoader())); 
      return beanDefinitionReader;
   } 
 

5
CodeRank
This code example shows how to use the following methods:
 * locations provided). 
 *  
 * @author Dave Syer 
 *  
 */ 
public class ParentContextLoader extends GenericXmlContextLoader {
 
    private String parentLocation;
 
    @Override 
    protected String[] modifyLocations(Class<?> clazz, String... locations) {
        String[] result = new String[locations.length - 1];
        System.arraycopy(locations, 1, result, 0, result.length);
        parentLocation = locations[0];
        return result;
    } 
 
    @Override 
    protected void customizeContext(GenericApplicationContext context) {
        GenericXmlApplicationContext parent = new GenericXmlApplicationContext();
5
CodeRank
This code example shows how to use the following methods:
 
/** 
 * A simplified loader that ignores any user defined configuration files. 
 * @author Thomas Krause <krauseto@hu-berlin.de> 
 */ 
public class AnnisXmlContextLoader extends GenericXmlContextLoader
{ 
   
  private static final Logger log = LoggerFactory.getLogger(AnnisXmlContextLoader.class); 
 
   
  @Override 
  protected void prepareContext(GenericApplicationContext ctx)
  { 
    super.customizeContext(ctx);
     
    /*  
     * Only use the local configuration,  
     * thus do not use AnnisXmlContextHelper.prepareContext()!  
     */ 
4
CodeRank
This code example shows how to use the following methods:
 * used from {@link YarnDelegatingSmartContextLoader}. 
 * 
 * @author Janne Valkealahti 
 * 
 */ 
public class YarnClusterInjectingXmlContextLoader extends GenericXmlContextLoader {
 
	private final static Log log = LogFactory.getLog(YarnClusterInjectingXmlContextLoader.class);
 
	@Override 
	protected void loadBeanDefinitions(GenericApplicationContext context,
			MergedContextConfiguration mergedConfig) {
 
		String[] activeProfiles = context.getEnvironment().getActiveProfiles();
		log.info("Active profiles: " + StringUtils.arrayToCommaDelimitedString(activeProfiles));
 
		// let parent do its magic 
		super.loadBeanDefinitions(context, mergedConfig);
		if (!ObjectUtils.containsElement(activeProfiles, YarnTestSystemConstants.PROFILE_ID_NOMINICLUSTER)) {
			YarnClusterInjectUtils.handleClusterInject(context, mergedConfig);
4
CodeRank
This code example shows how to use the following methods:
public class MergedContextConfigurationTests { 
 
	private static final String[] EMPTY_STRING_ARRAY = new String[0];
	private static final Class<?>[] EMPTY_CLASS_ARRAY = new Class<?>[0];
 
	private final GenericXmlContextLoader loader = new GenericXmlContextLoader();
 
 
	@Test
	public void hashCodeWithNulls() { 
		MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(null, null, null, null, null);
		MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(null, null, null, null, null);
		assertTrue(mergedConfig1.hashCode() > 0);
		assertEquals(mergedConfig1.hashCode(), mergedConfig2.hashCode());
	} 
 
	@Test
	public void hashCodeWithNullArrays() { 
		MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), null, null, null, loader);
		MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), null, null, null, loader);
4
CodeRank
This code example shows how to use the following methods:
 * used from {@link HadoopDelegatingSmartContextLoader}. 
 * 
 * @author Janne Valkealahti 
 * 
 */ 
public class HadoopClusterInjectingXmlContextLoader extends GenericXmlContextLoader { 
 
	@Override 
	protected void loadBeanDefinitions(GenericApplicationContext context, 
			MergedContextConfiguration mergedConfig) { 
 
		// let parent do its magic 
		super.loadBeanDefinitions(context, mergedConfig); 
		HadoopClusterInjectUtils.handleClusterInject(context, mergedConfig); 
	} 
 
} 
4
CodeRank
This code example shows how to use the following methods:
 * @author Ðîìàí Åðæóêîâ I-Teco 23.09.2010 
 */ 
public class SpringContextLoader implements ContextLoader {
	 
	private final String[] defaultLocations = { "/testContext.xml" };
	private final GenericXmlContextLoader loader = new GenericXmlContextLoader();
 
	public String[] processLocations(Class<?> clazz, String... locations) {
		return defaultLocations;
	} 
 
	public ApplicationContext loadContext(String... locations) throws Exception {
		return loader.loadContext(locations);
	} 
} 
4
CodeRank
This code example shows how to use the following methods:
     * Class used to expose the {@link GenericXmlContextLoader#createBeanDefinitionReader} method so that it<br>  
     * could be delegated to by the encapsulating class   
     * @author guy 
     * 
     */ 
    private static final class ExternalizingGenericXmlContextLoader extends GenericXmlContextLoader { 
        @Override 
        public final BeanDefinitionReader createBeanDefinitionReader(GenericApplicationContext context) {
            return super.createBeanDefinitionReader(context);
        } 
    }//EOC ExternalizingGenericXmlContextLoader 
     
    private static final class DisposableApplicationContext extends GenericApplicationContext { 
        @Override 
        public final void close() { 
            if(!this.isActive()) { 
             // Destroy all cached singletons in the context's BeanFactory. 
                this.destroyBeans();
 
                // Close the state of this context itself. 
1
CodeRank