/** * Configure the {@link ConfigurableApplicationContext#setParent(ApplicationContext) * parent} of the {@link ApplicationContext}. * @param parent the parent * @return a new instance with the updated parent */ public SELF withParent(ApplicationContext parent) { return newInstance(this.contextFactory, this.initializers, this.environmentProperties, this.systemProperties, this.classLoader, parent, this.configurations); }
/** * Customize the {@link ClassLoader} that the {@link ApplicationContext} should use * for resource loading and bean class loading. * @param classLoader the classloader to use (can be null to use the default) * @return a new instance with the updated class loader * @see FilteredClassLoader */ public SELF withClassLoader(ClassLoader classLoader) { return newInstance(this.contextFactory, this.initializers, this.environmentProperties, this.systemProperties, classLoader, this.parent, this.configurations); }
/** * Register the specified configuration classes with the {@link ApplicationContext}. * @param configurations the configurations to add * @return a new instance with the updated configuration */ public SELF withConfiguration(Configurations configurations) { Assert.notNull(configurations, "Configurations must not be null"); return newInstance(this.contextFactory, this.initializers, this.environmentProperties, this.systemProperties, this.classLoader, this.parent, add(this.configurations, configurations)); }
/** * Add a {@link ApplicationContextInitializer} to be called when the context is * created. * @param initializer the initializer to add * @return a new instance with the updated initializers */ public SELF withInitializer( ApplicationContextInitializer<? super ConfigurableApplicationContext> initializer) { Assert.notNull(initializer, "Initializer must not be null"); return newInstance(this.contextFactory, add(this.initializers, initializer), this.environmentProperties, this.systemProperties, this.classLoader, this.parent, this.configurations); }
/** * Add the specified {@link Environment} property pairs. Key-value pairs can be * specified with colon (":") or equals ("=") separators. Override matching keys that * might have been specified previously. * @param pairs the key-value pairs for properties that need to be added to the * environment * @return a new instance with the updated property values * @see TestPropertyValues * @see #withSystemProperties(String...) */ public SELF withPropertyValues(String... pairs) { return newInstance(this.contextFactory, this.initializers, this.environmentProperties.and(pairs), this.systemProperties, this.classLoader, this.parent, this.configurations); }
/** * Add the specified {@link System} property pairs. Key-value pairs can be specified * with colon (":") or equals ("=") separators. System properties are added before the * context is {@link #run(ContextConsumer) run} and restored when the context is * closed. * @param pairs the key-value pairs for properties that need to be added to the system * @return a new instance with the updated system properties * @see TestPropertyValues * @see #withSystemProperties(String...) */ public SELF withSystemProperties(String... pairs) { return newInstance(this.contextFactory, this.initializers, this.environmentProperties, this.systemProperties.and(pairs), this.classLoader, this.parent, this.configurations); }