diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/ScriptHelperFactory.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/ScriptHelperFactory.java deleted file mode 100644 index 56e7cda718..0000000000 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/ScriptHelperFactory.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * 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.ofbiz.base.util; - -import javax.script.ScriptContext; - -import org.apache.ofbiz.base.lang.Factory; - -/** - * A ScriptHelper factory. - */ -public interface ScriptHelperFactory extends Factory { - - ScriptHelper getInstance(ScriptContext context); -} diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/ScriptUtil.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/ScriptUtil.java index 44ba579d3b..5d3b347b63 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/ScriptUtil.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/ScriptUtil.java @@ -27,10 +27,8 @@ import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.ServiceLoader; import java.util.Set; import javax.script.Bindings; @@ -47,6 +45,8 @@ import javax.script.SimpleScriptContext; import org.apache.ofbiz.base.location.FlexibleLocation; import org.apache.ofbiz.base.util.cache.UtilCache; +import org.apache.ofbiz.base.util.ScriptHelper; +import org.apache.ofbiz.common.scripting.ScriptHelperImpl; import org.codehaus.groovy.runtime.InvokerHelper; /** @@ -70,7 +70,6 @@ public final class ScriptUtil { public static final String SCRIPT_HELPER_KEY = "ofbiz"; private static final UtilCache parsedScripts = UtilCache.createUtilCache("script.ParsedScripts", 0, 0, false); private static final Object[] EMPTY_ARGS = {}; - private static ScriptHelperFactory helperFactory = null; /** A set of script names - derived from the JSR-223 scripting engines. */ public static final Set SCRIPT_NAMES; @@ -104,15 +103,6 @@ public final class ScriptUtil { } } SCRIPT_NAMES = Collections.unmodifiableSet(writableScriptNames); - Iterator iter = ServiceLoader.load(ScriptHelperFactory.class).iterator(); - if (iter.hasNext()) { - helperFactory = iter.next(); - if (Debug.verboseOn()) { - Debug.logVerbose("ScriptHelper factory set to " + helperFactory.getClass().getName(), module); - } - } else { - Debug.logWarning("ScriptHelper factory not found", module); - } } /** @@ -206,7 +196,7 @@ public final class ScriptUtil { localContext.put(WIDGET_CONTEXT_KEY, context); localContext.put("context", context); ScriptContext scriptContext = new SimpleScriptContext(); - ScriptHelper helper = createScriptHelper(scriptContext); + ScriptHelper helper = new ScriptHelperImpl(scriptContext); if (helper != null) { localContext.put(SCRIPT_HELPER_KEY, helper); } @@ -233,21 +223,11 @@ public final class ScriptUtil { ScriptContext scriptContext = new SimpleScriptContext(); Bindings bindings = new ProtectedBindings(localContext, Collections.unmodifiableSet(protectedKeys)); scriptContext.setBindings(bindings, ScriptContext.ENGINE_SCOPE); - ScriptHelper helper = createScriptHelper(scriptContext); - if (helper != null) { - localContext.put(SCRIPT_HELPER_KEY, helper); - } + localContext.put(SCRIPT_HELPER_KEY, new ScriptHelperImpl(scriptContext)); return scriptContext; } - public static ScriptHelper createScriptHelper(ScriptContext context) { - if (helperFactory != null) { - return helperFactory.getInstance(context); - } - return null; - } - - /** + /** * Executes a script String and returns the result. * * @param language diff --git a/framework/common/src/main/java/META-INF/services/org.apache.ofbiz.base.util.ScriptHelperFactory b/framework/common/src/main/java/META-INF/services/org.apache.ofbiz.base.util.ScriptHelperFactory deleted file mode 100644 index 73994bd032..0000000000 --- a/framework/common/src/main/java/META-INF/services/org.apache.ofbiz.base.util.ScriptHelperFactory +++ /dev/null @@ -1,18 +0,0 @@ -# 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. - -org.apache.ofbiz.common.scripting.ScriptHelperFactoryImpl diff --git a/framework/common/src/main/java/org/apache/ofbiz/common/scripting/ScriptHelperFactoryImpl.java b/framework/common/src/main/java/org/apache/ofbiz/common/scripting/ScriptHelperFactoryImpl.java deleted file mode 100644 index 044eff8652..0000000000 --- a/framework/common/src/main/java/org/apache/ofbiz/common/scripting/ScriptHelperFactoryImpl.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * 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.ofbiz.common.scripting; - -import javax.script.ScriptContext; - -import org.apache.ofbiz.base.util.ScriptHelper; -import org.apache.ofbiz.base.util.ScriptHelperFactory; - -/** - * An implementation of the ScriptHelperFactory interface. - */ -public final class ScriptHelperFactoryImpl implements ScriptHelperFactory { - - @Override - public ScriptHelper getInstance(ScriptContext context) { - return new ScriptHelperImpl(context); - } -}