Package webit.script.servlet.loaders

Source Code of webit.script.servlet.loaders.ServletLoader

// Copyright (c) 2013-2014, Webit Team. All Rights Reserved.
package webit.script.servlet.loaders;

import javax.servlet.ServletContext;
import webit.script.loaders.AbstractLoader;
import webit.script.loaders.Resource;
import webit.script.loaders.impl.resources.FileResource;

/**
*
* @author Zqq
*/
public class ServletLoader extends AbstractLoader {

    private ServletContext servletContext;

    public Resource get(String path) {
        path = getRealPath(path);
        final String filepath = servletContext.getRealPath(path);
        if (filepath != null) {
            return new FileResource(filepath, encoding);
        }
        return new ServletContextResource(path, encoding, servletContext);
    }

    public void setServletContext(ServletContext servletContext) {
        this.servletContext = servletContext;
    }
}
TOP

Related Classes of webit.script.servlet.loaders.ServletLoader

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.