package com.eactive.eai.adapter.app;

import java.util.concurrent.ConcurrentHashMap;

public class BusinessApplicationFactory {
	static private ConcurrentHashMap<String, BusinessApplication> h = new ConcurrentHashMap<String, BusinessApplication>();

	@SuppressWarnings("rawtypes")
	public static BusinessApplication createApplication(String className) throws Exception {
		if (h.containsKey(className)) {
			return (BusinessApplication) h.get(className);
		}

		BusinessApplication app = null;
		try {
			Class cl = Class.forName(className);
			app = (BusinessApplication) cl.newInstance();
			if (app != null) {
				h.put(className, app);
			}
		} catch (Exception e) {
			throw new Exception("Cannot create a BusinessApplication. - " + className);
		}
		return app;
	}
}
