Announcement Announcement Module
Collapse
No announcement yet.
Generalizing context event support? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Generalizing context event support?

    In another post in this forum someone questions how use of the event system ties a system to the Spring API, see http://forum.springframework.org/showthread.php?t=15105

    This should have a very simple solution: beans subscribe declaritively to receive events specific event types.

    Example:
    Code:
    <beans>
        <bean 
            id="someBean" class="......"
            subscribe="event,destroy"> 
        </bean>
    
        <!-- alternative approach -->
        <bean
            id="someBean2" class="....">
            
            <subscribe>
               <event class=".... class of event " />
            </subscribe> 
        </bean>
    
    </beans>
    In this defintion, the beans don't subclass or implement any Spring classes or interfaces.

    Rather, the Spring container creates an association of the bean with an event dispatcher information structure (or just a simple list); the beans need only to extend Java's EventListener.

    This is also an approach to allow beans to provide generalized context hooks without being tied to the container, similarly to how the "init" initialization method is used:

    Code:
    <beans>
        <bean
            id="someBean2" class="....">
            <subscribe>
               <event 
                    class=".... class of event "
                    method="methodName"/>
            </subscribe> 
        </bean>
    </beans>

    Of course, a better 'definition' format should be used. For example, a bean could depend on another bean for events too, such as:
    Code:
              <event  ref="someEventBean"/>
    ----
    J. Betancourt

    ----
    Last edited by robyn; May 14th, 2006, 11:32 AM.
Working...
X