Skip to content

Commit

Permalink
work in progress
Browse files Browse the repository at this point in the history
Signed-off-by: Greg Wilkins <[email protected]>
  • Loading branch information
gregw committed Jan 17, 2019
1 parent 65c4c2c commit c61a3c4
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 41 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>1.3.1</version>
<version>1.3.2</version>
</plugin>
</plugins>

Expand Down
2 changes: 2 additions & 0 deletions src/main/appengine/app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
runtime: custom
env: flex
2 changes: 2 additions & 0 deletions src/main/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM gcr.io/google-appengine/jetty
ADD gae-dump-1.0-SNAPSHOT.war $JETTY_BASE/webapps/root.war
116 changes: 76 additions & 40 deletions src/main/java/com/webtide/gae/Dump.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,7 @@
import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.net.URL;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.Enumeration;
import java.util.Locale;
import java.util.Timer;
import java.util.TimerTask;
import java.util.*;

/**
* Dump Servlet Request.
Expand Down Expand Up @@ -707,7 +701,7 @@ else if (values.length > 1)
a= getInitParameterNames();
while (a.hasMoreElements())
{
name= (String)a.nextElement();
name = (String)a.nextElement();
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">"+name+":&nbsp;</th>");
pout.write("<td>"+ toString(getInitParameter(name)) +"</td>");
Expand All @@ -718,7 +712,7 @@ else if (values.length > 1)
a= getServletContext().getInitParameterNames();
while (a.hasMoreElements())
{
name= (String)a.nextElement();
name = (String)a.nextElement();
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\" valign=\"top\">"+name.replace("."," .")+":&nbsp;</th>");
pout.write("<td>"+ toString(getServletContext().getInitParameter(name)) + "</td>");
Expand All @@ -729,12 +723,84 @@ else if (values.length > 1)
a= getServletContext().getAttributeNames();
while (a.hasMoreElements())
{
name= (String)a.nextElement();
name = (String)a.nextElement();
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\" valign=\"top\">"+name.replace("."," .")+":&nbsp;</th>");
pout.write("<td>"+"<pre>" + toString(getServletContext().getAttribute(name)) + "</pre>"+"</td>");
}

/* ------------------------------------------------------------ */
pout.write("<h2>Request Wrappers</h2>\n");
ServletRequest rw=request;
int w=0;
while (rw !=null)
{
pout.write((w++)+": "+rw.getClass().getName()+"<br/>");
if (rw instanceof HttpServletRequestWrapper)
rw=((HttpServletRequestWrapper)rw).getRequest();
else if (rw instanceof ServletRequestWrapper)
rw=((ServletRequestWrapper)rw).getRequest();
else
rw=null;
}

/* ------------------------------------------------------------ */
pout.write("<h2>Response Wrappers</h2>\n");
ServletResponse rsw=response;
w=0;
while (rsw !=null)
{
pout.write((w++)+": "+rsw.getClass().getName()+"<br/>");
if (rsw instanceof HttpServletResponseWrapper)
rsw=((HttpServletResponseWrapper)rsw).getResponse();
else if (rsw instanceof ServletResponseWrapper)
rsw=((ServletResponseWrapper)rsw).getResponse();
else
rsw=null;
}

/* ------------------------------------------------------------ */
pout.write("</tr><tr>\n");
pout.write("<th align=\"left\" colspan=\"2\"><big><br/>System Properties:</big></th>");
Enumeration p = System.getProperties().propertyNames();
while (p.hasMoreElements())
{
name = (String)p.nextElement();
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\" valign=\"top\">"+name+":&nbsp;</th>");
pout.write("<td>"+"<pre>" + toString(System.getProperty(name)) + "</pre>"+"</td>");
}

/* ------------------------------------------------------------ */
pout.write("</tr><tr>\n");
pout.write("<th align=\"left\" colspan=\"2\"><big><br/>Environment:</big></th>");
for (Iterator<String> i = System.getenv().keySet().iterator(); i.hasNext() ;)
{
name = i.next();
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\" valign=\"top\">"+name+":&nbsp;</th>");
pout.write("<td>"+"<pre>" + toString(System.getenv(name)) + "</pre>"+"</td>");
}

/* ------------------------------------------------------------ */
pout.write("</tr><tr>\n");
pout.write("<th align=\"left\" colspan=\"2\"><big><br/>Runtime:</big></th>");
Runtime rt = Runtime.getRuntime();
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">availableProcessors:&nbsp;</th>");
pout.write("<td><pre>"+rt.availableProcessors()+"</pre></td>");
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">freeMemory:&nbsp;</th>");
pout.write("<td><pre>"+rt.freeMemory()+"</pre></td>");
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">maxMemory:&nbsp;</th>");
pout.write("<td><pre>"+rt.maxMemory()+"</pre></td>");
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">totalMemory:&nbsp;</th>");
pout.write("<td><pre>"+rt.totalMemory()+"</pre></td>");


/* ------------------------------------------------------------ */
String res= request.getParameter("resource");
if (res != null && res.length() > 0)
{
Expand Down Expand Up @@ -809,36 +875,6 @@ else if (values.length > 1)

pout.write("</tr></table>\n");

/* ------------------------------------------------------------ */
pout.write("<h2>Request Wrappers</h2>\n");
ServletRequest rw=request;
int w=0;
while (rw !=null)
{
pout.write((w++)+": "+rw.getClass().getName()+"<br/>");
if (rw instanceof HttpServletRequestWrapper)
rw=((HttpServletRequestWrapper)rw).getRequest();
else if (rw instanceof ServletRequestWrapper)
rw=((ServletRequestWrapper)rw).getRequest();
else
rw=null;
}

/* ------------------------------------------------------------ */
pout.write("<h2>Response Wrappers</h2>\n");
ServletResponse rsw=response;
w=0;
while (rsw !=null)
{
pout.write((w++)+": "+rsw.getClass().getName()+"<br/>");
if (rsw instanceof HttpServletResponseWrapper)
rsw=((HttpServletResponseWrapper)rsw).getResponse();
else if (rsw instanceof ServletResponseWrapper)
rsw=((ServletResponseWrapper)rsw).getResponse();
else
rsw=null;
}

/* ------------------------------------------------------------ */
pout.write("<h2>Stack</h2>\n<pre>");
new Throwable("Stack dump").printStackTrace(pout);
Expand Down

0 comments on commit c61a3c4

Please sign in to comment.