examples that I've found討論瞭如何在unmarshaller
對象上設置驗證處理程序。如何在Jersey中使用Moxy註冊ValidationEventHandler?
但是,使用Jersey,MOXy/JAXB爲我初始化,我不知道如何訪問unmarshaller。
目前,我像這樣引導Jersey,jersey-media-moxy
在類路徑上。
@ApplicationPath("rest")
public class ApplicationConfig extends ResourceConfig {
Logger logger = LoggerFactory.getLogger(ApplicationConfig.class);
public ApplicationConfig() {
// Scan classes in this package and subpackages
logger.info("Registering REST Application");
packages("rest");
register(new AbstractBinder() {
@Override
protected void configure() {
// used to automatically inject a Connection instance and close it
bindFactory(ConnectionFactory.class).to(Connection.class)
.proxy(true).proxyForSameScope(false).in(RequestScoped.class);
}
});
}
}
用這種方法,我怎麼能註冊的解組一個ValidationEventHandler
?