Example usage for org.hibernate.cache.spi.access AccessType READ_ONLY

List of usage examples for org.hibernate.cache.spi.access AccessType READ_ONLY

Introduction

In this page you can find the example usage for org.hibernate.cache.spi.access AccessType READ_ONLY.

Prototype

AccessType READ_ONLY

To view the source code for org.hibernate.cache.spi.access AccessType READ_ONLY.

Click Source Link

Document

Read-only access.

Usage

From source file:com.googlecode.hibernate.memcached.region.MemcachedCollectionRegion.java

License:Apache License

public CollectionRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException {
    if (AccessType.READ_ONLY.equals(accessType)) {
        if (metadata.isMutable()) {
            log.warn("read-only cache configured for mutable entity [" + getName() + "]");
        }/*from  w  ww .  jav  a2 s  .c o  m*/
        return new ReadOnlyMemcachedCollectionRegionAccessStrategy(this, settings);
    } else if (AccessType.READ_WRITE.equals(accessType)) {
        return new ReadWriteMemcachedCollectionRegionAccessStrategy(this, settings);
    } else if (AccessType.NONSTRICT_READ_WRITE.equals(accessType)) {
        return new NonStrictReadWriteMemcachedCollectionRegionAccessStrategy(this, settings);
    } else if (AccessType.TRANSACTIONAL.equals(accessType)) {
        return new TransactionalMemcachedCollectionRegionAccessStrategy(this, cache, settings);
    } else {
        throw new IllegalArgumentException("unrecognized access strategy type [" + accessType + "]");
    }
}

From source file:com.googlecode.hibernate.memcached.region.MemcachedEntityRegion.java

License:Apache License

public EntityRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException {

    if (AccessType.READ_ONLY.equals(accessType)) {
        if (metadata.isMutable()) {
            log.warn("read-only cache configured for mutable entity [" + getName() + "]");
        }/*from w  ww.  j  a  v a  2 s  . c  o m*/
        return new ReadOnlyMemcachedEntityRegionAccessStrategy(this, settings);
    } else if (AccessType.READ_WRITE.equals(accessType)) {
        return new ReadWriteMemcachedEntityRegionAccessStrategy(this, settings);
    } else if (AccessType.NONSTRICT_READ_WRITE.equals(accessType)) {
        return new NonStrictReadWriteMemcachedEntityRegionAccessStrategy(this, settings);
    } else if (AccessType.TRANSACTIONAL.equals(accessType)) {
        return new TransactionalMemcachedEntityRegionAccessStrategy(this, cache, settings);
    } else {
        throw new IllegalArgumentException("unrecognized access strategy type [" + accessType + "]");
    }
}

From source file:com.hazelcast.hibernate.CacheHitMissReadOnlyTest.java

License:Open Source License

protected String getCacheStrategy() {
    return AccessType.READ_ONLY.getExternalName();
}

From source file:com.hazelcast.hibernate.region.HazelcastCollectionRegion.java

License:Open Source License

public CollectionRegionAccessStrategy buildAccessStrategy(final AccessType accessType) throws CacheException {
    if (null == accessType) {
        throw new CacheException(
                "Got null AccessType while attempting to build CollectionRegionAccessStrategy. This can't happen!");
    }//from  w  ww . j  av a  2 s  .  c om
    if (AccessType.READ_ONLY.equals(accessType)) {
        return new CollectionRegionAccessStrategyAdapter(
                new ReadOnlyAccessDelegate<HazelcastCollectionRegion>(this, props));
    }
    if (AccessType.NONSTRICT_READ_WRITE.equals(accessType)) {
        return new CollectionRegionAccessStrategyAdapter(
                new NonStrictReadWriteAccessDelegate<HazelcastCollectionRegion>(this, props));
    }
    if (AccessType.READ_WRITE.equals(accessType)) {
        return new CollectionRegionAccessStrategyAdapter(
                new ReadWriteAccessDelegate<HazelcastCollectionRegion>(this, props));
    }
    if (AccessType.TRANSACTIONAL.equals(accessType)) {
        throw new CacheException("Transactional access is not currently supported by Hazelcast.");
    }
    throw new CacheException("Got unknown AccessType " + accessType
            + " while attempting to build CollectionRegionAccessStrategy.");
}

From source file:com.hazelcast.hibernate.region.HazelcastEntityRegion.java

License:Open Source License

public EntityRegionAccessStrategy buildAccessStrategy(final AccessType accessType) throws CacheException {
    if (null == accessType) {
        throw new CacheException(
                "Got null AccessType while attempting to determine a proper EntityRegionAccessStrategy. This can't happen!");
    }/*from   w  ww.  j  av  a2 s .  c o m*/
    if (AccessType.READ_ONLY.equals(accessType)) {
        return new EntityRegionAccessStrategyAdapter(
                new ReadOnlyAccessDelegate<HazelcastEntityRegion>(this, props));
    }
    if (AccessType.NONSTRICT_READ_WRITE.equals(accessType)) {
        return new EntityRegionAccessStrategyAdapter(
                new NonStrictReadWriteAccessDelegate<HazelcastEntityRegion>(this, props));
    }
    if (AccessType.READ_WRITE.equals(accessType)) {
        return new EntityRegionAccessStrategyAdapter(
                new ReadWriteAccessDelegate<HazelcastEntityRegion>(this, props));
    }
    if (AccessType.TRANSACTIONAL.equals(accessType)) {
        throw new CacheException("Transactional access is not currently supported by Hazelcast.");
    }
    throw new CacheException("Got unknown AccessType \"" + accessType
            + "\" while attempting to build EntityRegionAccessStrategy.");
}

From source file:com.hazelcast.hibernate.region.HazelcastNaturalIdRegion.java

License:Open Source License

public NaturalIdRegionAccessStrategy buildAccessStrategy(final AccessType accessType) throws CacheException {
    if (null == accessType) {
        throw new CacheException(
                "Got null AccessType while attempting to determine a proper NaturalIdRegionAccessStrategy. "
                        + "This can't happen!");
    }/*  ww  w  .j av  a  2 s.c om*/
    if (AccessType.READ_ONLY.equals(accessType)) {
        return new NaturalIdRegionAccessStrategyAdapter(
                new ReadOnlyAccessDelegate<HazelcastNaturalIdRegion>(this, props));
    }
    if (AccessType.NONSTRICT_READ_WRITE.equals(accessType)) {
        return new NaturalIdRegionAccessStrategyAdapter(
                new NonStrictReadWriteAccessDelegate<HazelcastNaturalIdRegion>(this, props));
    }
    if (AccessType.READ_WRITE.equals(accessType)) {
        return new NaturalIdRegionAccessStrategyAdapter(
                new ReadWriteAccessDelegate<HazelcastNaturalIdRegion>(this, props));
    }
    if (AccessType.TRANSACTIONAL.equals(accessType)) {
        throw new CacheException("Transactional access is not currently supported by Hazelcast.");
    }
    throw new CacheException("Got unknown AccessType \"" + accessType
            + "\" while attempting to build EntityRegionAccessStrategy.");
}

From source file:com.hazelcast.hibernate4.region.HazelcastNaturalIdRegion.java

License:Open Source License

public NaturalIdRegionAccessStrategy buildAccessStrategy(final AccessType accessType) throws CacheException {
    if (null == accessType) {
        throw new CacheException(
                "Got null AccessType while attempting to determine a proper NaturalIdRegionAccessStrategy. This can't happen!");
    }//from ww w .j  a  v a 2  s  .  c o m
    if (AccessType.READ_ONLY.equals(accessType)) {
        return new NaturalIdRegionAccessStrategyAdapter(
                new ReadOnlyAccessDelegate<HazelcastNaturalIdRegion>(this, props));
    }
    if (AccessType.NONSTRICT_READ_WRITE.equals(accessType)) {
        return new NaturalIdRegionAccessStrategyAdapter(
                new NonStrictReadWriteAccessDelegate<HazelcastNaturalIdRegion>(this, props));
    }
    if (AccessType.READ_WRITE.equals(accessType)) {
        return new NaturalIdRegionAccessStrategyAdapter(
                new ReadWriteAccessDelegate<HazelcastNaturalIdRegion>(this, props));
    }
    if (AccessType.TRANSACTIONAL.equals(accessType)) {
        throw new CacheException("Transactional access is not currently supported by Hazelcast.");
    }
    throw new CacheException("Got unknown AccessType \"" + accessType
            + "\" while attempting to build EntityRegionAccessStrategy.");
}

From source file:com.oracle.coherence.hibernate.cache.access.AbstractCoherenceRegionAccessStrategyTest.java

License:CDDL license

/**
 * Returns a new CollectionReadOnlyCoherenceRegionAccessStrategy.
 *
 * @return an CollectionReadOnlyCoherenceRegionAccessStrategy
 *//*from  w w  w .  j  a  v  a2s  .c om*/
protected CoherenceRegionAccessStrategy newCollectionReadOnlyCoherenceRegionAccessStrategy() {
    return (CoherenceRegionAccessStrategy) getCoherenceCollectionRegion()
            .buildAccessStrategy(AccessType.READ_ONLY);
}

From source file:com.oracle.coherence.hibernate.cache.access.AbstractCoherenceRegionAccessStrategyTest.java

License:CDDL license

/**
 * Returns a new EntityReadOnlyCoherenceRegionAccessStrategy.
 *
 * @return an EntityReadOnlyCoherenceRegionAccessStrategy
 *//*from   www .j  a va 2 s. co m*/
protected CoherenceRegionAccessStrategy newEntityReadOnlyCoherenceRegionAccessStrategy() {
    return (CoherenceRegionAccessStrategy) getCoherenceEntityRegion().buildAccessStrategy(AccessType.READ_ONLY);
}

From source file:com.oracle.coherence.hibernate.cache.access.AbstractCoherenceRegionAccessStrategyTest.java

License:CDDL license

/**
 * Returns a new NaturalIdReadOnlyCoherenceRegionAccessStrategy.
 *
 * @return an NaturalIdReadOnlyCoherenceRegionAccessStrategy
 *///from   www  .jav  a  2s.c om
protected CoherenceRegionAccessStrategy newNaturalIdReadOnlyCoherenceRegionAccessStrategy() {
    return (CoherenceRegionAccessStrategy) getCoherenceNaturalIdRegion()
            .buildAccessStrategy(AccessType.READ_ONLY);
}