blob: 19a97b5b93992b302e1557a758bd1f0324a3c6ca [file] [log] [blame]
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -08001package net.floodlightcontroller.jython;
2
3import java.util.Collection;
4import java.util.HashMap;
5import java.util.Map;
6
7import org.slf4j.Logger;
8import org.slf4j.LoggerFactory;
9
10import net.floodlightcontroller.core.module.FloodlightModuleContext;
11import net.floodlightcontroller.core.module.FloodlightModuleException;
12import net.floodlightcontroller.core.module.IFloodlightModule;
13import net.floodlightcontroller.core.module.IFloodlightService;
14
15public class JythonDebugInterface implements IFloodlightModule {
16 protected static Logger log = LoggerFactory.getLogger(JythonDebugInterface.class);
17 protected JythonServer debug_server;
18 protected static int JYTHON_PORT = 6655;
19
20 @Override
21 public Collection<Class<? extends IFloodlightService>> getModuleServices() {
22 // We don't export services
23 return null;
24 }
25
26 @Override
27 public Map<Class<? extends IFloodlightService>, IFloodlightService>
28 getServiceImpls() {
29 // We don't export services
30 return null;
31 }
32
33 @Override
34 public Collection<Class<? extends IFloodlightService>>
35 getModuleDependencies() {
36 // We don't have any dependencies
37 return null;
38 }
39
40 @Override
41 public void init(FloodlightModuleContext context)
42 throws FloodlightModuleException {
43 // no-op
44 }
45
46 @Override
47 public void startUp(FloodlightModuleContext context) {
48 Map<String, Object> locals = new HashMap<String, Object>();
49 // add all existing module references to the debug server
50 for (Class<? extends IFloodlightService> s : context.getAllServices()) {
51 // Put only the last part of the name
52 String[] bits = s.getCanonicalName().split("\\.");
53 String name = bits[bits.length-1];
54 locals.put(name, context.getServiceImpl(s));
55 }
56
57 // read our config options
58 Map<String, String> configOptions = context.getConfigParams(this);
59 int port = JYTHON_PORT;
60 String portNum = configOptions.get("port");
61 if (portNum != null) {
62 port = Integer.parseInt(portNum);
63 }
64
65 JythonServer debug_server = new JythonServer(port, locals);
66 debug_server.start();
67 }
68}