You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ss...@apache.org on 2025/03/28 16:41:37 UTC
(sling-org-apache-sling-scripting-sightly-js-provider) branch feature/SLING-12730-parent-62 created (now c54d7f8)
This is an automated email from the ASF dual-hosted git repository.
sseifert pushed a change to branch feature/SLING-12730-parent-62
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-sightly-js-provider.git
at c54d7f8 SLING-12730 apply spotless formatting
This branch includes the following new commits:
new 903f374 SLING-12730 Update to Parent 62
new c54d7f8 SLING-12730 apply spotless formatting
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(sling-org-apache-sling-scripting-sightly-js-provider) 02/02: SLING-12730 apply spotless formatting
Posted by ss...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
sseifert pushed a commit to branch feature/SLING-12730-parent-62
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-sightly-js-provider.git
commit c54d7f8ec20dec6c86cd2bad3f278ac3e43b06a8
Author: Stefan Seifert <st...@users.noreply.github.com>
AuthorDate: Fri Mar 28 17:41:26 2025 +0100
SLING-12730 apply spotless formatting
---
pom.xml | 73 ++++++++++------------
.../sling/scripting/sightly/js/impl/Console.java | 4 +-
.../scripting/sightly/js/impl/JsEnvironment.java | 27 ++++----
.../scripting/sightly/js/impl/JsUseProvider.java | 22 +++----
.../sling/scripting/sightly/js/impl/Utils.java | 30 ++++-----
.../sling/scripting/sightly/js/impl/Variables.java | 4 +-
.../sightly/js/impl/async/AsyncContainer.java | 4 +-
.../sightly/js/impl/async/AsyncExtractor.java | 12 ++--
.../impl/async/TimingBindingsValuesProvider.java | 7 +--
.../sightly/js/impl/async/TimingFunction.java | 11 ++--
.../sightly/js/impl/async/UnaryCallback.java | 4 +-
.../sightly/js/impl/cjs/CommonJsModule.java | 5 +-
.../sightly/js/impl/cjs/ExportsObject.java | 5 +-
.../js/impl/jsapi/ProxyAsyncScriptableFactory.java | 44 ++++++-------
.../js/impl/jsapi/SlyBindingsValuesProvider.java | 54 ++++++----------
.../scripting/sightly/js/impl/loop/EventLoop.java | 8 +--
.../sightly/js/impl/loop/EventLoopInterop.java | 5 +-
.../sling/scripting/sightly/js/impl/loop/Task.java | 4 +-
.../sightly/js/impl/rhino/HybridObject.java | 7 +--
.../scripting/sightly/js/impl/rhino/JsUtils.java | 7 +--
.../sightly/js/impl/rhino/JsValueAdapter.java | 14 +++--
.../sightly/js/impl/use/DependencyResolver.java | 18 +++---
.../scripting/sightly/js/impl/use/UseFunction.java | 20 +++---
.../impl/jsapi/SlyBindingsValuesProviderTest.java | 44 ++++++-------
.../js/impl/use/DependencyResolverTest.java | 46 +++++++-------
25 files changed, 228 insertions(+), 251 deletions(-)
diff --git a/pom.xml b/pom.xml
index d805086..1bfec3a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
@@ -37,38 +37,29 @@
<name>Apache Sling Scripting HTL JS Use Provider</name>
- <description>
- The Apache Sling HTL JavaScript Use Provider adds support for accessing JS scripts from HTL's Use-API.
- </description>
-
- <properties>
- <sling.java.version>8</sling.java.version>
- </properties>
+ <description>The Apache Sling HTL JavaScript Use Provider adds support for accessing JS scripts from HTL's Use-API.</description>
<scm>
<connection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-sightly-js-provider.git</connection>
<developerConnection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-sightly-js-provider.git</developerConnection>
+ <tag>HEAD</tag>
<url>https://github.com/apache/sling-org-apache-sling-scripting-sightly-js-provider.git</url>
- <tag>HEAD</tag>
- </scm>
+ </scm>
- <!-- ======================================================================= -->
- <!-- B U I L D -->
- <!-- ======================================================================= -->
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <configuration>
- <!-- No javadocs -->
- <excludePackageNames>
- org.apache.sling.scripting.sightly.js.impl
- </excludePackageNames>
- </configuration>
- </plugin>
- </plugins>
- </build>
+ <properties>
+ <sling.java.version>8</sling.java.version>
+ </properties>
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.junit</groupId>
+ <artifactId>junit-bom</artifactId>
+ <version>5.12.1</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
<!-- ======================================================================= -->
<!-- D E P E N D E N C I E S -->
@@ -144,7 +135,6 @@
<scope>provided</scope>
</dependency>
-
<!-- Rhino -->
<dependency>
<groupId>org.apache.servicemix.bundles</groupId>
@@ -176,16 +166,21 @@
<scope>test</scope>
</dependency>
</dependencies>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.junit</groupId>
- <artifactId>junit-bom</artifactId>
- <version>5.12.1</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
+
+ <!-- ======================================================================= -->
+ <!-- B U I L D -->
+ <!-- ======================================================================= -->
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <configuration>
+ <!-- No javadocs -->
+ <excludePackageNames>org.apache.sling.scripting.sightly.js.impl</excludePackageNames>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git a/src/main/java/org/apache/sling/scripting/sightly/js/impl/Console.java b/src/main/java/org/apache/sling/scripting/sightly/js/impl/Console.java
index 355e253..3ff6b10 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/js/impl/Console.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/js/impl/Console.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* 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
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- ******************************************************************************/
+ */
package org.apache.sling.scripting.sightly.js.impl;
import org.slf4j.Logger;
diff --git a/src/main/java/org/apache/sling/scripting/sightly/js/impl/JsEnvironment.java b/src/main/java/org/apache/sling/scripting/sightly/js/impl/JsEnvironment.java
index 577d603..336941d 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/js/impl/JsEnvironment.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/js/impl/JsEnvironment.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* 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
@@ -15,11 +15,9 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- ******************************************************************************/
+ */
package org.apache.sling.scripting.sightly.js.impl;
-import java.io.Closeable;
-
import javax.script.Bindings;
import javax.script.Compilable;
import javax.script.ScriptContext;
@@ -27,6 +25,8 @@ import javax.script.ScriptEngine;
import javax.script.ScriptException;
import javax.script.SimpleScriptContext;
+import java.io.Closeable;
+
import org.apache.sling.api.scripting.LazyBindings;
import org.apache.sling.scripting.core.ScriptNameAwareReader;
import org.apache.sling.scripting.sightly.SightlyException;
@@ -53,8 +53,7 @@ public class JsEnvironment {
private final DependencyResolver dependencyResolver;
private EventLoop eventLoop;
- public JsEnvironment(@NotNull ScriptEngine jsEngine,
- @NotNull DependencyResolver dependencyResolver) {
+ public JsEnvironment(@NotNull ScriptEngine jsEngine, @NotNull DependencyResolver dependencyResolver) {
this.jsEngine = jsEngine;
this.dependencyResolver = dependencyResolver;
engineBindings = new LazyBindings();
@@ -75,7 +74,8 @@ public class JsEnvironment {
Context.exit();
}
- public void runScript(ScriptNameAwareReader reader, Bindings globalBindings, Bindings arguments, UnaryCallback callback) {
+ public void runScript(
+ ScriptNameAwareReader reader, Bindings globalBindings, Bindings arguments, UnaryCallback callback) {
ScriptContext scriptContext = new SimpleScriptContext();
CommonJsModule module = new CommonJsModule();
Bindings scriptBindings = buildBindings(reader, globalBindings, arguments, module);
@@ -89,7 +89,8 @@ public class JsEnvironment {
return asyncContainer;
}
- private Bindings buildBindings(ScriptNameAwareReader reader, Bindings globalBindings, Bindings arguments, CommonJsModule commonJsModule) {
+ private Bindings buildBindings(
+ ScriptNameAwareReader reader, Bindings globalBindings, Bindings arguments, CommonJsModule commonJsModule) {
Bindings bindings = new LazyBindings();
bindings.putAll(globalBindings);
bindings.putAll(engineBindings);
@@ -106,7 +107,8 @@ public class JsEnvironment {
eventLoop.schedule(scriptTask(reader, scriptContext, callback));
}
- private Task scriptTask(final ScriptNameAwareReader reader, final ScriptContext scriptContext, final UnaryCallback callback) {
+ private Task scriptTask(
+ final ScriptNameAwareReader reader, final ScriptContext scriptContext, final UnaryCallback callback) {
return new Task(() -> {
try {
Object result;
@@ -116,8 +118,9 @@ public class JsEnvironment {
result = jsEngine.eval(reader, scriptContext);
}
if (result == null) {
- CommonJsModule commonJsModule =
- (CommonJsModule) scriptContext.getBindings(ScriptContext.ENGINE_SCOPE).get(Variables.MODULE);
+ CommonJsModule commonJsModule = (CommonJsModule) scriptContext
+ .getBindings(ScriptContext.ENGINE_SCOPE)
+ .get(Variables.MODULE);
if (commonJsModule != null && commonJsModule.isModified()) {
result = commonJsModule.getExports();
}
@@ -142,6 +145,4 @@ public class JsEnvironment {
// ignore
}
}
-
-
}
diff --git a/src/main/java/org/apache/sling/scripting/sightly/js/impl/JsUseProvider.java b/src/main/java/org/apache/sling/scripting/sightly/js/impl/JsUseProvider.java
index 721c51c..db8aae5 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/js/impl/JsUseProvider.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/js/impl/JsUseProvider.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* 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
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- ******************************************************************************/
+ */
package org.apache.sling.scripting.sightly.js.impl;
import javax.script.Bindings;
@@ -46,21 +46,17 @@ import org.osgi.service.metatype.annotations.AttributeDefinition;
@Component(
service = UseProvider.class,
configurationPid = "org.apache.sling.scripting.sightly.js.impl.JsUseProvider",
- property = {
- Constants.SERVICE_RANKING + ":Integer=80"
- }
-)
+ property = {Constants.SERVICE_RANKING + ":Integer=80"})
public class JsUseProvider implements UseProvider {
@interface Configuration {
@AttributeDefinition(
name = "Service Ranking",
- description = "The Service Ranking value acts as the priority with which this Use Provider is queried to return an " +
- "Use-object. A higher value represents a higher priority."
- )
+ description =
+ "The Service Ranking value acts as the priority with which this Use Provider is queried to return an "
+ + "Use-object. A higher value represents a higher priority.")
int service_ranking() default 80;
-
}
private static final String JS_ENGINE_NAME = "rhino";
@@ -84,11 +80,13 @@ public class JsUseProvider implements UseProvider {
}
ScriptEngine jsEngine = scriptEngineManager.getEngineByName(JS_ENGINE_NAME);
if (jsEngine == null) {
- return ProviderOutcome.failure(new SightlyException("Failed to obtain a " + JS_ENGINE_NAME + " JavaScript engine."));
+ return ProviderOutcome.failure(
+ new SightlyException("Failed to obtain a " + JS_ENGINE_NAME + " JavaScript engine."));
}
JsEnvironment environment = null;
try {
- ResourceResolver slingScriptingResolver = scriptingResourceResolverProvider.getRequestScopedResourceResolver();
+ ResourceResolver slingScriptingResolver =
+ scriptingResourceResolverProvider.getRequestScopedResourceResolver();
DependencyResolver dependencyResolver = new DependencyResolver(slingScriptingResolver);
environment = new JsEnvironment(jsEngine, dependencyResolver);
environment.initialize();
diff --git a/src/main/java/org/apache/sling/scripting/sightly/js/impl/Utils.java b/src/main/java/org/apache/sling/scripting/sightly/js/impl/Utils.java
index 4a9c1a4..7a92f99 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/js/impl/Utils.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/js/impl/Utils.java
@@ -1,19 +1,21 @@
-/*******************************************************************************
- * 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
+/*
+ * 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
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * 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.
- ******************************************************************************/
+ * 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.apache.sling.scripting.sightly.js.impl;
import javax.script.Bindings;
diff --git a/src/main/java/org/apache/sling/scripting/sightly/js/impl/Variables.java b/src/main/java/org/apache/sling/scripting/sightly/js/impl/Variables.java
index 176e85f..f7a238b 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/js/impl/Variables.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/js/impl/Variables.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* 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
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- ******************************************************************************/
+ */
package org.apache.sling.scripting.sightly.js.impl;
/**
diff --git a/src/main/java/org/apache/sling/scripting/sightly/js/impl/async/AsyncContainer.java b/src/main/java/org/apache/sling/scripting/sightly/js/impl/async/AsyncContainer.java
index b9bbd5c..2617cb5 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/js/impl/async/AsyncContainer.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/js/impl/async/AsyncContainer.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* 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
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- ******************************************************************************/
+ */
package org.apache.sling.scripting.sightly.js.impl.async;
import java.util.ArrayList;
diff --git a/src/main/java/org/apache/sling/scripting/sightly/js/impl/async/AsyncExtractor.java b/src/main/java/org/apache/sling/scripting/sightly/js/impl/async/AsyncExtractor.java
index 098bd71..edc5c08 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/js/impl/async/AsyncExtractor.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/js/impl/async/AsyncExtractor.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* 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
@@ -15,16 +15,16 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- ******************************************************************************/
+ */
package org.apache.sling.scripting.sightly.js.impl.async;
import org.apache.sling.scripting.sightly.SightlyException;
+import org.apache.sling.scripting.sightly.js.impl.loop.EventLoopInterop;
import org.mozilla.javascript.BaseFunction;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.Function;
import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.ScriptableObject;
-import org.apache.sling.scripting.sightly.js.impl.loop.EventLoopInterop;
/**
*
@@ -55,12 +55,12 @@ public class AsyncExtractor {
EventLoopInterop.schedule(context, new Runnable() {
@Override
public void run() {
- ScriptableObject.callMethod(promise, THEN_METHOD,
- new Object[] {successHandler, errorHandler});
+ ScriptableObject.callMethod(promise, THEN_METHOD, new Object[] {successHandler, errorHandler});
}
});
if (errorContainer.isCompleted()) {
- throw new SightlyException("Promise has completed with failure: " + Context.toString(errorContainer.getResult()));
+ throw new SightlyException(
+ "Promise has completed with failure: " + Context.toString(errorContainer.getResult()));
}
} finally {
Context.exit();
diff --git a/src/main/java/org/apache/sling/scripting/sightly/js/impl/async/TimingBindingsValuesProvider.java b/src/main/java/org/apache/sling/scripting/sightly/js/impl/async/TimingBindingsValuesProvider.java
index 623de69..c1678d6 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/js/impl/async/TimingBindingsValuesProvider.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/js/impl/async/TimingBindingsValuesProvider.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* 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
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- ******************************************************************************/
+ */
package org.apache.sling.scripting.sightly.js.impl.async;
import javax.script.Bindings;
@@ -30,8 +30,7 @@ public final class TimingBindingsValuesProvider implements BindingsValuesProvide
public static final TimingBindingsValuesProvider INSTANCE = new TimingBindingsValuesProvider();
- private TimingBindingsValuesProvider() {
- }
+ private TimingBindingsValuesProvider() {}
@Override
public void addBindings(Bindings bindings) {
diff --git a/src/main/java/org/apache/sling/scripting/sightly/js/impl/async/TimingFunction.java b/src/main/java/org/apache/sling/scripting/sightly/js/impl/async/TimingFunction.java
index 5cf43b7..9c83901 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/js/impl/async/TimingFunction.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/js/impl/async/TimingFunction.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* 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
@@ -15,15 +15,15 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- ******************************************************************************/
+ */
package org.apache.sling.scripting.sightly.js.impl.async;
+import org.apache.sling.scripting.sightly.js.impl.loop.EventLoopInterop;
+import org.apache.sling.scripting.sightly.js.impl.rhino.JsUtils;
import org.mozilla.javascript.BaseFunction;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.Function;
import org.mozilla.javascript.Scriptable;
-import org.apache.sling.scripting.sightly.js.impl.loop.EventLoopInterop;
-import org.apache.sling.scripting.sightly.js.impl.rhino.JsUtils;
/**
* Timing function for JS scripts that use async constructs
@@ -32,8 +32,7 @@ public final class TimingFunction extends BaseFunction {
public static final TimingFunction INSTANCE = new TimingFunction();
- private TimingFunction() {
- }
+ private TimingFunction() {}
@Override
public Object call(final Context cx, final Scriptable scope, Scriptable thisObj, Object[] args) {
diff --git a/src/main/java/org/apache/sling/scripting/sightly/js/impl/async/UnaryCallback.java b/src/main/java/org/apache/sling/scripting/sightly/js/impl/async/UnaryCallback.java
index 0ec0e61..5f23392 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/js/impl/async/UnaryCallback.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/js/impl/async/UnaryCallback.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* 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
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- ******************************************************************************/
+ */
package org.apache.sling.scripting.sightly.js.impl.async;
/**
diff --git a/src/main/java/org/apache/sling/scripting/sightly/js/impl/cjs/CommonJsModule.java b/src/main/java/org/apache/sling/scripting/sightly/js/impl/cjs/CommonJsModule.java
index 9b1c675..42c79ce 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/js/impl/cjs/CommonJsModule.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/js/impl/cjs/CommonJsModule.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* 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
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- ******************************************************************************/
+ */
package org.apache.sling.scripting.sightly.js.impl.cjs;
import org.mozilla.javascript.Scriptable;
@@ -31,7 +31,6 @@ public class CommonJsModule extends ScriptableObject {
private Object exports = new ExportsObject();
private boolean modifiedModule;
-
@Override
public Object get(String name, Scriptable start) {
if (name.equals(EXPORTS)) {
diff --git a/src/main/java/org/apache/sling/scripting/sightly/js/impl/cjs/ExportsObject.java b/src/main/java/org/apache/sling/scripting/sightly/js/impl/cjs/ExportsObject.java
index 3822861..92c7783 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/js/impl/cjs/ExportsObject.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/js/impl/cjs/ExportsObject.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* 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
@@ -15,10 +15,9 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- ******************************************************************************/
+ */
package org.apache.sling.scripting.sightly.js.impl.cjs;
-
import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.ScriptableObject;
diff --git a/src/main/java/org/apache/sling/scripting/sightly/js/impl/jsapi/ProxyAsyncScriptableFactory.java b/src/main/java/org/apache/sling/scripting/sightly/js/impl/jsapi/ProxyAsyncScriptableFactory.java
index 180dcde..9e75305 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/js/impl/jsapi/ProxyAsyncScriptableFactory.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/js/impl/jsapi/ProxyAsyncScriptableFactory.java
@@ -1,27 +1,29 @@
-/*******************************************************************************
- * 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
+/*
+ * 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
*
* 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.
- ******************************************************************************/
+ * 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.apache.sling.scripting.sightly.js.impl.jsapi;
-import java.util.HashSet;
-import java.util.Set;
-
import javax.script.Bindings;
import javax.script.ScriptEngine;
+import java.util.HashSet;
+import java.util.Set;
+
import org.apache.commons.lang3.StringUtils;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.scripting.LazyBindings;
@@ -35,9 +37,7 @@ import org.osgi.service.component.annotations.Reference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Component(
- service = ProxyAsyncScriptableFactory.class
-)
+@Component(service = ProxyAsyncScriptableFactory.class)
public class ProxyAsyncScriptableFactory {
private static final Logger LOGGER = LoggerFactory.getLogger(ProxyAsyncScriptableFactory.class);
@@ -83,8 +83,10 @@ public class ProxyAsyncScriptableFactory {
if (StringUtils.isNotEmpty(script)) {
if (scriptNSUse.add(clazz + ":" + script)) {
LOGGER.warn(
- "Script {} uses the deprecated asynchronous API provided by the '{}' namespace. Please refactor the script to" +
- " use the synchronous API provided by the org.apache.sling.scripting.javascript bundle.", script, clazz);
+ "Script {} uses the deprecated asynchronous API provided by the '{}' namespace. Please refactor the script to"
+ + " use the synchronous API provided by the org.apache.sling.scripting.javascript bundle.",
+ script,
+ clazz);
}
}
return hybridObject.get(name, start);
diff --git a/src/main/java/org/apache/sling/scripting/sightly/js/impl/jsapi/SlyBindingsValuesProvider.java b/src/main/java/org/apache/sling/scripting/sightly/js/impl/jsapi/SlyBindingsValuesProvider.java
index 8bb98d0..bdc5ead 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/js/impl/jsapi/SlyBindingsValuesProvider.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/js/impl/jsapi/SlyBindingsValuesProvider.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* 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
@@ -15,9 +15,13 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- ******************************************************************************/
+ */
package org.apache.sling.scripting.sightly.js.impl.jsapi;
+import javax.script.Bindings;
+import javax.script.ScriptEngine;
+import javax.servlet.http.HttpServletRequest;
+
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -27,10 +31,6 @@ import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
-import javax.script.Bindings;
-import javax.script.ScriptEngine;
-import javax.servlet.http.HttpServletRequest;
-
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.scripting.LazyBindings;
@@ -67,29 +67,22 @@ import org.slf4j.LoggerFactory;
*/
@Component(
service = SlyBindingsValuesProvider.class,
- configurationPid = "org.apache.sling.scripting.sightly.js.impl.jsapi.SlyBindingsValuesProvider"
-)
-@Designate(
- ocd = SlyBindingsValuesProvider.Configuration.class
-)
+ configurationPid = "org.apache.sling.scripting.sightly.js.impl.jsapi.SlyBindingsValuesProvider")
+@Designate(ocd = SlyBindingsValuesProvider.Configuration.class)
@SuppressWarnings("unused")
public class SlyBindingsValuesProvider {
@ObjectClassDefinition(
name = "Apache Sling Scripting HTL JavaScript Use-API Factories Configuration",
- description = "HTL JavaScript Use-API Factories configuration options"
- )
+ description = "HTL JavaScript Use-API Factories configuration options")
@interface Configuration {
@AttributeDefinition(
name = "Script Factories",
- description = "Script factories to load in the bindings map. The entries should be in the form " +
- "'namespace:/path/from/repository'. If the factories depend on each other, add them in the correct order of their" +
- " dependency chain."
-
- )
+ description = "Script factories to load in the bindings map. The entries should be in the form "
+ + "'namespace:/path/from/repository'. If the factories depend on each other, add them in the correct order of their"
+ + " dependency chain.")
String[] org_apache_sling_scripting_sightly_js_bindings() default SlyBindingsValuesProvider.SLING_NS_PATH;
-
}
public static final String SCR_PROP_JS_BINDING_IMPLEMENTATIONS = "org.apache.sling.scripting.sightly.js.bindings";
@@ -144,9 +137,7 @@ public class SlyBindingsValuesProvider {
@Activate
protected void activate(Configuration configuration) {
String[] configuredFactories = PropertiesUtil.toStringArray(
- configuration.org_apache_sling_scripting_sightly_js_bindings(),
- new String[]{SLING_NS_PATH}
- );
+ configuration.org_apache_sling_scripting_sightly_js_bindings(), new String[] {SLING_NS_PATH});
scriptPaths = new LinkedHashMap<>(configuredFactories.length);
for (String f : configuredFactories) {
String[] parts = f.split(":");
@@ -166,7 +157,6 @@ public class SlyBindingsValuesProvider {
}
}
-
private void addBinding(Context context, Function factory, Bindings bindings, String globalName, Object qInstance) {
if (factory == null) {
return;
@@ -190,7 +180,8 @@ public class SlyBindingsValuesProvider {
}
}
- private Function loadFactory(ResourceResolver resolver, JsEnvironment jsEnvironment, String path, Bindings bindings) {
+ private Function loadFactory(
+ ResourceResolver resolver, JsEnvironment jsEnvironment, String path, Bindings bindings) {
Resource resource = resolver.getResource(path);
if (resource == null) {
throw new SightlyException("Sly namespace loader could not find the following script: " + path);
@@ -199,15 +190,11 @@ public class SlyBindingsValuesProvider {
if (inputStream == null) {
throw new SightlyException("Sly namespace loader could not read the following script: " + path);
}
- AsyncContainer container =
- jsEnvironment.runScript(
- new ScriptNameAwareReader(
- new InputStreamReader(inputStream, StandardCharsets.UTF_8),
- resource.getPath()
- ),
- createBindings(bindings, resource.getPath()),
- new LazyBindings()
- );
+ AsyncContainer container = jsEnvironment.runScript(
+ new ScriptNameAwareReader(
+ new InputStreamReader(inputStream, StandardCharsets.UTF_8), resource.getPath()),
+ createBindings(bindings, resource.getPath()),
+ new LazyBindings());
Object obj = container.getResult();
if (!(obj instanceof Function)) {
throw new SightlyException("Script " + path + " was expected to return a function.");
@@ -284,5 +271,4 @@ public class SlyBindingsValuesProvider {
}
return null;
}
-
}
diff --git a/src/main/java/org/apache/sling/scripting/sightly/js/impl/loop/EventLoop.java b/src/main/java/org/apache/sling/scripting/sightly/js/impl/loop/EventLoop.java
index ed565ef..288720d 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/js/impl/loop/EventLoop.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/js/impl/loop/EventLoop.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* 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
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- ******************************************************************************/
+ */
package org.apache.sling.scripting.sightly.js.impl.loop;
import java.util.LinkedList;
@@ -25,7 +25,6 @@ import org.apache.sling.scripting.sightly.SightlyException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
/**
* Simulates an event loop for the Rhino JS engine.
*/
@@ -61,7 +60,7 @@ public class EventLoop {
task.run();
} catch (Exception e) {
if (thrownException == null) {
- thrownException = e; //first exception
+ thrownException = e; // first exception
} else {
log.error("Additional error occurred while running JS script: ", e);
}
@@ -74,5 +73,4 @@ public class EventLoop {
isRunning = false;
}
}
-
}
diff --git a/src/main/java/org/apache/sling/scripting/sightly/js/impl/loop/EventLoopInterop.java b/src/main/java/org/apache/sling/scripting/sightly/js/impl/loop/EventLoopInterop.java
index af9b8d5..94bb950 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/js/impl/loop/EventLoopInterop.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/js/impl/loop/EventLoopInterop.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* 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
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- ******************************************************************************/
+ */
package org.apache.sling.scripting.sightly.js.impl.loop;
import org.mozilla.javascript.Context;
@@ -49,5 +49,4 @@ public class EventLoopInterop {
private static EventLoop getEventLoop(Context context) {
return (EventLoop) context.getThreadLocal(EVENT_LOOP_KEY);
}
-
}
diff --git a/src/main/java/org/apache/sling/scripting/sightly/js/impl/loop/Task.java b/src/main/java/org/apache/sling/scripting/sightly/js/impl/loop/Task.java
index 1a96a12..c1db542 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/js/impl/loop/Task.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/js/impl/loop/Task.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* 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
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- ******************************************************************************/
+ */
package org.apache.sling.scripting.sightly.js.impl.loop;
/**
diff --git a/src/main/java/org/apache/sling/scripting/sightly/js/impl/rhino/HybridObject.java b/src/main/java/org/apache/sling/scripting/sightly/js/impl/rhino/HybridObject.java
index 4f8b574..cc4c802 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/js/impl/rhino/HybridObject.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/js/impl/rhino/HybridObject.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* 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
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- ******************************************************************************/
+ */
package org.apache.sling.scripting.sightly.js.impl.rhino;
import java.util.HashSet;
@@ -27,7 +27,6 @@ import org.mozilla.javascript.Function;
import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.ScriptableObject;
-
/**
* Instances of this class can be used in both HTL & JavaScript scripts.
*/
@@ -60,7 +59,7 @@ public class HybridObject implements Scriptable, Record<Object> {
public Set<String> getPropertyNames() {
Object[] properties = scriptable.getIds();
Set<String> keys = new HashSet<String>();
- for (Object property: properties) {
+ for (Object property : properties) {
if (property instanceof String) {
keys.add((String) property);
}
diff --git a/src/main/java/org/apache/sling/scripting/sightly/js/impl/rhino/JsUtils.java b/src/main/java/org/apache/sling/scripting/sightly/js/impl/rhino/JsUtils.java
index cfc6cad..346986c 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/js/impl/rhino/JsUtils.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/js/impl/rhino/JsUtils.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* 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
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- ******************************************************************************/
+ */
package org.apache.sling.scripting.sightly.js.impl.rhino;
import org.mozilla.javascript.Context;
@@ -40,7 +40,4 @@ public class JsUtils {
}
return result;
}
-
-
-
}
diff --git a/src/main/java/org/apache/sling/scripting/sightly/js/impl/rhino/JsValueAdapter.java b/src/main/java/org/apache/sling/scripting/sightly/js/impl/rhino/JsValueAdapter.java
index 81226c6..a02724c 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/js/impl/rhino/JsValueAdapter.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/js/impl/rhino/JsValueAdapter.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* 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
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- ******************************************************************************/
+ */
package org.apache.sling.scripting.sightly.js.impl.rhino;
import java.util.ArrayList;
@@ -25,13 +25,13 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.apache.sling.scripting.sightly.js.impl.async.AsyncContainer;
+import org.apache.sling.scripting.sightly.js.impl.async.AsyncExtractor;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.Function;
import org.mozilla.javascript.NativeArray;
import org.mozilla.javascript.ScriptableObject;
import org.mozilla.javascript.Wrapper;
-import org.apache.sling.scripting.sightly.js.impl.async.AsyncContainer;
-import org.apache.sling.scripting.sightly.js.impl.async.AsyncExtractor;
/**
* Converts JS objects to Java objects
@@ -71,7 +71,7 @@ public class JsValueAdapter {
return extractScriptable((ScriptableObject) jsValue);
}
if (jsValue instanceof CharSequence) {
- //convert any string-like type to plain java strings
+ // convert any string-like type to plain java strings
return jsValue.toString();
}
if (jsValue instanceof Map) {
@@ -115,7 +115,9 @@ public class JsValueAdapter {
private Object extractScriptable(ScriptableObject scriptableObject) {
Object obj = tryKnownConversion(scriptableObject);
- if (obj != null) { return obj; }
+ if (obj != null) {
+ return obj;
+ }
if (scriptableObject instanceof NativeArray) {
return convertNativeArray((NativeArray) scriptableObject);
}
diff --git a/src/main/java/org/apache/sling/scripting/sightly/js/impl/use/DependencyResolver.java b/src/main/java/org/apache/sling/scripting/sightly/js/impl/use/DependencyResolver.java
index ed3bd66..11297cf 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/js/impl/use/DependencyResolver.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/js/impl/use/DependencyResolver.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* 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
@@ -15,8 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- ******************************************************************************/
-
+ */
package org.apache.sling.scripting.sightly.js.impl.use;
import javax.script.Bindings;
@@ -52,7 +51,8 @@ public class DependencyResolver {
public @Nullable ScriptNameAwareReader resolve(Bindings bindings, String dependency) {
if (!Utils.isJsScript(dependency)) {
- throw new SightlyException("Only JS scripts are allowed as dependencies. Invalid dependency: " + dependency);
+ throw new SightlyException(
+ "Only JS scripts are allowed as dependencies. Invalid dependency: " + dependency);
}
// attempt to retrieve the dependency directly (as an absolute path or relative to the search paths)
Resource scriptResource = scriptingResourceResolver.getResource(dependency);
@@ -68,7 +68,8 @@ public class DependencyResolver {
while (hierarchyResource != null && scriptResource == null) {
if (dependency.startsWith("..")) {
// relative path
- String absolutePath = ResourceUtil.normalize(hierarchyResource.getPath() + "/" + dependency);
+ String absolutePath =
+ ResourceUtil.normalize(hierarchyResource.getPath() + "/" + dependency);
if (StringUtils.isNotEmpty(absolutePath)) {
scriptResource = scriptingResourceResolver.getResource(absolutePath);
}
@@ -106,8 +107,8 @@ public class DependencyResolver {
if (scriptStream == null) {
throw new SightlyException(String.format("Unable to read script %s.", dependency));
}
- return new ScriptNameAwareReader(new InputStreamReader(scriptStream, StandardCharsets.UTF_8),
- scriptResource.getPath());
+ return new ScriptNameAwareReader(
+ new InputStreamReader(scriptStream, StandardCharsets.UTF_8), scriptResource.getPath());
}
private Resource getCaller(Bindings bindings) {
@@ -119,7 +120,8 @@ public class DependencyResolver {
if (caller == null) {
SlingScriptHelper scriptHelper = Utils.getHelper(bindings);
if (scriptHelper != null) {
- caller = scriptingResourceResolver.getResource(scriptHelper.getScript().getScriptResource().getPath());
+ caller = scriptingResourceResolver.getResource(
+ scriptHelper.getScript().getScriptResource().getPath());
}
}
return caller;
diff --git a/src/main/java/org/apache/sling/scripting/sightly/js/impl/use/UseFunction.java b/src/main/java/org/apache/sling/scripting/sightly/js/impl/use/UseFunction.java
index 85c80d8..a77ca41 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/js/impl/use/UseFunction.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/js/impl/use/UseFunction.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* 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
@@ -15,18 +15,17 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- ******************************************************************************/
-
+ */
package org.apache.sling.scripting.sightly.js.impl.use;
+import javax.script.Bindings;
+import javax.script.ScriptEngine;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
-import javax.script.Bindings;
-import javax.script.ScriptEngine;
-
import org.apache.sling.api.scripting.LazyBindings;
import org.apache.sling.scripting.core.ScriptNameAwareReader;
import org.apache.sling.scripting.sightly.SightlyException;
@@ -53,7 +52,11 @@ public class UseFunction extends BaseFunction {
private final Scriptable thisObj;
private final Bindings globalBindings;
- public UseFunction(JsEnvironment jsEnvironment, DependencyResolver dependencyResolver, Bindings globalBindings, Bindings arguments) {
+ public UseFunction(
+ JsEnvironment jsEnvironment,
+ DependencyResolver dependencyResolver,
+ Bindings globalBindings,
+ Bindings arguments) {
this.jsEnvironment = jsEnvironment;
this.dependencyResolver = dependencyResolver;
this.globalBindings = globalBindings;
@@ -106,7 +109,8 @@ public class UseFunction extends BaseFunction {
return asyncContainer;
}
- private void callImmediate(final Function callback, final AsyncContainer asyncContainer, final Context cx, final Scriptable scope) {
+ private void callImmediate(
+ final Function callback, final AsyncContainer asyncContainer, final Context cx, final Scriptable scope) {
EventLoopInterop.schedule(cx, () -> {
Object value = JsUtils.callFn(callback, cx, scope, thisObj, new Object[0]);
asyncContainer.complete(value);
diff --git a/src/test/java/org/apache/sling/scripting/sightly/js/impl/jsapi/SlyBindingsValuesProviderTest.java b/src/test/java/org/apache/sling/scripting/sightly/js/impl/jsapi/SlyBindingsValuesProviderTest.java
index 974b5b6..0294f7b 100644
--- a/src/test/java/org/apache/sling/scripting/sightly/js/impl/jsapi/SlyBindingsValuesProviderTest.java
+++ b/src/test/java/org/apache/sling/scripting/sightly/js/impl/jsapi/SlyBindingsValuesProviderTest.java
@@ -1,29 +1,29 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ~ 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
- ~
- ~ 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.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+/*
+ * 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
+ *
+ * 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 org.apache.sling.scripting.sightly.js.impl.jsapi;
+import javax.script.Bindings;
+
import java.io.IOException;
import java.io.InputStream;
import java.util.Objects;
-import javax.script.Bindings;
-
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.scripting.SlingBindings;
@@ -76,7 +76,8 @@ class SlyBindingsValuesProviderTest {
when(resolver.getResource(scriptPath)).thenReturn(scriptResource);
when(scriptResource.adaptTo(InputStream.class)).thenReturn(inputStream);
when(asyncContainer.getResult()).thenReturn(function);
- when(jsEnvironment.runScript(any(ScriptNameAwareReader.class), any(Bindings.class), any(Bindings.class))).thenReturn(asyncContainer);
+ when(jsEnvironment.runScript(any(ScriptNameAwareReader.class), any(Bindings.class), any(Bindings.class)))
+ .thenReturn(asyncContainer);
}
@Test
@@ -89,5 +90,4 @@ class SlyBindingsValuesProviderTest {
verify(inputStream, never()).read(any(byte[].class));
verify(inputStream, never()).read(any(byte[].class), anyInt(), anyInt());
}
-
}
diff --git a/src/test/java/org/apache/sling/scripting/sightly/js/impl/use/DependencyResolverTest.java b/src/test/java/org/apache/sling/scripting/sightly/js/impl/use/DependencyResolverTest.java
index 3a2e060..7210eff 100644
--- a/src/test/java/org/apache/sling/scripting/sightly/js/impl/use/DependencyResolverTest.java
+++ b/src/test/java/org/apache/sling/scripting/sightly/js/impl/use/DependencyResolverTest.java
@@ -1,30 +1,30 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ~ 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
- ~
- ~ 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.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+/*
+ * 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
+ *
+ * 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 org.apache.sling.scripting.sightly.js.impl.use;
+import javax.script.Bindings;
+import javax.script.ScriptEngine;
+
import java.io.IOException;
import java.io.InputStream;
import java.util.concurrent.atomic.AtomicInteger;
-import javax.script.Bindings;
-import javax.script.ScriptEngine;
-
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
@@ -75,7 +75,6 @@ class DependencyResolverTest {
private DependencyResolver dependencyResolver;
private Bindings bindings;
-
@BeforeEach
void beforeEach() {
when(dependency.getPath()).thenReturn(SCRIPT_PATH);
@@ -128,11 +127,8 @@ class DependencyResolverTest {
assertNotNull(reader);
assertEquals(SCRIPT_PATH, reader.getScriptName());
-
verify(stream, never()).read(any(), anyInt(), anyInt());
verify(stream, never()).read();
verify(stream, never()).close();
}
-
-
}
(sling-org-apache-sling-scripting-sightly-js-provider) 01/02: SLING-12730 Update to Parent 62
Posted by ss...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
sseifert pushed a commit to branch feature/SLING-12730-parent-62
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-sightly-js-provider.git
commit 903f374b623d22f167db44988a4e02c400624822
Author: Stefan Seifert <st...@users.noreply.github.com>
AuthorDate: Fri Mar 28 17:41:01 2025 +0100
SLING-12730 Update to Parent 62
---
.sling-module.json | 5 +++++
pom.xml | 28 +++++++++++++++++++++++-----
2 files changed, 28 insertions(+), 5 deletions(-)
diff --git a/.sling-module.json b/.sling-module.json
new file mode 100644
index 0000000..cfad4d2
--- /dev/null
+++ b/.sling-module.json
@@ -0,0 +1,5 @@
+{
+ "jenkins": {
+ "jdks": [17, 21]
+ }
+}
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 0cdfbe3..d805086 100644
--- a/pom.xml
+++ b/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.sling</groupId>
<artifactId>sling-bundle-parent</artifactId>
- <version>52</version>
+ <version>62</version>
<relativePath />
</parent>
@@ -41,6 +41,10 @@
The Apache Sling HTL JavaScript Use Provider adds support for accessing JS scripts from HTL's Use-API.
</description>
+ <properties>
+ <sling.java.version>8</sling.java.version>
+ </properties>
+
<scm>
<connection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-sightly-js-provider.git</connection>
<developerConnection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-sightly-js-provider.git</developerConnection>
@@ -96,7 +100,7 @@
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.api</artifactId>
- <version>2.21.0</version>
+ <version>2.25.4</version>
<scope>provided</scope>
</dependency>
<dependency>
@@ -153,21 +157,35 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
- <version>5.11.3</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
- <version>5.11.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
- <version>5.11.0</version>
+ <version>5.16.1</version>
<scope>test</scope>
</dependency>
</dependencies>
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.junit</groupId>
+ <artifactId>junit-bom</artifactId>
+ <version>5.12.1</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
</project>