List of usage examples for javax.servlet.http HttpServlet getServletName
public String getServletName()
From source file:org.apache.axis.transport.http.AxisServletBase.java
/** * This is a uniform method of initializing AxisServer in a servlet * context.//from ww w . j a va2 s . c om * @todo add catch for not being able to cast the context attr to an * engine and reinit the engine if so. */ public static AxisServer getEngine(HttpServlet servlet) throws AxisFault { AxisServer engine = null; if (isDebug) log.debug("Enter: getEngine()"); ServletContext context = servlet.getServletContext(); synchronized (context) { engine = retrieveEngine(servlet); if (engine == null) { Map environment = getEngineEnvironment(servlet); // Obtain an AxisServer by using whatever AxisServerFactory is // registered. The default one will just use the provider we // passed in, and presumably JNDI ones will use the ServletContext // to figure out a JNDI name to look up. // // The point of doing this rather than just creating the server // manually with the provider above is that we will then support // configurations where the server instance is managed by the // container, and pre-registered in JNDI at deployment time. It // also means we put the standard configuration pattern in one // place. engine = AxisServer.getServer(environment); // attach the AxisServer with the current Servlet engine.setName(servlet.getServletName()); storeEngine(servlet, engine); } } if (isDebug) log.debug("Exit: getEngine()"); return engine; }
From source file:org.apache.axis.transport.http.AxisServletBase.java
/** * 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 */// w ww .j a v a 2s . com 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); } }
From source file:org.apache.axis.transport.http.AxisServletBase.java
/** * 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/* www. j a v a2 s .co m*/ * @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; } }
From source file:org.apache.tapestry.asset.AssetExternalizer.java
/** * Gets the externalizer singleton for the application. If it does not already * exist, it is created and stored into the {@link ServletContext}. * * <p>Each Tapestry application within a single {@link ServletContext} * will have its own externalizer; they are differentiated by the * application name./*from w ww. java 2s. c o m*/ * * @see org.apache.tapestry.spec.ApplicationSpecification#getName() * **/ public static AssetExternalizer get(IRequestCycle cycle) { HttpServlet servlet = cycle.getRequestContext().getServlet(); ServletContext context = servlet.getServletContext(); String servletName = servlet.getServletName(); String attributeName = "org.apache.tapestry.AssetExternalizer:" + servletName; AssetExternalizer result = (AssetExternalizer) context.getAttribute(attributeName); if (result == null) { result = new AssetExternalizer(cycle); context.setAttribute(attributeName, result); } return result; }