You're thinking way too complex thoughts :)
/*
* created: Sep 23, 2003
* by: wtg
*/
package nl.wtg;
import java.util.Map;
import java.util.ResourceBundle;
/**
* @author wtg
*/
public class HandlerFactory
{
private static HandlerFactory instance = null;
private static ResourceBundle handlers = null;
private HandlerFactory()
{
handlers = ResourceBundle.getBundle("nl.wtg.handlers");
}
public static void resetFactory()
{
handlers = null;
instance = null;
}
/**
* retrieve the HandlerFactory
* @return the HandlerFactory
*/
public static synchronized HandlerFactory getInstance()
{
if (instance == null)
{
instance = new HandlerFactory();
}
return instance;
}
/**
* Retrieve a Handler. Add additional handler classes to resourcebundle<br />
* nl.wtg.handlers and restart application<br />
* All Handlers should derive directly or indirectly from <br />
* {@link nl.wtg.AbstractHandler AbstractHandler}
* @param handlerName name of the Handler to retrieve
* @param params further parameters to pass to the init function
* @return Handler Object of the correct type
*/
public AbstractHandler getHandler(String handlerName, Object params)
{
AbstractHandler h = null;
try
{
h = (AbstractHandler)Class.forName(handlers.getString(handlerName)).newInstance();
}
catch (InstantiationException e)
{
throw new UnsupportedOperationException("unsupporter Handler " + handlerName + ": " + e.getMessage());
}
catch (IllegalAccessException e)
{
throw new UnsupportedOperationException("unsupporter Handler " + handlerName + ": " + e.getMessage());
}
catch (ClassNotFoundException e)
{
throw new UnsupportedOperationException("error instantiating Handler " + handlerName + ": " + e.getMessage());
}
h.init(params);
return h;
}
}
/*
* created: Sep 26, 2003
* by: wtg
*/
package nl.wtg;
import java.util.Map;
/**
* @author wtg
*/
public …