Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.1.0.M2
    • Component/s: IoC
    • Labels:
      None

      Description

      Spring Java has the DisposableBean interface http://static.springsource.org/spring/docs/2.5.x/api/org/springframework/beans/factory/DisposableBean.html, which allows the class to provide a method to be invoked by container when the class (singletons only, actually) is about to be destroyed, i.e. similar to _del_ in Python, but invoked explicitly by the container. It would be nice to have DisposableObject in Spring Python too.

        Activity

        Hide
        Dariusz Suchojad added a comment -

        I've uploaded a patch (01) with DisposableObject along with testcases and changes to documentation.

        The patch registers an atexit handler which iterates through all singletons and invokes 'destroy-method' on every DisposableObject subclass when ApplicationContext is shutting down.

        What I'm not sure about is whether it shouldn't better use multiple threads (or processes with 'multiprocessing' module) to not block for each and every disposable object which is to be destroyed? What do you think?

        Show
        Dariusz Suchojad added a comment - I've uploaded a patch (01) with DisposableObject along with testcases and changes to documentation. The patch registers an atexit handler which iterates through all singletons and invokes 'destroy-method' on every DisposableObject subclass when ApplicationContext is shutting down. What I'm not sure about is whether it shouldn't better use multiple threads (or processes with 'multiprocessing' module) to not block for each and every disposable object which is to be destroyed? What do you think?
        Hide
        Greg Turnquist added a comment -

        1)
        springpython.factory._init_.py --> raise NotImplementedError("Should be overriden by subclasses")

        s/overriden/overidden/

        2)
        <classname>springpython.factory.DisposableObject</classname>

        I would make this <interfacename> for consistency.

        3)
        It is an error to extend <classname>springpython.factory.DisposableObject</classname>
        without providing neither <methodname>destroy</methodname> nor <methodname>destroy_method</methodname>,
        in that case an error will be written to Spring Python logs during
        the container shutting down.

        A little refinement to the writing:

        It is an error to extend <interfacename>springpython.factory.DisposableObject</interfacename> without providing either <methodname>destory</methodname> or <methodname>destroy_method</methodname>. If this occurs, an error will be written to Spring Python logs when the container shuts down.

        4)
        InitializingObject and DisposableObject actually belong in springpython.context, which is where you also find things like AppilcationContextAware, since they are only of value to ApplicationContext. springpython.factory is the place for object creation factories, that create instances of objects based on configuration meta data.

        Show
        Greg Turnquist added a comment - 1) springpython.factory._ init _.py --> raise NotImplementedError("Should be overriden by subclasses") s/overriden/overidden/ 2) <classname>springpython.factory.DisposableObject</classname> I would make this <interfacename> for consistency. 3) It is an error to extend <classname>springpython.factory.DisposableObject</classname> without providing neither <methodname>destroy</methodname> nor <methodname>destroy_method</methodname>, in that case an error will be written to Spring Python logs during the container shutting down. A little refinement to the writing: It is an error to extend <interfacename>springpython.factory.DisposableObject</interfacename> without providing either <methodname>destory</methodname> or <methodname>destroy_method</methodname>. If this occurs, an error will be written to Spring Python logs when the container shuts down. 4) InitializingObject and DisposableObject actually belong in springpython.context, which is where you also find things like AppilcationContextAware, since they are only of value to ApplicationContext. springpython.factory is the place for object creation factories, that create instances of objects based on configuration meta data.
        Hide
        Dariusz Suchojad added a comment -

        Committed to trunk in r588, closing the ticket.

        Show
        Dariusz Suchojad added a comment - Committed to trunk in r588, closing the ticket.

          People

          • Assignee:
            Dariusz Suchojad
            Reporter:
            Dariusz Suchojad
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: