Package com.dtikhonov.publishers.impl

Source Code of com.dtikhonov.publishers.impl.ApplicationEventAwarePublisher

package com.dtikhonov.publishers.impl;

import com.dtikhonov.messages.MyMessageEvent;
import com.dtikhonov.publishers.MyPublisherInterface;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;

/**
* Created by dtikhonov on 26/05/14.
*/
public class ApplicationEventAwarePublisher implements ApplicationEventPublisherAware, BeanNameAware,
        MyPublisherInterface {


    private String beanName = "Unknown Bean";

    private ApplicationEventPublisher eventPublisher;

    /**
     * Implementation of the BeanNameAware interface
     */
    public void setBeanName(String name) {

        this.beanName = name;
    }

    /**
     * This is the implementation of the MyPublisherInterface
     */
    public void publish(String messageToPublish) {
        eventPublisher.publishEvent(new MyMessageEvent(this, messageToPublish));
    }

    /**
     * @see org.springframework.context.ApplicationEventPublisherAware#setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher)
     */
    @Override
    public void setApplicationEventPublisher(ApplicationEventPublisher publisher) {
        this.eventPublisher = publisher;
    }
}
TOP

Related Classes of com.dtikhonov.publishers.impl.ApplicationEventAwarePublisher

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.