FileDocCategorySizeDatePackage
CacheProperties.javaAPI DocGlassfish v2 API5916Fri May 04 22:32:54 BST 2007com.sun.ejb.base.container.util

CacheProperties

public class CacheProperties extends Object
A util class to read the bean cache related entries from domain.xml and sun-ejb-jar.xml
author
Mahesh Kannan

Fields Summary
protected static final Logger
_logger
private int
maxCacheSize
private int
numberOfVictimsToSelect
private int
cacheIdleTimeoutInSeconds
private int
removalTimeoutInSeconds
private String
victimSelectionPolicy
Constructors Summary
public CacheProperties(com.sun.enterprise.deployment.EjbDescriptor desc)

        
       
        
        try {
            BeanCacheDescriptor beanCacheDes = null;
            Config cfg = null;
         
            IASEjbExtraDescriptors iased = desc.getIASEjbExtraDescriptors();
            if( iased != null) {
                beanCacheDes = iased.getBeanCache();
            }
        
            EjbContainer ejbContainer = null;
            ServerContext sc = ApplicationServer.getServerContext();
            cfg = ServerBeansFactory.getConfigBean(sc.getConfigContext());
            ejbContainer = cfg.getEjbContainer();

            loadProperties(ejbContainer, beanCacheDes);
            //container.setMonitorOn(ejbContainer.isMonitoringEnabled());
        }  catch (ConfigException ex) {
            _logger.log(Level.SEVERE, "", ex);
        }
    
Methods Summary
public intgetCacheIdleTimeoutInSeconds()

	return this.cacheIdleTimeoutInSeconds;
    
public intgetMaxCacheSize()

	return this.maxCacheSize;
    
public intgetNumberOfVictimsToSelect()

	return this.numberOfVictimsToSelect;
    
public intgetRemovalTimeoutInSeconds()

	return this.removalTimeoutInSeconds;
    
public java.lang.StringgetVictimSelectionPolicy()

	return this.victimSelectionPolicy;
    
private voidloadProperties(EjbContainer ejbContainer, com.sun.enterprise.deployment.runtime.BeanCacheDescriptor beanCacheDes)

	numberOfVictimsToSelect = 
	    new Integer(ejbContainer.getCacheResizeQuantity()).intValue();

	maxCacheSize =
	    new Integer(ejbContainer.getMaxCacheSize()).intValue();

	cacheIdleTimeoutInSeconds = new Integer(
		ejbContainer.getCacheIdleTimeoutInSeconds()).intValue();

	removalTimeoutInSeconds =
	    new Integer(ejbContainer.getRemovalTimeoutInSeconds()).intValue();

	victimSelectionPolicy = ejbContainer.getVictimSelectionPolicy();

	if (beanCacheDes != null) {
	    int temp = 0;
	    if ((temp =  beanCacheDes.getResizeQuantity()) != -1) {
		this.numberOfVictimsToSelect = temp;
	    }
	    if ((temp = beanCacheDes.getMaxCacheSize()) != -1) {
		this.maxCacheSize = temp;
	    }                              
	    if ((temp = beanCacheDes.getCacheIdleTimeoutInSeconds()) != -1){
		this.cacheIdleTimeoutInSeconds = temp;
	    }                
	    if ((temp = beanCacheDes.getRemovalTimeoutInSeconds()) != -1) {
		this.removalTimeoutInSeconds = temp;
	    }
	    if (( beanCacheDes.getVictimSelectionPolicy()) != null) {
		this.victimSelectionPolicy = 
		    beanCacheDes.getVictimSelectionPolicy();
	    }
	}
    
public java.lang.StringtoString()

	StringBuffer sbuf = new StringBuffer();
	sbuf.append("maxSize: ").append(maxCacheSize)
	    .append("; victims: ").append(numberOfVictimsToSelect)
	    .append("; idleTimeout: ").append(cacheIdleTimeoutInSeconds)
	    .append("; removalTimeout: ").append(removalTimeoutInSeconds)
	    .append("; policy: ").append(victimSelectionPolicy);

	return sbuf.toString();