Skip to content

Commit

Permalink
Fixed breaking changes
Browse files Browse the repository at this point in the history
  • Loading branch information
puneetbehl committed Dec 6, 2021
1 parent 66ad9cc commit f9bf965
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ springBootVersion=2.6.1
springLoadedVersion=1.2.8.RELEASE
springVersion=5.3.13
testingSupportVersion=2.2.0
testingSupportVersionForTests=2.2.0
testingSupportVersionForTests=2.2.1-SNAPSHOT
tomcatLog4jVersion=8.5.2
tomcatVersion=9.0.55
viewsVersion=2.1.1
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import grails.boot.GrailsApp
import grails.ui.console.support.GroovyConsoleApplicationContext
import grails.ui.console.support.GroovyConsoleWebApplicationContext
import groovy.transform.CompileStatic
import org.springframework.boot.ApplicationContextFactory
import org.springframework.context.ConfigurableApplicationContext
import org.springframework.core.io.ResourceLoader
import org.springframework.util.ClassUtils
Expand Down Expand Up @@ -47,12 +48,11 @@ class GrailsSwingConsole extends GrailsApp {
configureApplicationContextClass()
}

public configureApplicationContextClass() {
if(ClassUtils.isPresent("javax.servlet.ServletContext", Thread.currentThread().contextClassLoader)) {
setApplicationContextClass(GroovyConsoleWebApplicationContext)
}
else {
setApplicationContextClass(GroovyConsoleApplicationContext)
void configureApplicationContextClass() {
if (ClassUtils.isPresent("javax.servlet.ServletContext", Thread.currentThread().contextClassLoader)) {
setApplicationContextFactory(ApplicationContextFactory.ofContextClass(GroovyConsoleWebApplicationContext))
} else {
setApplicationContextFactory(ApplicationContextFactory.ofContextClass(GroovyConsoleApplicationContext))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import grails.ui.shell.support.GroovyshApplicationContext
import grails.ui.shell.support.GroovyshWebApplicationContext
import groovy.transform.CompileStatic
import groovy.transform.InheritConstructors
import org.springframework.boot.ApplicationContextFactory
import org.springframework.context.ConfigurableApplicationContext
import org.springframework.core.io.ResourceLoader
import org.springframework.util.ClassUtils
Expand All @@ -43,11 +44,10 @@ class GrailsShell extends GrailsApp {
}

public configureApplicationContextClass() {
if(ClassUtils.isPresent("javax.servlet.ServletContext", Thread.currentThread().contextClassLoader)) {
setApplicationContextClass(GroovyshWebApplicationContext)
}
else {
setApplicationContextClass(GroovyshApplicationContext)
if (ClassUtils.isPresent("javax.servlet.ServletContext", Thread.currentThread().contextClassLoader)) {
setApplicationContextFactory(ApplicationContextFactory.ofContextClass(GroovyshWebApplicationContext))
} else {
setApplicationContextFactory(ApplicationContextFactory.ofContextClass(GroovyshApplicationContext))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package grails.ui.support

import grails.boot.GrailsApp
import groovy.transform.CompileStatic
import org.springframework.boot.ApplicationContextFactory
import org.springframework.util.ClassUtils
import org.springframework.web.context.support.GenericWebApplicationContext

Expand All @@ -34,11 +35,10 @@ class DevelopmentGrailsApplication extends GrailsApp {
}

protected configureApplicationContextClass() {
if(ClassUtils.isPresent("javax.servlet.ServletContext", Thread.currentThread().contextClassLoader)) {
setApplicationContextClass(DevelopmentWebApplicationContext)
}
else {
setApplicationContextClass(GenericWebApplicationContext)
if (ClassUtils.isPresent("javax.servlet.ServletContext", Thread.currentThread().contextClassLoader)) {
setApplicationContextFactory(ApplicationContextFactory.ofContextClass(DevelopmentWebApplicationContext))
} else {
setApplicationContextFactory(ApplicationContextFactory.ofContextClass(GenericWebApplicationContext))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.grails.boot.context.web

import grails.boot.GrailsAppBuilder
import groovy.transform.CompileStatic
import org.springframework.boot.ApplicationContextFactory
import org.springframework.boot.SpringApplication
import org.springframework.boot.builder.ParentContextApplicationContextInitializer
import org.springframework.boot.builder.SpringApplicationBuilder
Expand Down Expand Up @@ -42,7 +43,7 @@ abstract class GrailsAppServletInitializer extends SpringBootServletInitializer
}
builder.initializers(new ServletContextApplicationContextInitializer(
servletContext))
builder.contextClass(AnnotationConfigServletWebServerApplicationContext.class)
builder.application().setApplicationContextFactory(ApplicationContextFactory.ofContextClass(AnnotationConfigServletWebServerApplicationContext))
builder = configure(builder)
SpringApplication application = builder.build()
if (application.getAllSources().isEmpty()
Expand Down

0 comments on commit f9bf965

Please sign in to comment.