Sunday, 15 June 2014

java - Spring 3.1.2: ApplicationEventPublisher not being set -



java - Spring 3.1.2: ApplicationEventPublisher not being set -

i have class defined this:

public class myclass extends simplechannelinboundhandler<dataframe<bytebuf>> implements applicationeventpublisheraware

(simplechannelinboundhandler io.netty class.)

then, in xml file define myclass this:

<bean id="myclass" class="com.mypackage.myclass" />

according documentation:

at configuration time, spring container observe emailservice implements applicationeventpublisheraware , automatically phone call setapplicationeventpublisher().

but it's null when run this.

any ideas why?

thanks

a mutual usage pattern applicationeventpublisheraware looks this:

package example; import org.springframework.stereotype.*; import org.springframework.context.*; @component public class mybean implements applicationeventpublisheraware { applicationeventpublisher applicationeventpublisher; public void setapplicationeventpublisher(applicationeventpublisher applicationeventpublisher) { system.out.println("publisher: " + applicationeventpublisher); this.applicationeventpublisher = applicationeventpublisher; } ... (use applicationeventpublisher in methods) }

you need create sure bean added context via component scan / configuration / <bean> tag, seek inject bean check that.

java spring applicationcontext

No comments:

Post a Comment