// Create a list of the custom Commons SCXML actions defined by the
// Shale dialog Commons SCXML implementation
List shaleDialogActions = new ArrayList();
// <shale:redirect>
CustomAction redirectAction =
new CustomAction(Globals.CUSTOM_SCXML_ACTIONS_URI,
"redirect", RedirectAction.class);
shaleDialogActions.add(redirectAction);
// <shale:view>
CustomAction viewAction =
new CustomAction(Globals.CUSTOM_SCXML_ACTIONS_URI,
"view", ViewAction.class);
shaleDialogActions.add(viewAction);
// Class loader for app developer defined custom Commons SCXML actions
ClassLoader loader = Thread.currentThread().getContextClassLoader();
if (loader == null) {
loader = ConfigurationParser.class.getClassLoader();
}
while (iterator.hasNext()) {
Map.Entry entry = (Map.Entry) iterator.next();
String name = (String) entry.getKey();
DialogMetadata dMetadata = (DialogMetadata) entry.getValue();
String scxmlconfig = dMetadata.getScxmlconfig();
// The custom actions available to this dialog is the
// summation of the ones defined by this Shale dialog module
// and those defined by the app developer using the dialog
// configuration file for this dialog
List customDialogActions = new ArrayList();
customDialogActions.addAll(shaleDialogActions);
List devActions = dMetadata.getDialogActions();
for (int i = 0; i < devActions.size(); i++) {
SCXMLAction scxmlAction = (SCXMLAction) devActions.get(i);
String actionname = scxmlAction.getName();
String uri = scxmlAction.getUri();
String actionFQCN = scxmlAction.getActionclassname();
if (actionname == null || uri == null || actionFQCN == null) {
// shouldn't happen if dialog-config is validated
throw new IllegalArgumentException("A custom Commons"
+ " SCXML action (<scxmlaction> element) in the"
+ " dialog configuration is missing the 'name',"
+ " 'uri' or 'actionclassname'");
}
Class customActionClass = null;
try {
customActionClass = loader.loadClass(actionFQCN);
} catch (Exception e) {
throw new IllegalArgumentException("Cannot load "
+ "custom Commons SCXML action class '"
+ actionFQCN + "' for action with name '"
+ actionname + "'");
}
CustomAction customAction = new CustomAction(uri,
actionname, customActionClass);
customDialogActions.add(customAction);
}
URL resource = new URL(getResource(), scxmlconfig);