Policy used to implement servant caching optimization in the POA. Creating a POA with an instance pol of this policy where pol.getType() > NO_SERVANT_CACHING will cause the servant to be looked up in the POA and cached in the LocalClientRequestDispatcher when the ClientRequestDispatcher is colocated with the implementation of the objref. This greatly speeds up invocations at the cost of violating the POA semantics. In particular, every request to a particular objref must be handled by the same servant. Note that this is typically the case for EJB implementations.
If servant caching is used, there are two different additional features of the POA that are expensive:
- POA current semantics
- Proper handling of POA destroy.
POA current semantics requires maintaining a ThreadLocal stack of invocation information that is always available for POACurrent operations. Maintaining this stack is expensive on the timescale of optimized co-located calls, so the option is provided to turn it off. Similarly, causing POA.destroy() calls to wait for all active calls in the POA to complete requires careful tracking of the entry and exit of invocations in the POA. Again, tracking this is somewhat expensive.