}
source = "Embedded script in message" ;
}
else
{
throw new ActionLifecycleException("'script' not configured on the action and message based scripting is not enabled ('supportMessageBasedScripting=false').");
}
}
else
{
InputStream scriptStream = null;
try
{
scriptStream = ClassUtil.getResourceAsStream(scriptPath, ScriptingAction.class);
if (scriptStream != null)
{
scriptStream = new BufferedInputStream(scriptStream);
script = new String( StreamUtils.readStream(scriptStream) );
}
else
{
throw new ActionLifecycleException("script '" + scriptPath + "' not found on classpath");
}
}
catch (Throwable t)
{
throw new ActionLifecycleException(t);
}
finally
{
try { if (scriptStream != null) scriptStream.close(); } catch (Throwable t) {}
}
source = scriptPath ;
}
this.source = source ;
// attempt to get the language
language = getAttribute("language");
if (language == null && script != null)
{
// the language attribute was not set but we found the script from the scriptPath,
// so deduce the extension from the scriptPath
int pos = scriptPath.lastIndexOf('.');
if (pos > -1 && pos < scriptPath.length()-1)
language = scriptPath.substring( pos+1, scriptPath.length() ).toLowerCase();
}
if (language != null)
{
if ( EXTN2LANG.containsKey(language) )
{
// either the user set the language property to the extension OR
// the language property was not set and we deduced the extension...
// either way, we now know two things:
// 1) we need to swap out the extension for the language
// 2) the language is already registered with BSF
language = EXTN2LANG.get(language);
}
else
{
// here we still need to make sure the language is registered with BSF
if ( !BSFManager.isLanguageRegistered(language) )
throw new ActionLifecycleException("language '" + language + "' not registered");
}
}
else
{
throw new ActionLifecycleException("language not specified");
}
}