Package org.apache.tapestry.engine

Source Code of org.apache.tapestry.engine.DefaultScriptSource

/* $$ 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.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},1096998272901L);
    private ClassResolver _classResolver;

    private Map _cache = new HashMap();

    public synchronized void resetEventDidOccur()
    {try { __CLOVER_79_0.M[456]++;
        __CLOVER_79_0.S[1986]++;_cache.clear();
    } finally { }}

    public synchronized IScript getScript(Resource resource)
    {try { __CLOVER_79_0.M[457]++;
        __CLOVER_79_0.S[1987]++;IScript result = (IScript) _cache.get(resource);

        __CLOVER_79_0.S[1988]++;if ((((result != null) && (++__CLOVER_79_0.CT[374] != 0)) || (++__CLOVER_79_0.CF[374] == 0))){
            __CLOVER_79_0.S[1989]++;return result;}

        __CLOVER_79_0.S[1990]++;result = parse(resource);

        __CLOVER_79_0.S[1991]++;_cache.put(resource, result);

        __CLOVER_79_0.S[1992]++;return result;
    } finally { }}

    private IScript parse(Resource resource)
    {try { __CLOVER_79_0.M[458]++;
        __CLOVER_79_0.S[1993]++;ScriptParser parser = new ScriptParser(_classResolver);

        __CLOVER_79_0.S[1994]++;try
        {
            __CLOVER_79_0.S[1995]++;return parser.parse(resource);
        }
        catch (DocumentParseException ex)
        {
            __CLOVER_79_0.S[1996]++;throw new ApplicationRuntimeException(Tapestry.format("DefaultScriptSource.unable-to-parse-script",
                    resource), ex);
        }
    } finally { }}

    public void setClassResolver(ClassResolver classResolver)
    {try { __CLOVER_79_0.M[459]++;
        __CLOVER_79_0.S[1997]++;_classResolver = classResolver;
    } finally { }}
}
TOP

Related Classes of org.apache.tapestry.engine.DefaultScriptSource

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.