Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Resource handler para poder fazer: `${linkTo[controllers.MeuController].metodo}` ou `${linkTo[gerenciador.MeuController]}`
@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
You can’t perform that action at this time.