wt.method.MethodContext的作用和意义
官方的JavaDoc指出:它是在MethodServer中一个活动的方法调用的上下文,用以维护当前线程和与该线程相关的资源,比如数据库连接之间的关系。
Context corresponding to an active method invocation in the method server. This class maintains an association between threads and resources currently assigned to the threads such as a database connections.
This class extends java.util.Hashtable so it can be used to maintain thread local storage that pertains to a particular method invocation. Methods are free to store whatever values they need under unique keys with confidence that the references will be freed when this context is unregistered.
For RMI calls, it is created immediately before argument unmarshaling begins and is unregisted after the reply has been marshaled back to the client. For non-RMI contexts (CORBA or internal), the context must be explicitly constructed and unregistered.
对于RMI调用,MethodContext会自动创建,并在返回时自动销毁;但对于非RMI调用,该上下文需要显示的构建和销毁。