/* $$ Clover has instrumented this file $$ */// Copyright 2004 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package org.apache.tapestry.engine;
import java.util.HashMap;
import java.util.Map;
import org.apache.hivemind.ApplicationRuntimeException;
import org.apache.hivemind.ClassResolver;
import org.apache.hivemind.Resource;
import org.apache.tapestry.IScript;
import org.apache.tapestry.Tapestry;
import org.apache.tapestry.event.ResetEventListener;
import org.apache.tapestry.script.ScriptParser;
import org.apache.tapestry.services.ExpressionEvaluator;
import org.apache.tapestry.util.xml.DocumentParseException;
/**
* Provides basic access to scripts available on the classpath. Scripts are cached in memory once
* parsed.
*
* @author Howard Lewis Ship
* @since 1.0.2
*/
public class DefaultScriptSource implements IScriptSource, ResetEventListener
{public static com.cortexeb.tools.clover.d __CLOVER_79_0 = com.cortexeb.tools.clover.aq.getRecorder(new char[] {67,58,92,119,111,114,107,115,112,97,99,101,92,106,97,107,97,114,116,97,45,116,97,112,101,115,116,114,121,92,102,114,97,109,101,119,111,114,107,92,116,97,114,103,101,116,92,99,108,111,118,101,114,45,100,98},1097439627296L);
private ClassResolver _classResolver;
/** @since 3.1 */
private ExpressionEvaluator _expressionEvaluator;
private Map _cache = new HashMap();
public synchronized void resetEventDidOccur()
{try { __CLOVER_79_0.M[3026]++;
__CLOVER_79_0.S[12455]++;_cache.clear();
} finally { }}
public synchronized IScript getScript(Resource resource)
{try { __CLOVER_79_0.M[3027]++;
__CLOVER_79_0.S[12456]++;IScript result = (IScript) _cache.get(resource);
__CLOVER_79_0.S[12457]++;if ((((result != null) && (++__CLOVER_79_0.CT[2135] != 0)) || (++__CLOVER_79_0.CF[2135] == 0))){
__CLOVER_79_0.S[12458]++;return result;}
__CLOVER_79_0.S[12459]++;result = parse(resource);
__CLOVER_79_0.S[12460]++;_cache.put(resource, result);
__CLOVER_79_0.S[12461]++;return result;
} finally { }}
private IScript parse(Resource resource)
{try { __CLOVER_79_0.M[3028]++;
__CLOVER_79_0.S[12462]++;ScriptParser parser = new ScriptParser(_classResolver, _expressionEvaluator);
__CLOVER_79_0.S[12463]++;try
{
__CLOVER_79_0.S[12464]++;return parser.parse(resource);
}
catch (DocumentParseException ex)
{
__CLOVER_79_0.S[12465]++;throw new ApplicationRuntimeException(Tapestry.format(
"DefaultScriptSource.unable-to-parse-script",
resource), ex);
}
} finally { }}
public void setClassResolver(ClassResolver classResolver)
{try { __CLOVER_79_0.M[3029]++;
__CLOVER_79_0.S[12466]++;_classResolver = classResolver;
} finally { }}
/** @since 3.1 */
public void setExpressionEvaluator(ExpressionEvaluator expressionEvaluator)
{try { __CLOVER_79_0.M[3030]++;
__CLOVER_79_0.S[12467]++;_expressionEvaluator = expressionEvaluator;
} finally { }}
}