Results 1 to 2 of 2

Thread: ApplicationEventPublisherAware

  1. #1
    Join Date
    Dec 2004
    Posts
    3

    Default ApplicationEventPublisherAware

    Is this interface supported by spring-rcp? After reading the docs, my assumption was that implementing the above interface on a bean declared in my application context would result in a call to setApplicationEventPublisher during deployment, but that doesn't seem to be happening. Is this an oversight, or is Application.services()... the preferred way to do things in rcp? Or am I misunderstanding what the interface is supposed to do? Thanks,

    Mike

  2. #2
    Join Date
    Dec 2004
    Posts
    3

    Default patch

    Just in case it was an oversight...

    Code:
    Index: DefaultViewDescriptor.java
    ===================================================================
    RCS file: /cvsroot/spring-rich-c/spring-richclient/src/org/springframework/richclient/application/support/DefaultViewDescriptor.java,v
    retrieving revision 1.9
    diff -u -r1.9 DefaultViewDescriptor.java
    --- DefaultViewDescriptor.java	12 Nov 2004 02:36:53 -0000	1.9
    +++ DefaultViewDescriptor.java	19 Dec 2004 07:17:07 -0000
    @@ -23,6 +23,8 @@
     import org.springframework.beans.factory.BeanInitializationException;
     import org.springframework.beans.factory.BeanNameAware;
     import org.springframework.beans.factory.InitializingBean;
    +import org.springframework.context.ApplicationContextAware;
    +import org.springframework.context.ApplicationEventPublisherAware;
     import org.springframework.context.ApplicationListener;
     import org.springframework.context.event.ApplicationEventMulticaster;
     import org.springframework.context.support.AbstractApplicationContext;
    @@ -97,9 +99,14 @@
                 }
                 getApplicationEventMulticaster().addApplicationListener((ApplicationListener)view);
             }
    -        if (viewProperties != null) {
    -            BeanWrapper wrapper = new BeanWrapperImpl(view);
    -            wrapper.setPropertyValues(viewProperties);
    +        setPropertyValues (view, viewProperties);
    +        
    +        if (view instanceof ApplicationEventPublisherAware) {
    +            ((ApplicationEventPublisherAware) view).setApplicationEventPublisher( getApplicationContext() );
    +        }
    +        
    +        if (view instanceof ApplicationContextAware) {
    +            ((ApplicationContextAware) view).setApplicationContext( getApplicationContext() );
             }
     
             if (view instanceof InitializingBean) {
    @@ -113,6 +120,13 @@
             return view;
         }
     
    +    protected void setPropertyValues( View view, Map properties ) {
    +        if (properties != null) {
    +            BeanWrapper wrapper = new BeanWrapperImpl(view);
    +            wrapper.setPropertyValues(properties);
    +        }
    +    }
    +
         public CommandButtonLabelInfo getShowViewCommandLabel() {
             return getLabel();
         }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •