Skip to content

Commit

Permalink
Load JaxRsContextProducer via BeanManager again
Browse files Browse the repository at this point in the history
It seems, that the @context annotation has problems with injecting our
JaxRsContextProducer also on RESTEasy. Unfortunately, the documentation
of @context itself isn't very helpful, so I just reverted the change and
load the Producer manually again.

see: #250
  • Loading branch information
erdlet committed Apr 19, 2021
1 parent 96a839e commit b5d31e1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*/
package org.eclipse.krazo.jaxrs;

import org.eclipse.krazo.util.CdiUtils;

import jakarta.annotation.Priority;
import jakarta.mvc.Controller;
import jakarta.servlet.http.HttpServletRequest;
Expand Down Expand Up @@ -56,11 +58,10 @@ public class PostMatchingRequestFilter implements ContainerRequestFilter {
@Context
private ResourceInfo resourceInfo;

@Context
private JaxRsContextProducer contextProducer;

@Override
public void filter(ContainerRequestContext requestContext) {
final JaxRsContextProducer contextProducer = CdiUtils.getApplicationBean(JaxRsContextProducer.class)
.orElseThrow(() -> new IllegalStateException("Cannot find CDI managed JaxRsContextProducer"));

// store JAX-RS context objects so we can produce them via CDI
contextProducer.setConfiguration(configuration);
Expand All @@ -69,7 +70,5 @@ public void filter(ContainerRequestContext requestContext) {
contextProducer.setApplication(application);
contextProducer.setUriInfo(uriInfo);
contextProducer.setResourceInfo(resourceInfo);

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import jakarta.ws.rs.core.Configuration;
import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.UriInfo;
import java.io.IOException;

/**
* Pre-Matching ContainerRequestFilter
Expand All @@ -56,11 +55,10 @@ public class PreMatchingRequestFilter implements ContainerRequestFilter {
@Context
private UriInfo uriInfo;

@Context
private JaxRsContextProducer contextProducer;

@Override
public void filter(ContainerRequestContext requestContext) {
final JaxRsContextProducer contextProducer = CdiUtils.getApplicationBean(JaxRsContextProducer.class)
.orElseThrow(() -> new IllegalStateException("Cannot find CDI managed JaxRsContextProducer"));

// store JAX-RS context objects so we can produce them via CDI
contextProducer.setConfiguration(configuration);
Expand Down

0 comments on commit b5d31e1

Please sign in to comment.