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

org.zkoss.bind.proxy.ZKProxyTargetHandlers Maven / Gradle / Ivy

There is a newer version: 10.0.0-jakarta
Show newest version
/** ZKProxyTargetHandlers.java.

	Purpose:

	Description:

	History:
 Tue Apr 19 16:12:31 CST 2016, Created by jameschu

Copyright (C) 2015 Potix Corporation. All Rights Reserved.
*/
package org.zkoss.bind.proxy;

import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.zkoss.bind.init.ZKBinderPhaseListeners;
import org.zkoss.zk.ui.util.AggregationListener;

/**
 * An aggregating proxy target handlers
 * @author jameschu
 * @since 8.0.2
 * @see ProxyTargetHandler
 */
public class ZKProxyTargetHandlers implements AggregationListener {
	private static final Logger _log = LoggerFactory.getLogger(ZKBinderPhaseListeners.class);
	private static Map _handlers = new LinkedHashMap();

	public boolean isHandled(Class klass) {
		if (ProxyTargetHandler.class.isAssignableFrom(klass)) {
			try {
				synchronized (_handlers) {
					if (!_handlers.containsKey(klass.getName())) {
						_handlers.put(klass.getName(), (ProxyTargetHandler) klass.newInstance());
					}
				}
			} catch (Exception e) {
				_log.error("Error when initial proxy target handler:" + klass, e);
			}
			return true;
		}
		return false;
	}

	/**
	 * Returns all of the system proxy target handlers
	 */
	public static List getSystemProxyTargetHandlers() {
		Collection values;
		synchronized (_handlers) {
			values = _handlers.values();
		}
		return new LinkedList(values);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy