How you can create restlet with Spring DM
1. need update 6 files
   - web.xml
   - applicationContext-osgi.xml
   - applicationContext.xml
   - MANIFEST.MF
   - TestApplication.java
   - TestDefaultResource.java
2. main point 
   use "org.restlet.component" as context-param
   in web.xml add below line
3. 
 [context-param]
  [param-name]org.restlet.component[/param-name]
  [param-value]component[/param-value]
 [/context-param]
4. "component is from "applicationContext.xml" file 
   [bean id="component" class="org.restlet.ext.spring.SpringComponent" ]
 [property name="defaultTarget" ref="application" /]
   [/bean]
5. "application" is from same file "applicationContext.xml" file 
   [bean id="application" class="applicationPackage.TestApplication"][/bean]
6. TestApplication.java
   import TestDefaultResouce;
import org.restlet.Application;
import org.restlet.Context;
import org.restlet.Restlet;
import org.restlet.Router;
public class EamApplication extends Application {
 
 public EamApplication() {
  super();
  // TODO Auto-generated constructor stub
 }
 public EamApplication(Context context) {
        super(context);
    }
    
 @Override
    public Restlet createRoot() {
     Router router = new Router(getContext());     
     router.attachDefault(TestDefaultResouce.class);        
        return router;
    }
}
7. TestDefaultResouce.java
import org.restlet.Context;
import org.restlet.data.MediaType;
import org.restlet.data.Request;
import org.restlet.data.Response;
import org.restlet.resource.Representation;
import org.restlet.resource.Resource;
import org.restlet.resource.StringRepresentation;
import org.restlet.resource.Variant;
public class EamDefaultResouce extends Resource {
 
 public EamDefaultResouce() {
  super();
  // TODO Auto-generated constructor stub
 }
 public EamDefaultResouce(Context context, Request request, Response response) {
  super(context, request, response);
  getVariants().add(new Variant(MediaType.TEXT_PLAIN));
 }
 @Override
 public Representation getRepresentation(Variant variant){
  Representation representation = new StringRepresentation("index page", MediaType.TEXT_PLAIN);
  return representation;
 }
}
Monday, 10 November 2008
Subscribe to:
Post Comments (Atom)
 
 
3 comments:
browse around this website Hermes Dolabuy hop over to this website replica louis vuitton bags pop over to this site Celine Dolabuy
his comment is here have a peek at this web-site pop over to this site replica bags i loved this replica designer bags wholesale
more info here best replica designer bags check this Dolabuy Louis Vuitton try this out gucci replica bags
Post a Comment