My favorites | Sign in
Project Home Downloads Wiki Issues Source
Repository:
Checkout   Browse   Changes   Clones    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package org.plovr;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;

import com.google.common.base.Preconditions;
import com.sun.net.httpserver.HttpHandler;

/**
* {@link Handler} is an enumeration of {@link HttpHandler}s that are registered
* with the {@link CompilationServer}.
*
* @author bolinfest@gmail.com (Michael Bolin)
*/
public enum Handler {
// Creating an enumeration of handlers makes it easier to generate HTML
// documentation, as demonstrated by ConfigOption and
// ConfigOptionDocumentationGenerator.
INDEX("/", IndexRequestHandler.class),
CONFIG("/config", ConfigRequestHandler.class),
COMPILE("/compile", CompileRequestHandler.class),
CSS("/css", CssHandler.class),
EXTERNS("/externs", ExternsHandler.class),
INPUT("/input", InputFileHandler.class),
LIST("/list", ListHandler.class),
MODULE("/module", ModuleHandler.class),
MODULES("/modules", ModulesHandler.class),
SIZE("/size", SizeHandler.class),
SOURCEMAP("/sourcemap", SourceMapHandler.class),
TEST("/test", TestHandler.class),
VIEW("/view", ViewFileHandler.class),
;

private final String context;

private final Class<?> httpHandlerClass;

Handler(String context, Class<?> httpHandlerClass) {
Preconditions.checkNotNull(context);
Preconditions.checkNotNull(httpHandlerClass);
Preconditions.checkArgument(
implementsInterface(httpHandlerClass, HttpHandler.class),
"Must implement HttpHandler: " + httpHandlerClass);
this.context = context;
this.httpHandlerClass = httpHandlerClass;
}

public String getContext() {
return context;
}

public HttpHandler createHandlerForCompilationServer(
CompilationServer server) {
try {
@SuppressWarnings("unchecked")
Constructor<HttpHandler> constructor = (Constructor<HttpHandler>) httpHandlerClass
.getConstructor(CompilationServer.class);
return constructor.newInstance(server);
} catch (NoSuchMethodException e) {
throw new RuntimeException(e);
} catch (InstantiationException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (InvocationTargetException e) {
throw new RuntimeException(e);
}
}

private static boolean implementsInterface(Class<?> clazz, Class<?> iface) {
while (clazz != null) {
Class<?>[] interfaces = clazz.getInterfaces();
if (Arrays.asList(interfaces).contains(iface)) {
return true;
} else {
clazz = clazz.getSuperclass();
}
}
return false;
}
}

Change log

819b590785fd by "Michael Bolin <bolinfest> on Feb 8, 2012   Diff
Initial support for Closure Stylesheets.
Currently, only works in serve mode.
Only options that can be specified from a
config are:
  css-inputs
  css-allowed-non-standard-functions
Options will be prefixed with "css-"
rather than doing:
  css: {
    inputs: ...
    allowed-non-standard-functions: ...
  }
...
Go to: 
Project members, sign in to write a code review

Older revisions

4e21c30acdce by Michael Bolin <bolinfest> on Oct 18, 2011   Diff
Laying the groundwork for generating
_test.html files for _test.js files.
Next step is to create the multitest
runner.
After that, need to make it possible
...
0e62678b4ca6 by Michael Bolin <bolinfest> on Jan 6, 2011   Diff
Created a ConfigRequestHandler that
simply displays the contents of the
config file and linked it from the
index page.
97017b071427 by Michael Bolin <bolinfest> on Jan 6, 2011   Diff
Created an enumeration of request
handlers so that they will be easier
to document in the near future.
Also created a new handler
(IndexRequestHandler) that will be
...
All revisions of this file

File info

Size: 2644 bytes, 82 lines
Powered by Google Project Hosting