Created
June 9, 2017 09:59
-
-
Save struberg/bc5638f15acd675113013522d5a17425 to your computer and use it in GitHub Desktop.
Register JAX-WS in Meecrowave. Just playing around with it for now
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
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