Skip to content

Instantly share code, notes, and snippets.

@struberg
Created June 9, 2017 09:59
Show Gist options
  • Save struberg/bc5638f15acd675113013522d5a17425 to your computer and use it in GitHub Desktop.
Save struberg/bc5638f15acd675113013522d5a17425 to your computer and use it in GitHub Desktop.
Register JAX-WS in Meecrowave. Just playing around with it for now
public class JaxWsRegistrationExtension implements Extension {
private List<AnnotatedType> webServices = new ArrayList<>();
public void collectWebServices(@Observes @WithAnnotations(WebService.class) ProcessAnnotatedType<?> pat) {
if (pat.getAnnotatedType().isAnnotationPresent(Path.class) && !pat.getAnnotatedType().getJavaClass().isInterface()) {
webServices.add(pat.getAnnotatedType());
}
}
public void registerWebServices(@Observes AfterDeploymentValidation adv, BeanManager bm) {
webServices.stream()
.filter(at -> at.isAnnotationPresent(Path.class))
.forEach(at -> Endpoint.publish(at.getAnnotation(Path.class).value(), getInstance(bm, at)));
}
private Object getInstance(BeanManager bm, AnnotatedType at) {
Bean<?> bean = bm.resolve(bm.getBeans(at.getBaseType()));
return bm.getReference(bean, at.getBaseType(), bm.createCreationalContext(bean));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment