Created
September 1, 2010 19:55
-
-
Save asouza/561238 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package br.com.caelum.vraptor.scala; | |
import java.io.File; | |
import javax.servlet.ServletContext; | |
import javax.servlet.http.HttpServletRequest; | |
import br.com.caelum.vraptor.ioc.Component; | |
import br.com.caelum.vraptor.ioc.RequestScoped; | |
import br.com.caelum.vraptor.resource.ResourceMethod; | |
import br.com.caelum.vraptor.view.AcceptHeaderToFormat; | |
import br.com.caelum.vraptor.view.DefaultPathResolver; | |
@Component | |
@RequestScoped | |
public class ScalatePathResolver extends DefaultPathResolver { | |
private final ServletContext context; | |
public ScalatePathResolver(HttpServletRequest request, | |
ServletContext context, | |
AcceptHeaderToFormat acceptHeaderToFormat) { | |
super(request, acceptHeaderToFormat); | |
this.context = context; | |
} | |
protected String getPrefix() { | |
return "/WEB-INF/ssp/"; | |
} | |
protected String getExtension() { | |
return "ssp"; | |
} | |
@Override | |
public String pathFor(ResourceMethod method) { | |
String path = super.pathFor(method); | |
String realPathToViewFile = context.getRealPath(path); | |
return new File(realPathToViewFile).exists() ? path : path.replace( | |
"/WEB-INF/ssp", "/WEB-INF/jsp").replace(".ssp", ".jsp"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment