Examples of RegionFactory


Examples of org.hibernate.cache.RegionFactory

    DEFAULT_CACHE_CONCURRENCY_STRATEGY = strategy;
  }

  private static CacheConcurrencyStrategy determineCacheConcurrencyStrategy(Mappings mappings) {
    if ( DEFAULT_CACHE_CONCURRENCY_STRATEGY == null ) {
      final RegionFactory cacheRegionFactory = SettingsFactory.createRegionFactory(
          mappings.getConfigurationProperties(), true
      );
      DEFAULT_CACHE_CONCURRENCY_STRATEGY = CacheConcurrencyStrategy.fromAccessType( cacheRegionFactory.getDefaultAccessType() );
    }
    return DEFAULT_CACHE_CONCURRENCY_STRATEGY;
  }
View Full Code Here

Examples of org.hibernate.cache.RegionFactory

    DEFAULT_CACHE_CONCURRENCY_STRATEGY = strategy;
  }

  private static CacheConcurrencyStrategy determineCacheConcurrencyStrategy(Mappings mappings) {
    if ( DEFAULT_CACHE_CONCURRENCY_STRATEGY == null ) {
      final RegionFactory cacheRegionFactory = SettingsFactory.createRegionFactory(
          mappings.getConfigurationProperties(), true
      );
      DEFAULT_CACHE_CONCURRENCY_STRATEGY = CacheConcurrencyStrategy.fromAccessType( cacheRegionFactory.getDefaultAccessType() );
    }
    return DEFAULT_CACHE_CONCURRENCY_STRATEGY;
  }
View Full Code Here

Examples of org.hibernate.cache.RegionFactory

    DEFAULT_CACHE_CONCURRENCY_STRATEGY = strategy;
  }

  private static CacheConcurrencyStrategy determineCacheConcurrencyStrategy(ExtendedMappings mappings) {
    if ( DEFAULT_CACHE_CONCURRENCY_STRATEGY == null ) {
      final RegionFactory cacheRegionFactory = SettingsFactory.createRegionFactory(
          mappings.getConfigurationProperties(), true
      );
      DEFAULT_CACHE_CONCURRENCY_STRATEGY = CacheConcurrencyStrategy.fromAccessType( cacheRegionFactory.getDefaultAccessType() );
    }
    return DEFAULT_CACHE_CONCURRENCY_STRATEGY;
  }
View Full Code Here

Examples of org.hibernate.cache.RegionFactory

    DEFAULT_CACHE_CONCURRENCY_STRATEGY = strategy;
  }

  private static CacheConcurrencyStrategy determineCacheConcurrencyStrategy(Mappings mappings) {
    if ( DEFAULT_CACHE_CONCURRENCY_STRATEGY == null ) {
      final RegionFactory cacheRegionFactory = SettingsFactory.createRegionFactory(
          mappings.getConfigurationProperties(), true
      );
      DEFAULT_CACHE_CONCURRENCY_STRATEGY = CacheConcurrencyStrategy.fromAccessType( cacheRegionFactory.getDefaultAccessType() );
    }
    return DEFAULT_CACHE_CONCURRENCY_STRATEGY;
  }
View Full Code Here

Examples of org.hibernate.cache.RegionFactory

  /**
   * Standard constructor.
   */
  public LocalRegionFactoryProxy() {
    RegionFactory rf = (RegionFactory) LocalSessionFactoryBean.getConfigTimeRegionFactory();
    // absolutely needs thread-bound RegionFactory to initialize
    if (rf == null) {
      throw new IllegalStateException("No Hibernate RegionFactory found - " +
        "'cacheRegionFactory' property must be set on LocalSessionFactoryBean");
    }
View Full Code Here

Examples of org.hibernate.cache.RegionFactory

  }

  @Test
  @SuppressWarnings("serial")
  public void testLocalSessionFactoryBeanWithCacheRegionFactory() throws Exception {
    final RegionFactory regionFactory = new NoCachingRegionFactory(null);
    final List invocations = new ArrayList();
    LocalSessionFactoryBean sfb = new LocalSessionFactoryBean() {
      @Override
      protected Configuration newConfiguration() {
        return new Configuration() {
View Full Code Here

Examples of org.hibernate.cache.RegionFactory

    DEFAULT_CACHE_CONCURRENCY_STRATEGY = strategy;
  }

  private static CacheConcurrencyStrategy determineCacheConcurrencyStrategy(Mappings mappings) {
    if ( DEFAULT_CACHE_CONCURRENCY_STRATEGY == null ) {
      final RegionFactory cacheRegionFactory = SettingsFactory.createRegionFactory(
          mappings.getConfigurationProperties(), true
      );
      DEFAULT_CACHE_CONCURRENCY_STRATEGY = CacheConcurrencyStrategy.fromAccessType( cacheRegionFactory.getDefaultAccessType() );
    }
    return DEFAULT_CACHE_CONCURRENCY_STRATEGY;
  }
View Full Code Here

Examples of org.hibernate.cache.spi.RegionFactory

    DEFAULT_CACHE_CONCURRENCY_STRATEGY = strategy;
  }

  private static CacheConcurrencyStrategy determineCacheConcurrencyStrategy(Mappings mappings) {
    if ( DEFAULT_CACHE_CONCURRENCY_STRATEGY == null ) {
      final RegionFactory cacheRegionFactory = SettingsFactory.createRegionFactory(
          mappings.getConfigurationProperties(), true
      );
      DEFAULT_CACHE_CONCURRENCY_STRATEGY = CacheConcurrencyStrategy.fromAccessType( cacheRegionFactory.getDefaultAccessType() );
    }
    return DEFAULT_CACHE_CONCURRENCY_STRATEGY;
  }
View Full Code Here

Examples of org.hibernate.cache.spi.RegionFactory

    ///////////////////////////////////////////////////////////////////////
    // Prepare persisters and link them up with their cache
    // region/access-strategy

    final RegionFactory regionFactory = cacheAccess.getRegionFactory();
    final String cacheRegionPrefix = settings.getCacheRegionPrefix() == null ? "" : settings.getCacheRegionPrefix() + ".";
    final PersisterFactory persisterFactory = serviceRegistry.getService( PersisterFactory.class );

    // todo : consider removing this silliness and just have EntityPersister directly implement ClassMetadata
    //    EntityPersister.getClassMetadata() for the internal impls simply "return this";
    //    collapsing those would allow us to remove this "extra" Map
    //
    // todo : similar for CollectionPersister/CollectionMetadata

    entityPersisters = new HashMap();
    Map entityAccessStrategies = new HashMap();
    Map<String,ClassMetadata> classMeta = new HashMap<String,ClassMetadata>();
    classes = cfg.getClassMappings();
    while ( classes.hasNext() ) {
      final PersistentClass model = (PersistentClass) classes.next();
      model.prepareTemporaryTables( mapping, getDialect() );
      final String cacheRegionName = cacheRegionPrefix + model.getRootClass().getCacheRegionName();
      // cache region is defined by the root-class in the hierarchy...
      EntityRegionAccessStrategy accessStrategy = ( EntityRegionAccessStrategy ) entityAccessStrategies.get( cacheRegionName );
      if ( accessStrategy == null && settings.isSecondLevelCacheEnabled() ) {
        final AccessType accessType = AccessType.fromExternalName( model.getCacheConcurrencyStrategy() );
        if ( accessType != null ) {
          LOG.tracef( "Building shared cache region for entity data [%s]", model.getEntityName() );
          EntityRegion entityRegion = regionFactory.buildEntityRegion( cacheRegionName, properties, CacheDataDescriptionImpl.decode( model ) );
          accessStrategy = entityRegion.buildAccessStrategy( accessType );
          entityAccessStrategies.put( cacheRegionName, accessStrategy );
          cacheAccess.addCacheRegion( cacheRegionName, entityRegion );
        }
      }

      NaturalIdRegionAccessStrategy naturalIdAccessStrategy = null;
      if ( model.hasNaturalId() && model.getNaturalIdCacheRegionName() != null ) {
        final String naturalIdCacheRegionName = cacheRegionPrefix + model.getNaturalIdCacheRegionName();
        naturalIdAccessStrategy = ( NaturalIdRegionAccessStrategy ) entityAccessStrategies.get( naturalIdCacheRegionName );

        if ( naturalIdAccessStrategy == null && settings.isSecondLevelCacheEnabled() ) {
          final CacheDataDescriptionImpl cacheDataDescription = CacheDataDescriptionImpl.decode( model );

          NaturalIdRegion naturalIdRegion = null;
          try {
            naturalIdRegion = regionFactory.buildNaturalIdRegion( naturalIdCacheRegionName, properties,
                cacheDataDescription );
          }
          catch ( UnsupportedOperationException e ) {
            LOG.warnf(
                "Shared cache region factory [%s] does not support natural id caching; " +
                    "shared NaturalId caching will be disabled for not be enabled for %s",
                regionFactory.getClass().getName(),
                model.getEntityName()
            );
          }

          if (naturalIdRegion != null) {
            naturalIdAccessStrategy = naturalIdRegion.buildAccessStrategy( regionFactory.getDefaultAccessType() );
            entityAccessStrategies.put( naturalIdCacheRegionName, naturalIdAccessStrategy );
            cacheAccess.addCacheRegionnaturalIdCacheRegionName, naturalIdRegion );
          }
        }
      }

      EntityPersister cp = persisterFactory.createEntityPersister(
          model,
          accessStrategy,
          naturalIdAccessStrategy,
          this,
          mapping
      );
      entityPersisters.put( model.getEntityName(), cp );
      classMeta.put( model.getEntityName(), cp.getClassMetadata() );
    }
    this.classMetadata = Collections.unmodifiableMap(classMeta);

    Map<String,Set<String>> tmpEntityToCollectionRoleMap = new HashMap<String,Set<String>>();
    collectionPersisters = new HashMap<String,CollectionPersister>();
    Map<String,CollectionMetadata> tmpCollectionMetadata = new HashMap<String,CollectionMetadata>();
    Iterator collections = cfg.getCollectionMappings();
    while ( collections.hasNext() ) {
      Collection model = (Collection) collections.next();
      final String cacheRegionName = cacheRegionPrefix + model.getCacheRegionName();
      final AccessType accessType = AccessType.fromExternalName( model.getCacheConcurrencyStrategy() );
      CollectionRegionAccessStrategy accessStrategy = null;
      if ( accessType != null && settings.isSecondLevelCacheEnabled() ) {
        LOG.tracev( "Building shared cache region for collection data [{0}]", model.getRole() );
        CollectionRegion collectionRegion = regionFactory.buildCollectionRegion( cacheRegionName, properties, CacheDataDescriptionImpl
            .decode( model ) );
        accessStrategy = collectionRegion.buildAccessStrategy( accessType );
        entityAccessStrategies.put( cacheRegionName, accessStrategy );
        cacheAccess.addCacheRegion( cacheRegionName, collectionRegion );
      }
View Full Code Here

Examples of org.hibernate.cache.spi.RegionFactory

    final boolean useQueryCache = ConfigurationHelper.getBoolean(
        AvailableSettings.USE_QUERY_CACHE,
        configurationValues
    );

    RegionFactory regionFactory = NoCachingRegionFactory.INSTANCE;

    // The cache provider is needed when we either have second-level cache enabled
    // or query cache enabled.  Note that useSecondLevelCache is enabled by default
    final String setting = ConfigurationHelper.getString( AvailableSettings.CACHE_REGION_FACTORY,
        configurationValues, null );
    if ( ( useSecondLevelCache || useQueryCache ) && setting != null ) {
      try {
        final Class<? extends RegionFactory> regionFactoryClass = registry.getService( StrategySelector.class )
            .selectStrategyImplementor( RegionFactory.class, setting );
        try {
          regionFactory = regionFactoryClass.getConstructor( Properties.class ).newInstance( p );
        }
        catch ( NoSuchMethodException e ) {
          // no constructor accepting Properties found, try no arg constructor
          LOG.debugf(
              "%s did not provide constructor accepting java.util.Properties; attempting no-arg constructor.",
              regionFactoryClass.getSimpleName() );
          regionFactory = regionFactoryClass.getConstructor().newInstance();
        }
      }
      catch ( Exception e ) {
        throw new HibernateException( "could not instantiate RegionFactory [" + setting + "]", e );
      }
    }

    LOG.debugf( "Cache region factory : %s", regionFactory.getClass().getName() );

    return regionFactory;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.