added initial ChatServer
git-svn-id: svn://anubis/gvsu@266 45c1a28c-8058-47b2-ae61-ca45b979098e
This commit is contained in:
parent
79df31d59e
commit
e98396b032
66
cs656/lab4/ChatServer.java
Normal file
66
cs656/lab4/ChatServer.java
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import org.restlet.Application;
|
||||||
|
import org.restlet.Restlet;
|
||||||
|
import org.restlet.Component;
|
||||||
|
import org.restlet.Restlet;
|
||||||
|
import org.restlet.Route;
|
||||||
|
import org.restlet.Router;
|
||||||
|
import org.restlet.data.Protocol;
|
||||||
|
import org.restlet.util.Variable;
|
||||||
|
|
||||||
|
public class ChatServer extends Application
|
||||||
|
{
|
||||||
|
public ChatServer()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Create application root node.
|
||||||
|
* @see org.restlet.Application#createRoot()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Restlet createRoot()
|
||||||
|
{
|
||||||
|
Router router = new Router(getContext());
|
||||||
|
|
||||||
|
// Add a route for user resources
|
||||||
|
router.attach("/users", UserResource.class);
|
||||||
|
|
||||||
|
// Add a route for a user resource
|
||||||
|
router.attach("/users/{id}", Userource.class);
|
||||||
|
|
||||||
|
return router;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
public ObjectContainer getContainer()
|
||||||
|
{
|
||||||
|
return this.container;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param args Passed in from the command line.
|
||||||
|
*/
|
||||||
|
public static void main(String[] args)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Create a component with an HTTP server connector
|
||||||
|
Component comp = new Component();
|
||||||
|
comp.getServers().add(Protocol.HTTP, 3000);
|
||||||
|
|
||||||
|
// Attach the application to the default host and start it
|
||||||
|
comp.getDefaultHost().attach("/v1", new ChatServer());
|
||||||
|
comp.start();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
System.out.println("Whoops, our server threw an exception while bootstrapping, details follow.");
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user