Package test.app

Source Code of test.app.TestApplication

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package test.app;

import org.restlet.Application;
import org.restlet.Context;
import org.restlet.Request;
import org.restlet.Response;
import org.restlet.Restlet;
import org.restlet.data.MediaType;
import org.restlet.data.Status;
import org.restlet.representation.StringRepresentation;

/**
*
* @author alex
*/
public class TestApplication extends Application {

   public TestApplication(Context context)
   {
      super(context);
   }
  
   public Restlet createRoot() {
      return new Restlet(getContext()) {
         public void handle(Request request,Response response) {
            StringBuilder builder = new StringBuilder();
            builder.append("Resource : "+request.getResourceRef()+"\n");
            builder.append("Base     : "+request.getResourceRef().getBaseRef()+"\n");
            builder.append("Remaining: "+request.getResourceRef().getRemainingPart()+"\n\n");
            builder.append("Attributes:\n");
            for (String name : request.getAttributes().keySet()) {
               builder.append("\t"+name+"="+request.getAttributes().get(name));
            }
            response.setEntity(new StringRepresentation(builder.toString(),MediaType.TEXT_PLAIN));
            response.setStatus(Status.SUCCESS_OK);
         }
      };
   }
}
TOP

Related Classes of test.app.TestApplication

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.