assertEquals(Key.get(HttpServlet.class).toString(), mockServlet.getServletName());
public String getActivatorName() { return _httpServlet.getServletName(); }
public String getActivatorName() { return _httpServlet.getServletName(); }
@Override public String getServletName() { return delegate.get().getServletName(); }
@Override public String getServletName() { return delegate.get().getServletName(); }
static String noApplicationSpecification(HttpServlet servlet) { return _formatter.format("no-application-specification", servlet.getServletName()); }
static String noApplicationSpecification(HttpServlet servlet) { return _formatter.format("no-application-specification", servlet.getServletName()); }
/** * put the engine back in to the context. * @param context servlet context to use * @param engine reference to the engine. If null, the engine is removed */ private static void storeEngine(HttpServlet servlet, AxisServer engine) { ServletContext context = servlet.getServletContext(); String axisServletName = servlet.getServletName(); if (engine == null) { context.removeAttribute(axisServletName + ATTR_AXIS_ENGINE); // find if there is other AxisEngine in Context AxisServer server = (AxisServer) context.getAttribute(ATTR_AXIS_ENGINE); // no other AxisEngine in ServletContext if (server != null && servlet.getServletName().equals(server.getName())) { context.removeAttribute(ATTR_AXIS_ENGINE); } } else { if (context.getAttribute(ATTR_AXIS_ENGINE) == null) { // first Axis servlet to store its AxisEngine // use default name context.setAttribute(ATTR_AXIS_ENGINE, engine); } context.setAttribute(axisServletName + ATTR_AXIS_ENGINE, engine); } }
/** * put the engine back in to the context. * @param context servlet context to use * @param engine reference to the engine. If null, the engine is removed */ private static void storeEngine(HttpServlet servlet, AxisServer engine) { ServletContext context = servlet.getServletContext(); String axisServletName = servlet.getServletName(); if (engine == null) { context.removeAttribute(axisServletName + ATTR_AXIS_ENGINE); // find if there is other AxisEngine in Context AxisServer server = (AxisServer) context.getAttribute(ATTR_AXIS_ENGINE); // no other AxisEngine in ServletContext if (server != null && servlet.getServletName().equals(server.getName())) { context.removeAttribute(ATTR_AXIS_ENGINE); } } else { if (context.getAttribute(ATTR_AXIS_ENGINE) == null) { // first Axis servlet to store its AxisEngine // use default name context.setAttribute(ATTR_AXIS_ENGINE, engine); } context.setAttribute(axisServletName + ATTR_AXIS_ENGINE, engine); } }
/** * put the engine back in to the context. * @param context servlet context to use * @param engine reference to the engine. If null, the engine is removed */ private static void storeEngine(HttpServlet servlet, AxisServer engine) { ServletContext context = servlet.getServletContext(); String axisServletName = servlet.getServletName(); if (engine == null) { context.removeAttribute(axisServletName + ATTR_AXIS_ENGINE); // find if there is other AxisEngine in Context AxisServer server = (AxisServer) context.getAttribute(ATTR_AXIS_ENGINE); // no other AxisEngine in ServletContext if (server != null && servlet.getServletName().equals(server.getName())) { context.removeAttribute(ATTR_AXIS_ENGINE); } } else { if (context.getAttribute(ATTR_AXIS_ENGINE) == null) { // first Axis servlet to store its AxisEngine // use default name context.setAttribute(ATTR_AXIS_ENGINE, engine); } context.setAttribute(axisServletName + ATTR_AXIS_ENGINE, engine); } }
@Override public void afterPropertiesSet() throws Exception { HttpContext actualHttpContext = (httpContext == null) ? httpService.createDefaultHttpContext() : httpContext; final Dictionary<String, String> initParams = new Hashtable<String, String>(); // The servlet will always have to match on uri prefix as some endpoints may do so initParams.put("matchOnUriPrefix", "true"); try { String servletName = servlet.getServletName(); initParams.put("servlet-name", servletName); } catch (Exception e) { // If getServletName is not implemented the default is to throw an exception // In this case we simply do not set a servlet name } httpService.registerServlet(alias, servlet, initParams, actualHttpContext); alreadyRegistered = true; }
/** * Get an engine from the servlet context; robust againt serialization * issues of hot-updated webapps. Remember than if a webapp is marked * as distributed, there is more than 1 servlet context, hence more than * one AxisEngine instance * @param servlet * @return the engine or null if either the engine couldnt be found or * the attribute wasnt of the right type */ private static AxisServer retrieveEngine(HttpServlet servlet) { Object contextObject = servlet.getServletContext().getAttribute(servlet.getServletName() + ATTR_AXIS_ENGINE); if (contextObject == null) { // if AxisServer not found : // fall back to the "default" AxisEngine contextObject = servlet.getServletContext().getAttribute(ATTR_AXIS_ENGINE); } if (contextObject instanceof AxisServer) { AxisServer server = (AxisServer) contextObject; // if this is "our" Engine if (server != null && servlet.getServletName().equals(server.getName())) { return server; } return null; } else { return null; } }
public void reallyProcess(String urlString, WebContext context) { HttpServletRequest request = context.getRequest(); HttpServletResponse response = context.getResponse(); try { servlet.service(request, response); } catch (Exception e) { logger.errorMessage("servlet:{}执行出错", e, servlet.getServletName()); throw new RuntimeException("servlet执行出错", e); } }
/** * Get an engine from the servlet context; robust againt serialization * issues of hot-updated webapps. Remember than if a webapp is marked * as distributed, there is more than 1 servlet context, hence more than * one AxisEngine instance * @param servlet * @return the engine or null if either the engine couldnt be found or * the attribute wasnt of the right type */ private static AxisServer retrieveEngine(HttpServlet servlet) { Object contextObject = servlet.getServletContext().getAttribute(servlet.getServletName() + ATTR_AXIS_ENGINE); if (contextObject == null) { // if AxisServer not found : // fall back to the "default" AxisEngine contextObject = servlet.getServletContext().getAttribute(ATTR_AXIS_ENGINE); } if (contextObject instanceof AxisServer) { AxisServer server = (AxisServer) contextObject; // if this is "our" Engine if (server != null && servlet.getServletName().equals(server.getName())) { return server; } return null; } else { return null; } }
private IApplicationSpecification constructStandinSpecification(HttpServlet servlet) { String servletName = servlet.getServletName(); ApplicationSpecification result = new ApplicationSpecification(); // Pretend the file exists in the most common expected location. Resource virtualLocation = new ContextResource(servlet.getServletContext(), "/WEB-INF/" + servletName + ".application"); result.setSpecificationLocation(virtualLocation); result.setName(servletName); return result; }
private IApplicationSpecification constructStandinSpecification(HttpServlet servlet) { String servletName = servlet.getServletName(); ApplicationSpecification result = new ApplicationSpecification(); // Pretend the file exists in the most common expected location. Resource virtualLocation = new ContextResource(servlet.getServletContext(), "/WEB-INF/" + servletName + ".application"); result.setSpecificationLocation(virtualLocation); result.setName(servletName); return result; }
@Override public RequestDispatcher getRequestDispatcher(String path) { Collection<ServletConfiguration> colls = ServletBridgeWebapp.get().getWebappConfig().getServletConfigurations(); HttpServlet servlet = null; String servletName = null; for (ServletConfiguration configuration : colls) { if (configuration.matchesUrlPattern(path)) { servlet = configuration.getHttpComponent(); servletName = configuration.getHttpComponent().getServletName(); } } return new RequestDispatcherImpl(servletName, path, servlet); }
private Resource findApplicationSpecification(HttpServlet servlet) { String path = servlet.getInitParameter(APP_SPEC_PATH_PARAM); if (path != null) return _classpathResourceFactory.newResource(path); ServletContext context = servlet.getServletContext(); String servletName = servlet.getServletName(); String expectedName = servletName + ".application"; Resource webInfLocation = new ContextResource(context, "/WEB-INF/"); Resource webInfAppLocation = webInfLocation.getRelativeResource(servletName + "/"); Resource result = check(webInfAppLocation, expectedName); if (result != null) return result; result = check(webInfLocation, expectedName); if (result != null) return result; // Now look for it in classpath, just in case result = _classpathResourceFactory.newResource(expectedName); if (result != null && result.getResourceURL() != null) return result; return null; }
private Resource findApplicationSpecification(HttpServlet servlet) { String path = servlet.getInitParameter(APP_SPEC_PATH_PARAM); if (path != null) return _classpathResourceFactory.newResource(path); ServletContext context = servlet.getServletContext(); String servletName = servlet.getServletName(); String expectedName = servletName + ".application"; Resource webInfLocation = new ContextResource(context, "/WEB-INF/"); Resource webInfAppLocation = webInfLocation.getRelativeResource(servletName + "/"); Resource result = check(webInfAppLocation, expectedName); if (result != null) return result; result = check(webInfLocation, expectedName); if (result != null) return result; // Now look for it in classpath, just in case result = _classpathResourceFactory.newResource(expectedName); if (result != null && result.getResourceURL() != null) return result; return null; }
@Override public void run() { Entity entity = null; if (marker != null) { entity = dsUtil.getMarker(marker); } HttpServletRequest req = DeferredTaskContext.getCurrentRequest(); if (marker == null || entity != null) { dsUtil.addRequestToDataStore(req, testParams); } HttpServletResponse resp = DeferredTaskContext.getCurrentResponse(); resp.setHeader("foo", "bar"); // try to do something more useful with response HttpServlet servlet = DeferredTaskContext.getCurrentServlet(); String sn = servlet.getServletName(); System.out.println("sn = " + sn); if (marker != null && entity == null) { DeferredTaskContext.markForRetry(); dsUtil.putMarker(marker); } else { DeferredTaskContext.setDoNotRetry(true); } } }