A synopsis of how I'm setting up Resteasy follows, but for
convenience/reference I posted the entire relevant code here:
http://pastebin.com/JYMP22h2
I'm setting up Resteasy by leveraging
org.jboss.resteasy.spi.ResteasyDeployment and
org.jboss.resteasy.plugins.server.servlet.HttpServlet30Dispatcher.
Essentially, I create a new instance of "ResteasyDeployment" and set an
"Application" class for the deployment.
ResteasyDeployment deployment = new ResteasyDeployment();
deployment.setApplicationClass(appClass.getName());
Then I configure the servlet:
ServletInfo servletInfo = Servlets.servlet("ResteasyServlet",
HttpServlet30Dispatcher.class)
.setAsyncSupported(true)
.setLoadOnStartup(1)
.addMapping(appPath);
I create a new DeploymentInfo instance and set a few properties:
new DeploymentInfo().setClassLoader(Server.class.getClassLoader())
.setContextPath("/")
.addServletContextAttribute(ResteasyDeployment.class.getName(), deployment)
.addServlet(servletInfo)
.setDeploymentName("api.example")
.addListeners(Servlets.listener(GuiceContextListener.class));
Then I add the deployment info to a container instance:
private final ServletContainer container =
ServletContainer.Factory.newInstance();
DeploymentManager manager = container.addDeployment(deployInfo);
manager.deploy();
Lastly, I set the undertow handlers, build, and start:
undertow = builder.setHandler(root).build();
undertow.start();
Thanks.
-Ari
On Wed, Aug 12, 2015 at 1:18 AM, Stuart Douglas <sdouglas(a)redhat.com> wrote:
Undertow does not do discovery or metadata/annotation parsing. This
is
expected to be handled by the embedding container (so the embedding
container has complete control over what is deployed).
How are you setting up Resteasy?
Stuart
----- Original Message -----
> From: "Ari King" <ari.brandeis.king(a)gmail.com>
> To: "Stuart Douglas" <sdouglas(a)redhat.com>
> Cc: undertow-dev(a)lists.jboss.org
> Sent: Wednesday, 12 August, 2015 10:08:34 AM
> Subject: Re: [undertow-dev] How to Access ServletContext?
>
> Hi Stuart,
>
> Thanks for the clarification. As a follow-up, does undertow handle/expose
> servlets like conventional containers (tomcat, jetty, etc)? I ask,
because
> injecting a HttpServletRequest via a context annotation in a resource
> method causes the following error:
>
> org.jboss.resteasy.spi.LoggableFailure: Unable to find contextual data of
> type: javax.servlet.http.HttpServletRequest
>
> -Ari
>
> On Mon, Aug 10, 2015 at 7:06 AM, Stuart Douglas <sdouglas(a)redhat.com>
wrote:
>
> >
> >
> > ----- Original Message -----
> > > From: "Ari King" <ari.brandeis.king(a)gmail.com>
> > > To: undertow-dev(a)lists.jboss.org
> > > Sent: Saturday, 8 August, 2015 7:53:00 AM
> > > Subject: [undertow-dev] How to Access ServletContext?
> > >
> > > I've embedded Undertow into a Resteasy (JAX-RS) app. One of the
> > libraries I'm
> > > using requires a servlet context attribute to be set. How can/should
I go
> > > about doing so?
> > >
> > > If I should use a ServletExtension, to clarify, I need to create a
file
> > named
> > > " io.undertow.servlet.ServletExtension" and put it in the
> > > "META-INF/services/ " directory?
> > >
> > > Within the above mentioned file do I need to provide the fully
qualified
> > name
> > > of the implementation class?
> >
> > Yes, although there are some other options:
> >
> > - You can use
io.undertow.servlet.api.DeploymentInfo#addServletExtension
> > to create the extension yourself
> > - You can also use a ServletContainerInitializer or
ServletContextListener
> > instead of a ServletExtension
> > - In your embedding code you can call
> > DeploymentManager.getDeployment().getServletContext()
> >
> > Stuart
> >
> >
> > >
> > > Thanks.
> > >
> > > Best,
> > > Ari
> > >
> > > _______________________________________________
> > > undertow-dev mailing list
> > > undertow-dev(a)lists.jboss.org
> > >
https://lists.jboss.org/mailman/listinfo/undertow-dev
> >
>