blob: c1d5b5f471ba09c2252a2abc24737488bbe0d1fb [file] [log] [blame]
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -08001package net.floodlightcontroller.ui.web;
2
3import java.util.ArrayList;
4import java.util.Collection;
5import java.util.Map;
6
7import org.restlet.Client;
8import org.restlet.Context;
9import org.restlet.Restlet;
10import org.restlet.data.Protocol;
11import org.restlet.resource.Directory;
12import org.restlet.routing.Router;
13
14import net.floodlightcontroller.core.module.FloodlightModuleContext;
15import net.floodlightcontroller.core.module.FloodlightModuleException;
16import net.floodlightcontroller.core.module.IFloodlightModule;
17import net.floodlightcontroller.core.module.IFloodlightService;
18import net.floodlightcontroller.restserver.IRestApiService;
19import net.floodlightcontroller.restserver.RestletRoutable;
20
21public class StaticWebRoutable implements RestletRoutable, IFloodlightModule {
22
23 private IRestApiService restApi;
24
25 @Override
26 public Collection<Class<? extends IFloodlightService>> getModuleDependencies() {
27 Collection<Class<? extends IFloodlightService>> l =
28 new ArrayList<Class<? extends IFloodlightService>>();
29 l.add(IRestApiService.class);
30 return l;
31 }
32
33 @Override
34 public Collection<Class<? extends IFloodlightService>> getModuleServices() {
35 return null;
36 }
37
38 @Override
39 public Map<Class<? extends IFloodlightService>, IFloodlightService>
40 getServiceImpls() {
41 return null;
42 }
43
44 @Override
45 public void init(FloodlightModuleContext context)
46 throws FloodlightModuleException {
47 restApi = context.getServiceImpl(IRestApiService.class);
48 }
49
50 @Override
51 public void startUp(FloodlightModuleContext context) {
52 // Add our REST API
53 restApi.addRestletRoutable(this);
54
55 }
56
57 @Override
58 public Restlet getRestlet(Context context) {
59 Router router = new Router(context);
60 router.attach("", new Directory(context, "clap://classloader/web/"));
61 context.setClientDispatcher(new Client(context, Protocol.CLAP));
62 return router;
63 }
64
65 @Override
66 public String basePath() {
67 return "/ui/";
68 }
69
70}