|
Play Framework/Scala example source code file (AssetsClassLoader.scala)
The AssetsClassLoader.scala Play Framework example source code/* * Copyright (C) 2009-2014 Typesafe Inc. <http://www.typesafe.com> */ package play.sbtplugin.run import sbt._ /** * A ClassLoader for serving assets. * * Serves assets from the given directories, at the given prefix. * * @param assets A list of assets directories, paired with the prefix they should be served from. */ class AssetsClassLoader(parent: ClassLoader, assets: Seq[(String, File)]) extends ClassLoader(parent) { override def findResource(name: String) = { assets.collectFirst { case (prefix, dir) if exists(name, prefix, dir) => (dir / name.substring(prefix.length)).toURI.toURL }.orNull } def exists(name: String, prefix: String, dir: File) = { name.startsWith(prefix) && (dir / name.substring(prefix.length)).isFile } } Other Play Framework source code examplesHere is a short list of links related to this Play Framework AssetsClassLoader.scala source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.