public class CollectionRegionImpl extends TransactionalDataRegionAdapter implements CollectionRegion { public static final String TYPE = "COLL"; private boolean optimistic; public CollectionRegionImpl(Cache jbcCache, String regionName, String regionPrefix, CacheDataDescription metadata) { super(jbcCache, regionName, regionPrefix, metadata); optimistic = (jbcCache.getConfiguration().getNodeLockingScheme() == NodeLockingScheme.OPTIMISTIC); } public CollectionRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException { if (AccessType.READ_ONLY.equals(accessType)) { return optimistic ? new OptimisticReadOnlyAccess(this) : new ReadOnlyAccess(this); } if (AccessType.TRANSACTIONAL.equals(accessType)) { return optimistic ? new OptimisticTransactionalAccess(this) : new TransactionalAccess(this); } // todo : add support for READ_WRITE ( + NONSTRICT_READ_WRITE ??? ) throw new CacheException("unsupported access type [" + accessType.getName() + "]"); } @Override protected Fqn<String> createRegionFqn(String regionName, String regionPrefix) { return getTypeLastRegionFqn(regionName, regionPrefix, TYPE);
public class EntityRegionImpl extends TransactionalDataRegionAdapter implements EntityRegion { public static final String TYPE = "ENTITY"; private boolean optimistic; public EntityRegionImpl(Cache jbcCache, String regionName, String regionPrefix, CacheDataDescription metadata) { super(jbcCache, regionName, regionPrefix, metadata); optimistic = (jbcCache.getConfiguration().getNodeLockingScheme() == NodeLockingScheme.OPTIMISTIC); } /** * {@inheritDoc} */ public EntityRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException { if (AccessType.READ_ONLY.equals(accessType)) { return optimistic ? new OptimisticReadOnlyAccess(this) : new ReadOnlyAccess(this); } if (AccessType.TRANSACTIONAL.equals(accessType)) { return optimistic ? new OptimisticTransactionalAccess(this) : new TransactionalAccess(this); } // todo : add support for READ_WRITE ( + NONSTRICT_READ_WRITE ??? ) throw new CacheException("unsupported access type [" + accessType.getName() + "]"); } @Override protected Fqn<String> createRegionFqn(String regionName, String regionPrefix) { return getTypeLastRegionFqn(regionName, regionPrefix, TYPE);
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/collection/CollectionRegionImpl.java File path: /hibernate-distribution-3.3.2.GA/project/cache-jbosscache2/src/main/java/org/hibernate/cache/jbc2/entity/EntityRegionImpl.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
1
public class CollectionRegionImpl extends TransactionalDataRegionAdapter implements CollectionRegion {
1
public class EntityRegionImpl extends TransactionalDataRegionAdapter implements EntityRegion {
2
    public static final String TYPE = "COLL";
2
    public static final String TYPE = "ENTITY";
3
    
3
    private boolean optimistic;
4
    private boolean optimistic;
4
    public CollectionRegionImpl(Cache jbcCache, String regionName, String regionPrefix, CacheDataDescription metadata) {
5
    public EntityRegionImpl(Cache jbcCache, String regionName, String regionPrefix, CacheDataDescription metadata) {
5
        super(jbcCache, regionName, regionPrefix, metadata);
6
        super(jbcCache, regionName, regionPrefix, metadata);
6
        optimistic = (jbcCache.getConfiguration().getNodeLockingScheme() == NodeLockingScheme.OPTIMISTIC);
7
        optimistic = (jbcCache.getConfiguration().getNodeLockingScheme() == NodeLockingScheme.OPTIMISTIC);
7
    }
8
    }
8
    public Collection
9
    /**
10
     * {@inheritDoc}
11
     */
9
RegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException {
12
    public EntityRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException {
10
        if (AccessType.READ_ONLY.equals(accessType)) {
13
        if (AccessType.READ_ONLY.equals(accessType)) {
11
            return optimistic ? new OptimisticReadOnlyAccess(this) : new ReadOnlyAccess(this);
14
            return optimistic ? new OptimisticReadOnlyAccess(this) : new ReadOnlyAccess(this);
12
        }
15
        }
13
        if (AccessType.TRANSACTIONAL.equals(accessType)) {
16
        if (AccessType.TRANSACTIONAL.equals(accessType)) {
14
            return optimistic ? new OptimisticTransactionalAccess(this) : new TransactionalAccess(this);
17
            return optimistic ? new OptimisticTransactionalAccess(this) : new TransactionalAccess(this);
15
        }
18
        }
16
        // todo : add support for READ_WRITE ( + NONSTRICT_READ_WRITE ??? )
19
        // todo : add support for READ_WRITE ( + NONSTRICT_READ_WRITE ??? )
17
        throw new CacheException("unsupported access type [" + accessType.getName() + "]");
20
        throw new CacheException("unsupported access type [" + accessType.getName() + "]");
18
    }
21
    }
19
    @Override
22
    @Override
20
    protected Fqn<String> createRegionFqn(String regionName, String regionPrefix) {
23
    protected Fqn<String> createRegionFqn(String regionName, String regionPrefix) {
21
        return getTypeLastRegionFqn(regionName, regionPrefix, TYPE);
24
        return getTypeLastRegionFqn(regionName, regionPrefix, TYPE);
22
    
25
    
Summary
Number of common nesting structure subtrees0
Number of refactorable cases0
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones location
Number of node comparisons0