public String getContextPath( CartePluginInterface servlet ) { String contextPath = servlet.getContextPath(); if ( !contextPath.startsWith( "/kettle" ) ) { contextPath = "/kettle" + contextPath; } return contextPath; }
private void registerServlet( CartePluginInterface servlet ) { TransformationMap transformationMap = CarteSingleton.getInstance().getTransformationMap(); JobMap jobMap = CarteSingleton.getInstance().getJobMap(); SocketRepository socketRepository = CarteSingleton.getInstance().getSocketRepository(); cartePluginRegistry.put( getServletKey( servlet ), servlet ); servlet.setup( transformationMap, jobMap, socketRepository, detections ); servlet.setJettyMode( false ); } }
public void doGet( HttpServletRequest req, HttpServletResponse resp ) throws ServletException, IOException { String servletPath = req.getPathInfo(); if ( servletPath.endsWith( "/" ) ) { servletPath = servletPath.substring( 0, servletPath.length() - 1 ); } CartePluginInterface plugin = cartePluginRegistry.get( servletPath ); if ( plugin != null ) { try { plugin.doGet( req, resp ); } catch ( ServletException e ) { throw e; } catch ( Exception e ) { throw new ServletException( e ); } } else { if ( log.isDebug() ) { log.logDebug( "Unable to find CartePlugin for key: /kettle" + req.getPathInfo() ); } resp.sendError( 404 ); } }
servlet.setup( transformationMap, jobMap, socketRepository, detections ); servlet.setJettyMode( true );
private String getServletKey( CartePluginInterface servlet ) { String key = servlet.getContextPath(); if ( key.startsWith( "/kettle" ) ) { key = key.substring( "/kettle".length() ); } return key; }