codeconsole commented on code in PR #15585: URL: https://github.com/apache/grails-core/pull/15585#discussion_r3139946853
########## grails-gsp/grails-sitemesh3/src/main/java/org/grails/plugins/sitemesh3/Sitemesh3LayoutFinder.java: ########## @@ -0,0 +1,255 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 + * + * https://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.grails.plugins.sitemesh3; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import groovy.lang.GroovyObject; + +import jakarta.servlet.http.HttpServletRequest; + +import org.sitemesh.DecoratorSelector; +import org.sitemesh.SiteMeshContext; +import org.sitemesh.content.Content; +import org.sitemesh.content.ContentProperty; +import org.sitemesh.webapp.WebAppContext; + +import grails.util.Environment; +import grails.util.GrailsClassUtils; +import grails.util.GrailsNameUtils; +import grails.util.GrailsStringUtils; +import org.grails.core.artefact.ControllerArtefactHandler; +import org.grails.gsp.io.GroovyPageScriptSource; +import org.grails.io.support.GrailsResourceUtils; +import org.grails.web.gsp.io.GrailsConventionGroovyPageLocator; +import org.grails.web.servlet.mvc.GrailsWebRequest; +import org.grails.web.util.GrailsApplicationAttributes; +import org.grails.web.util.WebUtils; + +/** + * {@link DecoratorSelector} that resolves layout paths using Grails + * conventions. The resolution order is: + * + * <ol> + * <li>Request attribute {@link WebUtils#LAYOUT_ATTRIBUTE}</li> + * <li>Content {@code meta.layout} property</li> + * <li>Controller's {@code static layout = 'x'} property</li> + * <li>{@code /layouts/<controllerName>/<actionUri>.gsp}</li> + * <li>{@code /layouts/<controllerName>.gsp}</li> + * <li>Configured default (e.g. {@code grails.sitemesh.default.layout})</li> + * </ol> + * + * <p>Results are cached by (controllerName, actionUri) outside of the + * DEVELOPMENT environment.</p> + */ +public class Sitemesh3LayoutFinder implements DecoratorSelector<SiteMeshContext> { + + private static final String LAYOUTS_PATH = "/layouts"; + private static final long LAYOUT_CACHE_EXPIRATION_MILLIS = Long.getLong("grails.gsp.reload.interval", 5000); Review Comment: Fixed — removed the system-property read; added a layoutCacheExpirationMillis setter injected from grails.sitemesh.layout.cache.interval via grailsApplication.config with default 5000 ms. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
