As originally proposed by Stefano, the FOM exposes a getComponent(id) method but not a corresponding releaseComponent(component), as Sylvain was quick to point out.
I agree with Sylvain that releaseComponent() is indeed needed for stateful, pooled components.
Btw, I'm sure when Stefano mentioned stateful components being questioned he referred to *EJB* stateful session beans that keep state on behalf of a remote client. In this arena, it's felt that keeping session state is best done at the webapp layer rather than inside the EJB container. But that's another matter...
*Avalon* stateful, pooled components, OTH, _require_ to be released after use.
That said, using try/catch blocks in Javascript to ensure proper stateful component release looks anti-scripting to me. In an ideal world, the flow implementation should take care of this aspect for the flow developer. Of course, I do see such a guarantee is easier hoped for than implemented.
Because of continuations, automatically releasing components at the end of request processing is clearly not appropriate.
Things are further complicated by the fact that continuations can be abandoned. How should we deal with active stateful components in this case? Even if we hook into continuation expiration, this could still lead to excesive tying up of pooled heavy-weight components.
Should we reclaim components at the end of sitemap-invoked function execution? This makes more sense because function completion can span across requests.
Performing component auto-releasing at the end of sitemap-invoked function completion (whether because of return or exception) seems a reasonable thing to do because, typically, such function call will embody a complete interaction between the user and the application. If any components were needed during that process it's ok to relase them at use-case completion.
However, it would preclude keeping components in use across flow functions. Would this truly limit flow usability?
What about specifying a "retention policy" (session, function) upon acquiring components? getComponent(id[, scope])
What do you guys think?