class EngineApplication extends Application {
    protected Engine engine;
    private final Configuration templateConfiguration;

    public EngineApplication(Engine engine) {
        this.engine = engine;
        getMetadataService().addExtension("log", MediaType.TEXT_PLAIN );
        getMetadataService().addExtension("cxml", MediaType.APPLICATION_XML );
        setStatusService(new EngineStatusService());
        templateConfiguration = new Configuration();
        templateConfiguration.setClassForTemplateLoading(getClass(), "");
        templateConfiguration.setObjectWrapper(ObjectWrapper.BEANS_WRAPPER);
    }

    @Override
    public Restlet createInboundRoot() {<FILL_FUNCTION_BODY>}

    public Engine getEngine() {
        return engine;
    }  
    
    /**
     * Customize Restlet error to include back button and full stack.
     */
    protected class EngineStatusService extends StatusService {

        @Override
        public Representation getRepresentation(Status status, Request request, Response response) {
            StringWriter st = new StringWriter();
            PrintWriter pw = new PrintWriter(st);
            if(status.getCode()==404){
                pw.append("<h1>Page not found</h1>\n");
                pw.append("The page you are looking for does not exist.  "+
                        "You may be able to recover by going " +
                "<a href='javascript:history.back();void(0);'>back</a>.\n");
            }
            else{
                pw.append("<h1>An error occurred</h1>\n");
                pw.append(
                        "You may be able to recover and try something " +
                        "else by going " +
                "<a href='javascript:history.back();void(0);'>back</a>.\n");
                if(status.getThrowable()!=null) {
                    pw.append("<h2>Cause: "+
                            status.getThrowable().toString()+"</h2>\n");
                    pw.append("<pre>");
                    status.getThrowable().printStackTrace(pw);
                    pw.append("</pre>");
                }
            }
            pw.flush();
            return new StringRepresentation(st.toString(),MediaType.TEXT_HTML);
        }

    }

    public Configuration getTemplateConfiguration() {
        return templateConfiguration;
    }
}

        Router router = new Router(getContext());

        router.attach("/",new Redirector(null,"/engine",Redirector.MODE_CLIENT_TEMPORARY));
        router.attach("/engine",EngineResource.class)
            .setMatchingMode(Template.MODE_EQUALS);
        router.attach("/engine/",EngineResource.class)
            .setMatchingMode(Template.MODE_EQUALS);

        Directory alljobsdir = new Directory(
                getContext(),
                engine.getJobsDir().toURI().toString());
        alljobsdir.setListingAllowed(true);
        router.attach("/engine/jobsdir",alljobsdir);
        
        
        EnhDirectory anypath = new EnhDirectory(
                getContext(),
                engine.getJobsDir().toURI().toString() /*TODO: changeme*/) {
                    @Override
                    protected Reference determineRootRef(Request request) {
                        String ref = "file:/";
                        return new Reference(ref);
                    }};
        anypath.setListingAllowed(true);
        anypath.setModifiable(true);
        anypath.setEditFilter(JobResource.EDIT_FILTER);
        
        router.attach("/engine/anypath/",anypath);
        
        EnhDirectory jobdir = new EnhDirectory(
                getContext(),
                engine.getJobsDir().toURI().toString() /*TODO: changeme*/) {
                    @Override
                    protected Reference determineRootRef(Request request) {
                        try {
                            return new Reference(
                                EngineApplication.this.getEngine()
                                .getJob(TextUtils.urlUnescape(
                                    (String)request.getAttributes().get("job")))
                                .getJobDir().getCanonicalFile().toURI().toString());
                        } catch (IOException e) {
                            throw new RuntimeException(e);
                        }
                    }};
        jobdir.setListingAllowed(true);
        jobdir.setModifiable(true);
        jobdir.setEditFilter(JobResource.EDIT_FILTER);
        router.attach("/engine/job/{job}/jobdir",jobdir);
        router.attach("/engine/job/{job}",JobResource.class);
        router.attach("/engine/job/{job}/report/{reportClass}",ReportGenResource.class);
        router.attach("/engine/job/{job}/beans",BeanBrowseResource.class);
        router.attach("/engine/job/{job}/beans/{beanPath}",BeanBrowseResource.class);
        router.attach("/engine/job/{job}/script",ScriptResource.class);

        // static files (won't serve directory, but will serve files in it)
        String resource = "clap://class/org/archive/crawler/restlet";
        Directory staticDir = new Directory(getContext(),resource); 
        router.attach("/engine/static/",staticDir);

        return router;
    
<no_super_class>