FileDocCategorySizeDatePackage
ServantCachingPolicy.javaAPI DocJava SE 5 API4412Fri Aug 26 14:54:36 BST 2005com.sun.corba.se.spi.extension

ServantCachingPolicy

public class ServantCachingPolicy extends org.omg.CORBA.LocalObject implements org.omg.CORBA.Policy
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:

  1. POA current semantics
  2. 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.

Fields Summary
public static final int
NO_SERVANT_CACHING
Do not cache servants in the ClientRequestDispatcher. This will always support the full POA semantics, including changing the servant that handles requests on a particular objref.
public static final int
FULL_SEMANTICS
Perform servant caching, preserving POA current and POA destroy semantics. We will use this as the new default, as the app server is making heavier use now of POA facilities.
public static final int
INFO_ONLY_SEMANTICS
Perform servant caching, preservent only POA current semantics. At least this level is required in order to support selection of ObjectCopiers for co-located RMI-IIOP calls, as the current copier is stored in OAInvocationInfo, which must be present on the stack inside the call.
public static final int
MINIMAL_SEMANTICS
Perform servant caching, not preserving POA current or POA destroy semantics.
private static ServantCachingPolicy
policy
private static ServantCachingPolicy
infoOnlyPolicy
private static ServantCachingPolicy
minimalPolicy
private int
type
Constructors Summary
private ServantCachingPolicy(int type)

	this.type = type ;
    
Methods Summary
public org.omg.CORBA.Policycopy()

	return this ;
    
public voiddestroy()

	// NO-OP
    
public static synchronized com.sun.corba.se.spi.extension.ServantCachingPolicygetFullPolicy()

	if (policy == null)
	    policy = new ServantCachingPolicy( FULL_SEMANTICS ) ;

	return policy ;
    
public static synchronized com.sun.corba.se.spi.extension.ServantCachingPolicygetInfoOnlyPolicy()

	if (infoOnlyPolicy == null)
	    infoOnlyPolicy = new ServantCachingPolicy( INFO_ONLY_SEMANTICS ) ;

	return infoOnlyPolicy ;
    
public static synchronized com.sun.corba.se.spi.extension.ServantCachingPolicygetMinimalPolicy()

	if (minimalPolicy == null)
	    minimalPolicy = new ServantCachingPolicy( MINIMAL_SEMANTICS ) ;

	return minimalPolicy ;
    
public static synchronized com.sun.corba.se.spi.extension.ServantCachingPolicygetPolicy()
Return the default servant caching policy.

	return getFullPolicy() ;
    
public intgetType()

	return type ;
    
public intpolicy_type()

	return ORBConstants.SERVANT_CACHING_POLICY ;
    
public java.lang.StringtoString()

	return "ServantCachingPolicy[" + typeToName() + "]" ;
    
public java.lang.StringtypeToName()

    
      
    
	switch (type) {
	    case FULL_SEMANTICS: 
		return "FULL" ;
	    case INFO_ONLY_SEMANTICS: 
		return "INFO_ONLY" ;
	    case MINIMAL_SEMANTICS: 
		return "MINIMAL" ;
	    default: 
		return "UNKNOWN(" + type + ")" ;
	}