-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
276 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Empty file.
47 changes: 0 additions & 47 deletions
47
...ugin-scaffolding/src/main/groovy/grails/plugin/scaffolding/ScaffoldingGrailsPlugin.groovy
This file was deleted.
Oops, something went wrong.
63 changes: 63 additions & 0 deletions
63
...affolding/src/main/groovy/org/grails/plugin/scaffolding/ScaffoldingAutoConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package org.grails.plugin.scaffolding; | ||
|
||
import org.springframework.beans.factory.ObjectProvider; | ||
import org.springframework.boot.autoconfigure.AutoConfiguration; | ||
import org.springframework.boot.autoconfigure.AutoConfigureOrder; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.core.Ordered; | ||
import org.springframework.core.annotation.Order; | ||
import org.springframework.util.ClassUtils; | ||
|
||
import grails.config.Config; | ||
import grails.config.Settings; | ||
import grails.core.GrailsApplication; | ||
import grails.plugin.scaffolding.ScaffoldingViewResolver; | ||
import grails.util.Environment; | ||
import org.grails.gsp.GroovyPagesTemplateEngine; | ||
import org.grails.web.gsp.io.GrailsConventionGroovyPageLocator; | ||
import org.grails.web.servlet.view.GroovyPageViewResolver; | ||
import org.grails.web.util.GrailsApplicationAttributes; | ||
|
||
@AutoConfiguration | ||
@AutoConfigureOrder | ||
public class ScaffoldingAutoConfiguration { | ||
|
||
private static final String GSP_RELOAD_INTERVAL = "grails.gsp.reload.interval"; | ||
|
||
@Bean | ||
@Order(-10) | ||
@ConditionalOnMissingBean | ||
public ScaffoldingViewResolver jspViewResolver(ObjectProvider<GrailsApplication> grailsApplication, | ||
ObjectProvider<GroovyPagesTemplateEngine> groovyPagesTemplateEngine, | ||
ObjectProvider<GrailsConventionGroovyPageLocator> groovyPageLocator) { | ||
|
||
Config config = grailsApplication.getIfAvailable().getConfig(); | ||
Environment env = Environment.getCurrent(); | ||
boolean developmentMode = Environment.isDevelopmentEnvironmentAvailable(); | ||
boolean gspEnableReload = config.getProperty(Settings.GSP_ENABLE_RELOAD, Boolean.class, false); | ||
boolean enableReload = env.isReloadEnabled() || gspEnableReload || (developmentMode && env == Environment.DEVELOPMENT); | ||
long gspCacheTimeout = config.getProperty(GSP_RELOAD_INTERVAL, Long.class, (developmentMode && env == Environment.DEVELOPMENT) ? 0L : 5000L); | ||
|
||
boolean jstlPresent = ClassUtils.isPresent("javax.servlet.jsp.jstl.core.Config", Thread.currentThread().getContextClassLoader()); | ||
|
||
final ScaffoldingViewResolver scaffoldingViewResolver = new ScaffoldingViewResolver(); | ||
scaffoldingViewResolver.setPrefix(GrailsApplicationAttributes.PATH_TO_VIEWS); | ||
|
||
if (jstlPresent) { | ||
scaffoldingViewResolver.setSuffix(GroovyPageViewResolver.JSP_SUFFIX); | ||
} | ||
else { | ||
scaffoldingViewResolver.setSuffix(GroovyPageViewResolver.GSP_SUFFIX); | ||
} | ||
groovyPagesTemplateEngine.ifAvailable(scaffoldingViewResolver::setTemplateEngine); | ||
groovyPageLocator.ifAvailable(scaffoldingViewResolver::setGroovyPageLocator); | ||
|
||
if (enableReload) { | ||
scaffoldingViewResolver.setCacheTimeout(gspCacheTimeout); | ||
} | ||
scaffoldingViewResolver.setOrder(Ordered.LOWEST_PRECEDENCE - 100); | ||
return scaffoldingViewResolver; | ||
} | ||
|
||
} |
2 changes: 2 additions & 0 deletions
2
grails-plugin-scaffolding/src/main/resources/META-INF/grails.factories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
grails.compiler.ast.ClassInjector=\ | ||
org.grails.compiler.scaffolding.ScaffoldingControllerInjector |
1 change: 1 addition & 0 deletions
1
...esources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.grails.plugin.scaffolding.ScaffoldingAutoConfiguration |
Oops, something went wrong.