diff --git a/xwiki-commons-core/xwiki-commons-velocity/src/main/java/org/xwiki/velocity/internal/util/DefaultVelocityDetector.java b/xwiki-commons-core/xwiki-commons-velocity/src/main/java/org/xwiki/velocity/internal/util/DefaultVelocityDetector.java deleted file mode 100644 index 5e6474379b..0000000000 --- a/xwiki-commons-core/xwiki-commons-velocity/src/main/java/org/xwiki/velocity/internal/util/DefaultVelocityDetector.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.xwiki.velocity.internal.util; - -import javax.inject.Singleton; - -import org.xwiki.component.annotation.Component; - -/** - * Default implementation of {@link VelocityDetector}. - * - * @version $Id$ - * @since 15.9RC1 - */ -@Component -@Singleton -public class DefaultVelocityDetector implements VelocityDetector -{ - @Override - public boolean containsVelocityScript(String input) - { - return input.contains("#") || input.contains("$"); - } -} diff --git a/xwiki-commons-core/xwiki-commons-velocity/src/main/java/org/xwiki/velocity/internal/util/VelocityDetector.java b/xwiki-commons-core/xwiki-commons-velocity/src/main/java/org/xwiki/velocity/internal/util/VelocityDetector.java index 6e06321565..a382e6d881 100644 --- a/xwiki-commons-core/xwiki-commons-velocity/src/main/java/org/xwiki/velocity/internal/util/VelocityDetector.java +++ b/xwiki-commons-core/xwiki-commons-velocity/src/main/java/org/xwiki/velocity/internal/util/VelocityDetector.java @@ -19,16 +19,19 @@ */ package org.xwiki.velocity.internal.util; -import org.xwiki.component.annotation.Role; +import javax.inject.Singleton; + +import org.xwiki.component.annotation.Component; /** - * Utility role to detect velocity scripts. + * Utility component to check if a string contains a velocity script. * * @version $Id$ * @since 15.9RC1 */ -@Role -public interface VelocityDetector +@Component(roles = VelocityDetector.class) +@Singleton +public class VelocityDetector { /** * Checks if a string contains a velocity script. @@ -36,5 +39,8 @@ public interface VelocityDetector * @param input the string to check * @return true if the string contains a velocity script, false otherwise */ - boolean containsVelocityScript(String input); + public boolean containsVelocityScript(String input) + { + return input.contains("#") || input.contains("$"); + } } diff --git a/xwiki-commons-core/xwiki-commons-velocity/src/main/resources/META-INF/components.txt b/xwiki-commons-core/xwiki-commons-velocity/src/main/resources/META-INF/components.txt index 9963821bab..5c34b92132 100644 --- a/xwiki-commons-core/xwiki-commons-velocity/src/main/resources/META-INF/components.txt +++ b/xwiki-commons-core/xwiki-commons-velocity/src/main/resources/META-INF/components.txt @@ -4,4 +4,4 @@ org.xwiki.velocity.internal.DefaultVelocityContextFactory org.xwiki.velocity.internal.DefaultVelocityManager org.xwiki.velocity.internal.InternalVelocityEngine org.xwiki.velocity.internal.ServicesVelocityContextInitializer -org.xwiki.velocity.internal.util.DefaultVelocityDetector +org.xwiki.velocity.internal.util.VelocityDetector diff --git a/xwiki-commons-core/xwiki-commons-velocity/src/test/java/org/xwiki/velocity/internal/util/DefaultVelocityDetectorTest.java b/xwiki-commons-core/xwiki-commons-velocity/src/test/java/org/xwiki/velocity/internal/util/VelocityDetectorTest.java similarity index 92% rename from xwiki-commons-core/xwiki-commons-velocity/src/test/java/org/xwiki/velocity/internal/util/DefaultVelocityDetectorTest.java rename to xwiki-commons-core/xwiki-commons-velocity/src/test/java/org/xwiki/velocity/internal/util/VelocityDetectorTest.java index f97bb2ca2f..daaa6a425d 100644 --- a/xwiki-commons-core/xwiki-commons-velocity/src/test/java/org/xwiki/velocity/internal/util/DefaultVelocityDetectorTest.java +++ b/xwiki-commons-core/xwiki-commons-velocity/src/test/java/org/xwiki/velocity/internal/util/VelocityDetectorTest.java @@ -27,15 +27,15 @@ import static org.junit.jupiter.api.Assertions.assertEquals; /** - * Tests for {@link DefaultVelocityDetector}. + * Tests for {@link VelocityDetector}. * * @version $Id$ */ @ComponentTest -class DefaultVelocityDetectorTest +class VelocityDetectorTest { @InjectMockComponents - private DefaultVelocityDetector detector; + private VelocityDetector detector; @ParameterizedTest @CsvSource({