All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.anotheria.anoprise.eventservice.EventChannelPushSupplierProxy Maven / Gradle / Ivy

Go to download

Collection of utils for different enterprise class projects. Among other stuff contains Caches, Mocking, DualCrud, MetaFactory and SessionDistributorService. Visit https://opensource.anotheria.net for details.

There is a newer version: 4.0.0
Show newest version
package net.anotheria.anoprise.eventservice;

import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;



/**
 * TODO Please remind lrosenberg to comment this class.
 * @author lrosenberg
 * Created on 22.09.2004
 */
public class EventChannelPushSupplierProxy extends AbstractEventChannel 
		implements EventChannelSupplierProxy{

	private List consumerProxies;
	
	
	public EventChannelPushSupplierProxy(String name){
		super(name);
		consumerProxies = new CopyOnWriteArrayList();
	}
	
	

	public void addConsumer(EventServiceConsumer consumer) {
		throw new UnsupportedOperationException("addConsumer");
	}

	public void push(Event e) {
		push(e, false);			
	}
	
	protected void push(Event e, boolean localOnly){
		for (EventChannelConsumerProxy proxy : consumerProxies){
			if (localOnly && (!proxy.isLocal())){
				log.debug("Skiping proxy: "+proxy);
			}else{
				//log.debug("delivering to proxy: "+proxy);
				try{
					proxy.pushEvent(e); 
				}catch(Exception ex){
					log.error("pushEvent("+e+")", ex);
				}
			}
		}
	}

	public void removeConsumer(EventServiceConsumer consumer) {
		throw new UnsupportedOperationException("removeConsumer");
	}
	

	public void addConsumerProxy(EventChannelConsumerProxy proxy) {
		out("Added consumer proxy: "+proxy);
		consumerProxies.add(proxy);
	}

	public void removeConsumerProxy(EventChannelConsumerProxy proxy) {
		consumerProxies.remove(proxy);
	}
	
	@Override
	public String toString(){
		return "PushSupplierProxy "+getName()+", connected to:"+consumerProxies;
	}
	

	public boolean isLocal() {
		return true;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy