n2Output,Hessian就是解析这两个东西来执行函数调用的。当然,在service里边还有一个重要的语句
Java代码
ServiceContext.begin(req, serviceId, objectId);
这个函数有点奇怪,我每次到这里serviceId和objectId都是空,不知道是不是历史遗留问题还存在这两个参数。
进去这个类看看
Java代码
public class ServiceContext {
private static final ThreadLocal _localContext = new ThreadLocal();
private ServletRequest _request;
private String _serviceName;
private String _objectId;
private int _count;
private HashMap _headers = new HashMap();
private ServiceContext()
{
}
/**
* Sets the request object prior to calling the service''s method.
*
* @param request the calling servlet request
* @param serviceId the service identifier
* @param objectId the object identifier
*/
public static void begin(ServletRequest request,
String serviceName,
String objectId)
throws ServletException
{
ServiceContext context = (ServiceContext) _localContext.get();
if (context == null) {
context = new ServiceContext();
_localContext.set(context);
}
context._request = request;
context._serviceName = serviceName;
context._objectId = objectId;
context._count++;
}
/**
* Returns the service request.
*/
public static ServiceContext getContext()
{
return (ServiceContext) _localContext.get();
}
/**
* Adds a header.
*/
public void addHeader(String header, Object value)
{
_headers.put(header, value);
}
/**
* Gets a header.
*/
public Object getHeader(String header)
{
return _headers.get(header);
}
/**
* Gets a header from the context.
*/
public static Object getContextHeader(String header)
{
ServiceContext context = (ServiceContext) _localContext.get();
if (context != null)
return context.getHeader(header);
else
return null;
}
/**
* Returns the service request.
*/
public static ServletRequest getContextRequest()
{
ServiceContext context = (ServiceContext) _localContext.get();
if (context != null)
return context._request;
else
return null;
}
/**
* Returns the service id, corresponding to the pathInfo of the URL.
*/
public static String getContextServiceName()
{
ServiceContext context = (ServiceContext) _localContext.get();
if (context != null)
return context._serviceName;
else
return null;
}
/**
* Returns the object id, corresponding to the ?id= of the URL.
*/
public static String getContextObjectId()
{
ServiceContext context = (ServiceContext) _localContext.get();
if (context != null)
return context._objectId;
else
return null;
}
/**
* Cleanup at the end of a request.
*/
public static void end()
{
ServiceContext context = (ServiceContext) _localContext.get();
if (context != null && --co
|