Going back to the old enableAliases because making it more complicated

did not fix the problem. :( Also avoiding literally building the directory
named "${build.dir}"
This commit is contained in:
dream
2010-09-22 02:21:36 +00:00
parent 8ce66e5cdd
commit 5c78eb3a3d
2 changed files with 3 additions and 50 deletions

View File

@ -10,7 +10,6 @@
<project name="enableAliases" default="default" basedir=".">
<description>Builds, tests, and runs the project enableAliases.</description>
<import file="nbproject/build-impl.xml"/>
<property name="warDir" value="${build.dir}/war"/>
<!--
There exist several targets which are by default empty and which can be
@ -75,6 +74,7 @@
<!-- Create the War File -->
<target name="-post-jar">
<property name="warDir" value="${build.dir}/war"/>
<copy todir="${warDir}/WEB-INF/classes">
<fileset dir="${build.classes.dir}" includes="**/*.class" />
</copy>

View File

@ -7,10 +7,6 @@ package i2p.dream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.ServletException;
import javax.servlet.ServletConfig;
import javax.servlet.http.HttpServlet;
@ -22,55 +18,14 @@ import org.mortbay.util.FileResource;
*
* @author dream
*/
class EnableAliases implements Runnable {
public void run() {
synchronized (FileResource.class) {
FileResource.setCheckAliases(false);
System.out.println("NO CHECK ALIASES GOD!");
}
}
static final EnableAliases instance = new EnableAliases();
}
class Repeatedly implements Runnable {
private final Runnable task;
private final long delay;
private final ExecutorService exec;
private int amount;
Repeatedly(int amount, long delay, ExecutorService exec, Runnable task) {
this.task = task;
this.delay = delay;
this.exec = exec;
this.amount = amount;
new Thread(this).run();
}
public void run() {
for(int i = 0;i<amount;++i) {
// to make sure task still happens in the executor thread
exec.submit(task);
try {
Thread.sleep(delay);
} catch (InterruptedException ex) {
Logger.getLogger(Repeatedly.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
}
public class AliasEnabler extends HttpServlet {
static final ExecutorService exec = Executors.newSingleThreadExecutor();
static void enableAliases() {
exec.submit(EnableAliases.instance);
FileResource.setCheckAliases(false);
}
static {
enableAliases();
new Repeatedly(3,10000,exec,EnableAliases.instance);
}
@Override
@ -80,7 +35,7 @@ public class AliasEnabler extends HttpServlet {
@Override
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
HttpServletResponse response) throws IOException, ServletException {
enableAliases();
response.setContentType("text/html");
PrintWriter out = response.getWriter();
@ -90,6 +45,4 @@ public class AliasEnabler extends HttpServlet {
out.close();
}
}
}