Permalink
Browse files

updated some configuration and adding a jetty distribution so folks c…

…an try it out of the box.
  • Loading branch information...
1 parent 976b547 commit 46f475beb5d8bc31db8500d98fc747798057cd67 thatcher committed Mar 11, 2010
View
@@ -1 +1,4 @@
+*~
.project
+server/logs/*.log
+server/logs/*.log.*
View
@@ -28,5 +28,5 @@ h2. Building:
h3. Related Technology Links
-"Rhino - Java-based JavaScript engin)":http://www.mozilla.org/rhino/
+"Rhino - Java-based JavaScript engine":http://www.mozilla.org/rhino/
Binary file not shown.
@@ -44,18 +44,9 @@ public RequestHandler( Shell shell, String dispatchMethod, ServletContext servl
public boolean processRequest(HttpServletRequest request, HttpServletResponse response) throws IOException
{
try{
- // ---------------------------------------------------------------------
- // STEP 0: if GET request then look for a static file first.
- // In production this step would be accomplished better by a proxy server
- // eg. nginx or Apache's httpd
- // ---------------------------------------------------------------------
-
- // ...
-
-
// ---------------------------------------------------------------------
- // STEP 1: prepare JavaScript request object from the Java request object and
+ // prepare JavaScript request object from the Java request object and
// create an empty response object that the JavaScript web framework and web app
// will populate. You could send the Java request and response objects
// to the JavaScript since Rhino allows mixing Java objects directly in
@@ -198,31 +189,38 @@ public boolean processRequest(HttpServletRequest request, HttpServletResponse re
int contentLength = -1;
String contentType = "text/html";
//TODO: Why the heck 1!!!
- for(int i = 1; i < responseHeadersFields.length; i++){
- String responseHeaderValue = Context.toString(
- ScriptableObject.getProperty(
- responseHeaders,
- responseHeadersFields[i].toString()
- )
- );
- logger.debug("Adding Header: " + responseHeadersFields[i] );
- logger.debug("Header Value: " + responseHeaderValue );
- if(!responseHeadersFields[i].toString().equalsIgnoreCase("")){
- if(responseHeadersFields[i].toString().equalsIgnoreCase("Content-Length")){
- logger.debug("contentLength : " + responseHeaderValue);
- contentLength = Integer.parseInt(responseHeaderValue.replace(" ",""));
- }else if(responseHeadersFields[i].toString().equalsIgnoreCase("Content-Type")){
- logger.debug("contentType : " + responseHeaderValue);
- contentType = responseHeaderValue;
- }
- response.addHeader(
- responseHeadersFields[i].toString(),
- Context.toString(
- ScriptableObject.getProperty(
- responseHeaders,
- responseHeadersFields[i].toString())
- ));
- }
+ for(int i = 0; i < responseHeadersFields.length; i++){
+ try{
+ String responseHeaderValue = Context.toString(
+ ScriptableObject.getProperty(
+ responseHeaders,
+ responseHeadersFields[i].toString()
+ )
+ );
+ logger.debug("Adding Header: " + responseHeadersFields[i] );
+ logger.debug("Header Value: " + responseHeaderValue );
+ if(!responseHeadersFields[i].toString().equalsIgnoreCase("")){
+ if(responseHeadersFields[i].toString().equalsIgnoreCase("Content-Length")){
+ logger.debug("contentLength : " + responseHeaderValue);
+ contentLength = Integer.parseInt(responseHeaderValue.replace(" ",""));
+ response.setContentLength(contentLength);
+ }else if(responseHeadersFields[i].toString().equalsIgnoreCase("Content-Type")){
+ logger.debug("contentType : " + responseHeaderValue);
+ contentType = responseHeaderValue;
+ response.setContentType(contentType);
+ }else{
+ response.addHeader(
+ responseHeadersFields[i].toString(),
+ Context.toString(
+ ScriptableObject.getProperty(
+ responseHeaders,
+ responseHeadersFields[i].toString())
+ ));
+ }
+ }
+ }catch(Exception e){
+ logger.debug(e);
+ }
}
if(contentType.indexOf("image") > -1){
byte[] body = (byte[])Context.toType(
Binary file not shown.
@@ -21,13 +21,13 @@
*/
public class Servlet extends HttpServlet {
- //protected ThreadLocal threadRequestHandler;
- //protected RequestHandler requestHandler = null;
- protected String shellFile;//applicationContainer;
- protected String dispatchFunction;//applicationLocation;
- protected String base;//applicationBasePath;
- protected String contextPath;//applicationBasePath;
+ protected String shellFile;
+ protected String dispatchFunction;
+ protected String base;
+ protected String contextPath;
protected String activeReload;
+ protected String applicationContext;
+ protected String optimizationLevel;
private Shell shell;
private RequestHandler requestHandler;
@@ -46,6 +46,7 @@ public void init(ServletConfig config) throws ServletException {
this.activeReload = config.getInitParameter("active-reload")!=null?
config.getInitParameter("active-reload"):
"true";
+ this.optimizationLevel = config.getInitParameter("opt-level");
if(this.shell == null){
//load global shell
@@ -59,13 +60,17 @@ public void init(ServletConfig config) throws ServletException {
log("APPLICATION DISPATCH METHOD : " + this.dispatchFunction);
getServletConfig().getServletContext().
log("APPLICATION ACTIVE RELOAD : " + this.activeReload);
+ getServletConfig().getServletContext().
+ log("APPLICATION OPT LEVEL : " + this.optimizationLevel);
// load the JavaScript files for the web app framework and
// the files for the specific web app.
this.shell = new Shell(
this.contextPath,
this.base,
this.shellFile,
- this.activeReload );
+ this.activeReload,
+ this.optimizationLevel
+ );
}catch (Exception ee) {
getServletConfig().getServletContext().
log(ee.toString());
@@ -84,9 +89,12 @@ public void init(ServletConfig config) throws ServletException {
}
/* (non-Javadoc)
- * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+ * @see javax.servlet.http.HttpServlet#doGet(
+ * javax.servlet.http.HttpServletRequest,
+ * javax.servlet.http.HttpServletResponse)
*/
- protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ protected void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
getServletConfig().getServletContext().
log("CONTEXT PATHNAME : " + request.getContextPath());
@@ -110,33 +118,48 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t
}
}
/* (non-Javadoc)
- * @see javax.servlet.http.HttpServlet#doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+ * @see javax.servlet.http.HttpServlet#doPost(
+ * javax.servlet.http.HttpServletRequest,
+ * javax.servlet.http.HttpServletResponse)
*/
- protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
+ protected void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException{
doGet(request, response);
}
/* (non-Javadoc)
- * @see javax.servlet.http.HttpServlet#doPut(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+ * @see javax.servlet.http.HttpServlet#doPut(
+ * javax.servlet.http.HttpServletRequest,
+ * javax.servlet.http.HttpServletResponse)
*/
- protected void doPut(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
+ protected void doPut(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException{
doGet(request, response);
}
/* (non-Javadoc)
- * @see javax.servlet.http.HttpServlet#doDelete(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+ * @see javax.servlet.http.HttpServlet#doDelete(
+ * javax.servlet.http.HttpServletRequest,
+ * javax.servlet.http.HttpServletResponse)
*/
- protected void doDelete(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
+ protected void doDelete(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException{
doGet(request, response);
}
/* (non-Javadoc)
- * @see javax.servlet.http.HttpServlet#doHead(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+ * @see javax.servlet.http.HttpServlet#doHead(
+ * javax.servlet.http.HttpServletRequest,
+ * javax.servlet.http.HttpServletResponse)
*/
- protected void doHead(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
+ protected void doHead(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException{
doGet(request, response);
}
/* (non-Javadoc)
- * @see javax.servlet.http.HttpServlet#doOptions(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+ * @see javax.servlet.http.HttpServlet#doOptions(
+ * javax.servlet.http.HttpServletRequest,
+ * javax.servlet.http.HttpServletResponse)
*/
- protected void doOptions(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
+ protected void doOptions(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException{
doGet(request, response);
}
Binary file not shown.
@@ -32,8 +32,10 @@
private String contextPath;
private String activeReload;
private FileMonitor monitor;
+ private String optimizationLevel;
- public Shell(String contextPath, String basePath, String appFile, String activeReload) {
+ public Shell(String contextPath, String basePath, String appFile, String activeReload,
+ String optimizationLevel) {
this.contextPath = contextPath;
this.basePath = basePath;
this.activeReload = activeReload;
@@ -46,6 +48,11 @@ public Shell(String contextPath, String basePath, String appFile, String activeR
}
cx = Context.enter();
cx.initStandardObjects(this);
+ this.optimizationLevel = optimizationLevel;
+ if(this.optimizationLevel != null){
+ if(this.optimizationLevel == "-1")
+ cx.setOptimizationLevel(-1);
+ }
// host objects --------------
// Give easy access to the global object by making a global property named "global".
@@ -6,9 +6,9 @@ var dispatch_envjs = function(request, response){
context_path =
request.attributes['javax.servlet.forward.context_path']||
- 'rhino-for-webapps';
+ cwd;
- print("\n\t<-@Dispatching request for envjs example@->\n");
+ print("\n\t<-@Dispatching request for envjs example@->\n" + context_path);
if(request.parameters.request){
window.request = request;
View
@@ -8,7 +8,7 @@
<servlet-class>claypool.server.Log4jInit</servlet-class>
<init-param>
<param-name>log4j-init-file</param-name>
- <param-value>WEB-INF/logging.conf</param-value>
+ <param-value>/WEB-INF/logging.conf</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
View
@@ -8,7 +8,7 @@
<property description="major release number" name="major" value="0" />
<property description="minor release number" name="minor" value="4" />
- <property description="build number" name="number" value="5" />
+ <property description="build number" name="number" value="7" />
<property description="build id" name="build_id" value="${major}.${minor}.${number}" />
<property description="Java Jars" name="JAVA_LIB_DIR" location="WEB-INF/lib" />
View
Binary file not shown.
View
Binary file not shown.

0 comments on commit 46f475b

Please sign in to comment.