0

Does Weld have any kind of scope like prototype in Spring? Weld has qualified @New but it is a little bit different.

What I want to do is following: I have bean with application scope. In this bean I need to have reference to bean with scope similar to prototype. I know I know in Spring it is possible to implement with lookup methods.

Unfortunately I could not found prototype scope and lookup method in Weld. Does Weld have anything similar?

1 Answers1

1

I'm not too familiar with Spring but, from a quick read of the docs, I think what you want are @Dependant beans.

With the @Dependant pseudo-scope, a new bean instance is created every time it's injected.

In your case your application scoped bean would have an instance injected into it when it's created, and that instance won't be injected anywhere else.

If another application scoped bean injected the same class, it would get a different instance.

If a request scoped bean injected the same class, then each instance of the request scoped bean would get it's own instance of your injected bean.

Does that sound like what you're looking for?

Azquelt
  • 1,380
  • 10
  • 15