KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > graph > action > ActionTypes


1 package org.jbpm.graph.action;
2
3 import java.util.HashMap JavaDoc;
4 import java.util.Map JavaDoc;
5 import java.util.Set JavaDoc;
6
7 import org.apache.commons.logging.Log;
8 import org.apache.commons.logging.LogFactory;
9 import org.jbpm.graph.def.Action;
10 import org.jbpm.graph.node.NodeTypes;
11 import org.jbpm.scheduler.def.CancelTimerAction;
12 import org.jbpm.scheduler.def.CreateTimerAction;
13
14
15 public class ActionTypes {
16
17   public static Set JavaDoc getActionTypes() {
18     return actionNames.keySet();
19   }
20   
21   public static Set JavaDoc getActionNames() {
22     return actionTypes.keySet();
23   }
24   
25   public static Class JavaDoc getActionType(String JavaDoc name) {
26     return (Class JavaDoc) actionTypes.get(name);
27   }
28   
29   public static String JavaDoc getActionName(Class JavaDoc type) {
30     return (String JavaDoc) actionNames.get(type);
31   }
32
33   public static boolean hasActionName(String JavaDoc name) {
34     return actionTypes.containsKey(name);
35   }
36
37   private static final Log log = LogFactory.getLog(ActionTypes.class);
38   private static Map JavaDoc actionTypes = initialiseActionTypes();
39   private static Map JavaDoc actionNames = NodeTypes.createInverseMapping(actionTypes);
40   
41   private static Map JavaDoc initialiseActionTypes() {
42     Map JavaDoc types = new HashMap JavaDoc();
43     types.put("action", Action.class);
44     types.put("create-timer", CreateTimerAction.class);
45     types.put("cancel-timer", CancelTimerAction.class);
46     try {
47       types.put("script", Script.class);
48     // if the beanshell lib is not in the class path
49
// this throws a NoClassDefFoundException
50
} catch (Throwable JavaDoc t) {
51       log.debug("no beanshell lib present, disabling script actions");
52     }
53     return types;
54   }
55 }
56
Popular Tags