Announcement Announcement Module
Collapse
No announcement yet.
Is it possible to unwire a bean? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Is it possible to unwire a bean?

    I'm working on integrating Spring with the Apache Beehive web framework in WebLogic Portal, in this framework there is a pageflow controller that typically lives for the life of the user session. Since I have no control over the lifecycle of this controller, I'm using the AutowireCapableBeanFactory.applyBeanPropertyValues in conjunction with inheritance to automatically wire in Spring beans when the controller is activated for a request.

    However once the request is terminated I'd like to unwire the controller and reset all the bean references back to null. Because the pageflow controller is session scoped (not in the Spring sense, I just mean it lives for the duration of the session), I don't necessarily want it holding on to references to beans which could be shorter lived, for example request scoped beans.

    First question I guess is it even worthwhile to do this? While I do not have a lot of experience with request scoped beans, I assume they can implement an interface to clean up any resources at the end of the request that would be invoked by Spring lessening the issue of the controller holding a reference to them.

    Having said that, I'm still curious if there is a way to unwire a bean for an existing instance.
    Last edited by gnunn; May 9th, 2008, 09:13 AM.

  • #2
    If I understand your question correctly, I don't think you need to worry about this. If you're wiring in request-scoped beans, your controller should see a fresh bean instance with each request. You are actually just wiring up a proxy that will create a bean with each request.

    That said, if you ever did need to muck with controllers on the fly, there are a couple things you could do:

    * AOP. Put advice around the handle method(s) that wires and unwires things.
    * Interceptor. Write an interceptor that looks for your controller (handler) and wires during preHandle(), unwires during postHandle().

    Hope that helps.

    Comment

    Working...
    X