users@jersey.java.net

[Jersey] Re: Where to put code that should be called at deployment time?

From: Michal Gajdos <michal.gajdos_at_oracle.com>
Date: Mon, 06 Jan 2014 15:46:13 +0100

Hi Ed,

are you registering your FaceletMvcFeature in your application and it's
still not invoked?

Thanks,
Michal

On 03.01.2014, 21:39 , Edward Burns wrote:
> Hello Jersey Users,
>
> I'm trying to hack upon the jersey-mvc-jsp module and produce a
> jersey-mvc-facelets module. My intent is to make it possible to return
> a Viewable that references a Facelets page so that users can take
> advantage of Facelets just as they would JSP, Freemarker, or Mustache.
>
> I'm having trouble with auto bootstrapping, however.
>
> The existing usage contract for pulling in a specific incarnation of the
> jersey-mvc-* feature seems to be to say:
>
> register([TemplateTechnology]MvcFeature.class);
>
> from your application class that extends ResourceConfig, where
> [TemplateTechnology] is Jsp, Freemarker, or Mustache. I'm trying to add
> Facelets to that set.
>
> Given that usage contract alone, I'd like to know how to make it so code
> specific to Facelets is executed at deployment time.
>
> I tried modifying my javax.ws.rs.core.Feature implementation to attempt
> to add an ApplicationEventListener implementation, but find that it is
> not called.
>
> @ConstrainedTo(RuntimeType.SERVER)
> public final class FaceletsMvcFeature implements Feature {
>
> @Override
> public boolean configure(final FeatureContext context) {
> if (!context.getConfiguration().isRegistered(MvcFeature.class)) {
> context.register(MvcFeature.class);
> }
>
> context.register(FaceletsTemplateProcessor.class);
> context.register(MyApplicationEventListener.class);
> return true;
> }
>
> public static class MyApplicationEventListener implements ApplicationEventListener {
>
> @Override
> public void onEvent(ApplicationEvent event) {
> System.out.println("debug: edburns: " + event.getType().name());
> }
>
> @Override
> public RequestEventListener onRequest(RequestEvent requestEvent) {
> return null;
> }
>
> }
>
> }
>
> What am I doing wrong? Any pointers?
>
> Thanks,
>
> Ed