From 89d9a3f85faf2c247951e60e2612c589809c3d7f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Jul 2024 04:59:45 +0000 Subject: [PATCH 1/3] Bump io.github.goooler.shadow from 8.1.7 to 8.1.8 Bumps [io.github.goooler.shadow](https://github.com/Goooler/shadow) from 8.1.7 to 8.1.8. - [Release notes](https://github.com/Goooler/shadow/releases) - [Commits](https://github.com/Goooler/shadow/compare/v8.1.7...v8.1.8) --- updated-dependencies: - dependency-name: io.github.goooler.shadow dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 6f1634b..6443dd0 100644 --- a/build.gradle +++ b/build.gradle @@ -13,7 +13,7 @@ plugins { // For building shadow jars with jdk 17 ONLY //id 'com.github.johnrengelman.shadow' version '8.1.1' // For building shadow jars using JDK 21 +, they had to fork - id "io.github.goooler.shadow" version "8.1.7" + id "io.github.goooler.shadow" version "8.1.8" // Download task id "de.undercouch.download" version "5.6.0" // Task visualizer From 2c70b9513a8da673cf9af3e9f47911f2aca5bd7d Mon Sep 17 00:00:00 2001 From: Github Actions Date: Fri, 12 Jul 2024 11:12:47 +0000 Subject: [PATCH 2/3] Version bump --- changelog.md | 7 +++++-- gradle.properties | 6 +++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/changelog.md b/changelog.md index 7b15458..1e6d354 100644 --- a/changelog.md +++ b/changelog.md @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.0.0-beta5] - 2024-07-12 + ## [1.0.0-beta4] - 2024-07-05 ## [1.0.0-beta3] - 2024-06-28 @@ -19,10 +21,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - First iteration of this runtime -[Unreleased]: https://github.com/ortus-boxlang/boxlang-servlet/compare/v1.0.0-beta4...HEAD +[Unreleased]: https://github.com/ortus-boxlang/boxlang-servlet/compare/v1.0.0-beta5...HEAD -[1.0.0-beta4]: https://github.com/ortus-boxlang/boxlang-servlet/compare/v1.0.0-beta4...v1.0.0-beta4 +[1.0.0-beta5]: https://github.com/ortus-boxlang/boxlang-servlet/compare/v1.0.0-beta4...v1.0.0-beta5 +[1.0.0-beta4]: https://github.com/ortus-boxlang/boxlang-servlet/compare/v1.0.0-beta4...v1.0.0-beta4 [1.0.0-beta3]: https://github.com/ortus-boxlang/boxlang-servlet/compare/v1.0.0-beta2...v1.0.0-beta3 diff --git a/gradle.properties b/gradle.properties index e98c44f..f2184e5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ -#Fri Jul 05 15:15:32 UTC 2024 -boxlangVersion=1.0.0-beta5 +#Fri Jul 12 11:12:45 UTC 2024 +boxlangVersion=1.0.0-beta6 jdkVersion=21 -version=1.0.0-beta5 +version=1.0.0-beta6 group=ortus.boxlang From 7194a0ee8420fad3228ab8116779c64a329d167a Mon Sep 17 00:00:00 2001 From: Brad Wood Date: Mon, 15 Jul 2024 20:42:00 -0500 Subject: [PATCH 3/3] BL-349 --- build.gradle | 2 +- .../ortus/boxlang/servlet/BoxLangServlet.java | 4 ++ .../servlet/ServletMappingInterceptor.java | 60 +++++++++++++++++++ 3 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 src/main/java/ortus/boxlang/servlet/ServletMappingInterceptor.java diff --git a/build.gradle b/build.gradle index 5b296e1..70cb136 100644 --- a/build.gradle +++ b/build.gradle @@ -45,7 +45,7 @@ repositories { dependencies { // LOCAL DEVELOPMENT ONLY // CHOOSE THE RIGHT LOCATION FOR YOUR LOCAL DEPENDENCIES - implementation files( '../boxlang/build/distributions/boxlang-' + boxlangVersion + '-all.jar' ) + implementation files( '../boxlang/build/libs/boxlang-' + boxlangVersion + '-all.jar' ) implementation files( '../boxlang-web-support/build/distributions/boxlang-web-support-' + boxlangVersion + '.jar' ) // Downloaded Dependencies diff --git a/src/main/java/ortus/boxlang/servlet/BoxLangServlet.java b/src/main/java/ortus/boxlang/servlet/BoxLangServlet.java index 9a8ee7e..6b34da7 100644 --- a/src/main/java/ortus/boxlang/servlet/BoxLangServlet.java +++ b/src/main/java/ortus/boxlang/servlet/BoxLangServlet.java @@ -81,6 +81,10 @@ public void init( ServletConfig config ) throws ServletException { } System.out.println( "Ortus BoxLang Servlet home: " + BLHome.toString() ); this.runtime = BoxRuntime.getInstance( debug, configPath, BLHome.toString() ); + + // Register the servlet mapping interceptor + this.runtime.getInterceptorService().register( new ServletMappingInterceptor( config.getServletContext() ) ); + System.out.println( "Ortus BoxLang Servlet initialized!" ); } diff --git a/src/main/java/ortus/boxlang/servlet/ServletMappingInterceptor.java b/src/main/java/ortus/boxlang/servlet/ServletMappingInterceptor.java new file mode 100644 index 0000000..a5591d0 --- /dev/null +++ b/src/main/java/ortus/boxlang/servlet/ServletMappingInterceptor.java @@ -0,0 +1,60 @@ +/** + * [BoxLang] + * + * Copyright [2023] [Ortus Solutions, Corp] + * + * Licensed 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 + * + * http://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 ortus.boxlang.servlet; + +import java.nio.file.Path; + +import javax.servlet.ServletContext; + +import ortus.boxlang.runtime.events.BaseInterceptor; +import ortus.boxlang.runtime.events.InterceptionPoint; +import ortus.boxlang.runtime.scopes.Key; +import ortus.boxlang.runtime.types.IStruct; +import ortus.boxlang.runtime.util.ResolvedFilePath; + +/** + * I allow paths to be expanded using the servlets mappings/resource manager + */ +public class ServletMappingInterceptor extends BaseInterceptor { + + private ServletContext servletContext; + + /** + * Constructor + * + */ + public ServletMappingInterceptor( ServletContext servletContext ) { + this.servletContext = servletContext; + } + + /** + * Listen to the "onMissingMapping" event + */ + @InterceptionPoint + public void onMissingMapping( IStruct data ) { + String path = data.getAsString( Key.path ); + // See if the servlet's resource manager can resolve the path + String realPath = servletContext.getRealPath( path ); + if ( realPath != null ) { + data.put( Key.resolvedFilePath, + ResolvedFilePath.of( "/", servletContext.getRealPath( "/" ), Path.of( path ).normalize().toString(), Path.of( realPath ).normalize() ) + ); + } + } + +}