1 7 package com.inversoft.verge.mvc.controller.actionflow; 8 9 10 import java.util.ArrayList ; 11 import java.util.HashMap ; 12 import java.util.List ; 13 import java.util.Map ; 14 15 import com.inversoft.util.StringTools; 16 17 18 50 public class NodeExecutorRegistry { 51 52 private final static Map executors = new HashMap (); 53 private static ExceptionHandler exceptionHandler = new BaseExceptionHandler(); 54 55 58 public static final String ACTION_HANDLER_KEY = "actionHandler"; 59 60 63 public static final String PRESENTATION_KEY = "presentation"; 64 65 68 static { 69 register(ACTION_HANDLER_KEY, new ActionHandlerNodeExecutor()); 70 register(PRESENTATION_KEY, new PresentationNodeExecutor()); 71 } 72 73 74 77 private NodeExecutorRegistry() { 78 } 80 81 82 92 public static NodeExecutor register(String name, NodeExecutor executor) { 93 if (executor == null || name == null || StringTools.isEmpty(name)) { 94 throw new IllegalArgumentException ("The NodeExecutor and/or name are null or empty"); 95 } 96 97 return (NodeExecutor) executors.put(name, executor); 98 } 99 100 108 public static NodeExecutor unregister(String name) { 109 if (name == null || StringTools.isEmpty(name)) { 110 throw new IllegalArgumentException ("The name is null or empty"); 111 } 112 113 return (NodeExecutor) executors.remove(name); 114 } 115 116 124 public static NodeExecutor lookup(String name) { 125 if (name == null || StringTools.isEmpty(name)) { 126 throw new IllegalArgumentException ("The name is null or empty"); 127 } 128 129 return (NodeExecutor) executors.get(name); 130 } 131 132 139 public static List registeredNames() { 140 return new ArrayList (executors.keySet()); 141 } 142 143 150 public static List registeredExcutors() { 151 return new ArrayList (executors.values()); 152 } 153 154 159 public static ExceptionHandler lookupExceptionHandler() { 160 return exceptionHandler; 161 } 162 163 171 public static ExceptionHandler registerExceptionHandler( 172 ExceptionHandler newHandler) 173 { 174 ExceptionHandler old = exceptionHandler; 175 exceptionHandler = newHandler; 176 return old; 177 } 178 } 179 | Popular Tags |