- remove double initialization of jetty

- refactor some var assignments
pull/1/head
reger 12 years ago
parent 8e52271491
commit 36b7159282

@ -56,7 +56,7 @@ public final class Connections_p {
// server sessions
// get the serverCore thread
final WorkflowThread httpd = sb.getThread("10_httpd");
//final WorkflowThread httpd = sb.getThread("10_httpd"); //not working with Jetty
// determines if name lookup should be done or not
final boolean doNameLookup;
@ -138,7 +138,7 @@ public final class Connections_p {
}
prop.put("list", idx);
prop.putNum("numMax", ((serverCore)httpd).getMaxSessionCount());
prop.putNum("numMax", -1/* ((serverCore)httpd).getMaxSessionCount()*/); //TODO: get limit from Jetty
prop.putNum("numActiveRunning", numActiveRunning);
prop.putNum("numActivePending", numActivePending);

@ -40,46 +40,46 @@ import org.eclipse.jetty.server.nio.SelectChannelConnector;
*/
public class HttpServer {
private Server server = new Server();
/**
* @param port TCP Port to listen for http requests
*/
public HttpServer(int port) {
Switchboard sb = Switchboard.getSwitchboard();
server = new Server();
private Server server = new Server();
/**
* @param port TCP Port to listen for http requests
*/
public HttpServer(int port) {
Switchboard sb = Switchboard.getSwitchboard();
SelectChannelConnector connector = new SelectChannelConnector();
connector.setPort(port);
//connector.setThreadPool(new QueuedThreadPool(20));
server.addConnector(connector);
YacyDomainHandler domainHandler = new YacyDomainHandler();
domainHandler.setAlternativeResolver(sb.peers);
ResourceHandler resource_handler = new ResourceHandler();
resource_handler.setDirectoriesListed(true);
resource_handler.setWelcomeFiles(new String[]{ "index.html" });
resource_handler.setWelcomeFiles(new String[]{"index.html"});
resource_handler.setResourceBase("htroot/");
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[]
{ domainHandler, new ProxyCacheHandler(), new ProxyHandler(), new RewriteHandler(),
new SSIHandler(new TemplateHandler()),
resource_handler, new DefaultHandler() });
{domainHandler, new ProxyCacheHandler(), new ProxyHandler(),
new RewriteHandler(), new SSIHandler(new TemplateHandler()),
resource_handler, new DefaultHandler()});
YaCySecurityHandler securityHandler = new YaCySecurityHandler();
securityHandler.setLoginService(new YaCyLoginService());
securityHandler.setRealmName("YaCy Admin Interface");
securityHandler.setHandler(new CrashProtectionHandler(handlers));
// context handler for dispatcher and security
ContextHandler context = new ContextHandler();
context.setContextPath("/");
context.setHandler(securityHandler);
server.setHandler(context);
}
}
/**
* start http server

@ -84,7 +84,7 @@ public class SSIHandler extends ContentModHandler implements Handler, HandlerCon
//
//dispatcher.include(request, response);
writeContent(path,request,response);
response.flushBuffer();
} catch (Exception e) {
ConcurrentLog.logException(e);
@ -102,7 +102,7 @@ public class SSIHandler extends ContentModHandler implements Handler, HandlerCon
*/
public void writeContent(final String path, HttpServletRequest request, HttpServletResponse response) {
// check if there are arguments in path string
String args = "";
String args;
String fname = path;
final int argpos = path.indexOf('?');
if (argpos > 0) {

@ -82,24 +82,25 @@ import org.eclipse.jetty.server.handler.AbstractHandler;
*/
public class TemplateHandler extends AbstractHandler implements Handler {
private String htLocalePath = "DATA/LOCALE/htroot";
private String htDefaultPath = "htroot";
private String htDocsPath = "DATA/HTDOCS";
private static final serverClassLoader provider = new serverClassLoader(/*this.getClass().getClassLoader()*/);
private String htLocalePath = "DATA/LOCALE/htroot";
private String htDefaultPath = "htroot";
private String htDocsPath = "DATA/HTDOCS";
private static final serverClassLoader provider = new serverClassLoader(/*this.getClass().getClassLoader()*/);
private ConcurrentHashMap<File, SoftReference<Method>> templateMethodCache = null;
@Override
protected void doStart() throws Exception {
super.doStart();
templateMethodCache = new ConcurrentHashMap<File, SoftReference<Method>>();
}
@Override
protected void doStart() throws Exception {
super.doStart();
templateMethodCache = new ConcurrentHashMap<File, SoftReference<Method>>();
htDocsPath = Switchboard.getSwitchboard().htDocsPath.getPath();
}
@Override
protected void doStop() throws Exception {
super.doStop();
}
@Override
protected void doStop() throws Exception {
super.doStop();
}
/** Returns a path to the localized or default file according to the parameter localeSelection
* @param path relative from htroot
@ -228,16 +229,13 @@ public class TemplateHandler extends AbstractHandler implements Handler {
try {
tmp = invokeServlet(targetClass, legacyRequestHeader, args);
} catch (InvocationTargetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
ConcurrentLog.logException(e);
throw new ServletException();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
ConcurrentLog.logException(e);
throw new ServletException();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
ConcurrentLog.logException(e);
throw new ServletException();
}
@ -245,15 +243,15 @@ public class TemplateHandler extends AbstractHandler implements Handler {
ByteBuffer result = null;
if (tmp instanceof RasterPlotter) {
final RasterPlotter yp = (RasterPlotter) tmp;
// send an image to client
result = RasterPlotter.exportImage(yp.getImage(), "png");
}
if (tmp instanceof EncodedImage) {
final EncodedImage yp = (EncodedImage) tmp;
result = yp.getImage();
}
if (tmp instanceof RasterPlotter) {
final RasterPlotter yp = (RasterPlotter) tmp;
// send an image to client
result = RasterPlotter.exportImage(yp.getImage(), "png");
}
if (tmp instanceof EncodedImage) {
final EncodedImage yp = (EncodedImage) tmp;
result = yp.getImage();
}
if (tmp instanceof Image) {
final Image i = (Image) tmp;

Loading…
Cancel
Save