Package edu.mit.simile.butterfly
Class Butterfly
- java.lang.Object
-
- javax.servlet.GenericServlet
-
- javax.servlet.http.HttpServlet
-
- edu.mit.simile.butterfly.Butterfly
-
- All Implemented Interfaces:
Serializable,javax.servlet.Servlet,javax.servlet.ServletConfig
public class Butterfly extends javax.servlet.http.HttpServletThis is the Butterfly servlet and the main entry point for a Butterfly-powered web application. This servlet is responsible for loading, configuring and wire together the various modules that compose your webapp and then manages the dispatching of requests to the modules that are supposed to handle them.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected ButterflyClassLoader_classLoaderprotected javax.servlet.ServletConfig_configprotected Exception_configurationExceptionprotected boolean_configuredprotected javax.servlet.ServletContext_contextprotected File_contextDirprotected Map<String,Boolean>_createdprotected File_homeDirprotected Map<String,org.apache.commons.collections.ExtendedProperties>_modulePropertiesprotected Map<String,Map<String,ButterflyModule>>_modulesByInterfaceprotected Map<String,ButterflyModule>_modulesByNameprotected ButterflyMounter_mounterprotected org.apache.commons.collections.ExtendedProperties_propertiesprotected edu.mit.simile.butterfly.ButterflyScriptWatcher_scriptWatcherprotected Timer_timerprotected File_webInfDirstatic StringAPPENGINEstatic StringAUTORELOADstatic StringBASE_URLstatic StringCONTEXT_HEADERprotected org.mozilla.javascript.ContextFactorycontextFactorystatic StringDEFAULT_MOUNTPOINTstatic StringDEFAULT_ZONEstatic StringHOMEstatic StringHOST_HEADERstatic StringMAIN_ZONEstatic StringMODULES_IGNOREstatic StringMODULES_PATHstatic StringNAMEprotected static StringPATH_PROPstatic StringZONE
-
Constructor Summary
Constructors Constructor Description Butterfly()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Fileabsolutize(File base, String location)voidconfigure()protected voidconfigureModules()protected ButterflyModulecreateModule(String name)protected voiddelay(javax.servlet.http.HttpServletResponse response, String title)voiddestroy()protected voiderror(javax.servlet.http.HttpServletResponse response, String title, String msg, Exception e)protected voidfindModulesIn(File f)static StringgetFullHost(javax.servlet.http.HttpServletRequest request)static StringgetTrueContextPath(javax.servlet.http.HttpServletRequest request, boolean absolute)static StringgetTrueHost(javax.servlet.http.HttpServletRequest request)static StringgetTrueRequestURI(javax.servlet.http.HttpServletRequest request, boolean absolute)voidinit(javax.servlet.ServletConfig config)protected voidinitializeModule(String name, Set<String> initialized, Set<String> initializing)static booleanisGAE(javax.servlet.ServletConfig config)voidservice(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)protected voidsetDependency(ButterflyModule subj, String dep, ButterflyModule obj)protected voidsetRoutingCookie(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)protected static voidsetScript(ButterflyModule mod, URL location, org.mozilla.javascript.Script script)protected voidsetScriptable(ButterflyModule mod, ButterflyScriptableObject scriptable)protected voidwatch(URL script, ButterflyModule module)protected voidwireModules(org.apache.commons.collections.ExtendedProperties wirings)-
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service
-
-
-
-
Field Detail
-
HOST_HEADER
public static final String HOST_HEADER
- See Also:
- Constant Field Values
-
CONTEXT_HEADER
public static final String CONTEXT_HEADER
- See Also:
- Constant Field Values
-
NAME
public static final String NAME
- See Also:
- Constant Field Values
-
APPENGINE
public static final String APPENGINE
- See Also:
- Constant Field Values
-
AUTORELOAD
public static final String AUTORELOAD
- See Also:
- Constant Field Values
-
HOME
public static final String HOME
- See Also:
- Constant Field Values
-
ZONE
public static final String ZONE
- See Also:
- Constant Field Values
-
BASE_URL
public static final String BASE_URL
- See Also:
- Constant Field Values
-
DEFAULT_ZONE
public static final String DEFAULT_ZONE
- See Also:
- Constant Field Values
-
DEFAULT_MOUNTPOINT
public static final String DEFAULT_MOUNTPOINT
- See Also:
- Constant Field Values
-
MODULES_IGNORE
public static final String MODULES_IGNORE
- See Also:
- Constant Field Values
-
MODULES_PATH
public static final String MODULES_PATH
- See Also:
- Constant Field Values
-
MAIN_ZONE
public static final String MAIN_ZONE
- See Also:
- Constant Field Values
-
_timer
protected transient Timer _timer
-
_classLoader
protected transient ButterflyClassLoader _classLoader
-
_scriptWatcher
protected transient edu.mit.simile.butterfly.ButterflyScriptWatcher _scriptWatcher
-
_config
protected transient javax.servlet.ServletConfig _config
-
_context
protected transient javax.servlet.ServletContext _context
-
_mounter
protected transient ButterflyMounter _mounter
-
_properties
protected org.apache.commons.collections.ExtendedProperties _properties
-
_contextDir
protected File _contextDir
-
_homeDir
protected File _homeDir
-
_webInfDir
protected File _webInfDir
-
_configurationException
protected Exception _configurationException
-
_configured
protected boolean _configured
-
contextFactory
protected org.mozilla.javascript.ContextFactory contextFactory
-
_modulesByName
protected Map<String,ButterflyModule> _modulesByName
-
_modulesByInterface
protected Map<String,Map<String,ButterflyModule>> _modulesByInterface
-
_moduleProperties
protected Map<String,org.apache.commons.collections.ExtendedProperties> _moduleProperties
-
PATH_PROP
protected static final String PATH_PROP
- See Also:
- Constant Field Values
-
-
Method Detail
-
getTrueHost
public static String getTrueHost(javax.servlet.http.HttpServletRequest request)
-
getTrueContextPath
public static String getTrueContextPath(javax.servlet.http.HttpServletRequest request, boolean absolute)
-
getTrueRequestURI
public static String getTrueRequestURI(javax.servlet.http.HttpServletRequest request, boolean absolute)
-
getFullHost
public static String getFullHost(javax.servlet.http.HttpServletRequest request)
-
isGAE
public static boolean isGAE(javax.servlet.ServletConfig config)
-
init
public void init(javax.servlet.ServletConfig config) throws javax.servlet.ServletException- Specified by:
initin interfacejavax.servlet.Servlet- Overrides:
initin classjavax.servlet.GenericServlet- Throws:
javax.servlet.ServletException
-
destroy
public void destroy()
- Specified by:
destroyin interfacejavax.servlet.Servlet- Overrides:
destroyin classjavax.servlet.GenericServlet
-
configure
public void configure()
-
initializeModule
protected void initializeModule(String name, Set<String> initialized, Set<String> initializing)
-
service
public void service(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException- Overrides:
servicein classjavax.servlet.http.HttpServlet- Throws:
javax.servlet.ServletExceptionIOException
-
setRoutingCookie
protected void setRoutingCookie(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
-
findModulesIn
protected void findModulesIn(File f)
-
createModule
protected ButterflyModule createModule(String name)
-
wireModules
protected void wireModules(org.apache.commons.collections.ExtendedProperties wirings)
-
configureModules
protected void configureModules()
-
setDependency
protected void setDependency(ButterflyModule subj, String dep, ButterflyModule obj)
-
setScriptable
protected void setScriptable(ButterflyModule mod, ButterflyScriptableObject scriptable)
-
watch
protected void watch(URL script, ButterflyModule module) throws IOException
- Throws:
IOException
-
delay
protected void delay(javax.servlet.http.HttpServletResponse response, String title) throws IOException- Throws:
IOException
-
error
protected void error(javax.servlet.http.HttpServletResponse response, String title, String msg, Exception e) throws IOException- Throws:
IOException
-
setScript
protected static void setScript(ButterflyModule mod, URL location, org.mozilla.javascript.Script script)
-
-