[ 
https://issues.apache.org/jira/browse/HADOOP-7532?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13086741#comment-13086741
 ] 

Luke Lu commented on HADOOP-7532:
---------------------------------

Thanks for the feedback Aaron. Not sure if you've actually used the new 
framework in an IDE. Here is some unique advantages of the framework:
# It's secure (always escape content (including attributes) unless you resort 
to use raw response writer, which is usually not necessary, I'll make it even 
harder to use raw writer, as I haven't found a legit use of raw writer in user 
code so far), making XSS practically (besides explicit script element handling) 
impossible; 
# IDE/refactor friendly (pure java, live html help/hints without plugins);
# Statically validates html (you can still generate bad html if you really try 
but you can generate valid html much easier).

None of the existing template engines (including jamon) has these properties. I 
have used many web frameworks and template engines and I honestly prefer Hamlet 
for views, as I can pretty much (with IDE hints) guarantee a correct layout 
when I finish typing, without the tedious modify, reload, inspect/validate 
cycles.

Vinod and Bobby did substantial amount of UI work with the new framework 
without having to ask me any questions related to the framework, which, IMO, is 
some significant evidence that the framework is fairly easy to use/explore. 
Excluding the generated code, the source of the entire framework (controller, 
router and basic view support) is only a couple of KLOC. The framework in 
MR-279 hasn't been changed since MR-279 branch is created (which IMO, is a 
testament of its stability). It will be significantly improved when it's moved 
to hadoop-common based on the experience of people besides myself.

Here is a complete 3 in 1 hello world example for the framework.
{code}
import org.apache.hadoop.webapp.Controller;
import static org.apache.hadoop.webapp.WebApps.newWebApp;
import org.apache.hadoop.webapp.view.HtmlPage;

/**
 * The obligatory example. No xml/jsp/templates/config files! No
 * proliferation of strange annotations either :)
 *
 * <p>3 in 1 example. Check results at
 * <br>http://localhost:8888/hello and
 * <br>http://localhost:8888/hello/html
 * <br>http://localhost:8888/hello/json
 */
public class HelloWorld {
  public static class Hello extends Controller {
    @Override public void index() { renderText("Hello world!"); }
    public void html() { setTitle("Hello world!"); }
    public void json() { renderJSON("Hello world!"); }
  }

  public static class HelloView extends HtmlPage {
    @Override protected void render(Page.Root html) {
      html.
        title($("title")).
        p("#hello-style").
          _($("title"))._()._();
    }
  }

  public static void main(String[] args) {
    newWebApp().at(8888).inDevMode().start().joinThread();
  }
}
{code}


> Hadoop web UI 2.0
> -----------------
>
>                 Key: HADOOP-7532
>                 URL: https://issues.apache.org/jira/browse/HADOOP-7532
>             Project: Hadoop Common
>          Issue Type: Improvement
>    Affects Versions: 0.23.0
>            Reporter: Luke Lu
>            Assignee: Luke Lu
>             Fix For: 0.23.0
>
>
> People have expressed interests of bringing Hadoop web UI up to date with the 
> lightweight embedded web mvc framework used in MAPREDUCE-279 (cf. 
> MAPREDUCE-2399). This is the umbrella jira for UI improvement for 0.23+. 
> Individual items like web framework refactor/move and the unique challenge 
> for MR2 webapp security will be filed separately.
> Thoughts/ideas on various improvement of Hadoop web UI are welcome here. Some 
> of the ideas will naturally become sub-issues.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to