Being new to Java, the classpath concept is still uncertain to me... but I hope 
this answer covers it.

>From a clean install of Windows 7, I installed the most typical package of 
>Eclipse for Java Developers in the default location.  I installed restlet 
>1.1.6 from the www.restlet.org/downloads.  I started a new project.  In the 
>project properties dialog, I requested to add external .jars and directed 
>Eclipse to the locations of com.noelios.restlet.jar and org.restlet.jar.

This application interacts with Google Documents so I also downloaded and added 
the locations of the appropriate jar files for that.

The organization of the app is simple and is adapted directly from the 
tutorials on the restlet.org website, if I remember correctly what I did last 
month.

Here is the root Application, with routing for other resources removed:

import org.restlet.Application;
import org.restlet.Context;
import org.restlet.Restlet;
import org.restlet.Route;
import org.restlet.Router;
import org.restlet.util.Template;


public class FileSyncApp extends Application {
        
        public FileSyncApp(Context parentContext) {
                super(parentContext);
        }

        public synchronized Restlet createRoot() {
                // Create RESTlet router
                Router router = new Router(getContext());
                Route discovery =
                        router.attach("/discovery", DiscoveryResource.class);
                discovery.getTemplate().setMatchingMode(Template.MODE_EQUALS);  
        
                router.attachDefault(DefaultResource.class);
                return router;
                
        }
}

****
And here is the executable class with main() that is used to launch the 
application.  Here again I have stripped the database load and other things 
that have no connection to serving the Resources.
****

import java.io.File;
import java.util.Map;

import org.restlet.Application;
import org.restlet.Component;
import org.restlet.Context;
import org.restlet.data.Protocol;

import java.util.logging.Logger;


public class FileSyncApplication extends Application {

        public static void main(String[] args) throws Exception {
                Component component = new Component();
                component.getServers().add(Protocol.HTTP, 3000);
                component.getClients().add(Protocol.FILE);
                Context ctx = component.getContext().createChildContext();
                component.getDefaultHost().attach(new FileSyncApp(ctx));
                // Start the server.
                try {
                        component.start();
                }
                catch (java.net.BindException e) {
                        System.err.println("Need to kill existing server 
process before restarting!");
                }
                catch (Exception e) {
                        e.printStackTrace();
                }
        }
}

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2418597

Reply via email to