Created
March 21, 2013 15:01
-
-
Save lucascs/5213718 to your computer and use it in GitHub Desktop.
Resource handler para poder fazer: `${linkTo[controllers.MeuController].metodo}` ou `${linkTo[gerenciador.MeuController]}`
This file contains 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
@Component // do vraptor | |
@ApplicationScoped | |
@org.springframework.stereotype.Component("stereotypeHandler") // só se for spring | |
public class PackageResourceHandler implements StereotypeHandler { | |
private final Map<String, Class> controllers; | |
private final Map<String, Class> gerenciador; | |
public PackageResourceHandler(ServletContext context) { | |
context.setAttribute("controllers", controllers); | |
context.setAttribute("gerenciador", gerenciador); | |
} | |
public void handle(Class<?> annotatedType) { | |
if (annotatedType.getPackage().getName().endsWith("controllers")) | |
controllers.put(annotatedType.getSimpleName(), annotatedType); | |
if (annotatedType.getPackage().getName().endsWith("gerenciador")) | |
gerenciador.put(annotatedType.getSimpleName(), annotatedType); | |
} | |
public Class<? extends Annotation> stereotype() { | |
return Resource.class; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment