Proposal: IOC support (optional) for Remote Interceptors
by Eric Wittmann
My use case is that I want an Auth interceptor which would support both
BASIC and Bearer Token authentication depending on the app's
configuration. My config information is accessible via a
@ApplicationScoped client service (ConfigurationService). I would like
to inject that into my interceptor. Currently the interceptors are
simply new'd up when needed.
I think we need to make interceptor creation asynchronous so that the
async bean manager in IOC can be (optionally) used. Attached to this
email are there files:
samplecode.txt - code generated now (e.g. JaxrsProxyLoaderImpl.java)
samplecode-async.txt - suggestion for how to make it async
samplecode-ioc.txt - optional code generation iff the IOC module is present
Thoughts?
I could take a stab at this if it seems reasonable, but I don't want to
start down this road if anyone can spot a glaring problem.
Also notice that I removed the return value for proceed() as I do not
believe it is required/used.
-Eric
10 years, 10 months
Re: [errai-dev] Client interceptors - jax-rs
by Eric Wittmann
I think I'm a fan of option #2. To be clear, would it look like this
(for example)?
@Templated
@Page(path="dashboard", role=DefaultPage.class)
@Dependent
public class DashboardPage extends AbstractPage {
@Inject
@Interceptors({ AuthInterceptor.class, ReqHeaderInterceptor.class })
private Caller<IMyRestService> caller;
}
That seems pretty slick to me. It does mean that if I inject that
Caller in multiple places I need to specify the interceptor list each
time. But that actually sounds pretty powerful to me.
Would the interceptors be managed beans (i.e. injected into the Caller)?
My use case would be that I'd have an AuthenticationInterceptor for my
Caller, but I would want to @Inject a configuration bean of some kind
into it, because I might be using either BASIC auth *or* Bearer Token
auth, and the managed configuration bean is what knows which it is.
-Eric
PS: adding the errai-dev list to the conversation, which is what I
should have done originally
On 2/7/2014 11:35 AM, Christian Sadilek wrote:
> Yeah, I had thought about that as well before but couldn't decide what's best:
>
> - Add a mapping to ErraiApp.properties
> - Add an annotation/qualifier @Interceptors(...) that can be used when injecting a Caller<?>
> - Add a parameter to call() that takes a List of interceptors
>
> Definitely a good feature to have. Wdyt?
>
> Cheers,
> Christian
>
> On 2014-02-07, at 10:06 AM, Eric Wittmann <eric.wittmann(a)redhat.com> wrote:
>
>> I was reading the documentation re: client interceptors for jax-rs in Errai and I was wondering what you thought about adding a mechanism to allow client interceptors to be defined either globally or in some way that doesn't require modifying the JAX-RS interface (to add annotations). I'm thinking that in some cases a developer might be creating a UI and invoking REST services where they have access to the jax-rs interfaces but do not have write privs. In other words they can consume them but not modify them. In that case it might be nice to able to apply interceptors in some other way.
>>
>> Thoughts?
>>
>> -Eric
>
10 years, 10 months