LaRRy
LaRRy

Reputation: 684

Is there any way to launch a method of EJB bean asynchronously without exposing this method as public?

I want to have some logic inside the EJB class and be able to launch it asynchronously.

OK, I can do that by getting the self bean proxy from the SessionContext and invoke the method. But that means the method must be public. So the method is visible and can be invoked by any class.

What I would like to have is a private method (not exposed to anyone outside), but still with the asynchronous possibilities. Is there a way to make that happen?

Upvotes: 0

Views: 45

Answers (1)

John Ament
John Ament

Reputation: 11723

@Asynchronous is based on the method being invoked. The only way I can think of is the way you mentioned, or to just do this (within your existing MyAsyncBean):

@EJB
private MyAsyncBean myAsyncBean;

You can make the method package level if you so choose. That will give you a bit more security to who can invoke it.

Upvotes: 1

Related Questions