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-java.git
commit 03b8a5ca3b828b108a7e40c83967365ddcda4b7b Author: Stefan Seifert <[email protected]> AuthorDate: Fri Mar 28 16:54:58 2025 +0100 SLING-12730 apply spotless formatting --- pom.xml | 198 ++++++++++----------- .../sling/scripting/java/impl/CompilationUnit.java | 42 ++--- .../sling/scripting/java/impl/CompilerOptions.java | 30 ++-- .../sling/scripting/java/impl/CompilerUtil.java | 102 +++++++---- .../java/impl/JavaScriptEngineFactory.java | 145 +++++++-------- .../scripting/java/impl/JavaServletConfig.java | 12 +- .../scripting/java/impl/JavaServletContext.java | 56 +++--- .../sling/scripting/java/impl/ServletCache.java | 40 +++-- .../sling/scripting/java/impl/ServletWrapper.java | 122 ++++++------- .../sling/scripting/java/impl/SlingIOProvider.java | 44 +++-- 10 files changed, 415 insertions(+), 376 deletions(-) diff --git a/pom.xml b/pom.xml index 73ec2d0..a69132d 100644 --- a/pom.xml +++ b/pom.xml @@ -19,112 +19,110 @@ --> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> + <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.apache.sling</groupId> - <artifactId>sling-bundle-parent</artifactId> - <version>62</version> - <relativePath /> - </parent> + <parent> + <groupId>org.apache.sling</groupId> + <artifactId>sling-bundle-parent</artifactId> + <version>62</version> + <relativePath /> + </parent> - <artifactId>org.apache.sling.scripting.java</artifactId> - <version>2.1.7-SNAPSHOT</version> + <artifactId>org.apache.sling.scripting.java</artifactId> + <version>2.1.7-SNAPSHOT</version> - <name>Apache Sling Scripting Java</name> - <description>Support for scripting Java</description> + <name>Apache Sling Scripting Java</name> + <description>Support for scripting Java</description> - <scm> - <connection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-java.git</connection> - <developerConnection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-java.git</developerConnection> - <url>https://github.com/apache/sling-org-apache-sling-scripting-java.git</url> - <tag>HEAD</tag> - </scm> + <scm> + <connection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-java.git</connection> + <developerConnection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-java.git</developerConnection> + <tag>HEAD</tag> + <url>https://github.com/apache/sling-org-apache-sling-scripting-java.git</url> + </scm> - <properties> - <sling.java.version>8</sling.java.version> - </properties> + <properties> + <sling.java.version>8</sling.java.version> + </properties> - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-javadoc-plugin</artifactId> - <configuration> - <!-- No javadocs --> - <excludePackageNames> - org.apache.sling.scripting.java.impl - </excludePackageNames> - </configuration> - </plugin> - </plugins> - </build> + <dependencies> + <!-- javax --> + <dependency> + <groupId>javax.inject</groupId> + <artifactId>javax.inject</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>javax.servlet-api</artifactId> + <scope>provided</scope> + </dependency> + <!-- OSGi --> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.framework</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.service.component.annotations</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.service.metatype.annotations</artifactId> + <scope>provided</scope> + </dependency> + <!-- Apache Sling --> + <dependency> + <groupId>org.apache.sling</groupId> + <artifactId>org.apache.sling.api</artifactId> + <version>2.11.0</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.sling</groupId> + <artifactId>org.apache.sling.scripting.api</artifactId> + <version>2.1.0</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.sling</groupId> + <artifactId>org.apache.sling.commons.compiler</artifactId> + <version>2.3.0</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.sling</groupId> + <artifactId>org.apache.sling.commons.osgi</artifactId> + <version>2.2.0</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.sling</groupId> + <artifactId>org.apache.sling.commons.classloader</artifactId> + <version>1.2.0</version> + <scope>provided</scope> + </dependency> + <!-- logging --> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <scope>provided</scope> + </dependency> + </dependencies> - <dependencies> - <!-- javax --> - <dependency> - <groupId>javax.inject</groupId> - <artifactId>javax.inject</artifactId> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>javax.servlet</groupId> - <artifactId>javax.servlet-api</artifactId> - <scope>provided</scope> - </dependency> - <!-- OSGi --> - <dependency> - <groupId>org.osgi</groupId> - <artifactId>org.osgi.framework</artifactId> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.osgi</groupId> - <artifactId>org.osgi.service.component.annotations</artifactId> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.osgi</groupId> - <artifactId>org.osgi.service.metatype.annotations</artifactId> - <scope>provided</scope> - </dependency> - <!-- Apache Sling --> - <dependency> - <groupId>org.apache.sling</groupId> - <artifactId>org.apache.sling.api</artifactId> - <version>2.11.0</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.apache.sling</groupId> - <artifactId>org.apache.sling.scripting.api</artifactId> - <version>2.1.0</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.apache.sling</groupId> - <artifactId>org.apache.sling.commons.compiler</artifactId> - <version>2.3.0</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.apache.sling</groupId> - <artifactId>org.apache.sling.commons.osgi</artifactId> - <version>2.2.0</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.apache.sling</groupId> - <artifactId>org.apache.sling.commons.classloader</artifactId> - <version>1.2.0</version> - <scope>provided</scope> - </dependency> - <!-- logging --> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> - <scope>provided</scope> - </dependency> - </dependencies> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-javadoc-plugin</artifactId> + <configuration> + <!-- No javadocs --> + <excludePackageNames>org.apache.sling.scripting.java.impl</excludePackageNames> + </configuration> + </plugin> + </plugins> + </build> </project> diff --git a/src/main/java/org/apache/sling/scripting/java/impl/CompilationUnit.java b/src/main/java/org/apache/sling/scripting/java/impl/CompilationUnit.java index ade8d8f..d88aa6c 100644 --- a/src/main/java/org/apache/sling/scripting/java/impl/CompilationUnit.java +++ b/src/main/java/org/apache/sling/scripting/java/impl/CompilationUnit.java @@ -1,18 +1,20 @@ /* - * 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.java.impl; @@ -21,17 +23,13 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; - -public class CompilationUnit - implements org.apache.sling.commons.compiler.CompilationUnitWithSource { +public class CompilationUnit implements org.apache.sling.commons.compiler.CompilationUnitWithSource { private final SlingIOProvider ioProvider; private final String className; private final String sourceFile; - public CompilationUnit(final String sourceFile, - final String className, - final SlingIOProvider ioProvider) { + public CompilationUnit(final String sourceFile, final String className, final SlingIOProvider ioProvider) { this.className = className; this.sourceFile = sourceFile; this.ioProvider = ioProvider; @@ -53,8 +51,11 @@ public class CompilationUnit fr = ioProvider.getInputStream(this.sourceFile); return new InputStreamReader(fr, ioProvider.getOptions().getJavaEncoding()); } catch (IOException e) { - if ( fr != null ) { - try { fr.close(); } catch (IOException ignore) {} + if (fr != null) { + try { + fr.close(); + } catch (IOException ignore) { + } } throw e; } @@ -67,7 +68,6 @@ public class CompilationUnit return this.ioProvider.lastModified(this.sourceFile); } - /** * @see org.apache.sling.commons.compiler.CompilationUnitWithSource#getLastModified() */ diff --git a/src/main/java/org/apache/sling/scripting/java/impl/CompilerOptions.java b/src/main/java/org/apache/sling/scripting/java/impl/CompilerOptions.java index 86d8776..9255e3a 100644 --- a/src/main/java/org/apache/sling/scripting/java/impl/CompilerOptions.java +++ b/src/main/java/org/apache/sling/scripting/java/impl/CompilerOptions.java @@ -1,18 +1,20 @@ /* - * 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.java.impl; @@ -35,12 +37,12 @@ public class CompilerOptions extends Options { opts.put(Options.KEY_GENERATE_DEBUG_INFO, config.java_classdebuginfo()); opts.put(Options.KEY_SOURCE_VERSION, config.java_compilerSourceVM()); - if ( JavaScriptEngineFactory.VERSION_AUTO.equalsIgnoreCase((String)opts.get(Options.KEY_SOURCE_VERSION)) ) { + if (JavaScriptEngineFactory.VERSION_AUTO.equalsIgnoreCase((String) opts.get(Options.KEY_SOURCE_VERSION))) { opts.put(Options.KEY_SOURCE_VERSION, currentVersion); } opts.put(Options.KEY_TARGET_VERSION, config.java_compilerTargetVM()); - if ( JavaScriptEngineFactory.VERSION_AUTO.equalsIgnoreCase((String)opts.get(Options.KEY_TARGET_VERSION)) ) { + if (JavaScriptEngineFactory.VERSION_AUTO.equalsIgnoreCase((String) opts.get(Options.KEY_TARGET_VERSION))) { opts.put(Options.KEY_TARGET_VERSION, currentVersion); } diff --git a/src/main/java/org/apache/sling/scripting/java/impl/CompilerUtil.java b/src/main/java/org/apache/sling/scripting/java/impl/CompilerUtil.java index 7b69572..53a0810 100644 --- a/src/main/java/org/apache/sling/scripting/java/impl/CompilerUtil.java +++ b/src/main/java/org/apache/sling/scripting/java/impl/CompilerUtil.java @@ -1,18 +1,20 @@ /* - * 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.java.impl; @@ -25,7 +27,7 @@ public class CompilerUtil { */ public static String mapSourcePath(final String path) { final String str; - if ( path.endsWith(".java") ) { + if (path.endsWith(".java")) { str = path.substring(0, path.length() - 5); } else { str = path; @@ -33,10 +35,10 @@ public class CompilerUtil { final StringBuilder sb = new StringBuilder(); int pos = 0; int start = 0; - while ( pos < str.length() ) { + while (pos < str.length()) { final char c = str.charAt(pos); - if ( c == '/' ) { - if ( start != pos ) { + if (c == '/') { + if (start != pos) { sb.append(makeJavaIdentifier(str.substring(start, pos))); } sb.append(c); @@ -56,8 +58,7 @@ public class CompilerUtil { * @return Legal Java identifier corresponding to the given identifier */ private static final String makeJavaIdentifier(String identifier) { - StringBuilder modifiedIdentifier = - new StringBuilder(identifier.length()); + StringBuilder modifiedIdentifier = new StringBuilder(identifier.length()); if (!Character.isJavaIdentifierStart(identifier.charAt(0))) { modifiedIdentifier.append('_'); } @@ -91,16 +92,56 @@ public class CompilerUtil { } private static final String javaKeywords[] = { - "abstract", "assert", "boolean", "break", "byte", "case", - "catch", "char", "class", "const", "continue", - "default", "do", "double", "else", "enum", "extends", - "final", "finally", "float", "for", "goto", - "if", "implements", "import", "instanceof", "int", - "interface", "long", "native", "new", "package", - "private", "protected", "public", "return", "short", - "static", "strictfp", "super", "switch", "synchronized", - "this", "throws", "transient", "try", "void", - "volatile", "while" }; + "abstract", + "assert", + "boolean", + "break", + "byte", + "case", + "catch", + "char", + "class", + "const", + "continue", + "default", + "do", + "double", + "else", + "enum", + "extends", + "final", + "finally", + "float", + "for", + "goto", + "if", + "implements", + "import", + "instanceof", + "int", + "interface", + "long", + "native", + "new", + "package", + "private", + "protected", + "public", + "return", + "short", + "static", + "strictfp", + "super", + "switch", + "synchronized", + "this", + "throws", + "transient", + "try", + "void", + "volatile", + "while" + }; /** * Test whether the argument is a Java keyword @@ -109,18 +150,17 @@ public class CompilerUtil { int i = 0; int j = javaKeywords.length; while (i < j) { - int k = (i+j)/2; + int k = (i + j) / 2; int result = javaKeywords[k].compareTo(key); if (result == 0) { return true; } if (result < 0) { - i = k+1; + i = k + 1; } else { j = k; } } return false; } - } diff --git a/src/main/java/org/apache/sling/scripting/java/impl/JavaScriptEngineFactory.java b/src/main/java/org/apache/sling/scripting/java/impl/JavaScriptEngineFactory.java index a59ac8b..153d37e 100644 --- a/src/main/java/org/apache/sling/scripting/java/impl/JavaScriptEngineFactory.java +++ b/src/main/java/org/apache/sling/scripting/java/impl/JavaScriptEngineFactory.java @@ -1,28 +1,23 @@ /* - * 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.java.impl; -import static org.apache.sling.api.scripting.SlingBindings.SLING; - -import java.io.IOException; -import java.io.Reader; -import java.util.List; -import java.util.Map; - import javax.script.Bindings; import javax.script.ScriptContext; import javax.script.ScriptEngine; @@ -31,6 +26,11 @@ import javax.servlet.ServletConfig; import javax.servlet.ServletContext; import javax.servlet.ServletException; +import java.io.IOException; +import java.io.Reader; +import java.util.List; +import java.util.Map; + import org.apache.sling.api.SlingException; import org.apache.sling.api.SlingHttpServletRequest; import org.apache.sling.api.SlingIOException; @@ -58,47 +58,55 @@ import org.osgi.service.metatype.annotations.ObjectClassDefinition; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.apache.sling.api.scripting.SlingBindings.SLING; + /** * The Java engine * */ -@Component(service={javax.script.ScriptEngineFactory.class, ResourceChangeListener.class}, - property={ - "extensions=" + JavaScriptEngineFactory.SCRIPT_TYPE, - "names=java", - "names=Java", - Constants.SERVICE_VENDOR + "=The Apache Software Foundation", - Constants.SERVICE_DESCRIPTION + "=" + JavaScriptEngineFactory.DESCRIPTION, - ResourceChangeListener.CHANGES + "=CHANGED", - ResourceChangeListener.CHANGES + "=REMOVED", - ResourceChangeListener.PATHS + "=glob:**/*.java" - }) +@Component( + service = {javax.script.ScriptEngineFactory.class, ResourceChangeListener.class}, + property = { + "extensions=" + JavaScriptEngineFactory.SCRIPT_TYPE, + "names=java", + "names=Java", + Constants.SERVICE_VENDOR + "=The Apache Software Foundation", + Constants.SERVICE_DESCRIPTION + "=" + JavaScriptEngineFactory.DESCRIPTION, + ResourceChangeListener.CHANGES + "=CHANGED", + ResourceChangeListener.CHANGES + "=REMOVED", + ResourceChangeListener.PATHS + "=glob:**/*.java" + }) @Designate(ocd = JavaScriptEngineFactory.Config.class) -public class JavaScriptEngineFactory - extends AbstractScriptEngineFactory - implements ResourceChangeListener, ExternalResourceChangeListener { +public class JavaScriptEngineFactory extends AbstractScriptEngineFactory + implements ResourceChangeListener, ExternalResourceChangeListener { public static final String DESCRIPTION = "Java Servlet Script Handler"; - @ObjectClassDefinition(name = "Apache Sling Java Script Handler", - description = "The Java Script Handler supports development of Java Servlets to render response content. ") - + @ObjectClassDefinition( + name = "Apache Sling Java Script Handler", + description = "The Java Script Handler supports development of Java Servlets to render response content. ") public @interface Config { - @AttributeDefinition(name = "Generate Debug Info", description = "Should the class file be compiled with " + - "debugging information? true or false, default true.") + @AttributeDefinition( + name = "Generate Debug Info", + description = "Should the class file be compiled with " + + "debugging information? true or false, default true.") boolean java_classdebuginfo() default true; @AttributeDefinition(name = "Source Encoding", description = "") String java_javaEncoding() default "UTF-8"; - @AttributeDefinition(name = "Source VM", description = "Java Specification to be used to read " + - "the source files. If left empty or the value \"auto\" is specified, the " + - "current vm version will be used.") + @AttributeDefinition( + name = "Source VM", + description = "Java Specification to be used to read " + + "the source files. If left empty or the value \"auto\" is specified, the " + + "current vm version will be used.") String java_compilerSourceVM() default JavaScriptEngineFactory.VERSION_AUTO; - @AttributeDefinition(name = "Target VM", description = "Target Java version for compilation. If left " + - "empty or the value \"auto\" is specified, the current vm version will be used.") + @AttributeDefinition( + name = "Target VM", + description = "Target Java version for compilation. If left " + + "empty or the value \"auto\" is specified, the current vm version will be used.") String java_compilerTargetVM() default JavaScriptEngineFactory.VERSION_AUTO; } @@ -109,7 +117,7 @@ public class JavaScriptEngineFactory @Reference private JavaCompiler javaCompiler; - @Reference(target="(name=org.apache.sling)") + @Reference(target = "(name=org.apache.sling)") private ServletContext slingServletContext; private SlingIOProvider ioProvider; @@ -173,8 +181,7 @@ public class JavaScriptEngineFactory protected void activate(final Config config, final Map<String, Object> props) { final CompilerOptions opts = CompilerOptions.createOptions(config); this.ioProvider = new SlingIOProvider(this.javaCompiler, opts); - this.javaServletContext = new JavaServletContext(ioProvider, - slingServletContext); + this.javaServletContext = new JavaServletContext(ioProvider, slingServletContext); this.servletConfig = new JavaServletConfig(javaServletContext, props); logger.info("Activating Apache Sling Script Engine for Java with options {}", opts); @@ -185,7 +192,7 @@ public class JavaScriptEngineFactory */ @Deactivate protected void deactivate() { - if ( this.ioProvider != null ) { + if (this.ioProvider != null) { this.ioProvider.destroy(); this.ioProvider = null; } @@ -202,16 +209,15 @@ public class JavaScriptEngineFactory * @throws SlingServletException * @throws SlingIOException */ - private void callServlet(final Bindings bindings, - final SlingScriptHelper scriptHelper, - final ScriptContext context) { + private void callServlet( + final Bindings bindings, final SlingScriptHelper scriptHelper, final ScriptContext context) { // create a SlingBindings object final SlingBindings slingBindings = new SlingBindings(); slingBindings.putAll(bindings); - ResourceResolver resolver = (ResourceResolver) context.getAttribute(SlingScriptConstants.ATTR_SCRIPT_RESOURCE_RESOLVER, - SlingScriptConstants.SLING_SCOPE); - if ( resolver == null ) { + ResourceResolver resolver = (ResourceResolver) context.getAttribute( + SlingScriptConstants.ATTR_SCRIPT_RESOURCE_RESOLVER, SlingScriptConstants.SLING_SCOPE); + if (resolver == null) { resolver = scriptHelper.getScript().getScriptResource().getResourceResolver(); } ioProvider.setRequestResourceResolver(resolver); @@ -238,8 +244,7 @@ public class JavaScriptEngineFactory } } - private ServletWrapper getWrapperAdapter(final SlingScriptHelper scriptHelper) - throws SlingException { + private ServletWrapper getWrapperAdapter(final SlingScriptHelper scriptHelper) throws SlingException { SlingScript script = scriptHelper.getScript(); final String scriptName = script.getScriptResource().getPath(); @@ -248,26 +253,23 @@ public class JavaScriptEngineFactory return wrapper; } - wrapper = new ServletWrapper(servletConfig, - ioProvider, - scriptName, - scriptHelper); + wrapper = new ServletWrapper(servletConfig, ioProvider, scriptName, scriptHelper); wrapper = this.ioProvider.getServletCache().addWrapper(scriptName, wrapper); return wrapper; } @Override - public void onChange(List<ResourceChange> resourceChange) { - for(ResourceChange change : resourceChange){ - ChangeType topic = change.getType(); - if (topic.equals(ChangeType.CHANGED)) { - this.handleModification(change.getPath(), false); - } else if (topic.equals(ChangeType.REMOVED)){ - this.handleModification(change.getPath(), true); - } - } - } + public void onChange(List<ResourceChange> resourceChange) { + for (ResourceChange change : resourceChange) { + ChangeType topic = change.getType(); + if (topic.equals(ChangeType.CHANGED)) { + this.handleModification(change.getPath(), false); + } else if (topic.equals(ChangeType.REMOVED)) { + this.handleModification(change.getPath(), true); + } + } + } private void handleModification(final String scriptName, final boolean remove) { this.ioProvider.getServletCache().removeWrapper(scriptName, remove); @@ -283,12 +285,11 @@ public class JavaScriptEngineFactory * @see javax.script.ScriptEngine#eval(java.io.Reader, javax.script.ScriptContext) */ @Override - public Object eval(Reader script, ScriptContext context) - throws ScriptException { + public Object eval(Reader script, ScriptContext context) throws ScriptException { final Bindings props = context.getBindings(ScriptContext.ENGINE_SCOPE); final SlingScriptHelper scriptHelper = (SlingScriptHelper) props.get(SLING); if (scriptHelper != null) { - ((JavaScriptEngineFactory)this.getFactory()).callServlet(props, scriptHelper, context); + ((JavaScriptEngineFactory) this.getFactory()).callServlet(props, scriptHelper, context); } return null; } diff --git a/src/main/java/org/apache/sling/scripting/java/impl/JavaServletConfig.java b/src/main/java/org/apache/sling/scripting/java/impl/JavaServletConfig.java index 6a3a172..91786cf 100644 --- a/src/main/java/org/apache/sling/scripting/java/impl/JavaServletConfig.java +++ b/src/main/java/org/apache/sling/scripting/java/impl/JavaServletConfig.java @@ -18,14 +18,14 @@ */ package org.apache.sling.scripting.java.impl; +import javax.servlet.ServletConfig; +import javax.servlet.ServletContext; + import java.util.Collections; import java.util.Enumeration; import java.util.HashMap; import java.util.Map; -import javax.servlet.ServletConfig; -import javax.servlet.ServletContext; - /** * The <code>JavaServletConfig</code> * is passed to the compiled servlets. @@ -44,9 +44,9 @@ public class JavaServletConfig implements ServletConfig { initParams = new HashMap<String, String>(); for (final Map.Entry<String, Object> entry : config.entrySet()) { if (entry.getKey().startsWith("java.")) { - if ( entry.getValue() != null ) { + if (entry.getValue() != null) { final String strValue = String.valueOf(entry.getValue()).trim(); - if ( strValue.length() > 0 ) { + if (strValue.length() > 0) { initParams.put(entry.getKey().substring("java.".length()), strValue); } } @@ -85,4 +85,4 @@ public class JavaServletConfig implements ServletConfig { public String getServletName() { return JavaScriptEngineFactory.DESCRIPTION; } -} \ No newline at end of file +} diff --git a/src/main/java/org/apache/sling/scripting/java/impl/JavaServletContext.java b/src/main/java/org/apache/sling/scripting/java/impl/JavaServletContext.java index c9c2775..b42e911 100644 --- a/src/main/java/org/apache/sling/scripting/java/impl/JavaServletContext.java +++ b/src/main/java/org/apache/sling/scripting/java/impl/JavaServletContext.java @@ -1,29 +1,23 @@ /* - * 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.java.impl; -import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.Enumeration; -import java.util.EventListener; -import java.util.Map; -import java.util.Set; - import javax.servlet.Filter; import javax.servlet.FilterRegistration; import javax.servlet.RequestDispatcher; @@ -36,6 +30,14 @@ import javax.servlet.SessionCookieConfig; import javax.servlet.SessionTrackingMode; import javax.servlet.descriptor.JspConfigDescriptor; +import java.io.InputStream; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Enumeration; +import java.util.EventListener; +import java.util.Map; +import java.util.Set; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -85,8 +87,7 @@ public class JavaServletContext implements ServletContext { return ioProvider.getInputStream(path); } catch (Exception ex) { // FileNotFoundException or IOException - log.debug("getResourceAsStream: Cannot get resource {}: {}", - path, ex.getMessage()); + log.debug("getResourceAsStream: Cannot get resource {}: {}", path, ex.getMessage()); } } @@ -98,9 +99,7 @@ public class JavaServletContext implements ServletContext { return url.openStream(); } } catch (Exception e) { - log.debug( - "getResourceAsStream: Cannot access resource {} through URL: {}", - path, e.getMessage()); + log.debug("getResourceAsStream: Cannot access resource {} through URL: {}", path, e.getMessage()); } return null; @@ -429,11 +428,11 @@ public class JavaServletContext implements ServletContext { return delegatee.getVirtualServerName(); } - //---------- internal ----------------------------------------------------- + // ---------- internal ----------------------------------------------------- private URL getUrlForResource(String path) { int cs = path.indexOf(":/"); - if (cs > 0 && cs < path.length()-2) { + if (cs > 0 && cs < path.length() - 2) { // insert second slash after scheme (was canonicalized away) cs += 2; if (cs < path.length() && path.charAt(cs) != '/') { @@ -444,8 +443,7 @@ public class JavaServletContext implements ServletContext { try { return new URL(path); } catch (MalformedURLException mue) { - log.debug("getUrlForResource: Cannot create URL for {}: {}", - path, mue.getMessage()); + log.debug("getUrlForResource: Cannot create URL for {}: {}", path, mue.getMessage()); } } diff --git a/src/main/java/org/apache/sling/scripting/java/impl/ServletCache.java b/src/main/java/org/apache/sling/scripting/java/impl/ServletCache.java index 0484283..e761254 100644 --- a/src/main/java/org/apache/sling/scripting/java/impl/ServletCache.java +++ b/src/main/java/org/apache/sling/scripting/java/impl/ServletCache.java @@ -1,20 +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.java.impl; import java.util.Iterator; @@ -39,7 +40,7 @@ public final class ServletCache { */ public ServletWrapper addWrapper(final String servletUri, final ServletWrapper sw) { ServletWrapper previous = servlets.putIfAbsent(servletUri, sw); - if ( previous != null ) { + if (previous != null) { return previous; } return sw; @@ -63,13 +64,14 @@ public final class ServletCache { */ public void removeWrapper(final String servletUri, final boolean isRemove) { final ServletWrapper wrapper = servlets.remove(servletUri); - if ( wrapper != null ) { + if (wrapper != null) { wrapper.destroy(); - } else if ( isRemove ) { - final Iterator<Map.Entry<String, ServletWrapper>> iter = servlets.entrySet().iterator(); - while ( iter.hasNext() ) { + } else if (isRemove) { + final Iterator<Map.Entry<String, ServletWrapper>> iter = + servlets.entrySet().iterator(); + while (iter.hasNext()) { final Map.Entry<String, ServletWrapper> entry = iter.next(); - if ( entry.getKey().startsWith(servletUri) ) { + if (entry.getKey().startsWith(servletUri)) { iter.remove(); entry.getValue().destroy(); } diff --git a/src/main/java/org/apache/sling/scripting/java/impl/ServletWrapper.java b/src/main/java/org/apache/sling/scripting/java/impl/ServletWrapper.java index c1e0233..876fe40 100644 --- a/src/main/java/org/apache/sling/scripting/java/impl/ServletWrapper.java +++ b/src/main/java/org/apache/sling/scripting/java/impl/ServletWrapper.java @@ -1,30 +1,23 @@ /* - * 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.java.impl; -import java.lang.reflect.Array; -import java.lang.reflect.Field; -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; - import javax.inject.Inject; import javax.servlet.Servlet; import javax.servlet.ServletConfig; @@ -34,6 +27,14 @@ import javax.servlet.UnavailableException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.lang.reflect.Array; +import java.lang.reflect.Field; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; + import org.apache.sling.api.scripting.SlingScriptHelper; import org.apache.sling.commons.classloader.DynamicClassLoader; import org.apache.sling.commons.compiler.CompilationResult; @@ -79,14 +80,16 @@ public class ServletWrapper { /** * A wrapper for servlets. */ - public ServletWrapper(final ServletConfig config, - final SlingIOProvider ioProvider, - final String servletPath, - final SlingScriptHelper scriptHelper) { + public ServletWrapper( + final ServletConfig config, + final SlingIOProvider ioProvider, + final String servletPath, + final SlingScriptHelper scriptHelper) { this.config = config; this.ioProvider = ioProvider; this.sourcePath = servletPath; - this.className = CompilerUtil.mapSourcePath(this.sourcePath).substring(1).replace('/', '.'); + this.className = + CompilerUtil.mapSourcePath(this.sourcePath).substring(1).replace('/', '.'); this.scriptHelper = scriptHelper; } @@ -96,16 +99,12 @@ public class ServletWrapper { * @param response The current response. * @throws Exception */ - public void service(HttpServletRequest request, - HttpServletResponse response) - throws Exception { + public void service(HttpServletRequest request, HttpServletResponse response) throws Exception { try { if ((available > 0L) && (available < Long.MAX_VALUE)) { if (available > System.currentTimeMillis()) { response.setDateHeader("Retry-After", available); - response.sendError - (HttpServletResponse.SC_SERVICE_UNAVAILABLE, - "Servlet unavailable."); + response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, "Servlet unavailable."); logger.error("Java servlet {} is unavailable.", this.sourcePath); return; } @@ -129,13 +128,10 @@ public class ServletWrapper { } catch (final UnavailableException ex) { int unavailableSeconds = ex.getUnavailableSeconds(); if (unavailableSeconds <= 0) { - unavailableSeconds = 60; // Arbitrary default + unavailableSeconds = 60; // Arbitrary default } - available = System.currentTimeMillis() + - (unavailableSeconds * 1000L); - response.sendError - (HttpServletResponse.SC_SERVICE_UNAVAILABLE, - ex.getMessage()); + available = System.currentTimeMillis() + (unavailableSeconds * 1000L); + response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, ex.getMessage()); logger.error("Java servlet {} is unavailable.", this.sourcePath); } } @@ -154,8 +150,8 @@ public class ServletWrapper { * Check if the used classloader is still valid */ private boolean checkReload() { - if ( theServlet != null && theServlet.getClass().getClassLoader() instanceof DynamicClassLoader ) { - return !((DynamicClassLoader)theServlet.getClass().getClassLoader()).isLive(); + if (theServlet != null && theServlet.getClass().getClassLoader() instanceof DynamicClassLoader) { + return !((DynamicClassLoader) theServlet.getClass().getClassLoader()).isLive(); } return theServlet == null; } @@ -164,9 +160,8 @@ public class ServletWrapper { * Get the servlet class - if the used classloader is not valid anymore * the class is reloaded. */ - public Servlet getServlet() - throws Exception { - if ( this.compileException != null ) { + public Servlet getServlet() throws Exception { + if (this.compileException != null) { throw this.compileException; } // check if the used class loader is still alive @@ -205,13 +200,16 @@ public class ServletWrapper { } else if (type instanceof ParameterizedType) { ParameterizedType ptype = (ParameterizedType) type; if (ptype.getActualTypeArguments().length != 1) { - logger.warn("Field {} of {} has more than one type parameter.", field.getName(), sourcePath); + logger.warn( + "Field {} of {} has more than one type parameter.", field.getName(), sourcePath); continue; } Class<?> collectionType = (Class<?>) ptype.getRawType(); - if (!(collectionType.equals(Collection.class) || - collectionType.equals(List.class))) { - logger.warn("Field {} of {} was not an injectable collection type.", field.getName(), sourcePath); + if (!(collectionType.equals(Collection.class) || collectionType.equals(List.class))) { + logger.warn( + "Field {} of {} was not an injectable collection type.", + field.getName(), + sourcePath); continue; } @@ -222,9 +220,11 @@ public class ServletWrapper { logger.warn("Field {} of {} was not an injectable type.", field.getName(), sourcePath); } } catch (final IllegalArgumentException e) { - logger.error(String.format("Unable to inject into field %s of %s.", field.getName(), sourcePath), e); + logger.error( + String.format("Unable to inject into field %s of %s.", field.getName(), sourcePath), e); } catch (final IllegalAccessException e) { - logger.error(String.format("Unable to inject into field %s of %s.", field.getName(), sourcePath), e); + logger.error( + String.format("Unable to inject into field %s of %s.", field.getName(), sourcePath), e); } finally { field.setAccessible(false); } @@ -236,24 +236,25 @@ public class ServletWrapper { * Compile the servlet java class. If the compiled class has * injected fields, don't create an instance of it. */ - private void compile() - throws Exception { + private void compile() throws Exception { logger.debug("Compiling {}", this.sourcePath); // clear exception this.compileException = null; try { final CompilerOptions opts = this.ioProvider.getForceCompileOptions(); final CompilationUnit unit = new CompilationUnit(this.sourcePath, className, ioProvider); - final CompilationResult result = this.ioProvider.getCompiler().compile(new org.apache.sling.commons.compiler.CompilationUnit[] {unit}, - opts); + final CompilationResult result = this.ioProvider + .getCompiler() + .compile(new org.apache.sling.commons.compiler.CompilationUnit[] {unit}, opts); final List<CompilerMessage> errors = result.getErrors(); this.destroy(); - if ( errors != null && errors.size() > 0 ) { + if (errors != null && errors.size() > 0) { throw CompilerException.create(errors, this.sourcePath); } - final Servlet servlet = (Servlet) result.loadCompiledClass(this.className).newInstance(); + final Servlet servlet = + (Servlet) result.loadCompiledClass(this.className).newInstance(); servlet.init(this.config); this.injectFields(servlet); @@ -268,22 +269,21 @@ public class ServletWrapper { } /** Compiler exception .*/ - protected final static class CompilerException extends ServletException { + protected static final class CompilerException extends ServletException { private static final long serialVersionUID = 7353686069328527452L; - public static CompilerException create(final List<CompilerMessage> errors, - final String fileName) { + public static CompilerException create(final List<CompilerMessage> errors, final String fileName) { final StringBuilder buffer = new StringBuilder(); buffer.append("Compilation errors in "); buffer.append(fileName); buffer.append(":\n"); - for(final CompilerMessage e : errors) { + for (final CompilerMessage e : errors) { buffer.append("Line "); buffer.append(e.getLine()); buffer.append(", column "); buffer.append(e.getColumn()); - buffer.append(" : " ); + buffer.append(" : "); buffer.append(e.getMessage()); buffer.append("\n"); } @@ -291,7 +291,7 @@ public class ServletWrapper { } public CompilerException(final String message) { - super(message); + super(message); } } } diff --git a/src/main/java/org/apache/sling/scripting/java/impl/SlingIOProvider.java b/src/main/java/org/apache/sling/scripting/java/impl/SlingIOProvider.java index a7ef07a..f2c6e8f 100644 --- a/src/main/java/org/apache/sling/scripting/java/impl/SlingIOProvider.java +++ b/src/main/java/org/apache/sling/scripting/java/impl/SlingIOProvider.java @@ -1,18 +1,20 @@ /* - * 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.java.impl; @@ -37,7 +39,7 @@ import org.slf4j.LoggerFactory; /** * The <code>SlingIOProvider</code> */ -public class SlingIOProvider { +public class SlingIOProvider { /** Default logger */ private final Logger logger = LoggerFactory.getLogger(SlingIOProvider.class); @@ -60,8 +62,7 @@ public class SlingIOProvider { /** * Constructor. */ - SlingIOProvider(final JavaCompiler compiler, - final CompilerOptions options) { + SlingIOProvider(final JavaCompiler compiler, final CompilerOptions options) { this.requestResourceResolver = new ThreadLocal<ResourceResolver>(); this.compiler = compiler; this.options = options; @@ -104,8 +105,7 @@ public class SlingIOProvider { * ResourceProvider and retrieved from the Resource if the StreamProvider * interface is implemented. */ - public InputStream getInputStream(String fileName) - throws FileNotFoundException, IOException { + public InputStream getInputStream(String fileName) throws FileNotFoundException, IOException { try { final Resource resource = getResourceInternal(fileName); if (resource == null) { @@ -120,8 +120,7 @@ public class SlingIOProvider { return stream; } catch (SlingException se) { - throw (IOException) new IOException( - "Failed to get InputStream for " + fileName).initCause(se); + throw (IOException) new IOException("Failed to get InputStream for " + fileName).initCause(se); } } @@ -153,8 +152,7 @@ public class SlingIOProvider { final Resource resource = getResourceInternal(path); return resource != null ? resource.adaptTo(URL.class) : null; } catch (SlingException se) { - throw (MalformedURLException) new MalformedURLException( - "Cannot get URL for " + path).initCause(se); + throw (MalformedURLException) new MalformedURLException("Cannot get URL for " + path).initCause(se); } } @@ -163,7 +161,8 @@ public class SlingIOProvider { try { final Resource resource = getResourceInternal(path); if (resource != null) { - final Iterator<Resource> entries = resource.getResourceResolver().listChildren(resource); + final Iterator<Resource> entries = + resource.getResourceResolver().listChildren(resource); while (entries.hasNext()) { paths.add(entries.next().getPath()); } @@ -183,5 +182,4 @@ public class SlingIOProvider { return null; } - }
