Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Bartel2012-05-08 13:21:43 +0000
committerJan Bartel2012-05-08 13:21:43 +0000
commit4926fa9bd5b6916801dd01476bd88637a057ad6c (patch)
tree2b0f86a08aeb26a8c94b92e17021d227cfbcb451
parent72befc31b0037254f083256d71ebd9bbb38ce3ff (diff)
downloadorg.eclipse.jetty.project-4926fa9bd5b6916801dd01476bd88637a057ad6c.tar.gz
org.eclipse.jetty.project-4926fa9bd5b6916801dd01476bd88637a057ad6c.tar.xz
org.eclipse.jetty.project-4926fa9bd5b6916801dd01476bd88637a057ad6c.zip
Reformatted classes.
-rw-r--r--jetty-osgi/jetty-osgi-servletbridge/src/main/java/org/eclipse/jetty/nested/Dump.java873
-rw-r--r--jetty-osgi/jetty-osgi-servletbridge/src/main/java/org/eclipse/jetty/osgi/servletbridge/BridgeServletExtended.java44
-rw-r--r--jetty-osgi/jetty-osgi-servletbridge/src/main/java/org/eclipse/jetty/osgi/servletbridge/FrameworkLauncherExtended.java689
-rw-r--r--jetty-osgi/jetty-osgi-servletbridge/src/main/java/org/eclipse/jetty/osgi/servletbridge/hook/ServletBridgeClassLoaderDelegateHook.java107
4 files changed, 818 insertions, 895 deletions
diff --git a/jetty-osgi/jetty-osgi-servletbridge/src/main/java/org/eclipse/jetty/nested/Dump.java b/jetty-osgi/jetty-osgi-servletbridge/src/main/java/org/eclipse/jetty/nested/Dump.java
index dbb0e2a78c..7359b98bf2 100644
--- a/jetty-osgi/jetty-osgi-servletbridge/src/main/java/org/eclipse/jetty/nested/Dump.java
+++ b/jetty-osgi/jetty-osgi-servletbridge/src/main/java/org/eclipse/jetty/nested/Dump.java
@@ -1,4 +1,5 @@
package org.eclipse.jetty.nested;
+
// ========================================================================
// Copyright (c) 1996-2009 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
@@ -12,7 +13,6 @@ package org.eclipse.jetty.nested;
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
-
import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
@@ -46,38 +46,28 @@ import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;
import javax.sql.DataSource;
-//import org.eclipse.jetty.continuation.Continuation;
-//import org.eclipse.jetty.continuation.ContinuationListener;
-//import org.eclipse.jetty.continuation.ContinuationSupport;
-//import org.eclipse.jetty.http.HttpHeaders;
-//import org.eclipse.jetty.util.StringUtil;
-//import org.eclipse.jetty.util.log.Log;
-//import org.eclipse.jetty.util.log.Logger;
-
-
-
/* ------------------------------------------------------------ */
-/** Dump Servlet Request.
+/**
+ * Dump Servlet Request.
*
+ * Copied from test-jetty-webapp's Dump servlet.
*/
public class Dump extends HttpServlet
{
- //private static final Logger LOG = Log.getLogger(Dump.class);
-
boolean fixed;
-
+
/* ------------------------------------------------------------ */
@Override
public void init(ServletConfig config) throws ServletException
{
- super.init(config);
-
- if (config.getInitParameter("unavailable")!=null && !fixed)
- {
-
- fixed=true;
- throw new UnavailableException("Unavailable test",Integer.parseInt(config.getInitParameter("unavailable")));
- }
+ super.init(config);
+
+ if (config.getInitParameter("unavailable") != null && !fixed)
+ {
+
+ fixed = true;
+ throw new UnavailableException("Unavailable test", Integer.parseInt(config.getInitParameter("unavailable")));
+ }
}
/* ------------------------------------------------------------ */
@@ -92,163 +82,42 @@ public class Dump extends HttpServlet
public void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException
{
// Handle a dump of data
- final String data= request.getParameter("data");
- final String chars= request.getParameter("chars");
- final String block= request.getParameter("block");
- final String dribble= request.getParameter("dribble");
- final boolean flush= request.getParameter("flush")!=null?Boolean.parseBoolean(request.getParameter("flush")):false;
-
-
- if(request.getPathInfo()!=null && request.getPathInfo().toLowerCase().indexOf("script")!=-1)
+ final String data = request.getParameter("data");
+ final String chars = request.getParameter("chars");
+ final String block = request.getParameter("block");
+ final String dribble = request.getParameter("dribble");
+ final boolean flush = request.getParameter("flush") != null ? Boolean.parseBoolean(request.getParameter("flush")) : false;
+
+ if (request.getPathInfo() != null && request.getPathInfo().toLowerCase().indexOf("script") != -1)
{
response.sendRedirect(response.encodeRedirectURL(getServletContext().getContextPath() + "/dump/info"));
return;
}
-
+
request.setCharacterEncoding("UTF-8");
-
- if (request.getParameter("empty")!=null)
+
+ if (request.getParameter("empty") != null)
{
response.setStatus(200);
response.flushBuffer();
return;
}
-
-/* if (request.getParameter("sleep")!=null)
- {
- try
- {
- long s = Long.parseLong(request.getParameter("sleep"));
- if (request.getHeader(HttpHeaders.EXPECT)!=null &&request.getHeader(HttpHeaders.EXPECT).indexOf("102")>=0)
- {
- Thread.sleep(s/2);
- response.sendError(102);
- Thread.sleep(s/2);
- }
- else
- Thread.sleep(s);
- }
- catch (InterruptedException e)
- {
- return;
- }
- catch (Exception e)
- {
- throw new ServletException(e);
- }
- }
-
- if (request.getAttribute("RESUME")==null && request.getParameter("resume")!=null)
- {
- request.setAttribute("RESUME",Boolean.TRUE);
-
- final long resume=Long.parseLong(request.getParameter("resume"));
- new Thread(new Runnable()
- {
- public void run()
- {
- try
- {
- Thread.sleep(resume);
- }
- catch (InterruptedException e)
- {
- e.printStackTrace();
- }
- Continuation continuation = ContinuationSupport.getContinuation(request);
- continuation.resume();
- }
-
- }).start();
- }
-
- if (request.getParameter("complete")!=null)
- {
- final long complete=Long.parseLong(request.getParameter("complete"));
- new Thread(new Runnable()
- {
- public void run()
- {
- try
- {
- Thread.sleep(complete);
- }
- catch (InterruptedException e)
- {
- e.printStackTrace();
- }
- try
- {
- response.setContentType("text/html");
- response.getOutputStream().println("<h1>COMPLETED</h1>");
- Continuation continuation = ContinuationSupport.getContinuation(request);
- continuation.complete();
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
- }
- }).start();
- }
-
- if (request.getParameter("suspend")!=null && request.getAttribute("SUSPEND")!=Boolean.TRUE)
- {
- request.setAttribute("SUSPEND",Boolean.TRUE);
- try
- {
- Continuation continuation = ContinuationSupport.getContinuation(request);
- continuation.setTimeout(Long.parseLong(request.getParameter("suspend")));
- continuation.suspend();
-
- continuation.addContinuationListener(new ContinuationListener()
- {
- public void onTimeout(Continuation continuation)
- {
- response.addHeader("Dump","onTimeout");
- try
- {
- dump(response,data,chars,block,dribble,flush);
- continuation.complete();
- }
- catch (IOException e)
- {
- LOG.ignore(e);
- }
- }
-
- public void onComplete(Continuation continuation)
- {
- response.addHeader("Dump","onComplete");
- }
- });
-
- continuation.undispatch();
- }
- catch(Exception e)
- {
- throw new ServletException(e);
- }
- } */
-
request.setAttribute("Dump", this);
- getServletContext().setAttribute("Dump",this);
- // getServletContext().log("dump "+request.getRequestURI());
+ getServletContext().setAttribute("Dump", this);
// Force a content length response
- String length= request.getParameter("length");
+ String length = request.getParameter("length");
if (length != null && length.length() > 0)
{
response.setContentLength(Integer.parseInt(length));
}
// Handle a dump of data
- if (dump(response,data,chars,block,dribble,flush))
- return;
-
+ if (dump(response, data, chars, block, dribble, flush)) return;
+
// handle an exception
- String info= request.getPathInfo();
+ String info = request.getPathInfo();
if (info != null && info.endsWith("Exception"))
{
try
@@ -262,17 +131,16 @@ public class Dump extends HttpServlet
}
// test a reset
- String reset= request.getParameter("reset");
+ String reset = request.getParameter("reset");
if (reset != null && reset.length() > 0)
{
response.getOutputStream().println("THIS SHOULD NOT BE SEEN!");
- response.setHeader("SHOULD_NOT","BE SEEN");
+ response.setHeader("SHOULD_NOT", "BE SEEN");
response.reset();
}
-
-
+
// handle an redirect
- String redirect= request.getParameter("redirect");
+ String redirect = request.getParameter("redirect");
if (redirect != null && redirect.length() > 0)
{
response.getOutputStream().println("THIS SHOULD NOT BE SEEN!");
@@ -281,7 +149,7 @@ public class Dump extends HttpServlet
{
response.getOutputStream().println("THIS SHOULD NOT BE SEEN!");
}
- catch(IOException e)
+ catch (IOException e)
{
// ignored as stream is closed.
}
@@ -289,8 +157,8 @@ public class Dump extends HttpServlet
}
// handle an error
- String error= request.getParameter("error");
- if (error != null && error.length() > 0 && request.getAttribute("javax.servlet.error.status_code")==null)
+ String error = request.getParameter("error");
+ if (error != null && error.length() > 0 && request.getAttribute("javax.servlet.error.status_code") == null)
{
response.getOutputStream().println("THIS SHOULD NOT BE SEEN!");
response.sendError(Integer.parseInt(error));
@@ -298,34 +166,36 @@ public class Dump extends HttpServlet
{
response.getOutputStream().println("THIS SHOULD NOT BE SEEN!");
}
- catch(IllegalStateException e)
+ catch (IllegalStateException e)
{
try
{
- response.getWriter().println("NOR THIS!!");
+ response.getWriter().println("NOR THIS!!");
+ }
+ catch (IOException e2)
+ {
}
- catch(IOException e2){}
}
- catch(IOException e){}
+ catch (IOException e)
+ {
+ }
return;
}
-
- // Handle a extra headers
- String headers= request.getParameter("headers");
+
+ // Handle a extra headers
+ String headers = request.getParameter("headers");
if (headers != null && headers.length() > 0)
{
- long h=Long.parseLong(headers);
- for (int i=0;i<h;i++)
- response.addHeader("Header"+i,"Value"+i);
+ long h = Long.parseLong(headers);
+ for (int i = 0; i < h; i++)
+ response.addHeader("Header" + i, "Value" + i);
}
- String buffer= request.getParameter("buffer");
- if (buffer != null && buffer.length() > 0)
- response.setBufferSize(Integer.parseInt(buffer));
+ String buffer = request.getParameter("buffer");
+ if (buffer != null && buffer.length() > 0) response.setBufferSize(Integer.parseInt(buffer));
- String charset= request.getParameter("charset");
- if (charset==null)
- charset="UTF-8";
+ String charset = request.getParameter("charset");
+ if (charset == null) charset = "UTF-8";
response.setCharacterEncoding(charset);
response.setContentType("text/html");
@@ -333,9 +203,9 @@ public class Dump extends HttpServlet
{
try
{
- String locale_name= info.substring(info.indexOf("Locale/") + 7);
- Field f= java.util.Locale.class.getField(locale_name);
- response.setLocale((Locale)f.get(null));
+ String locale_name = info.substring(info.indexOf("Locale/") + 7);
+ Field f = java.util.Locale.class.getField(locale_name);
+ response.setLocale((Locale) f.get(null));
}
catch (Exception e)
{
@@ -344,21 +214,20 @@ public class Dump extends HttpServlet
}
}
- String cn= request.getParameter("cookie");
- String cv=request.getParameter("cookiev");
- if (cn!=null && cv!=null)
+ String cn = request.getParameter("cookie");
+ String cv = request.getParameter("cookiev");
+ if (cn != null && cv != null)
{
- Cookie cookie= new Cookie(cn, cv);
- if (request.getParameter("version")!=null)
- cookie.setVersion(Integer.parseInt(request.getParameter("version")));
+ Cookie cookie = new Cookie(cn, cv);
+ if (request.getParameter("version") != null) cookie.setVersion(Integer.parseInt(request.getParameter("version")));
cookie.setComment("Cookie from dump servlet");
response.addCookie(cookie);
}
- String pi= request.getPathInfo();
+ String pi = request.getPathInfo();
if (pi != null && pi.startsWith("/ex"))
{
- OutputStream out= response.getOutputStream();
+ OutputStream out = response.getOutputStream();
out.write("</H1>This text should be reset</H1>".getBytes());
if ("/ex0".equals(pi))
throw new ServletException("test ex0", new Throwable());
@@ -366,29 +235,26 @@ public class Dump extends HttpServlet
throw new IOException("test ex1");
else if ("/ex2".equals(pi))
throw new UnavailableException("test ex2");
- else if (pi.startsWith("/ex3/"))
- throw new UnavailableException("test ex3",Integer.parseInt(pi.substring(5)));
+ else if (pi.startsWith("/ex3/")) throw new UnavailableException("test ex3", Integer.parseInt(pi.substring(5)));
throw new RuntimeException("test");
}
- if ("true".equals(request.getParameter("close")))
- response.setHeader("Connection","close");
+ if ("true".equals(request.getParameter("close"))) response.setHeader("Connection", "close");
+
+ String buffered = request.getParameter("buffered");
+
+ PrintWriter pout = null;
- String buffered= request.getParameter("buffered");
-
- PrintWriter pout=null;
-
try
{
- pout =response.getWriter();
+ pout = response.getWriter();
}
- catch(IllegalStateException e)
+ catch (IllegalStateException e)
{
- pout=new PrintWriter(new OutputStreamWriter(response.getOutputStream(),charset));
+ pout = new PrintWriter(new OutputStreamWriter(response.getOutputStream(), charset));
}
- if (buffered!=null)
- pout = new PrintWriter(new BufferedWriter(pout,Integer.parseInt(buffered)));
-
+ if (buffered != null) pout = new PrintWriter(new BufferedWriter(pout, Integer.parseInt(buffered)));
+
try
{
pout.write("<html>\n<body>\n");
@@ -396,113 +262,113 @@ public class Dump extends HttpServlet
pout.write("<table width=\"95%\">");
pout.write("<tr>\n");
pout.write("<th align=\"right\">getMethod:&nbsp;</th>");
- pout.write("<td>" + notag(request.getMethod())+"</td>");
+ pout.write("<td>" + notag(request.getMethod()) + "</td>");
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">getContentLength:&nbsp;</th>");
- pout.write("<td>"+Integer.toString(request.getContentLength())+"</td>");
+ pout.write("<td>" + Integer.toString(request.getContentLength()) + "</td>");
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">getContentType:&nbsp;</th>");
- pout.write("<td>"+notag(request.getContentType())+"</td>");
+ pout.write("<td>" + notag(request.getContentType()) + "</td>");
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">getRequestURI:&nbsp;</th>");
- pout.write("<td>"+notag(request.getRequestURI())+"</td>");
+ pout.write("<td>" + notag(request.getRequestURI()) + "</td>");
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">getRequestURL:&nbsp;</th>");
- pout.write("<td>"+notag(request.getRequestURL().toString())+"</td>");
+ pout.write("<td>" + notag(request.getRequestURL().toString()) + "</td>");
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">getContextPath:&nbsp;</th>");
- pout.write("<td>"+request.getContextPath()+"</td>");
+ pout.write("<td>" + request.getContextPath() + "</td>");
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">getServletPath:&nbsp;</th>");
- pout.write("<td>"+notag(request.getServletPath())+"</td>");
+ pout.write("<td>" + notag(request.getServletPath()) + "</td>");
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">getPathInfo:&nbsp;</th>");
- pout.write("<td>"+notag(request.getPathInfo())+"</td>");
+ pout.write("<td>" + notag(request.getPathInfo()) + "</td>");
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">getPathTranslated:&nbsp;</th>");
- pout.write("<td>"+notag(request.getPathTranslated())+"</td>");
+ pout.write("<td>" + notag(request.getPathTranslated()) + "</td>");
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">getQueryString:&nbsp;</th>");
- pout.write("<td>"+notag(request.getQueryString())+"</td>");
+ pout.write("<td>" + notag(request.getQueryString()) + "</td>");
pout.write("</tr><tr>\n");
-
+
pout.write("<th align=\"right\">getProtocol:&nbsp;</th>");
- pout.write("<td>"+request.getProtocol()+"</td>");
+ pout.write("<td>" + request.getProtocol() + "</td>");
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">getScheme:&nbsp;</th>");
- pout.write("<td>"+request.getScheme()+"</td>");
+ pout.write("<td>" + request.getScheme() + "</td>");
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">getServerName:&nbsp;</th>");
- pout.write("<td>"+notag(request.getServerName())+"</td>");
+ pout.write("<td>" + notag(request.getServerName()) + "</td>");
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">getServerPort:&nbsp;</th>");
- pout.write("<td>"+Integer.toString(request.getServerPort())+"</td>");
+ pout.write("<td>" + Integer.toString(request.getServerPort()) + "</td>");
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">getLocalName:&nbsp;</th>");
- pout.write("<td>"+request.getLocalName()+"</td>");
+ pout.write("<td>" + request.getLocalName() + "</td>");
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">getLocalAddr:&nbsp;</th>");
- pout.write("<td>"+request.getLocalAddr()+"</td>");
+ pout.write("<td>" + request.getLocalAddr() + "</td>");
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">getLocalPort:&nbsp;</th>");
- pout.write("<td>"+Integer.toString(request.getLocalPort())+"</td>");
+ pout.write("<td>" + Integer.toString(request.getLocalPort()) + "</td>");
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">getRemoteUser:&nbsp;</th>");
- pout.write("<td>"+request.getRemoteUser()+"</td>");
+ pout.write("<td>" + request.getRemoteUser() + "</td>");
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">getUserPrincipal:&nbsp;</th>");
- pout.write("<td>"+request.getUserPrincipal()+"</td>");
+ pout.write("<td>" + request.getUserPrincipal() + "</td>");
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">getRemoteAddr:&nbsp;</th>");
- pout.write("<td>"+request.getRemoteAddr()+"</td>");
+ pout.write("<td>" + request.getRemoteAddr() + "</td>");
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">getRemoteHost:&nbsp;</th>");
- pout.write("<td>"+request.getRemoteHost()+"</td>");
+ pout.write("<td>" + request.getRemoteHost() + "</td>");
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">getRemotePort:&nbsp;</th>");
- pout.write("<td>"+request.getRemotePort()+"</td>");
+ pout.write("<td>" + request.getRemotePort() + "</td>");
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">getRequestedSessionId:&nbsp;</th>");
- pout.write("<td>"+request.getRequestedSessionId()+"</td>");
+ pout.write("<td>" + request.getRequestedSessionId() + "</td>");
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">isSecure():&nbsp;</th>");
- pout.write("<td>"+request.isSecure()+"</td>");
+ pout.write("<td>" + request.isSecure() + "</td>");
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">isUserInRole(admin):&nbsp;</th>");
- pout.write("<td>"+request.isUserInRole("admin")+"</td>");
+ pout.write("<td>" + request.isUserInRole("admin") + "</td>");
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">getLocale:&nbsp;</th>");
- pout.write("<td>"+request.getLocale()+"</td>");
-
- Enumeration locales= request.getLocales();
+ pout.write("<td>" + request.getLocale() + "</td>");
+
+ Enumeration locales = request.getLocales();
while (locales.hasMoreElements())
{
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">getLocales:&nbsp;</th>");
- pout.write("<td>"+locales.nextElement()+"</td>");
+ pout.write("<td>" + locales.nextElement() + "</td>");
}
pout.write("</tr><tr>\n");
-
+
pout.write("<th align=\"left\" colspan=\"2\"><big><br/>Other HTTP Headers:</big></th>");
- Enumeration h= request.getHeaderNames();
+ Enumeration h = request.getHeaderNames();
String name;
while (h.hasMoreElements())
{
- name= (String)h.nextElement();
+ name = (String) h.nextElement();
- Enumeration h2= request.getHeaders(name);
+ Enumeration h2 = request.getHeaders(name);
while (h2.hasMoreElements())
{
- String hv= (String)h2.nextElement();
+ String hv = (String) h2.nextElement();
pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\">"+notag(name)+":&nbsp;</th>");
- pout.write("<td>"+notag(hv)+"</td>");
+ pout.write("<th align=\"right\">" + notag(name) + ":&nbsp;</th>");
+ pout.write("<td>" + notag(hv) + "</td>");
}
}
- //Test the system properties
+ // Test the system properties
if ("true".equals(request.getParameter("env")))
{
pout.write("</tr><tr>\n");
@@ -511,7 +377,7 @@ public class Dump extends HttpServlet
{
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">" + notag(String.valueOf(e.getKey())) + ":&nbsp;</th>");
- pout.write("<td>"+notag(String.valueOf(e.getValue()))+"</td>");
+ pout.write("<td>" + notag(String.valueOf(e.getValue())) + "</td>");
}
pout.write("</tr><tr>\n");
@@ -521,93 +387,98 @@ public class Dump extends HttpServlet
{
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">" + notag(String.valueOf(e.getKey())) + ":&nbsp;</th>");
- pout.write("<td>"+notag(String.valueOf(e.getValue()))+"</td>");
+ pout.write("<td>" + notag(String.valueOf(e.getValue())) + "</td>");
}
}
- //handle testing jdbc connections:
+ // handle testing jdbc connections:
String jdbcUrl = request.getParameter("jdbc-url");
String jdbcDriver = request.getParameter("jdbc-driver");
if (jdbcUrl != null)
{
- Connection con = null;
- try
- {
- String user = request.getParameter("jdbc-user");
- String pass = request.getParameter("jdbc-pass");
- String query = request.getParameter("jdbc-query");
- if (user.length() == 0) user = null;
- if (pass.length() == 0) pass = null;
- if (query == null || query.length() == 0) query = "show tables;";
+ Connection con = null;
+ try
+ {
+ String user = request.getParameter("jdbc-user");
+ String pass = request.getParameter("jdbc-pass");
+ String query = request.getParameter("jdbc-query");
+ if (user.length() == 0) user = null;
+ if (pass.length() == 0) pass = null;
+ if (query == null || query.length() == 0) query = "show tables;";
pout.write("</tr><tr>\n");
pout.write("<th align=\"left\" colspan=\"2\"><big><br/>JDBC test:&nbsp;</big></th>");
-
- Class driver = Thread.currentThread().getContextClassLoader().loadClass(jdbcDriver);
-
+
+ Class driver = Thread.currentThread().getContextClassLoader().loadClass(jdbcDriver);
+
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">Driver class:&nbsp;</th>");
- pout.write("<td>"+driver.getName()+" loaded by " + driver.getClassLoader()+"</td>");
+ pout.write("<td>" + driver.getName() + " loaded by " + driver.getClassLoader() + "</td>");
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">Connection url:&nbsp;</th>");
- pout.write("<td>"+jdbcUrl+"</td>");
+ pout.write("<td>" + jdbcUrl + "</td>");
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">User (optional):&nbsp;</th>");
- pout.write("<td>"+user+"</td>");
+ pout.write("<td>" + user + "</td>");
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">Is there a password (optional):&nbsp;</th>");
- pout.write("<td>"+(pass != null ? "yes" : "no" )+"</td>");
+ pout.write("<td>" + (pass != null ? "yes" : "no") + "</td>");
+
+ con = user != null ? DriverManager.getConnection(jdbcUrl, user, pass) : DriverManager.getConnection(jdbcUrl);
- con = user != null ? DriverManager.getConnection(jdbcUrl, user, pass) : DriverManager.getConnection(jdbcUrl);
-
Statement statement = con.createStatement();
boolean success = statement.execute(query);
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">Query:&nbsp;</th>");
- pout.write("<td>"+query+"</td>");
+ pout.write("<td>" + query + "</td>");
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">Successful query:&nbsp;</th>");
- pout.write("<td>"+success+"</td>");
-
- }
- catch (Throwable t)
- {
+ pout.write("<td>" + success + "</td>");
+
+ }
+ catch (Throwable t)
+ {
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">JDBC test error:&nbsp;</th>");
- pout.write("<td>"+t+"</td>");
- }
- finally
- {
- if (con != null)
- {
- try { con.close(); } catch (Throwable ee) {}
- }
- }
+ pout.write("<td>" + t + "</td>");
+ }
+ finally
+ {
+ if (con != null)
+ {
+ try
+ {
+ con.close();
+ }
+ catch (Throwable ee)
+ {
+ }
+ }
+ }
}
-
pout.write("</tr><tr>\n");
pout.write("<th align=\"left\" colspan=\"2\"><big><br/>Request Parameters:</big></th>");
- h= request.getParameterNames();
+ h = request.getParameterNames();
while (h.hasMoreElements())
{
- name= (String)h.nextElement();
+ name = (String) h.nextElement();
pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\">"+notag(name)+":&nbsp;</th>");
- pout.write("<td>"+notag(request.getParameter(name))+"</td>");
- String[] values= request.getParameterValues(name);
+ pout.write("<th align=\"right\">" + notag(name) + ":&nbsp;</th>");
+ pout.write("<td>" + notag(request.getParameter(name)) + "</td>");
+ String[] values = request.getParameterValues(name);
if (values == null)
{
pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\">"+notag(name)+" Values:&nbsp;</th>");
- pout.write("<td>"+"NULL!"+"</td>");
+ pout.write("<th align=\"right\">" + notag(name) + " Values:&nbsp;</th>");
+ pout.write("<td>" + "NULL!" + "</td>");
}
else if (values.length > 1)
{
- for (int i= 0; i < values.length; i++)
+ for (int i = 0; i < values.length; i++)
{
pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\">"+notag(name)+"["+i+"]:&nbsp;</th>");
- pout.write("<td>"+notag(values[i])+"</td>");
+ pout.write("<th align=\"right\">" + notag(name) + "[" + i + "]:&nbsp;</th>");
+ pout.write("<td>" + notag(values[i]) + "</td>");
}
}
}
@@ -615,219 +486,231 @@ public class Dump extends HttpServlet
pout.write("</tr><tr>\n");
pout.write("<th align=\"left\" colspan=\"2\"><big><br/>Cookies:</big></th>");
Cookie[] cookies = request.getCookies();
- for (int i=0; cookies!=null && i<cookies.length;i++)
+ for (int i = 0; cookies != null && i < cookies.length; i++)
{
Cookie cookie = cookies[i];
pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\">"+notag(cookie.getName())+":&nbsp;</th>");
- pout.write("<td>"+notag(cookie.getValue())+"</td>");
+ pout.write("<th align=\"right\">" + notag(cookie.getName()) + ":&nbsp;</th>");
+ pout.write("<td>" + notag(cookie.getValue()) + "</td>");
}
-
- String content_type=request.getContentType();
- if (content_type!=null &&
- !content_type.startsWith("application/x-www-form-urlencoded") &&
- !content_type.startsWith("multipart/form-data"))
+
+ String content_type = request.getContentType();
+ if (content_type != null && !content_type.startsWith("application/x-www-form-urlencoded") && !content_type.startsWith("multipart/form-data"))
{
pout.write("</tr><tr>\n");
pout.write("<th align=\"left\" valign=\"top\" colspan=\"2\"><big><br/>Content:</big></th>");
pout.write("</tr><tr>\n");
pout.write("<td><pre>");
- char[] content= new char[4096];
+ char[] content = new char[4096];
int len;
- try{
- Reader in=request.getReader();
-
- while((len=in.read(content))>=0)
- pout.write(notag(new String(content,0,len)));
+ try
+ {
+ Reader in = request.getReader();
+
+ while ((len = in.read(content)) >= 0)
+ pout.write(notag(new String(content, 0, len)));
}
- catch(IOException e)
+ catch (IOException e)
{
pout.write(e.toString());
}
-
+
pout.write("</pre></td>");
}
-
+
pout.write("</tr><tr>\n");
pout.write("<th align=\"left\" colspan=\"2\"><big><br/>Request Attributes:</big></th>");
- Enumeration a= request.getAttributeNames();
+ Enumeration a = request.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>");
- Object value=request.getAttribute(name);
+ pout.write("<th align=\"right\" valign=\"top\">" + name.replace(".", " .") + ":&nbsp;</th>");
+ Object value = request.getAttribute(name);
if (value instanceof File)
{
- File file = (File)value;
- pout.write("<td>"+"<pre>" + file.getName()+" ("+file.length()+" "+new Date(file.lastModified())+ ")</pre>"+"</td>");
+ File file = (File) value;
+ pout.write("<td>" + "<pre>" + file.getName() + " (" + file.length() + " " + new Date(file.lastModified()) + ")</pre>" + "</td>");
}
else
- pout.write("<td>"+"<pre>" + toString(request.getAttribute(name)) + "</pre>"+"</td>");
+ pout.write("<td>" + "<pre>" + toString(request.getAttribute(name)) + "</pre>" + "</td>");
}
- request.setAttribute("org.eclipse.jetty.servlet.MultiPartFilter.files",null);
+ request.setAttribute("org.eclipse.jetty.servlet.MultiPartFilter.files", null);
-
pout.write("</tr><tr>\n");
pout.write("<th align=\"left\" colspan=\"2\"><big><br/>Servlet InitParameters:</big></th>");
- a= getInitParameterNames();
+ 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>");
+ pout.write("<th align=\"right\">" + name + ":&nbsp;</th>");
+ pout.write("<td>" + toString(getInitParameter(name)) + "</td>");
}
pout.write("</tr><tr>\n");
pout.write("<th align=\"left\" colspan=\"2\"><big><br/>ServletContext Misc:</big></th>");
pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\" valign=\"top\">"+"servletContext.getContextPath()"+":&nbsp;</th>");
- pout.write("<td>"+ getServletContext().getContextPath() + "</td>");
+ pout.write("<th align=\"right\" valign=\"top\">" + "servletContext.getContextPath()" + ":&nbsp;</th>");
+ pout.write("<td>" + getServletContext().getContextPath() + "</td>");
pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\" valign=\"top\">"+"getServletContext().getRealPath(\"/WEB-INF/\")"+":&nbsp;</th>");
- pout.write("<td>"+ getServletContext().getRealPath("/WEB-INF/") + "</td>");
-
+ pout.write("<th align=\"right\" valign=\"top\">" + "getServletContext().getRealPath(\"/WEB-INF/\")" + ":&nbsp;</th>");
+ pout.write("<td>" + getServletContext().getRealPath("/WEB-INF/") + "</td>");
+
String webinfRealPath = getServletContext().getRealPath("/WEB-INF/");
if (webinfRealPath != null)
{
- try
- {
- File webInfRealPathFile = new File(webinfRealPath);
- pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\" valign=\"top\">"+"new File(getServletContext().getRealPath(\"/WEB-INF/\"))"+":&nbsp;</th>");
- pout.write("<td>exists()="+ webInfRealPathFile.exists()
- + "; isFile()="+webInfRealPathFile.isFile()
- + "; isDirectory()="+webInfRealPathFile.isDirectory()
- + "; isAbsolute()=" + webInfRealPathFile.isAbsolute()
- + "; canRead()=" + webInfRealPathFile.canRead()
- + "; canWrite()=" + webInfRealPathFile.canWrite()
- +"</td>");
+ try
+ {
+ File webInfRealPathFile = new File(webinfRealPath);
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\" valign=\"top\">" + "new File(getServletContext().getRealPath(\"/WEB-INF/\"))" + ":&nbsp;</th>");
+ pout.write("<td>exists()=" + webInfRealPathFile.exists()
+ + "; isFile()="
+ + webInfRealPathFile.isFile()
+ + "; isDirectory()="
+ + webInfRealPathFile.isDirectory()
+ + "; isAbsolute()="
+ + webInfRealPathFile.isAbsolute()
+ + "; canRead()="
+ + webInfRealPathFile.canRead()
+ + "; canWrite()="
+ + webInfRealPathFile.canWrite()
+ + "</td>");
if (webInfRealPathFile.exists() && webInfRealPathFile.isDirectory())
{
- File webxml = new File(webInfRealPathFile, "web.xml");
- pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\" valign=\"top\">"+"new File(getServletContext().getRealPath(\"/WEB-INF/web.xml\"))"+":&nbsp;</th>");
- pout.write("<td>exists()="+ webxml.exists()
- + "; isFile()="+webxml.isFile()
- + "; isDirectory()="+webxml.isDirectory()
- + "; isAbsolute()=" + webxml.isAbsolute()
- + "; canRead()=" + webxml.canRead()
- + "; canWrite()=" + webxml.canWrite()
- +"</td>");
+ File webxml = new File(webInfRealPathFile, "web.xml");
+ pout.write("</tr><tr>\n");
+ pout.write("<th align=\"right\" valign=\"top\">" + "new File(getServletContext().getRealPath(\"/WEB-INF/web.xml\"))" + ":&nbsp;</th>");
+ pout.write("<td>exists()=" + webxml.exists()
+ + "; isFile()="
+ + webxml.isFile()
+ + "; isDirectory()="
+ + webxml.isDirectory()
+ + "; isAbsolute()="
+ + webxml.isAbsolute()
+ + "; canRead()="
+ + webxml.canRead()
+ + "; canWrite()="
+ + webxml.canWrite()
+ + "</td>");
}
- }
- catch (Throwable t)
- {
- pout.write("<th align=\"right\" valign=\"top\">"+"Error probing the java.io.File(getServletContext().getRealPath(\"/WEB-INF/\"))"+":&nbsp;</th>");
- pout.write("<td>"+ t + "</td>");
- }
+ }
+ catch (Throwable t)
+ {
+ pout.write("<th align=\"right\" valign=\"top\">" + "Error probing the java.io.File(getServletContext().getRealPath(\"/WEB-INF/\"))"
+ + ":&nbsp;</th>");
+ pout.write("<td>" + t + "</td>");
+ }
}
-
pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\" valign=\"top\">"+"getServletContext().getServerInfo()"+":&nbsp;</th>");
- pout.write("<td>"+ getServletContext().getServerInfo() + "</td>");
+ pout.write("<th align=\"right\" valign=\"top\">" + "getServletContext().getServerInfo()" + ":&nbsp;</th>");
+ pout.write("<td>" + getServletContext().getServerInfo() + "</td>");
pout.write("</tr><tr>\n");
- pout.write("<th align=\"right\" valign=\"top\">"+"getServletContext().getServletContextName()"+":&nbsp;</th>");
- pout.write("<td>"+ getServletContext().getServletContextName() + "</td>");
+ pout.write("<th align=\"right\" valign=\"top\">" + "getServletContext().getServletContextName()" + ":&nbsp;</th>");
+ pout.write("<td>" + getServletContext().getServletContextName() + "</td>");
pout.write("</tr><tr>\n");
pout.write("<th align=\"left\" colspan=\"2\"><big><br/>Context InitParameters:</big></th>");
- a= getServletContext().getInitParameterNames();
+ 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>");
+ pout.write("<th align=\"right\" valign=\"top\">" + name.replace(".", " .") + ":&nbsp;</th>");
+ pout.write("<td>" + toString(getServletContext().getInitParameter(name)) + "</td>");
}
pout.write("</tr><tr>\n");
pout.write("<th align=\"left\" colspan=\"2\"><big><br/>Context Attributes:</big></th>");
- a= getServletContext().getAttributeNames();
+ 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("<th align=\"right\" valign=\"top\">" + name.replace(".", " .") + ":&nbsp;</th>");
+ pout.write("<td>" + "<pre>" + toString(getServletContext().getAttribute(name)) + "</pre>" + "</td>");
}
- String res= request.getParameter("resource");
+ String res = request.getParameter("resource");
if (res != null && res.length() > 0)
{
pout.write("</tr><tr>\n");
- pout.write("<th align=\"left\" colspan=\"2\"><big><br/>Get Resource: \""+res+"\"</big></th>");
+ pout.write("<th align=\"left\" colspan=\"2\"><big><br/>Get Resource: \"" + res + "\"</big></th>");
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">getServletContext().getContext(...):&nbsp;</th>");
-
+
ServletContext context = getServletContext().getContext(res);
- pout.write("<td>"+context+"</td>");
-
- if (context!=null)
+ pout.write("<td>" + context + "</td>");
+
+ if (context != null)
{
- String cp=context.getContextPath();
- if (cp==null || "/".equals(cp))
- cp="";
+ String cp = context.getContextPath();
+ if (cp == null || "/".equals(cp)) cp = "";
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">getServletContext().getContext(...),getRequestDispatcher(...):&nbsp;</th>");
- pout.write("<td>"+getServletContext().getContext(res).getRequestDispatcher(res.substring(cp.length()))+"</td>");
+ pout.write("<td>" + getServletContext().getContext(res).getRequestDispatcher(res.substring(cp.length())) + "</td>");
}
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">this.getClass().getResource(...):&nbsp;</th>");
- pout.write("<td>"+this.getClass().getResource(res)+"</td>");
+ pout.write("<td>" + this.getClass().getResource(res) + "</td>");
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">this.getClass().getClassLoader().getResource(...):&nbsp;</th>");
- pout.write("<td>"+this.getClass().getClassLoader().getResource(res)+"</td>");
+ pout.write("<td>" + this.getClass().getClassLoader().getResource(res) + "</td>");
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">Thread.currentThread().getContextClassLoader().getResource(...):&nbsp;</th>");
- pout.write("<td>"+Thread.currentThread().getContextClassLoader().getResource(res)+"</td>");
+ pout.write("<td>" + Thread.currentThread().getContextClassLoader().getResource(res) + "</td>");
pout.write("</tr><tr>\n");
pout.write("<th align=\"right\">getServletContext().getResource(...):&nbsp;</th>");
- try{pout.write("<td>"+getServletContext().getResource(res)+"</td>");}
- catch(Exception e) {pout.write("<td>"+"" +e+"</td>");}
+ try
+ {
+ pout.write("<td>" + getServletContext().getResource(res) + "</td>");
+ }
+ catch (Exception e)
+ {
+ pout.write("<td>" + "" + e + "</td>");
+ }
}
-
pout.write("</tr></table>\n");
/* ------------------------------------------------------------ */
pout.write("<h2>Request Wrappers</h2>\n");
- ServletRequest rw=request;
- int w=0;
- while (rw !=null)
+ ServletRequest rw = request;
+ int w = 0;
+ while (rw != null)
{
- pout.write((w++)+": "+rw.getClass().getName()+"<br/>");
+ pout.write((w++) + ": " + rw.getClass().getName() + "<br/>");
if (rw instanceof HttpServletRequestWrapper)
- rw=((HttpServletRequestWrapper)rw).getRequest();
+ rw = ((HttpServletRequestWrapper) rw).getRequest();
else if (rw instanceof ServletRequestWrapper)
- rw=((ServletRequestWrapper)rw).getRequest();
+ rw = ((ServletRequestWrapper) rw).getRequest();
else
- rw=null;
+ rw = null;
}
/* ------------------------------------------------------------ */
pout.write("<h2>Response Wrappers</h2>\n");
- ServletResponse rsw=response;
- w=0;
- while (rsw !=null)
+ ServletResponse rsw = response;
+ w = 0;
+ while (rsw != null)
{
- pout.write((w++)+": "+rsw.getClass().getName()+"<br/>");
+ pout.write((w++) + ": " + rsw.getClass().getName() + "<br/>");
if (rsw instanceof HttpServletResponseWrapper)
- rsw=((HttpServletResponseWrapper)rsw).getResponse();
+ rsw = ((HttpServletResponseWrapper) rsw).getResponse();
else if (rsw instanceof ServletResponseWrapper)
- rsw=((ServletResponseWrapper)rsw).getResponse();
+ rsw = ((ServletResponseWrapper) rsw).getResponse();
else
- rsw=null;
+ rsw = null;
}
-
+
pout.write("<br/>");
pout.write("<h2>International Characters (UTF-8)</h2>");
pout.write("LATIN LETTER SMALL CAPITAL AE<br/>\n");
@@ -837,15 +720,15 @@ public class Dump extends HttpServlet
pout.write("Javascript unicode (\\u1d01) : <script language='javascript'>document.write(\"\u1d01\");</script><br/>");
pout.write("<br/>");
pout.write("<h2>Form to generate GET content</h2>");
- pout.write("<form method=\"GET\" action=\""+response.encodeURL(getURI(request))+"\">");
+ pout.write("<form method=\"GET\" action=\"" + response.encodeURL(getURI(request)) + "\">");
pout.write("TextField: <input type=\"text\" name=\"TextField\" value=\"value\"/><br/>\n");
pout.write("<input type=\"submit\" name=\"Action\" value=\"Submit\">");
pout.write("</form>");
pout.write("<br/>");
-
+
pout.write("<h2>Form to generate POST content</h2>");
- pout.write("<form method=\"POST\" accept-charset=\"utf-8\" action=\""+response.encodeURL(getURI(request))+"\">");
+ pout.write("<form method=\"POST\" accept-charset=\"utf-8\" action=\"" + response.encodeURL(getURI(request)) + "\">");
pout.write("TextField: <input type=\"text\" name=\"TextField\" value=\"value\"/><br/>\n");
pout.write("Select: <select multiple name=\"Select\">\n");
pout.write("<option>ValueA</option>");
@@ -855,11 +738,11 @@ public class Dump extends HttpServlet
pout.write("<input type=\"submit\" name=\"Action\" value=\"Submit\"><br/>");
pout.write("</form>");
pout.write("<br/>");
-
+
pout.write("<h2>Form to generate UPLOAD content</h2>");
- pout.write("<form method=\"POST\" enctype=\"multipart/form-data\" accept-charset=\"utf-8\" action=\""+
- response.encodeURL(getURI(request))+(request.getQueryString()==null?"":("?"+request.getQueryString()))+
- "\">");
+ pout.write("<form method=\"POST\" enctype=\"multipart/form-data\" accept-charset=\"utf-8\" action=\"" + response.encodeURL(getURI(request))
+ + (request.getQueryString() == null ? "" : ("?" + request.getQueryString()))
+ + "\">");
pout.write("TextField: <input type=\"text\" name=\"TextField\" value=\"comment\"/><br/>\n");
pout.write("File 1: <input type=\"file\" name=\"file1\" /><br/>\n");
pout.write("File 2: <input type=\"file\" name=\"file2\" /><br/>\n");
@@ -867,18 +750,18 @@ public class Dump extends HttpServlet
pout.write("</form>");
pout.write("<h2>Form to set Cookie</h2>");
- pout.write("<form method=\"POST\" action=\""+response.encodeURL(getURI(request))+"\">");
+ pout.write("<form method=\"POST\" action=\"" + response.encodeURL(getURI(request)) + "\">");
pout.write("cookie: <input type=\"text\" name=\"cookie\" /><br/>\n");
pout.write("value: <input type=\"text\" name=\"cookiev\" /><br/>\n");
pout.write("<input type=\"submit\" name=\"Action\" value=\"setCookie\">");
pout.write("</form>\n");
-
+
pout.write("<h2>Form to get Resource</h2>");
- pout.write("<form method=\"POST\" action=\""+response.encodeURL(getURI(request))+"\">");
+ pout.write("<form method=\"POST\" action=\"" + response.encodeURL(getURI(request)) + "\">");
pout.write("resource: <input type=\"text\" name=\"resource\" /><br/>\n");
pout.write("<input type=\"submit\" name=\"Action\" value=\"getResource\">");
pout.write("</form>\n");
-
+
pout.write("<h2>Form to test a JDBC connection URL</h2>");
String jdbcUser = request.getParameter("jdbc-user");
if (jdbcUser == null || jdbcUser.length() == 0) jdbcUser = "root";
@@ -890,7 +773,7 @@ public class Dump extends HttpServlet
if (jdbcQuery == null || jdbcQuery.length() == 0) jdbcQuery = "show tables;";
String jdbcUrll = request.getParameter("jdbc-url");
if (jdbcUrll == null || jdbcUrll.length() == 0) jdbcUrll = "jdbc:mysql://127.0.0.1:3306/example";
- pout.write("<form method=\"POST\" accept-charset=\"utf-8\" action=\""+response.encodeURL(getURI(request))+"\">");
+ pout.write("<form method=\"POST\" accept-charset=\"utf-8\" action=\"" + response.encodeURL(getURI(request)) + "\">");
pout.write("JDBC Driver class: <input type=\"text\" name=\"jdbc-driver\" value=\"" + jdbcDriverr + "\"/><br/>\n");
pout.write("JDBC URL: <input type=\"text\" name=\"jdbc-url\" value=\"" + jdbcUrll + "\"/><br/>\n");
pout.write("JDBC Username: <input type=\"text\" name=\"jdbc-user\" value=\"" + jdbcUser + "\"/><br/>\n");
@@ -905,36 +788,31 @@ public class Dump extends HttpServlet
{
getServletContext().log("dump", e);
}
-
- String lines= request.getParameter("lines");
- if (lines!=null)
+
+ String lines = request.getParameter("lines");
+ if (lines != null)
{
char[] line = "<span>A line of characters. Blah blah blah blah. blooble blooble</span></br>\n".toCharArray();
- for (int l=Integer.parseInt(lines);l-->0;)
+ for (int l = Integer.parseInt(lines); l-- > 0;)
{
- pout.write("<span>"+l+" </span>");
+ pout.write("<span>" + l + " </span>");
pout.write(line);
}
}
-
+
pout.write("</body>\n</html>\n");
-
+
pout.close();
if (pi != null)
{
- if ("/ex4".equals(pi))
- throw new ServletException("test ex4", new Throwable());
- if ("/ex5".equals(pi))
- throw new IOException("test ex5");
- if ("/ex6".equals(pi))
- throw new UnavailableException("test ex6");
+ if ("/ex4".equals(pi)) throw new ServletException("test ex4", new Throwable());
+ if ("/ex5".equals(pi)) throw new IOException("test ex5");
+ if ("/ex6".equals(pi)) throw new UnavailableException("test ex6");
}
-
}
-
/* ------------------------------------------------------------ */
@Override
public String getServletInfo()
@@ -951,17 +829,15 @@ public class Dump extends HttpServlet
/* ------------------------------------------------------------ */
private String getURI(HttpServletRequest request)
{
- String uri= (String)request.getAttribute("javax.servlet.forward.request_uri");
- if (uri == null)
- uri= request.getRequestURI();
+ String uri = (String) request.getAttribute("javax.servlet.forward.request_uri");
+ if (uri == null) uri = request.getRequestURI();
return uri;
}
/* ------------------------------------------------------------ */
private static String toString(Object o)
{
- if (o == null)
- return null;
+ if (o == null) return null;
try
{
@@ -970,11 +846,10 @@ public class Dump extends HttpServlet
StringBuffer sb = new StringBuffer();
if (!o.getClass().getComponentType().isPrimitive())
{
- Object[] array= (Object[])o;
- for (int i= 0; i < array.length; i++)
+ Object[] array = (Object[]) o;
+ for (int i = 0; i < array.length; i++)
{
- if (i > 0)
- sb.append("\n");
+ if (i > 0) sb.append("\n");
sb.append(array.getClass().getComponentType().getName());
sb.append("[");
sb.append(i);
@@ -984,13 +859,12 @@ public class Dump extends HttpServlet
return sb.toString();
}
else
- {
+ {
int length = Array.getLength(o);
- for (int i=0;i<length;i++)
+ for (int i = 0; i < length; i++)
{
- if (i > 0)
- sb.append("\n");
- sb.append(o.getClass().getComponentType().getName());
+ if (i > 0) sb.append("\n");
+ sb.append(o.getClass().getComponentType().getName());
sb.append("[");
sb.append(i);
sb.append("]=");
@@ -1012,38 +886,37 @@ public class Dump extends HttpServlet
{
if (data != null && data.length() > 0)
{
- long d=Long.parseLong(data);
- int b=(block!=null&&block.length()>0)?Integer.parseInt(block):50;
- byte[] buf=new byte[b];
- for (int i=0;i<b;i++)
+ long d = Long.parseLong(data);
+ int b = (block != null && block.length() > 0) ? Integer.parseInt(block) : 50;
+ byte[] buf = new byte[b];
+ for (int i = 0; i < b; i++)
{
-
- buf[i]=(byte)('0'+(i%10));
- if (i%10==9)
- buf[i]=(byte)'\n';
+
+ buf[i] = (byte) ('0' + (i % 10));
+ if (i % 10 == 9) buf[i] = (byte) '\n';
}
- buf[0]='o';
- OutputStream out=response.getOutputStream();
+ buf[0] = 'o';
+ OutputStream out = response.getOutputStream();
response.setContentType("text/plain");
while (d > 0)
{
- if (b==1)
+ if (b == 1)
{
- out.write(d%80==0?'\n':'.');
+ out.write(d % 80 == 0 ? '\n' : '.');
d--;
}
- else if (d>=b)
+ else if (d >= b)
{
out.write(buf);
- d=d-b;
+ d = d - b;
}
else
{
- out.write(buf,0,(int)d);
- d=0;
+ out.write(buf, 0, (int) d);
+ d = 0;
}
-
- if (dribble!=null)
+
+ if (dribble != null)
{
out.flush();
try
@@ -1056,87 +929,83 @@ public class Dump extends HttpServlet
break;
}
}
-
+
}
-
- if (flush)
- out.flush();
-
+
+ if (flush) out.flush();
+
return true;
}
// Handle a dump of data
if (chars != null && chars.length() > 0)
{
- long d=Long.parseLong(chars);
- int b=(block!=null&&block.length()>0)?Integer.parseInt(block):50;
- char[] buf=new char[b];
- for (int i=0;i<b;i++)
+ long d = Long.parseLong(chars);
+ int b = (block != null && block.length() > 0) ? Integer.parseInt(block) : 50;
+ char[] buf = new char[b];
+ for (int i = 0; i < b; i++)
{
- buf[i]=(char)('0'+(i%10));
- if (i%10==9)
- buf[i]='\n';
+ buf[i] = (char) ('0' + (i % 10));
+ if (i % 10 == 9) buf[i] = '\n';
}
- buf[0]='o';
+ buf[0] = 'o';
response.setContentType("text/plain");
- PrintWriter out=response.getWriter();
+ PrintWriter out = response.getWriter();
while (d > 0 && !out.checkError())
{
- if (b==1)
+ if (b == 1)
{
- out.write(d%80==0?'\n':'.');
+ out.write(d % 80 == 0 ? '\n' : '.');
d--;
}
- else if (d>=b)
+ else if (d >= b)
{
out.write(buf);
- d=d-b;
+ d = d - b;
}
else
{
- out.write(buf,0,(int)d);
- d=0;
+ out.write(buf, 0, (int) d);
+ d = 0;
}
}
return true;
- }
+ }
return false;
}
-
+
private String notag(String s)
{
- if (s==null)
- return "null";
- s=replace(s,"&","&amp;");
- s=replace(s,"<","&lt;");
- s=replace(s,">","&gt;");
+ if (s == null) return "null";
+ s = replace(s, "&", "&amp;");
+ s = replace(s, "<", "&lt;");
+ s = replace(s, ">", "&gt;");
return s;
}
-
+
/**
* replace substrings within string.
*/
public static String replace(String s, String sub, String with)
{
- int c=0;
- int i=s.indexOf(sub,c);
- if (i == -1)
- return s;
-
- StringBuffer buf = new StringBuffer(s.length()+with.length());
-
- synchronized(buf)
+ int c = 0;
+ int i = s.indexOf(sub, c);
+ if (i == -1) return s;
+
+ StringBuffer buf = new StringBuffer(s.length() + with.length());
+
+ synchronized (buf)
{
do
{
- buf.append(s.substring(c,i));
+ buf.append(s.substring(c, i));
buf.append(with);
- c=i+sub.length();
- } while ((i=s.indexOf(sub,c))!=-1);
-
- if (c<s.length())
- buf.append(s.substring(c,s.length()));
-
+ c = i + sub.length();
+ }
+ while ((i = s.indexOf(sub, c)) != -1);
+
+ if (c < s.length()) buf.append(s.substring(c, s.length()));
+
return buf.toString();
}
}
diff --git a/jetty-osgi/jetty-osgi-servletbridge/src/main/java/org/eclipse/jetty/osgi/servletbridge/BridgeServletExtended.java b/jetty-osgi/jetty-osgi-servletbridge/src/main/java/org/eclipse/jetty/osgi/servletbridge/BridgeServletExtended.java
index 4bf16ee2b4..720efbb926 100644
--- a/jetty-osgi/jetty-osgi-servletbridge/src/main/java/org/eclipse/jetty/osgi/servletbridge/BridgeServletExtended.java
+++ b/jetty-osgi/jetty-osgi-servletbridge/src/main/java/org/eclipse/jetty/osgi/servletbridge/BridgeServletExtended.java
@@ -21,28 +21,32 @@ import javax.servlet.http.HttpServletResponse;
import org.eclipse.equinox.servletbridge.BridgeServlet;
/**
- * Override the BridgeServlet to report on whether equinox is actually started or not
- * in case it is started asynchroneously.
+ * Override the BridgeServlet to report on whether equinox is actually started
+ * or not in case it is started asynchronously.
*
* @author hmalphettes
*/
-public class BridgeServletExtended extends BridgeServlet {
+public class BridgeServletExtended extends BridgeServlet
+{
+
+ @Override
+ protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
+ {
+ if (FrameworkLauncherExtended.ASYNCH_START_IN_PROGRESS != null && req.getMethod().equals("GET"))
+ {
+ if (FrameworkLauncherExtended.ASYNCH_START_IN_PROGRESS)
+ {
+ resp.getWriter().append("Equinox is currently starting...\n");
+ return;
+ }
+ else if (FrameworkLauncherExtended.ASYNCH_START_FAILURE != null)
+ {
+ resp.getWriter().append("Equinox failed to start:\n");
+ FrameworkLauncherExtended.ASYNCH_START_FAILURE.printStackTrace(resp.getWriter());
+ return;
+ }
+ }
+ super.service(req, resp);
+ }
- @Override
- protected void service(HttpServletRequest req, HttpServletResponse resp)
- throws ServletException, IOException {
- if (FrameworkLauncherExtended.ASYNCH_START_IN_PROGRESS != null
- && req.getMethod().equals("GET")) {
- if (FrameworkLauncherExtended.ASYNCH_START_IN_PROGRESS) {
- resp.getWriter().append("Equinox is currently starting...\n");
- return;
- } else if (FrameworkLauncherExtended.ASYNCH_START_FAILURE != null) {
- resp.getWriter().append("Equinox failed to start:\n");
- FrameworkLauncherExtended.ASYNCH_START_FAILURE.printStackTrace(resp.getWriter());
- return;
- }
- }
- super.service(req, resp);
- }
-
}
diff --git a/jetty-osgi/jetty-osgi-servletbridge/src/main/java/org/eclipse/jetty/osgi/servletbridge/FrameworkLauncherExtended.java b/jetty-osgi/jetty-osgi-servletbridge/src/main/java/org/eclipse/jetty/osgi/servletbridge/FrameworkLauncherExtended.java
index a0f2021e92..8dd8c8ef4d 100644
--- a/jetty-osgi/jetty-osgi-servletbridge/src/main/java/org/eclipse/jetty/osgi/servletbridge/FrameworkLauncherExtended.java
+++ b/jetty-osgi/jetty-osgi-servletbridge/src/main/java/org/eclipse/jetty/osgi/servletbridge/FrameworkLauncherExtended.java
@@ -34,62 +34,82 @@ import java.util.zip.ZipEntry;
import org.eclipse.equinox.servletbridge.FrameworkLauncher;
/**
- * Extend the servletbridge FrameworkLauncher to support launching an equinox installation
- * made by p2director.
+ * Extend the servletbridge FrameworkLauncher to support launching an equinox
+ * installation made by p2director.
*/
public class FrameworkLauncherExtended extends FrameworkLauncher
{
/**
- * if the OSGI_INSTALL_AREA installed area is specified as a sytem property and matches a Folder on the file system, we don't copy the whole eclipse
+ * if the OSGI_INSTALL_AREA installed area is specified as a sytem property
+ * and matches a Folder on the file system, we don't copy the whole eclipse
* installation instead we use that folder as it is
*/
private static final String DEPLOY_IN_PLACE_WHEN_INSTALL_AREA_IS_FOLDER = "org.eclipse.equinox.servletbridge.deployinplace"; //$NON-NLS-1$
- public static final String FRAMEWORK_BOOTDELEGATION = "org.osgi.framework.bootdelegation";
-
+
+ public static final String FRAMEWORK_BOOTDELEGATION = "org.osgi.framework.bootdelegation";
+
private boolean deployedInPlace = false;
+
private URL resourceBaseAsURL = null;
-
+
protected static Boolean ASYNCH_START_IN_PROGRESS;
+
protected static Throwable ASYNCH_START_FAILURE = null;
-
+
/**
- * If the start is asynch we do it in a different thread and return immediately.
+ * If the start is asynch we do it in a different thread and return
+ * immediately.
*/
@Override
- public synchronized void start() {
- if (ASYNCH_START_IN_PROGRESS == null && "true".equals(super.config.getInitParameter("asyncStart"))) {
- final ClassLoader webappCl = Thread.currentThread().getContextClassLoader();
- Thread th = new Thread() {
- public void run() {
- Thread.currentThread().setContextClassLoader(webappCl);
- System.out.println("Jetty-Nested: Starting equinox asynchroneously.");
- FrameworkLauncherExtended.this.start();
- System.out.println("Jetty-Nested: Finished starting equinox asynchroneously.");
- }
- };
- ASYNCH_START_IN_PROGRESS = true;
- try {
- th.start();
- } catch (Throwable t) {
- ASYNCH_START_FAILURE = t;
- if (t instanceof RuntimeException) {
- throw (RuntimeException)t;
- } else {
- throw new RuntimeException("Equinox failed to start", t);
- }
- } finally {
- ASYNCH_START_IN_PROGRESS = false;
- }
- } else {
- System.out.println("Jetty-Nested: Starting equinox synchroneously.");
- super.start();
- System.out.println("Jetty-Nested: Finished starting equinox synchroneously.");
- }
+ public synchronized void start()
+ {
+ if (ASYNCH_START_IN_PROGRESS == null && "true".equals(super.config.getInitParameter("asyncStart")))
+ {
+ final ClassLoader webappCl = Thread.currentThread().getContextClassLoader();
+ Thread th = new Thread()
+ {
+ public void run()
+ {
+ Thread.currentThread().setContextClassLoader(webappCl);
+ System.out.println("Jetty-Nested: Starting equinox asynchronously.");
+ FrameworkLauncherExtended.this.start();
+ System.out.println("Jetty-Nested: Finished starting equinox asynchronously.");
+ }
+ };
+ ASYNCH_START_IN_PROGRESS = true;
+ try
+ {
+ th.start();
+ }
+ catch (Throwable t)
+ {
+ ASYNCH_START_FAILURE = t;
+ if (t instanceof RuntimeException)
+ {
+ throw (RuntimeException) t;
+ }
+ else
+ {
+ throw new RuntimeException("Equinox failed to start", t);
+ }
+ }
+ finally
+ {
+ ASYNCH_START_IN_PROGRESS = false;
+ }
+ }
+ else
+ {
+ System.out.println("Jetty-Nested: Starting equinox synchronously.");
+ super.start();
+ System.out.println("Jetty-Nested: Finished starting equinox synchronously.");
+ }
}
/**
- * try to find the resource base for this webapp by looking for the launcher initialization file.
+ * try to find the resource base for this webapp by looking for the launcher
+ * initialization file.
*/
protected void initResourceBase()
{
@@ -102,28 +122,29 @@ public class FrameworkLauncherExtended extends FrameworkLauncher
}
if (resourceBaseStr != null && resourceBaseStr.length() != 0)
{
- // If the path starts with a reference to a system property, resolve it.
+ // If the path starts with a reference to a system property,
+ // resolve it.
resourceBaseStr = resolveSystemProperty(resourceBaseStr);
if (resourceBaseStr.startsWith("/WEB-INF/"))
{
- String rpath = context.getRealPath(resourceBaseStr);
- if (rpath != null)
- {
- File rpathFile = new File(rpath);
- if (rpathFile.exists() && rpathFile.isDirectory() && rpathFile.canWrite())
- {
- resourceBaseStr = rpath;
- }
- }
+ String rpath = context.getRealPath(resourceBaseStr);
+ if (rpath != null)
+ {
+ File rpathFile = new File(rpath);
+ if (rpathFile.exists() && rpathFile.isDirectory() && rpathFile.canWrite())
+ {
+ resourceBaseStr = rpath;
+ }
+ }
}
-
+
if (resourceBaseStr.startsWith("file://"))
{
- resourceBaseAsURL = new URL(resourceBaseStr.replace(" ","%20")); //$NON-NLS-1$ //$NON-NLS-2$
+ resourceBaseAsURL = new URL(resourceBaseStr.replace(" ", "%20")); //$NON-NLS-1$ //$NON-NLS-2$
}
else if (new File(resourceBaseStr).exists())
{
- resourceBaseAsURL = new URL("file://" + new File(resourceBaseStr).getCanonicalPath().replace(" ","%20")); //$NON-NLS-1$ //$NON-NLS-2$
+ resourceBaseAsURL = new URL("file://" + new File(resourceBaseStr).getCanonicalPath().replace(" ", "%20")); //$NON-NLS-1$ //$NON-NLS-2$
}
else
{
@@ -132,14 +153,14 @@ public class FrameworkLauncherExtended extends FrameworkLauncher
}
else
{
- if (context.getResource(RESOURCE_BASE + ECLIPSE) != null)
- {
- resourceBase = RESOURCE_BASE + ECLIPSE;
- }
- else
- {
+ if (context.getResource(RESOURCE_BASE + ECLIPSE) != null)
+ {
+ resourceBase = RESOURCE_BASE + ECLIPSE;
+ }
+ else
+ {
super.initResourceBase();
- }
+ }
resourceBaseAsURL = context.getResource(resourceBase);
}
}
@@ -151,7 +172,8 @@ public class FrameworkLauncherExtended extends FrameworkLauncher
{
// ignore
}
- if (resourceBaseAsURL != null && resourceBaseAsURL.getProtocol().equals("file")) { //$NON-NLS-1$
+ if (resourceBaseAsURL != null && resourceBaseAsURL.getProtocol().equals("file"))
+ {
File resBase = new File(resourceBaseAsURL.getPath());
if (resBase.exists() && resBase.isDirectory()
&& !Boolean.FALSE.toString().equalsIgnoreCase(System.getProperty(DEPLOY_IN_PLACE_WHEN_INSTALL_AREA_IS_FOLDER)))
@@ -163,11 +185,11 @@ public class FrameworkLauncherExtended extends FrameworkLauncher
}
/**
- * Override this method to be able to set default system properties computed on the fly depending on the environment where equinox and jetty-osgi are
+ * Override this method to be able to set default system properties computed
+ * on the fly depending on the environment where equinox and jetty-osgi are
* deployed.
*
- * @param resource
- * - The target to read properties from
+ * @param resource - The target to read properties from
* @return the properties
*/
protected Properties loadProperties(String resource)
@@ -179,7 +201,7 @@ public class FrameworkLauncherExtended extends FrameworkLauncher
if (osgiInstall == null)
{
// compute the osgi install dynamically.
- props.put(OSGI_INSTALL_AREA,getPlatformDirectory().getAbsolutePath());
+ props.put(OSGI_INSTALL_AREA, getPlatformDirectory().getAbsolutePath());
}
String osgiFramework = props.getProperty(OSGI_FRAMEWORK);
File pluginsFolder = null;
@@ -187,20 +209,21 @@ public class FrameworkLauncherExtended extends FrameworkLauncher
{
File osgiFrameworkF = findOsgiFramework(getPlatformDirectory());
pluginsFolder = osgiFrameworkF.getParentFile();
- props.put(OSGI_FRAMEWORK,osgiFrameworkF.getAbsoluteFile().getAbsolutePath());
+ props.put(OSGI_FRAMEWORK, osgiFrameworkF.getAbsoluteFile().getAbsolutePath());
}
String osgiFrameworkExtensions = props.getProperty(OSGI_FRAMEWORK_EXTENSIONS);
if (osgiFrameworkExtensions == null)
{
- //this bundle will make the javax.servlet and javax.servlet.http packages passed from
- //the bootstrap classloader into equinox
+ // this bundle will make the javax.servlet and
+ // javax.servlet.http packages passed from
+ // the bootstrap classloader into equinox
osgiFrameworkExtensions = "org.eclipse.equinox.servletbridge.extensionbundle";
}
File configIni = new File(getPlatformDirectory(), "configuration/config.ini");
Properties configIniProps = new Properties();
if (configIni.exists())
{
- System.out.println("Got the " + configIni.getAbsolutePath());
+ System.out.println("Got the " + configIni.getAbsolutePath());
InputStream configIniStream = null;
try
{
@@ -209,11 +232,17 @@ public class FrameworkLauncherExtended extends FrameworkLauncher
}
catch (IOException ioe)
{
-
+
}
finally
{
- try { configIniStream.close(); } catch (IOException ioe2) {}
+ try
+ {
+ configIniStream.close();
+ }
+ catch (IOException ioe2)
+ {
+ }
}
String confIniFrameworkExt = configIniProps.getProperty(OSGI_FRAMEWORK_EXTENSIONS);
if (confIniFrameworkExt != null)
@@ -223,82 +252,82 @@ public class FrameworkLauncherExtended extends FrameworkLauncher
}
else
{
- System.out.println("Unable to locate the " + configIni.getAbsolutePath());
+ System.out.println("Unable to locate the " + configIni.getAbsolutePath());
}
- props.setProperty(OSGI_FRAMEWORK_EXTENSIONS,osgiFrameworkExtensions);
- //__deployExtensionBundle(pluginsFolder);
+ props.setProperty(OSGI_FRAMEWORK_EXTENSIONS, osgiFrameworkExtensions);
+ // __deployExtensionBundle(pluginsFolder);
deployExtensionBundle(pluginsFolder, true);
-
-
+
String bootDeleg = props.getProperty(FRAMEWORK_BOOTDELEGATION);
if (bootDeleg == null)
{
- bootDeleg = configIniProps.getProperty(FRAMEWORK_BOOTDELEGATION);
+ bootDeleg = configIniProps.getProperty(FRAMEWORK_BOOTDELEGATION);
}
if (bootDeleg == null || bootDeleg.indexOf("javax.servlet.http") == -1)
{
- String add = "javax.servlet,javax.servlet.http,javax.servlet.resources";
- if (bootDeleg != null)
- {
- bootDeleg += add;
- }
- else
- {
- bootDeleg = add;
- }
- props.setProperty(FRAMEWORK_BOOTDELEGATION, bootDeleg);
+ String add = "javax.servlet,javax.servlet.http,javax.servlet.resources";
+ if (bootDeleg != null)
+ {
+ bootDeleg += add;
+ }
+ else
+ {
+ bootDeleg = add;
+ }
+ props.setProperty(FRAMEWORK_BOOTDELEGATION, bootDeleg);
}
-
+
String jettyHome = System.getProperty("jetty.home");
if (jettyHome == null)
{
- jettyHome = getPlatformDirectory().getAbsolutePath();
- System.setProperty("jetty.home",jettyHome);
- props.setProperty("jetty.home",jettyHome);
+ jettyHome = getPlatformDirectory().getAbsolutePath();
+ System.setProperty("jetty.home", jettyHome);
+ props.setProperty("jetty.home", jettyHome);
}
else
{
- jettyHome = resolveSystemProperty(jettyHome);
+ jettyHome = resolveSystemProperty(jettyHome);
}
String etcJettyXml = System.getProperty("jetty.etc.config.urls");
if (etcJettyXml == null)
{
- if (new File(jettyHome,"etc/jetty-osgi-nested.xml").exists())
- {
- System.setProperty("jetty.etc.config.urls","etc/jetty-osgi-nested.xml");
- props.setProperty("jetty.etc.config.urls","etc/jetty-osgi-nested.xml");
- }
+ if (new File(jettyHome, "etc/jetty-osgi-nested.xml").exists())
+ {
+ System.setProperty("jetty.etc.config.urls", "etc/jetty-osgi-nested.xml");
+ props.setProperty("jetty.etc.config.urls", "etc/jetty-osgi-nested.xml");
+ }
}
String startLevel = System.getProperty("osgi.startLevel");
if (startLevel == null)
{
- startLevel = props.getProperty("osgi.startLevel");
- if (startLevel == null)
- {
- startLevel = configIniProps.getProperty("osgi.startLevel");
- }
- if (startLevel != null)
- {
- props.setProperty("osgi.startLevel",startLevel);
- System.setProperty("osgi.startLevel",startLevel);
- }
+ startLevel = props.getProperty("osgi.startLevel");
+ if (startLevel == null)
+ {
+ startLevel = configIniProps.getProperty("osgi.startLevel");
+ }
+ if (startLevel != null)
+ {
+ props.setProperty("osgi.startLevel", startLevel);
+ System.setProperty("osgi.startLevel", startLevel);
+ }
}
String logback = System.getProperty("logback.configurationFile");
if (logback == null)
{
- File etcLogback = new File(jettyHome,"etc/logback-nested.xml");
- if (!etcLogback.exists()) {
- etcLogback = new File(jettyHome,"etc/logback.xml");
- }
- if (etcLogback.exists())
- {
- System.setProperty("logback.configurationFile",etcLogback.getAbsolutePath());
- props.setProperty("logback.configurationFile",etcLogback.getAbsolutePath());
- }
+ File etcLogback = new File(jettyHome, "etc/logback-nested.xml");
+ if (!etcLogback.exists())
+ {
+ etcLogback = new File(jettyHome, "etc/logback.xml");
+ }
+ if (etcLogback.exists())
+ {
+ System.setProperty("logback.configurationFile", etcLogback.getAbsolutePath());
+ props.setProperty("logback.configurationFile", etcLogback.getAbsolutePath());
+ }
}
else
{
- logback = resolveSystemProperty(logback);
+ logback = resolveSystemProperty(logback);
}
System.out.println("sysout: logback.configurationFile=" + System.getProperty("logback.configurationFile"));
}
@@ -306,9 +335,11 @@ public class FrameworkLauncherExtended extends FrameworkLauncher
}
/**
- * Look for the eclipse.ini file. or any *.ini Search for the argument -startup The next line is a relative path to the launcher osgi bundle:
- * ../bundlepool/plugins/org.eclipse.equinox.launcher_1.1.0.v20100507.jar Get that file, get the parent folder. This is where the plugins are located. In
- * that folder look for the
+ * Look for the eclipse.ini file. or any *.ini Search for the argument
+ * -startup The next line is a relative path to the launcher osgi bundle:
+ * ../bundlepool/plugins/org.eclipse.equinox.launcher_1.1.0.v20100507.jar
+ * Get that file, get the parent folder. This is where the plugins are
+ * located. In that folder look for the
*
* @param installFolder
* @return The osgi framework bundle.
@@ -319,7 +350,8 @@ public class FrameworkLauncherExtended extends FrameworkLauncher
for (int i = 0; i < fs.length; i++)
{
File f = fs[i];
- if (f.isFile() && f.getName().endsWith(".ini") && !f.getName().equals(LAUNCH_INI)) { //$NON-NLS-1$
+ if (f.isFile() && f.getName().endsWith(".ini") && !f.getName().equals(LAUNCH_INI))
+ {
BufferedReader br = null;
try
{
@@ -338,7 +370,8 @@ public class FrameworkLauncherExtended extends FrameworkLauncher
}
break;
}
- else if (line.trim().equals("-startup")) { //$NON-NLS-1$
+ else if (line.trim().equals("-startup"))
+ {
gotStartArg = true;
}
}
@@ -346,35 +379,37 @@ public class FrameworkLauncherExtended extends FrameworkLauncher
{
File currFolder = getPlatformDirectory();
String oriStartup = pathToLauncherJar;
- while (pathToLauncherJar.startsWith("../")) { //$NON-NLS-1$
+ while (pathToLauncherJar.startsWith("../"))
+ {
currFolder = currFolder.getParentFile();
pathToLauncherJar = pathToLauncherJar.substring(3);
}
- File pluginsfolder = new File(currFolder,pathToLauncherJar).getParentFile();
- // System.err.println("Got the pluginsfolder " + pluginsfolder);
- if (!pluginsfolder.exists())
- {
- throw new IllegalStateException("The -startup argument in " + f.getPath() + //$NON-NLS-1$
- " is " + oriStartup + ". It points to " + pluginsfolder.getPath() + //$NON-NLS-1$ //$NON-NLS-2$
- " plugins directory that does not exists."); //$NON-NLS-1$
- }
+ File pluginsfolder = new File(currFolder, pathToLauncherJar).getParentFile();
+ // System.err.println("Got the pluginsfolder " +
+ // pluginsfolder);
+ if (!pluginsfolder.exists()) { throw new IllegalStateException("The -startup argument in " + f.getPath()
+ + " is "
+ + oriStartup
+ + ". It points to "
+ + pluginsfolder.getPath()
+ + " plugins directory that does not exists."); }
TreeMap osgis = new TreeMap();
File[] plugins = pluginsfolder.listFiles();
for (int j = 0; j < plugins.length; j++)
{
File b = plugins[j];
- if (b.isFile() && b.getName().startsWith(FRAMEWORK_BUNDLE_NAME + "_") && b.getName().endsWith(".jar")) { //$NON-NLS-1$ //$NON-NLS-2$
- osgis.put(b.getName(),b);
+ if (b.isFile() && b.getName().startsWith(FRAMEWORK_BUNDLE_NAME + "_") && b.getName().endsWith(".jar"))
+ {
+ osgis.put(b.getName(), b);
}
}
- if (osgis.isEmpty())
- {
- throw new IllegalStateException("The -startup argument in " + f.getPath() + //$NON-NLS-1$
- " is " + oriStartup + //$NON-NLS-1$
- ". It points to " + pluginsfolder.getPath() + //$NON-NLS-1$
- " plugins directory but there is no org.eclipse.osgi.*.jar files there."); //$NON-NLS-1$
- }
- File osgiFramework = (File)osgis.values().iterator().next();
+ if (osgis.isEmpty()) { throw new IllegalStateException("The -startup argument in " + f.getPath()
+ + " is "
+ + oriStartup
+ + ". It points to "
+ + pluginsfolder.getPath()
+ + " plugins directory but there is no org.eclipse.osgi.*.jar files there."); }
+ File osgiFramework = (File) osgis.values().iterator().next();
String path = osgiFramework.getPath();
System.err.println("Using " + path + " for the osgi framework.");
return osgiFramework;
@@ -386,14 +421,13 @@ public class FrameworkLauncherExtended extends FrameworkLauncher
}
finally
{
- if (br != null)
- try
- {
- br.close();
- }
- catch (IOException ii)
- {
- }
+ if (br != null) try
+ {
+ br.close();
+ }
+ catch (IOException ii)
+ {
+ }
}
}
@@ -403,39 +437,36 @@ public class FrameworkLauncherExtended extends FrameworkLauncher
/**
* recursively substitute the ${sysprop} by their actual system property.
- * ${sysprop,defaultvalue} will use 'defaultvalue' as the value if no sysprop is defined.
- * Not the most efficient code but we are shooting for simplicity and speed of development here.
+ * ${sysprop,defaultvalue} will use 'defaultvalue' as the value if no
+ * sysprop is defined. Not the most efficient code but we are shooting for
+ * simplicity and speed of development here.
*
* @param value
* @return
*/
public static String resolveSystemProperty(String value)
- {
+ {
int ind = value.indexOf("${");
- if (ind == -1) {
- return value;
- }
+ if (ind == -1) { return value; }
int ind2 = value.indexOf('}', ind);
- if (ind2 == -1) {
- return value;
- }
- String sysprop = value.substring(ind+2, ind2);
+ if (ind2 == -1) { return value; }
+ String sysprop = value.substring(ind + 2, ind2);
String defaultValue = null;
int comma = sysprop.indexOf(',');
- if (comma != -1 && comma+1 != sysprop.length())
+ if (comma != -1 && comma + 1 != sysprop.length())
{
- defaultValue = sysprop.substring(comma+1);
+ defaultValue = sysprop.substring(comma + 1);
defaultValue = resolveSystemProperty(defaultValue);
- sysprop = sysprop.substring(0,comma);
+ sysprop = sysprop.substring(0, comma);
}
else
{
- defaultValue = "${" + sysprop + "}";
+ defaultValue = "${" + sysprop + "}";
}
-
+
String v = System.getProperty(sysprop);
-
- String reminder = value.length() > ind2 + 1 ? value.substring(ind2+1) : "";
+
+ String reminder = value.length() > ind2 + 1 ? value.substring(ind2 + 1) : "";
reminder = resolveSystemProperty(reminder);
if (v != null)
{
@@ -447,20 +478,19 @@ public class FrameworkLauncherExtended extends FrameworkLauncher
}
}
-
-
// introspection trick to be able to set the private field platformDirectory
private static Field _field;
+
void __setPlatformDirectory(File platformDirectory)
{
try
{
if (_field == null)
{
- _field = org.eclipse.equinox.servletbridge.FrameworkLauncher.class.getDeclaredField("platformDirectory"); //$NON-NLS-1$
+ _field = org.eclipse.equinox.servletbridge.FrameworkLauncher.class.getDeclaredField("platformDirectory");
_field.setAccessible(true);
}
- _field.set(this,platformDirectory);
+ _field.set(this, platformDirectory);
}
catch (SecurityException e)
{
@@ -479,26 +509,25 @@ public class FrameworkLauncherExtended extends FrameworkLauncher
e.printStackTrace();
}
}
-
- //introspection trick to invoke the generateExtensionBundle method
+
+ // introspection trick to invoke the generateExtensionBundle method
private static Method _deployExtensionBundleMethod;
+
private void __deployExtensionBundle(File plugins)
{
- //look for the extensionbundle
- //if it is already there no need to do something:
+ // look for the extensionbundle
+ // if it is already there no need to do something:
for (String file : plugins.list())
{
- if (file.startsWith("org.eclipse.equinox.servletbridge.extensionbundle"))//EXTENSIONBUNDLE_DEFAULT_BSN
- {
- return;
- }
+ if (file.startsWith("org.eclipse.equinox.servletbridge.extensionbundle"))// EXTENSIONBUNDLE_DEFAULT_BSN
+ { return; }
}
-
+
try
{
- //invoke deployExtensionBundle(File plugins)
+ // invoke deployExtensionBundle(File plugins)
if (_deployExtensionBundleMethod == null)
- {
+ {
_deployExtensionBundleMethod = FrameworkLauncher.class.getDeclaredMethod("deployExtensionBundle", File.class);
_deployExtensionBundleMethod.setAccessible(true);
}
@@ -509,139 +538,173 @@ public class FrameworkLauncherExtended extends FrameworkLauncher
t.printStackTrace();
}
}
-//--end of introspection to invoke deployExtensionBundle
-
-//from Framework with support for the equinox hook
- private static final String EXTENSIONBUNDLE_DEFAULT_BSN = "org.eclipse.equinox.servletbridge.extensionbundle"; //$NON-NLS-1$
- private static final String EXTENSIONBUNDLE_DEFAULT_VERSION = "1.2.0"; //$NON-NLS-1$
- private static final String MANIFEST_VERSION = "Manifest-Version"; //$NON-NLS-1$
- private static final String BUNDLE_MANIFEST_VERSION = "Bundle-ManifestVersion"; //$NON-NLS-1$
- private static final String BUNDLE_NAME = "Bundle-Name"; //$NON-NLS-1$
- private static final String BUNDLE_SYMBOLIC_NAME = "Bundle-SymbolicName"; //$NON-NLS-1$
- private static final String BUNDLE_VERSION = "Bundle-Version"; //$NON-NLS-1$
- private static final String FRAGMENT_HOST = "Fragment-Host"; //$NON-NLS-1$
- private static final String EXPORT_PACKAGE = "Export-Package"; //$NON-NLS-1$
-
- private static final String CONFIG_EXTENDED_FRAMEWORK_EXPORTS = "extendedFrameworkExports"; //$NON-NLS-1$
-
- private void deployExtensionBundle(File plugins, boolean configureEquinoxHook) {
- // we might want to parameterize the extension bundle BSN in the future
- final String extensionBundleBSN = EXTENSIONBUNDLE_DEFAULT_BSN;
- File extensionBundleFile = findExtensionBundleFile(plugins, extensionBundleBSN);
-
- if (extensionBundleFile == null)
- generateExtensionBundle(plugins, extensionBundleBSN, EXTENSIONBUNDLE_DEFAULT_VERSION, configureEquinoxHook);
- else /*if (Boolean.valueOf(config.getInitParameter(CONFIG_OVERRIDE_AND_REPLACE_EXTENSION_BUNDLE)).booleanValue())*/ {
- String extensionBundleVersion = findExtensionBundleVersion(extensionBundleFile, extensionBundleBSN);
- if (extensionBundleFile.isDirectory()) {
- deleteDirectory(extensionBundleFile);
- } else {
- extensionBundleFile.delete();
- }
- generateExtensionBundle(plugins, extensionBundleBSN, extensionBundleVersion, true);
-// } else {
-// processExtensionBundle(extensionBundleFile);
- }
- }
-
- private File findExtensionBundleFile(File plugins, final String extensionBundleBSN) {
- FileFilter extensionBundleFilter = new FileFilter() {
- public boolean accept(File candidate) {
- return candidate.getName().startsWith(extensionBundleBSN + "_"); //$NON-NLS-1$
- }
- };
- File[] extensionBundles = plugins.listFiles(extensionBundleFilter);
- if (extensionBundles.length == 0)
- return null;
-
- if (extensionBundles.length > 1) {
- for (int i = 1; i < extensionBundles.length; i++) {
- if (extensionBundles[i].isDirectory()) {
- deleteDirectory(extensionBundles[i]);
- } else {
- extensionBundles[i].delete();
- }
- }
- }
- return extensionBundles[0];
- }
-
- private String findExtensionBundleVersion(File extensionBundleFile, String extensionBundleBSN) {
- String fileName = extensionBundleFile.getName();
- if (fileName.endsWith(".jar")) {
- return fileName.substring(extensionBundleBSN.length() + 1, fileName.length() - ".jar".length());
- }
- return fileName.substring(extensionBundleBSN.length() + 1);
- }
-
-
- private void generateExtensionBundle(File plugins, String extensionBundleBSN, String extensionBundleVersion,
- boolean configureEquinoxHook) {
- Manifest mf = new Manifest();
- Attributes attribs = mf.getMainAttributes();
- attribs.putValue(MANIFEST_VERSION, "1.0"); //$NON-NLS-1$
- attribs.putValue(BUNDLE_MANIFEST_VERSION, "2"); //$NON-NLS-1$
- attribs.putValue(BUNDLE_NAME, "Servletbridge Extension Bundle"); //$NON-NLS-1$
- attribs.putValue(BUNDLE_SYMBOLIC_NAME, extensionBundleBSN);
- attribs.putValue(BUNDLE_VERSION, extensionBundleVersion);
- attribs.putValue(FRAGMENT_HOST, "system.bundle; extension:=framework"); //$NON-NLS-1$
-
- String servletVersion = context.getMajorVersion() + "." + context.getMinorVersion(); //$NON-NLS-1$
- String packageExports = "org.eclipse.equinox.servletbridge; version=1.1" + //$NON-NLS-1$
- ", javax.servlet; version=" + servletVersion + //$NON-NLS-1$
- ", javax.servlet.http; version=" + servletVersion + //$NON-NLS-1$
- ", javax.servlet.resources; version=" + servletVersion; //$NON-NLS-1$
-
- String extendedExports = config.getInitParameter(CONFIG_EXTENDED_FRAMEWORK_EXPORTS);
- if (extendedExports != null && extendedExports.trim().length() != 0)
- packageExports += ", " + extendedExports; //$NON-NLS-1$
-
- attribs.putValue(EXPORT_PACKAGE, packageExports);
- writeJarFile(new File(plugins, extensionBundleBSN + "_" + extensionBundleVersion + ".jar"), mf, configureEquinoxHook); //$NON-NLS-1$
- }
-
- private void writeJarFile(File jarFile, Manifest mf, boolean configureEquinoxHook) {
- try {
- JarOutputStream jos = null;
- try {
- jos = new JarOutputStream(new FileOutputStream(jarFile), mf);
-
- if (configureEquinoxHook) {
- //hook configurator properties:
- ZipEntry e = new ZipEntry("hookconfigurators.properties");
- jos.putNextEntry(e);
- Properties props = new Properties();
- props.put("hook.configurators", "org.eclipse.jetty.osgi.servletbridge.hook.ServletBridgeClassLoaderDelegateHook");
- props.store(jos, "");
- jos.closeEntry();
-
- //the hook class
- e = new ZipEntry("org/eclipse/jetty/osgi/servletbridge/hook/ServletBridgeClassLoaderDelegateHook.class");
- jos.putNextEntry(e);
- InputStream in = getClass().getResourceAsStream("/org/eclipse/jetty/osgi/servletbridge/hook/ServletBridgeClassLoaderDelegateHook.class");
-
- byte[] buffer = new byte[512];
- try {
- int n;
- while ((n = in.read(buffer)) != -1)
- {
- jos.write(buffer, 0, n);
- }
- } finally {
- in.close();
- }
- jos.closeEntry();
- }
-
- jos.finish();
- } finally {
- if (jos != null)
- jos.close();
- }
- } catch (IOException e) {
- context.log("Error writing extension bundle", e); //$NON-NLS-1$
- }
- }
-//--from Framework with support for the equinox hook
+
+ // --end of introspection to invoke deployExtensionBundle
+
+ // from Framework with support for the equinox hook
+ private static final String EXTENSIONBUNDLE_DEFAULT_BSN = "org.eclipse.equinox.servletbridge.extensionbundle"; //$NON-NLS-1$
+
+ private static final String EXTENSIONBUNDLE_DEFAULT_VERSION = "1.2.0"; //$NON-NLS-1$
+
+ private static final String MANIFEST_VERSION = "Manifest-Version"; //$NON-NLS-1$
+
+ private static final String BUNDLE_MANIFEST_VERSION = "Bundle-ManifestVersion"; //$NON-NLS-1$
+
+ private static final String BUNDLE_NAME = "Bundle-Name"; //$NON-NLS-1$
+
+ private static final String BUNDLE_SYMBOLIC_NAME = "Bundle-SymbolicName"; //$NON-NLS-1$
+
+ private static final String BUNDLE_VERSION = "Bundle-Version"; //$NON-NLS-1$
+
+ private static final String FRAGMENT_HOST = "Fragment-Host"; //$NON-NLS-1$
+
+ private static final String EXPORT_PACKAGE = "Export-Package"; //$NON-NLS-1$
+
+ private static final String CONFIG_EXTENDED_FRAMEWORK_EXPORTS = "extendedFrameworkExports"; //$NON-NLS-1$
+
+ private void deployExtensionBundle(File plugins, boolean configureEquinoxHook)
+ {
+ // we might want to parameterize the extension bundle BSN in the future
+ final String extensionBundleBSN = EXTENSIONBUNDLE_DEFAULT_BSN;
+ File extensionBundleFile = findExtensionBundleFile(plugins, extensionBundleBSN);
+
+ if (extensionBundleFile == null)
+ generateExtensionBundle(plugins, extensionBundleBSN, EXTENSIONBUNDLE_DEFAULT_VERSION, configureEquinoxHook);
+ else
+ /*
+ * if (Boolean.valueOf(config.getInitParameter(
+ * CONFIG_OVERRIDE_AND_REPLACE_EXTENSION_BUNDLE)).booleanValue())
+ */{
+ String extensionBundleVersion = findExtensionBundleVersion(extensionBundleFile, extensionBundleBSN);
+ if (extensionBundleFile.isDirectory())
+ {
+ deleteDirectory(extensionBundleFile);
+ }
+ else
+ {
+ extensionBundleFile.delete();
+ }
+ generateExtensionBundle(plugins, extensionBundleBSN, extensionBundleVersion, true);
+ // } else {
+ // processExtensionBundle(extensionBundleFile);
+ }
+ }
+
+ private File findExtensionBundleFile(File plugins, final String extensionBundleBSN)
+ {
+ FileFilter extensionBundleFilter = new FileFilter()
+ {
+ public boolean accept(File candidate)
+ {
+ return candidate.getName().startsWith(extensionBundleBSN + "_"); //$NON-NLS-1$
+ }
+ };
+ File[] extensionBundles = plugins.listFiles(extensionBundleFilter);
+ if (extensionBundles.length == 0) return null;
+
+ if (extensionBundles.length > 1)
+ {
+ for (int i = 1; i < extensionBundles.length; i++)
+ {
+ if (extensionBundles[i].isDirectory())
+ {
+ deleteDirectory(extensionBundles[i]);
+ }
+ else
+ {
+ extensionBundles[i].delete();
+ }
+ }
+ }
+ return extensionBundles[0];
+ }
+
+ private String findExtensionBundleVersion(File extensionBundleFile, String extensionBundleBSN)
+ {
+ String fileName = extensionBundleFile.getName();
+ if (fileName.endsWith(".jar")) { return fileName.substring(extensionBundleBSN.length() + 1, fileName.length() - ".jar".length()); }
+ return fileName.substring(extensionBundleBSN.length() + 1);
+ }
+
+ private void generateExtensionBundle(File plugins, String extensionBundleBSN, String extensionBundleVersion, boolean configureEquinoxHook)
+ {
+ Manifest mf = new Manifest();
+ Attributes attribs = mf.getMainAttributes();
+ attribs.putValue(MANIFEST_VERSION, "1.0"); //$NON-NLS-1$
+ attribs.putValue(BUNDLE_MANIFEST_VERSION, "2"); //$NON-NLS-1$
+ attribs.putValue(BUNDLE_NAME, "Servletbridge Extension Bundle"); //$NON-NLS-1$
+ attribs.putValue(BUNDLE_SYMBOLIC_NAME, extensionBundleBSN);
+ attribs.putValue(BUNDLE_VERSION, extensionBundleVersion);
+ attribs.putValue(FRAGMENT_HOST, "system.bundle; extension:=framework"); //$NON-NLS-1$
+
+ String servletVersion = context.getMajorVersion() + "." + context.getMinorVersion(); //$NON-NLS-1$
+ String packageExports = "org.eclipse.equinox.servletbridge; version=1.1"
+ + ", javax.servlet; version="
+ + servletVersion
+ + ", javax.servlet.http; version="
+ + servletVersion
+ + ", javax.servlet.resources; version="
+ + servletVersion;
+
+ String extendedExports = config.getInitParameter(CONFIG_EXTENDED_FRAMEWORK_EXPORTS);
+ if (extendedExports != null && extendedExports.trim().length() != 0) packageExports += ", " + extendedExports; //$NON-NLS-1$
+
+ attribs.putValue(EXPORT_PACKAGE, packageExports);
+ writeJarFile(new File(plugins, extensionBundleBSN + "_" + extensionBundleVersion + ".jar"), mf, configureEquinoxHook); //$NON-NLS-1$
+ }
+
+ private void writeJarFile(File jarFile, Manifest mf, boolean configureEquinoxHook)
+ {
+ try
+ {
+ JarOutputStream jos = null;
+ try
+ {
+ jos = new JarOutputStream(new FileOutputStream(jarFile), mf);
+
+ if (configureEquinoxHook)
+ {
+ // hook configurator properties:
+ ZipEntry e = new ZipEntry("hookconfigurators.properties");
+ jos.putNextEntry(e);
+ Properties props = new Properties();
+ props.put("hook.configurators", "org.eclipse.jetty.osgi.servletbridge.hook.ServletBridgeClassLoaderDelegateHook");
+ props.store(jos, "");
+ jos.closeEntry();
+
+ // the hook class
+ e = new ZipEntry("org/eclipse/jetty/osgi/servletbridge/hook/ServletBridgeClassLoaderDelegateHook.class");
+ jos.putNextEntry(e);
+ InputStream in = getClass().getResourceAsStream("/org/eclipse/jetty/osgi/servletbridge/hook/ServletBridgeClassLoaderDelegateHook.class");
+
+ byte[] buffer = new byte[512];
+ try
+ {
+ int n;
+ while ((n = in.read(buffer)) != -1)
+ {
+ jos.write(buffer, 0, n);
+ }
+ }
+ finally
+ {
+ in.close();
+ }
+ jos.closeEntry();
+ }
+
+ jos.finish();
+ }
+ finally
+ {
+ if (jos != null) jos.close();
+ }
+ }
+ catch (IOException e)
+ {
+ context.log("Error writing extension bundle", e); //$NON-NLS-1$
+ }
+ }
+ // --from Framework with support for the equinox hook
}
diff --git a/jetty-osgi/jetty-osgi-servletbridge/src/main/java/org/eclipse/jetty/osgi/servletbridge/hook/ServletBridgeClassLoaderDelegateHook.java b/jetty-osgi/jetty-osgi-servletbridge/src/main/java/org/eclipse/jetty/osgi/servletbridge/hook/ServletBridgeClassLoaderDelegateHook.java
index 7bc82a566a..f9698f90a9 100644
--- a/jetty-osgi/jetty-osgi-servletbridge/src/main/java/org/eclipse/jetty/osgi/servletbridge/hook/ServletBridgeClassLoaderDelegateHook.java
+++ b/jetty-osgi/jetty-osgi-servletbridge/src/main/java/org/eclipse/jetty/osgi/servletbridge/hook/ServletBridgeClassLoaderDelegateHook.java
@@ -27,80 +27,67 @@ import org.eclipse.osgi.framework.adaptor.ClassLoaderDelegateHook;
import org.eclipse.osgi.internal.loader.BundleLoader;
/**
- * With some complex osgi products, experience shows that using
- * a system bundle extension to pass certain packages from the bootstrapping
- * server to equinox fails.
- * The bundles keep loading javax.servlet.http from the javax.servlet bundle.
- * This class is in fact copied into the servletbridge.extensionbundle; it is not loaded by the webapp.
+ * With some complex osgi products, experience shows that using a system bundle
+ * extension to pass certain packages from the bootstrapping server to equinox
+ * fails. The bundles keep loading javax.servlet.http from the javax.servlet
+ * bundle. This class is in fact copied into the servletbridge.extensionbundle;
+ * it is not loaded by the webapp.
*/
public class ServletBridgeClassLoaderDelegateHook implements ClassLoaderDelegateHook, HookConfigurator
{
-
- private static Set<String> packagesInBootstrapClassLoader = new HashSet<String>();
- static
- {
- packagesInBootstrapClassLoader.add("javax.servlet");
- packagesInBootstrapClassLoader.add("javax.servlet.http");
- }
- public void addHooks(HookRegistry hookRegistry)
- {
- hookRegistry.addClassLoaderDelegateHook(this);
- }
-
- public Class preFindClass(String name, BundleClassLoader classLoader,
- BundleData data) throws ClassNotFoundException
- {
- String pkgName = BundleLoader.getPackageName(name);
- if (packagesInBootstrapClassLoader.contains(pkgName))
- {
- return EclipseStarter.class.getClassLoader().loadClass(name);
- }
- return null;
- }
+ private static Set<String> packagesInBootstrapClassLoader = new HashSet<String>();
+ static
+ {
+ packagesInBootstrapClassLoader.add("javax.servlet");
+ packagesInBootstrapClassLoader.add("javax.servlet.http");
+ }
+
+ public void addHooks(HookRegistry hookRegistry)
+ {
+ hookRegistry.addClassLoaderDelegateHook(this);
+ }
+
+ public Class preFindClass(String name, BundleClassLoader classLoader, BundleData data) throws ClassNotFoundException
+ {
+ String pkgName = BundleLoader.getPackageName(name);
+ if (packagesInBootstrapClassLoader.contains(pkgName)) { return EclipseStarter.class.getClassLoader().loadClass(name); }
+ return null;
+ }
- public Class postFindClass(String name, BundleClassLoader classLoader,
- BundleData data) throws ClassNotFoundException
- {
- return null;
- }
+ public Class postFindClass(String name, BundleClassLoader classLoader, BundleData data) throws ClassNotFoundException
+ {
+ return null;
+ }
- public URL preFindResource(String name, BundleClassLoader classLoader,
- BundleData data) throws FileNotFoundException
+ public URL preFindResource(String name, BundleClassLoader classLoader, BundleData data) throws FileNotFoundException
{
- return null;
- }
+ return null;
+ }
- public URL postFindResource(String name, BundleClassLoader classLoader,
- BundleData data) throws FileNotFoundException
- {
- return null;
- }
+ public URL postFindResource(String name, BundleClassLoader classLoader, BundleData data) throws FileNotFoundException
+ {
+ return null;
+ }
- public Enumeration preFindResources(String name,
- BundleClassLoader classLoader, BundleData data)
- throws FileNotFoundException
+ public Enumeration preFindResources(String name, BundleClassLoader classLoader, BundleData data) throws FileNotFoundException
{
- return null;
- }
+ return null;
+ }
- public Enumeration postFindResources(String name,
- BundleClassLoader classLoader, BundleData data)
- throws FileNotFoundException
+ public Enumeration postFindResources(String name, BundleClassLoader classLoader, BundleData data) throws FileNotFoundException
{
- return null;
- }
+ return null;
+ }
- public String preFindLibrary(String name, BundleClassLoader classLoader,
- BundleData data) throws FileNotFoundException
+ public String preFindLibrary(String name, BundleClassLoader classLoader, BundleData data) throws FileNotFoundException
{
- return null;
- }
+ return null;
+ }
- public String postFindLibrary(String name, BundleClassLoader classLoader,
- BundleData data)
+ public String postFindLibrary(String name, BundleClassLoader classLoader, BundleData data)
{
- return null;
- }
-
+ return null;
+ }
+
}

Back to the top