Registry.java 968 Bytes
package se.lil.om;

import java.util.ArrayList;

public class Registry {
	private static ArrayList<OraMon> oraList = null;
	public static boolean test = true;
	
	public static synchronized ArrayList<OraMon> getList() {
		if (oraList == null) {
			oraList = new ArrayList<OraMon>();
		}
		return oraList;
	}
	
	public static synchronized OraMon findOrCreate(String conStr, String usrStr, String pwdStr) {
		for (OraMon item : getList()) {
			if(item.getConString().equals(conStr)) {
				return item;
			}
		}
		// Not found, create it
		OraMon monitor = new OraMon(conStr, usrStr, pwdStr);
		oraList.add(monitor);
		return monitor;
	}
	
	public static synchronized void remove(String conStr) {
		OraMon mon = null;
		for (OraMon item : getList()) {
			if(item.getConString().equals(conStr)) {
				mon = item;
			}
		}
		if(mon != null) {
			try {
				mon.close();
			} catch (Throwable t) {}
			getList().remove(mon);
		}
	}
}