@Override
protected Action getAction(ActionContext context, String type, ActionConfig actionConfig) throws Exception
{
String className = type;
Action action = null;
ModuleConfig moduleConfig = actionConfig.getModuleConfig();
String actionsKey = Constants.ACTIONS_KEY + moduleConfig.getPrefix();
final Map applicationScope = context.getApplicationScope();
Map<String, Action> actions = (Map<String, Action>) applicationScope.get(actionsKey);
if (actions == null)
{
actions = new HashMap<String, Action>();
applicationScope.put(actionsKey, actions);
}
boolean isNew = false;
synchronized (actions)
{
action = (Action) actions.get(className);
if (action == null)
{
// load the action class
Class clazz = Class.forName(className);
// delegate action creation to ActionCreator
action = actionCreator.createAction(clazz);
isNew = true;
}
if (isNew)
{
actions.put(className, action);
if (action.getServlet() == null)
{
ServletActionContext saContext = (ServletActionContext) context;
ActionServlet actionServlet = saContext.getActionServlet();
action.setServlet(actionServlet);
}
}
}
return action;
}