package com.doctor.esper.common;

import java.util.ArrayList;
import java.util.List;

import com.espertech.esper.client.Configuration;
import com.espertech.esper.client.EPServiceProvider;
import com.espertech.esper.client.EPServiceProviderManager;
import com.espertech.esper.client.EPStatement;
import com.espertech.esper.client.EventBean;
import com.espertech.esper.client.SafeIterator;

/**
 * @author docotr
 *
 * @time 2015年6月1日 下午4:28:33
 */
public enum EsperUtil {
	;
	public static List<EventBean> get(EPStatement epStatement) {
		List<EventBean> list = new ArrayList<>();
		SafeIterator<EventBean> safeIterator = epStatement.safeIterator();
		try {
			while (safeIterator.hasNext()) {
				list.add(safeIterator.next());
			}
		} catch (Throwable e) {
			safeIterator.close();
			e.printStackTrace();
		} finally {
			safeIterator.close();
		}
		return list;
	}

	public static EPServiceProvider esperConfig(String config) {
		Configuration configuration = new Configuration();
		configuration.configure(EsperUtil.class.getClassLoader().getResource(config));
		return EPServiceProviderManager.getDefaultProvider(configuration);
	}
}

@@ -863,16 +863,471 @@
 st;%0A%09%7D%0A%0A
+%09/**%0A%09 * @see 15.2. The Service Provider Interface%0A%09 * %0A%09 *      EPServiceProvider%E5%B0%B1%E4%BB%A3%E8%A1%A8%E4%B8%80%E4%B8%AAesper%E5%BC%95%E6%93%8E%E5%AE%9E%E4%BE%8B%E3%80%82 %E4%B8%80%E4%B8%AAesper%E5%BC%95%E6%93%8E%E7%9A%84%E5%AE%9E%E4%BE%8B%E4%B8%8E%E5%85%B6%E5%AE%83%E5%BC%95%E6%93%8E%E7%9A%84%E5%AE%9E%E4%BE%8B%E6%98%AF%E6%B2%A1%E6%9C%89%E5%85%B3%E8%81%94%E6%80%A7%E7%9A%84%EF%BC%88%E7%8B%AC%E7%AB%8B%E6%80%A7%EF%BC%89%E3%80%82%0A%09 *      %E6%AF%8F%E4%B8%AA%E5%BC%95%E6%93%8E%E7%9A%84%E5%AE%9E%E4%BE%8B%E9%83%BD%E6%9C%89%E8%87%AA%E5%B7%B1%E7%9A%84administrative and runtime interface.%0A%09 *      %E4%B8%80%E4%B8%AA%E5%BC%95%E6%93%8E%E7%9A%84%E5%AE%9E%E4%BE%8B%E6%9C%89%E8%AE%B8%E5%A4%9A%E4%B8%AA%EF%BC%8C%E8%8E%B7%E5%BE%97%E5%AE%9E%E4%BE%8B%E7%9A%84EPServiceProviderManager%E6%96%B9%E6%B3%95%E4%B8%BAgetDefaultProvider%E5%92%8CgetProvider(String providerURI)%E3%80%82%0A%09 *      %E5%90%8E%E8%80%85%E5%8F%AF%E4%BB%A5%E7%94%A8%E4%BA%8E%E6%A0%B9%E6%8D%AE%E4%B8%8D%E5%90%8C%E7%9A%84%E8%8E%B7%E5%BE%97providerURI%EF%BC%8C%E5%BC%95%E6%93%8E%E5%8F%AF%E4%BB%A5%E7%94%9F%E6%88%90%E4%B8%8D%E5%90%8C%E5%AE%9E%E4%BE%8B%E3%80%82EPServiceProviderManager%E6%A0%B9%E6%8D%AEproviderURI%E5%AD%98%E5%9C%A8%E4%B8%8E%E5%90%A6%EF%BC%8C%0A%09 *      %E8%8E%B7%E5%8F%96%E5%B7%B2%E7%BB%8F%E5%AD%98%E5%9C%A8%E7%9A%84%E5%AE%9E%E4%BE%8B%E6%88%96%E8%80%85%E6%96%B0%E7%9A%84%E5%AE%9E%E4%BE%8B%E3%80%82%0A%09 * %0A%09 * %0A%09 * @param config%0A%09 * @return%0A%09 */%0A
 %09public 

add 15.2. comment The Service Provider Interface