-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathButterflyModule.java
More file actions
140 lines (80 loc) · 4.89 KB
/
ButterflyModule.java
File metadata and controls
140 lines (80 loc) · 4.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
package edu.mit.simile.butterfly;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.URL;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Timer;
import jakarta.servlet.ServletConfig;
import jakarta.servlet.ServletContext;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.apache.commons.collections.ExtendedProperties;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.VelocityEngine;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.Script;
import org.mozilla.javascript.Scriptable;
import edu.mit.simile.butterfly.ButterflyModuleImpl.Level;
/**
* This is the interface that defines what Butterfly modules behave and
* what functionality is made available to them.
*/
public interface ButterflyModule {
// -------------- Life Cycle --------------
public void init(ServletConfig config) throws Exception;
public void destroy() throws Exception;
public void initScope(Context context, Scriptable scope);
// -------------- Setters --------------
public void setClassLoader(ClassLoader classLoader);
public void setMounter(ButterflyMounter mounter);
public void setName(String name);
public void setPath(File path);
public void setMountPoint(MountPoint mountPoint);
public void setExtended(ButterflyModule extended);
public void addExtendedBy(ButterflyModule extender);
public void setImplementation(String id);
public void setDependency(String name, ButterflyModule module);
public void setModules(Map<String,ButterflyModule> map);
public void setScript(URL location, Script script);
public void setScriptable(ButterflyScriptableObject scriptable);
public void setTemplateEngine(VelocityEngine velocity);
public void setProperties(ExtendedProperties properties);
public void setTimer(Timer timer);
// -------------- Getters --------------
public ServletConfig getServletConfig();
public ServletContext getServletContext();
public String getName();
public ExtendedProperties getProperties();
public File getPath();
public MountPoint getMountPoint();
public ButterflyMounter getMounter();
public File getTemporaryDir();
public ButterflyModule getModule(String name);
public ButterflyModule getExtendedModule();
public Map<String,ButterflyModule> getDependencies();
public Set<String> getImplementations();
public Set<ButterflyScriptableObject> getScriptables();
public VelocityEngine getTemplateEngine();
public URL getResource(String name);
public String getRelativePath(HttpServletRequest request);
public PrintWriter getFilteringWriter(HttpServletRequest request, HttpServletResponse response, boolean absolute) throws IOException;
public String getString(HttpServletRequest request) throws Exception;
public String getContextPath(HttpServletRequest request, boolean absolute);
// -------------- Operation --------------
public boolean process(String path, HttpServletRequest request, HttpServletResponse response) throws Exception;
// -------------- Outward Methods --------------
public boolean redirect(HttpServletRequest request, HttpServletResponse response, String location) throws Exception;
public boolean sendBinary(HttpServletRequest request, HttpServletResponse response, String file, String mimeType) throws Exception;
public boolean sendBinary(HttpServletRequest request, HttpServletResponse response, URL resource, String mimeType) throws Exception;
public boolean sendText(HttpServletRequest request, HttpServletResponse response, String file, String encoding, String mimeType, boolean absolute) throws Exception;
public boolean sendText(HttpServletRequest request, HttpServletResponse response, URL resource, String encoding, String mimeType, boolean absolute) throws Exception;
public boolean sendWrappedText(HttpServletRequest request, HttpServletResponse response, URL resource, String encoding, String mimeType, String prologue, String epilogue, boolean absolute) throws Exception;
public boolean sendTextFromTemplate(HttpServletRequest request, HttpServletResponse response, VelocityContext velocity, String template, String encoding, String mimeType, boolean absolute) throws Exception;
public boolean sendString(HttpServletRequest request, HttpServletResponse response, String str, String encoding, String mimeType) throws Exception;
public boolean sendError(HttpServletRequest request, HttpServletResponse response, int code, String str) throws Exception;
// -------------- Utility Methods -----------------
public List<Level> makePath(String path, Map<String,String> descs);
}