Fields Summary |
---|
protected org.apache.axis.server.AxisServer | axisServerper-instance cache of the axis server |
private static Log | log |
private static boolean | isDebug |
private static int | loadCountercount number of service requests in progress |
private static Object | loadCounterLockand a lock |
protected static final String | ATTR_AXIS_ENGINEname of the axis engine to use in the servlet context |
private String | webInfPathCached path to our WEB-INF directory |
private String | homeDirCached path to our "root" dir |
private boolean | isDevelopmentflag set to true for a 'production' server |
private static final String | INIT_PROPERTY_DEVELOPMENT_SYSTEMproperty name for a production server |
Methods Summary |
---|
protected static void | decLockCounter()thread safe lock counter decrement
synchronized(loadCounterLock) {
loadCounter--;
}
|
public void | destroy()Destroy method is called when the servlet is going away. Pass this
down to the AxisEngine to let it clean up... But don't create the
engine if it hasn't already been created.
super.destroy();
//if we have had anything to do with creating an axis server
if (axisServer != null) {
//then we lock it
synchronized(axisServer) {
if (axisServer != null) {
//clean it up
axisServer.cleanup();
//and erase our history of it
axisServer =null;
storeEngine(this,null);
}
}
}
|
public org.apache.axis.server.AxisServer | getEngine()get the engine for this servlet from cache or context
if (axisServer == null)
axisServer = getEngine(this);
return axisServer;
|
public static org.apache.axis.server.AxisServer | getEngine(javax.servlet.http.HttpServlet servlet)This is a uniform method of initializing AxisServer in a servlet
context.
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;
|
protected static java.util.Map | getEngineEnvironment(javax.servlet.http.HttpServlet servlet)extract information from the servlet configuration files
Map environment = new HashMap();
String attdir= servlet.getInitParameter(AxisEngine.ENV_ATTACHMENT_DIR);
if (attdir != null)
environment.put(AxisEngine.ENV_ATTACHMENT_DIR, attdir);
ServletContext context = servlet.getServletContext();
environment.put(AxisEngine.ENV_SERVLET_CONTEXT, context);
String webInfPath = context.getRealPath("/WEB-INF");
if (webInfPath != null)
environment.put(AxisEngine.ENV_SERVLET_REALPATH,
webInfPath + File.separator + "attachments");
EngineConfiguration config =
EngineConfigurationFactoryFinder.newFactory(servlet)
.getServerEngineConfig();
if (config != null) {
environment.put(EngineConfiguration.PROPERTY_NAME, config);
}
return environment;
|
protected java.lang.String | getHomeDir()what is the root dir of the applet?
return homeDir;
|
public static int | getLoadCounter()get a count of the # of services running. This is only
ever an approximate number in a busy system
return loadCounter;
|
protected java.lang.String | getOption(javax.servlet.ServletContext context, java.lang.String param, java.lang.String dephault)Retrieve option, in order of precedence:
(Managed) System property (see discovery.ManagedProperty),
servlet init param, context init param.
Use of system properties is discouraged in production environments,
as it overrides everything else.
String value = AxisProperties.getProperty(param);
if (value == null)
value = getInitParameter(param);
if (value == null)
value = context.getInitParameter(param);
try {
AxisServer engine = getEngine(this);
if (value == null && engine != null)
value = (String) engine.getOption(param);
} catch (AxisFault axisFault) {
}
return (value != null) ? value : dephault;
|
public javax.servlet.ServletContext | getServletContext()what is the servlet context
return getServletConfig().getServletContext();
|
protected java.lang.String | getWebInfPath()accessor to webinf
return webInfPath;
|
protected java.lang.String | getWebappBase(javax.servlet.http.HttpServletRequest request)extract the base of our webapp from an inbound request
StringBuffer baseURL=new StringBuffer(128);
baseURL.append(request.getScheme());
baseURL.append("://");
baseURL.append(request.getServerName());
if(request.getServerPort()!=80) {
baseURL.append(":");
baseURL.append(request.getServerPort());
}
baseURL.append(request.getContextPath());
return baseURL.toString();
|
protected static void | incLockCounter()thread safe lock counter increment
synchronized(loadCounterLock) {
loadCounter++;
}
|
public void | init()our initialize routine; subclasses should call this if they override it
ServletContext context = getServletConfig().getServletContext();
webInfPath = context.getRealPath("/WEB-INF");
homeDir = context.getRealPath("/");
isDebug = log.isDebugEnabled();
if(log.isDebugEnabled()) log.debug("In AxisServletBase init");
isDevelopment= JavaUtils.isTrueExplicitly(getOption(context,
INIT_PROPERTY_DEVELOPMENT_SYSTEM, null));
|
public boolean | isDevelopment()probe for the system being 'production'
return isDevelopment;
|
private static org.apache.axis.server.AxisServer | retrieveEngine(javax.servlet.http.HttpServlet servlet)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
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;
}
|
protected void | service(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)subclass of service method that tracks entry count; calls the
parent's implementation to have the http method cracked and delegated
to the doGet, doPost method.
incLockCounter();
try {
super.service(req, resp);
}
finally {
decLockCounter();
}
|
private static void | storeEngine(javax.servlet.http.HttpServlet servlet, org.apache.axis.server.AxisServer engine)put the engine back in to the context.
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);
}
|