jsr345-experts@ejb-spec.java.net

[jsr345-experts] Re: [ejb-spec users] Re: Re: Re: Asynchronous *Client* Invocation Semantics

From: Adam Bien <abien_at_adam-bien.com>
Date: Mon, 4 Jul 2011 13:30:53 +0200

Pete,

I like your suggestion:

@Inject @Asynchronous SomeBean bean;

because of EJB spec we should also support something like: @EJB(async=true) SomeBean bean;


We could also allow: @Inject Future<SomeBean> bean; for beans with a single method (like Single Abstract Method in JDK 1.8). It means: a bean with a single, void method, would be injected as a Future automatically.

any thoughts?

thanks!,

adam bien



On 01.07.2011, at 14:38, Pete Muir wrote:

> I do agree with Carlo that often it is the client that knows whether an invocation should be sync or async.
>
> I also agree with Reza that the proposed syntax is a little obtuse. Some comments:
>
> * I don't like the use of static helper methods at all, it's
> (a) clunky and
> (b) inconsistent with the rest of Java EE
> * Where possible the API should avoid having classes in it
> * I don't really understand the naming of the methods beyond async()
>
> public class Async {
>
> public static <T> T async(T bean);
>
> public static Future<?> divine(); <<< What does divine() mean?
>
> public static <R> Future<R> divine(R dummyResult);
> }
>
> I would have thought that it is more consistent with the EJB component model to expose a special JNDI name returning an async or future wrapped version of the bean. With CDI we could then expose these as @Asynchronous and just future wrapped options.
>
> e.g.
>
> @Inject @Asynchronous SomeBean bean;
>
> @Inject Future<SomeBean> bean;
>
> On 30 Jun 2011, at 19:18, Reza Rahman wrote:
>
>> Personally, I think @Asynchronous is fine (in fact, I think it is probably more intuitive than the proposed syntax). The cases are very rare that a synchronous method would suddenly be used asynchronously without the bean developer's knowledge. It's also the case that in order to support things like cancellation, the bean would have to be aware that it is being invoked asynchronously.
>>
>> Cheers,
>> Reza
>>
>>
>> On 6/30/2011 1:57 PM, Marina Vatkina wrote:
>>> Thanks for asking. The official guideline is to use this list :)
>>>
>>> -marina
>>>
>>> Pete Muir wrote:
>>>> Where should we discuss this - comments thread? email list?
>>>>
>>>> Marina, what is the official guideline?
>>>>
>>>> On 30 Jun 2011, at 09:59, Carlo de Wolf wrote:
>>>>
>>>>> As I mentioned on the EJB 3.1 EG when we did asynchronous, I don't like that it is tied into the bean developer realm.
>>>>>
>>>>> I've opened up http://java.net/jira/browse/EJB_SPEC-11 as a proposed alternative.
>>>>> Looking forward to your comments.
>>>>>
>>>>> Carlo
>>>>
>>>
>>>
>>> -----
>>> No virus found in this message.
>>> Checked by AVG - www.avg.com
>>> Version: 10.0.1388 / Virus Database: 1516/3735 - Release Date: 06/30/11
>>>
>>>
>>
>

Independent Consultant, Speaker, Java Champion
 
 Weblog: blog.adam-bien.com
 press: press.adam-bien.com
 eMail: abien_at_adam-bien.com
 twitter: twitter.com/AdamBien
 Mobile: 0049(0)170 280 3144

 Author of:
 "Real World Java EE Night Hacks", "Real World Java EE Patterns--Rethinking Best Practices"