FileDocCategorySizeDatePackage
SecondLevelCacheUtil.javaAPI DocJBoss 4.2.13208Fri Jul 13 20:53:58 BST 2007org.jboss.ejb3.entity

SecondLevelCacheUtil

public class SecondLevelCacheUtil extends Object
Utilities related to the Hibernate 2nd Level Cache
author
Brian Stansberry

Fields Summary
public static final String
HIBERNATE_CACHE_REGION_PREFIX
Constructors Summary
private SecondLevelCacheUtil()

Methods Summary
public static java.lang.StringcreateCacheRegionPrefix(java.lang.String earName, java.lang.String jarName, java.lang.String unitName)

   
           
   
      StringBuilder sb = new StringBuilder();
      if (earName != null)
      {
         sb.append(earName);
         if (!earName.endsWith(".ear")) 
            sb.append("_ear");
         sb.append(",");
      }
      if (jarName != null)
      {
         sb.append(jarName);
         if (!jarName.endsWith(".jar"))
            sb.append("_jar");
         sb.append(",");
      }
      sb.append(unitName);
      String raw = sb.toString();
      // Replace any '.' otherwise the JBoss Cache integration may replace
      // it with a '/' and it will become a level in the FQN
      String escaped = raw.replace('.", '_");
      return escaped;
   
public static java.lang.StringcreateRegionFqn(java.lang.String regionName, java.lang.String regionPrefix)

      String escaped = null;
      int idx = -1;
      if (regionPrefix != null)
      {
         idx = regionName.indexOf(regionPrefix);
      }
      
      if (idx > -1)
      {
         int regionEnd = idx + regionPrefix.length();
         String prefix = regionName.substring(0, regionEnd);
         String suffix = regionName.substring(regionEnd);
         suffix = suffix.replace('.", '/");
         escaped = prefix + suffix;
      }
      else
      {
         escaped = regionName.replace('.", '/");
      }
      return escaped;
   
public static booleanisSharedClassLoaderRegion(java.lang.String regionName)

      return (StandardQueryCache.class.getName().equals(regionName) 
               || UpdateTimestampsCache.class.getName().equals(regionName));