org.springframework.extensions.surf.core.scripts
Class ScriptResourceHelper

java.lang.Object
  extended by org.springframework.extensions.surf.core.scripts.ScriptResourceHelper

public class ScriptResourceHelper
extends Object

Author:
Kevin Roast

Constructor Summary
ScriptResourceHelper()
           
 
Method Summary
static String resolveScriptImports(String script, ScriptResourceLoader loader, org.apache.commons.logging.Log logger)
          Resolve the import directives in the specified script.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScriptResourceHelper

public ScriptResourceHelper()
Method Detail

resolveScriptImports

public static String resolveScriptImports(String script,
                                          ScriptResourceLoader loader,
                                          org.apache.commons.logging.Log logger)
Resolve the import directives in the specified script. The implementation of the supplied ScriptResourceLoader instance is responsible for handling the resource retrieval.

Multiple includes of the same resource are dealt with correctly and nested includes of scripts is fully supported.

Note that for performance reasons the script import directive syntax and placement in the file is very strict. The import lines must always be first in the file - even before any comments. Immediately that the script service detects a non-import line it will assume the rest of the file is executable script and no longer attempt to search for any further import directives. Therefore all imports should be at the top of the script, one following the other, in the correct syntax and with no comments present - the only separators valid between import directives is white space.

Parameters:
script - The script content to resolve imports in
Returns:
a valid script with all nested includes resolved into a single script instance


Copyright © 2009 SpringSource, Inc. All Rights Reserved.