Merged HEAD-BUG-FIX (4.3/Cloud) to HEAD (4.3/Cloud)

69946: Merged V4.2-BUG-FIX (4.2.3) to HEAD-BUG-FIX (4.3/Cloud)
      69860: MNT-11371: Alfresco unable to bootstrap due to LockTryExceptions following an upgrade from 3.4.8 -> 3.4.13 -> 4.0.2 to either 4.1.8 or 4.2.1
      Merged 4.1.N to V4.2.N (4.2.3)
         69848: MNT-11371: Alfresco unable to bootstrap due to LockTryExceptions following an upgrade from 3.4.8 -> 3.4.13 -> 4.0.2 to either 4.1.8 or 4.2.1
           Ability to configure try lock timeout for several different contexts has been implemented. New configuration for every context has been added:
           - system.lockTryTimeout=100
           - system.lockTryTimeout.DictionaryDAOImpl=2000
           - system.lockTryTimeout.MessageServiceImpl=${system.lockTryTimeout}
            - system.lockTryTimeout.PolicyComponentImpl=${system.lockTryTimeout}
           'LockHelper.tryLock()' has been modified to accept additional string 'useCase' parameter. Parameter is used for throwing exceptions with contextual messages when lock is not acquired
         69858: MNT-11371: Alfresco unable to bootstrap due to LockTryExceptions following an upgrade from 3.4.8 -> 3.4.13 -> 4.0.2 to either 4.1.8 or 4.2.1
           Additional boolean parameter 'haveWriteLock' has been added to 'MessageServiceImpl.getResourceBundleBaseNames()' method. It serves to avoid unlocking external write locks. The method still assumes that read lock is acquired if 'haveWriteLock=false'. Read lock will be upgraded to write lock only if 'haveWriteLock' parameter is equal to false


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@70462 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2014-05-16 20:06:48 +00:00
parent dab8858288
commit c505322c35
10 changed files with 104 additions and 45 deletions

View File

@@ -502,6 +502,9 @@
<property name="messagesCache"> <property name="messagesCache">
<ref bean="messagesCache"/> <ref bean="messagesCache"/>
</property> </property>
<property name="tryLockTimeout">
<value>${system.lockTryTimeout.MessageServiceImpl}</value>
</property>
</bean> </bean>
<!-- --> <!-- -->
@@ -732,6 +735,9 @@
<property name="defaultAnalyserResourceBundleName"> <property name="defaultAnalyserResourceBundleName">
<value>${lucene.defaultAnalyserResourceBundleName}</value> <value>${lucene.defaultAnalyserResourceBundleName}</value>
</property> </property>
<property name="tryLockTimeout">
<value>${system.lockTryTimeout.DictionaryDAOImpl}</value>
</property>
</bean> </bean>
<bean id="dictionaryService" class="org.alfresco.repo.dictionary.DictionaryComponent" depends-on="dictionaryBootstrap"> <bean id="dictionaryService" class="org.alfresco.repo.dictionary.DictionaryComponent" depends-on="dictionaryBootstrap">

View File

@@ -44,6 +44,9 @@
<property name="transactionInvocationHandlerFactory"> <property name="transactionInvocationHandlerFactory">
<ref bean="policyTransactionHandlerFactory"/> <ref bean="policyTransactionHandlerFactory"/>
</property> </property>
<property name="tryLockTimeout">
<value>${system.lockTryTimeout.PolicyComponentImpl}</value>
</property>
</bean> </bean>
<bean id="policyRegistration" abstract="true" init-method="register"> <bean id="policyRegistration" abstract="true" init-method="register">

View File

@@ -1091,4 +1091,12 @@ system.cronJob.startDelayMinutes=1
# #
# Enable transformation retrying if the file has MIME type differ than file extension. # Enable transformation retrying if the file has MIME type differ than file extension.
# #
content.transformer.retryOn.different.mimetype=true content.transformer.retryOn.different.mimetype=true
#
# Lock timeout configuration
#
system.lockTryTimeout=100
system.lockTryTimeout.DictionaryDAOImpl=2000
system.lockTryTimeout.MessageServiceImpl=${system.lockTryTimeout}
system.lockTryTimeout.PolicyComponentImpl=${system.lockTryTimeout}

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2013 Alfresco Software Limited. * Copyright (C) 2005-2014 Alfresco Software Limited.
* *
* This file is part of Alfresco * This file is part of Alfresco
* *
@@ -85,7 +85,10 @@ public class MessageServiceImpl implements MessageService
private ContentService contentService; private ContentService contentService;
private NamespaceService namespaceService; private NamespaceService namespaceService;
private NodeService nodeService; private NodeService nodeService;
// Try lock timeout (MNT-11371)
private long tryLockTimeout;
/** /**
* List of registered bundles * List of registered bundles
*/ */
@@ -138,7 +141,12 @@ public class MessageServiceImpl implements MessageService
{ {
this.messagesCache = messagesCache; this.messagesCache = messagesCache;
} }
public void setTryLockTimeout(long tryLockTimeout)
{
this.tryLockTimeout = tryLockTimeout;
}
public void setLocale(Locale locale) public void setLocale(Locale locale)
{ {
I18NUtil.setLocale(locale); I18NUtil.setLocale(locale);
@@ -173,7 +181,7 @@ public class MessageServiceImpl implements MessageService
{ {
String tenantDomain = getTenantDomain(); String tenantDomain = getTenantDomain();
Set<String> tenantResourceBundleBaseNames = null; Set<String> tenantResourceBundleBaseNames = null;
LockHelper.tryLock(readLock, 100); LockHelper.tryLock(readLock, tryLockTimeout, "getting resource bundle base names in 'MessageServiceImpl.registerResourceBundle()'");
try try
{ {
tenantResourceBundleBaseNames = getResourceBundleBaseNames(tenantDomain); tenantResourceBundleBaseNames = getResourceBundleBaseNames(tenantDomain);
@@ -183,7 +191,7 @@ public class MessageServiceImpl implements MessageService
readLock.unlock(); readLock.unlock();
} }
LockHelper.tryLock(writeLock, 100); LockHelper.tryLock(writeLock, tryLockTimeout, "adding new resource bundle path and clearing loaded resource bundles in 'MessageServiceImpl.registerResourceBundle()'");
try try
{ {
if (! tenantResourceBundleBaseNames.contains(resBundlePath)) if (! tenantResourceBundleBaseNames.contains(resBundlePath))
@@ -273,7 +281,7 @@ public class MessageServiceImpl implements MessageService
Set<String> resourceBundleBaseNamesForAllLocales; Set<String> resourceBundleBaseNamesForAllLocales;
String tenantDomain = getTenantDomain(); String tenantDomain = getTenantDomain();
LockHelper.tryLock(readLock, 100); LockHelper.tryLock(readLock, tryLockTimeout, "getting loaded resource bundles, messages and base names in 'MessageServiceImpl.unregisterResourceBundle()'");
try try
{ {
// all locales // all locales
@@ -286,7 +294,7 @@ public class MessageServiceImpl implements MessageService
readLock.unlock(); readLock.unlock();
} }
LockHelper.tryLock(writeLock, 100); LockHelper.tryLock(writeLock, tryLockTimeout, "removing resource bundle by path in 'MessageServiceImpl.unregisterResourceBundle()'");
try try
{ {
// unload resource bundles for each locale (by tenant, if applicable) // unload resource bundles for each locale (by tenant, if applicable)
@@ -388,7 +396,7 @@ public class MessageServiceImpl implements MessageService
Map<Locale, Map<String, String>> tenantCachedMessages = null; Map<Locale, Map<String, String>> tenantCachedMessages = null;
Set<String> tenantResourceBundleBaseNames = null; Set<String> tenantResourceBundleBaseNames = null;
LockHelper.tryLock(readLock, 100); LockHelper.tryLock(readLock, tryLockTimeout, "getting loaded resource bundles, messages and base names in 'MessageServiceImpl.getLocaleProperties()'");
try try
{ {
tenantLoadedResourceBundles = getLoadedResourceBundles(tenantDomain); tenantLoadedResourceBundles = getLoadedResourceBundles(tenantDomain);
@@ -407,7 +415,7 @@ public class MessageServiceImpl implements MessageService
if (loadedBundles == null) if (loadedBundles == null)
{ {
LockHelper.tryLock(writeLock, 100); LockHelper.tryLock(writeLock, tryLockTimeout, "adding resource bundle for locale in 'MessageServiceImpl.getLocaleProperties()'");
try try
{ {
loadedBundles = new HashSet<String>(); loadedBundles = new HashSet<String>();
@@ -422,7 +430,8 @@ public class MessageServiceImpl implements MessageService
if (props == null) if (props == null)
{ {
LockHelper.tryLock(writeLock, 100); LockHelper.tryLock(writeLock, tryLockTimeout,
"adding resource bundle properties into the cache (because properties are not cached) in 'MessageServiceImpl.getLocaleProperties()'");
try try
{ {
props = new HashMap<String, String>(); props = new HashMap<String, String>();
@@ -437,7 +446,8 @@ public class MessageServiceImpl implements MessageService
if ((loadedBundles.size() != loadedBundleCount) || (init == true)) if ((loadedBundles.size() != loadedBundleCount) || (init == true))
{ {
LockHelper.tryLock(writeLock, 100); LockHelper.tryLock(writeLock, tryLockTimeout,
"searching resource bundle and adding new resource bundle for locale if the bundle is not found in 'MessageServiceImpl.getLocaleProperties()'");
try try
{ {
// get registered resource bundles // get registered resource bundles
@@ -582,7 +592,7 @@ public class MessageServiceImpl implements MessageService
public Set<String> getRegisteredBundles() public Set<String> getRegisteredBundles()
{ {
LockHelper.tryLock(readLock, 100); LockHelper.tryLock(readLock, tryLockTimeout, "getting resource bundle base names in 'MessageServiceImpl.getRegisteredBundles()'");
try try
{ {
return getResourceBundleBaseNames(getTenantDomain()); return getResourceBundleBaseNames(getTenantDomain());
@@ -604,7 +614,7 @@ public class MessageServiceImpl implements MessageService
// They are not there. Upgrade to the write lock. // They are not there. Upgrade to the write lock.
readLock.unlock(); readLock.unlock();
LockHelper.tryLock(writeLock, 100); LockHelper.tryLock(writeLock, tryLockTimeout, "getting cached resource bundle base names by tenant domain in 'MessageServiceImpl.getRegisteredBundles()'");
try try
{ {
resourceBundleBaseNames = resourceBundleBaseNamesCache.get(tenantDomain); resourceBundleBaseNames = resourceBundleBaseNamesCache.get(tenantDomain);
@@ -618,7 +628,7 @@ public class MessageServiceImpl implements MessageService
finally finally
{ {
writeLock.unlock(); writeLock.unlock();
LockHelper.tryLock(readLock, 100); LockHelper.tryLock(readLock, tryLockTimeout, "upgrading to read lock in MessageServiceImpl.getResourceBundleBaseNames()");
} }
if (resourceBundleBaseNames == null) if (resourceBundleBaseNames == null)
@@ -655,7 +665,7 @@ public class MessageServiceImpl implements MessageService
// Not present. Upgrade to write lock. // Not present. Upgrade to write lock.
readLock.unlock(); readLock.unlock();
LockHelper.tryLock(writeLock, 100); LockHelper.tryLock(writeLock, tryLockTimeout, "getting cached resource bundle by tenant domain in 'MessageServiceImpl.getLoadedResourceBundles()'");
try try
{ {
loadedResourceBundles = loadedResourceBundlesCache.get(tenantDomain); loadedResourceBundles = loadedResourceBundlesCache.get(tenantDomain);
@@ -669,7 +679,7 @@ public class MessageServiceImpl implements MessageService
finally finally
{ {
writeLock.unlock(); writeLock.unlock();
LockHelper.tryLock(readLock, 100); LockHelper.tryLock(readLock, tryLockTimeout, "upgrading to read lock in MessageServiceImpl.getLoadedResourceBundles()");
} }
if (loadedResourceBundles == null) if (loadedResourceBundles == null)
@@ -714,7 +724,7 @@ public class MessageServiceImpl implements MessageService
// Need to create it. Upgrade to write lock. // Need to create it. Upgrade to write lock.
readLock.unlock(); readLock.unlock();
LockHelper.tryLock(writeLock, 100); LockHelper.tryLock(writeLock, tryLockTimeout, "getting messages by tenant domain from the cache in 'MessageServiceImpl.getMessages()'");
try try
{ {
messages = messagesCache.get(tenantDomain); messages = messagesCache.get(tenantDomain);
@@ -728,7 +738,7 @@ public class MessageServiceImpl implements MessageService
finally finally
{ {
writeLock.unlock(); writeLock.unlock();
LockHelper.tryLock(readLock, 100); LockHelper.tryLock(readLock, tryLockTimeout, "upgrading to read lock in MessageServiceImpl.getMessages()");
} }
if (messages == null) if (messages == null)

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2010 Alfresco Software Limited. * Copyright (C) 2005-2014 Alfresco Software Limited.
* *
* This file is part of Alfresco * This file is part of Alfresco
* *
@@ -52,7 +52,7 @@ public class AssociationPolicyDelegate<P extends AssociationPolicy>
* @param index the behaviour index to query against * @param index the behaviour index to query against
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
/*package*/ AssociationPolicyDelegate(DictionaryService dictionary, Class<P> policyClass, BehaviourIndex<ClassFeatureBehaviourBinding> index) /*package*/ AssociationPolicyDelegate(DictionaryService dictionary, Class<P> policyClass, BehaviourIndex<ClassFeatureBehaviourBinding> index, long tryLockTimeout)
{ {
// Get list of all pre-registered behaviours for the policy and // Get list of all pre-registered behaviours for the policy and
// ensure they are valid. // ensure they are valid.
@@ -65,6 +65,7 @@ public class AssociationPolicyDelegate<P extends AssociationPolicy>
// Rely on cached implementation of policy factory // Rely on cached implementation of policy factory
// Note: Could also use PolicyFactory (without caching) // Note: Could also use PolicyFactory (without caching)
this.factory = new CachedPolicyFactory<ClassFeatureBehaviourBinding, P>(policyClass, index); this.factory = new CachedPolicyFactory<ClassFeatureBehaviourBinding, P>(policyClass, index);
this.factory.setTryLockTimeout(tryLockTimeout);
this.dictionary = dictionary; this.dictionary = dictionary;
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2010 Alfresco Software Limited. * Copyright (C) 2005-2013 Alfresco Software Limited.
* *
* This file is part of Alfresco * This file is part of Alfresco
* *
@@ -59,7 +59,16 @@ import org.apache.commons.logging.LogFactory;
*/ */
private Map<B, Collection<P>> listCache = new HashMap<B, Collection<P>>(); private Map<B, Collection<P>> listCache = new HashMap<B, Collection<P>>();
// Try lock timeout (MNT-11371)
private long tryLockTimeout;
public void setTryLockTimeout(long tryLockTimeout)
{
this.tryLockTimeout = tryLockTimeout;
}
/** /**
* Construct cached policy factory * Construct cached policy factory
* *
@@ -93,7 +102,7 @@ import org.apache.commons.logging.LogFactory;
return super.create(binding); return super.create(binding);
} }
LockHelper.tryLock(lock.readLock(), 100); LockHelper.tryLock(lock.readLock(), tryLockTimeout, "getting policy from cache in 'CachedPolicyFactory.create()'");
try try
{ {
P policyInterface = singleCache.get(binding); P policyInterface = singleCache.get(binding);
@@ -108,7 +117,7 @@ import org.apache.commons.logging.LogFactory;
} }
// There wasn't one // There wasn't one
LockHelper.tryLock(lock.writeLock(), 100); LockHelper.tryLock(lock.writeLock(), tryLockTimeout, "putting new policy to cache in 'CachedPolicyFactory.create()'");
try try
{ {
P policyInterface = singleCache.get(binding); P policyInterface = singleCache.get(binding);
@@ -140,7 +149,7 @@ import org.apache.commons.logging.LogFactory;
return super.createList(binding); return super.createList(binding);
} }
LockHelper.tryLock(lock.readLock(), 100); LockHelper.tryLock(lock.readLock(), tryLockTimeout, "getting policy list from cache in 'CachedPolicyFactory.createList()'");
try try
{ {
Collection<P> policyInterfaces = listCache.get(binding); Collection<P> policyInterfaces = listCache.get(binding);
@@ -155,7 +164,7 @@ import org.apache.commons.logging.LogFactory;
} }
// There wasn't one // There wasn't one
LockHelper.tryLock(lock.writeLock(), 100); LockHelper.tryLock(lock.writeLock(), tryLockTimeout, "putting policy list to cache in 'CachedPolicyFactory.createList()'");
try try
{ {
Collection<P> policyInterfaces = listCache.get(binding); Collection<P> policyInterfaces = listCache.get(binding);
@@ -188,7 +197,7 @@ import org.apache.commons.logging.LogFactory;
{ {
if (binding == null) if (binding == null)
{ {
LockHelper.tryLock(lock.writeLock(), 100); LockHelper.tryLock(lock.writeLock(), tryLockTimeout, "clearing policy cache in 'CachedPolicyFactory.clearCache()'");
try try
{ {
// A specific binding has not been provided, so clear all entries // A specific binding has not been provided, so clear all entries
@@ -226,7 +235,7 @@ import org.apache.commons.logging.LogFactory;
// Remove all invalid bindings // Remove all invalid bindings
if (invalidBindings.size() > 0) if (invalidBindings.size() > 0)
{ {
LockHelper.tryLock(lock.writeLock(), 100); LockHelper.tryLock(lock.writeLock(), tryLockTimeout, "removing invalid policy bindings from cache in 'CachedPolicyFactory.clearCache()'");
try try
{ {
for (B invalidBinding : invalidBindings) for (B invalidBinding : invalidBindings)

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2010 Alfresco Software Limited. * Copyright (C) 2005-2014 Alfresco Software Limited.
* *
* This file is part of Alfresco * This file is part of Alfresco
* *
@@ -53,7 +53,15 @@ import org.alfresco.util.LockHelper;
// Behaviour Filter // Behaviour Filter
private BehaviourFilter filter = null; private BehaviourFilter filter = null;
// Try lock timeout (MNT-11371)
private long tryLockTimeout;
public void setTryLockTimeout(long tryLockTimeout)
{
this.tryLockTimeout = tryLockTimeout;
}
/** /**
* Construct. * Construct.
*/ */
@@ -92,7 +100,7 @@ import org.alfresco.util.LockHelper;
@Override @Override
public Collection<BehaviourDefinition> getAll() public Collection<BehaviourDefinition> getAll()
{ {
LockHelper.tryLock(lock.readLock(), 100); LockHelper.tryLock(lock.readLock(), tryLockTimeout, "getting all behavior definitions in 'ClassBehaviourIndex.getAll()'");
try try
{ {
@@ -112,7 +120,7 @@ import org.alfresco.util.LockHelper;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public Collection<BehaviourDefinition> find(B binding) public Collection<BehaviourDefinition> find(B binding)
{ {
LockHelper.tryLock(lock.readLock(), 100); LockHelper.tryLock(lock.readLock(), tryLockTimeout, "searching behavior definitions list in 'ClassBehaviourIndex.find()'");
try try
{ {
@@ -175,7 +183,7 @@ import org.alfresco.util.LockHelper;
*/ */
public void putClassBehaviour(BehaviourDefinition<B> behaviour) public void putClassBehaviour(BehaviourDefinition<B> behaviour)
{ {
LockHelper.tryLock(lock.writeLock(), 100); LockHelper.tryLock(lock.writeLock(), tryLockTimeout, "putting behavior definition in 'ClassBehaviourIndex.putClassBehavior()'");
try try
{ {
classMap.put(behaviour); classMap.put(behaviour);
@@ -194,7 +202,7 @@ import org.alfresco.util.LockHelper;
*/ */
public void putServiceBehaviour(BehaviourDefinition<ServiceBehaviourBinding> behaviour) public void putServiceBehaviour(BehaviourDefinition<ServiceBehaviourBinding> behaviour)
{ {
LockHelper.tryLock(lock.writeLock(), 100); LockHelper.tryLock(lock.writeLock(), tryLockTimeout, "putting behavior definition in 'ClassBehaviourIndex.putServiceBehavior()'");
try try
{ {
serviceMap.put(behaviour); serviceMap.put(behaviour);
@@ -212,7 +220,7 @@ import org.alfresco.util.LockHelper;
*/ */
public void removeClassBehaviour(BehaviourDefinition<B> behaviour) public void removeClassBehaviour(BehaviourDefinition<B> behaviour)
{ {
LockHelper.tryLock(lock.writeLock(), 100); LockHelper.tryLock(lock.writeLock(), tryLockTimeout, "removing behavior definition in 'ClassBehaviourIndex.removeClassBehavior()'");
try try
{ {
classMap.remove(behaviour); classMap.remove(behaviour);

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2010 Alfresco Software Limited. * Copyright (C) 2005-2014 Alfresco Software Limited.
* *
* This file is part of Alfresco * This file is part of Alfresco
* *
@@ -51,7 +51,7 @@ public class ClassPolicyDelegate<P extends ClassPolicy>
* @param index the behaviour index to query against * @param index the behaviour index to query against
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
/*package*/ ClassPolicyDelegate(DictionaryService dictionary, Class<P> policyClass, BehaviourIndex<ClassBehaviourBinding> index) /*package*/ ClassPolicyDelegate(DictionaryService dictionary, Class<P> policyClass, BehaviourIndex<ClassBehaviourBinding> index, long tryLockTimeout)
{ {
// Get list of all pre-registered behaviours for the policy and // Get list of all pre-registered behaviours for the policy and
// ensure they are valid. // ensure they are valid.
@@ -64,6 +64,7 @@ public class ClassPolicyDelegate<P extends ClassPolicy>
// Rely on cached implementation of policy factory // Rely on cached implementation of policy factory
// Note: Could also use PolicyFactory (without caching) // Note: Could also use PolicyFactory (without caching)
this.factory = new CachedPolicyFactory<ClassBehaviourBinding, P>(policyClass, index); this.factory = new CachedPolicyFactory<ClassBehaviourBinding, P>(policyClass, index);
this.factory.setTryLockTimeout(tryLockTimeout);
this.dictionary = dictionary; this.dictionary = dictionary;
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2010 Alfresco Software Limited. * Copyright (C) 2005-2014 Alfresco Software Limited.
* *
* This file is part of Alfresco * This file is part of Alfresco
* *
@@ -73,7 +73,15 @@ public class PolicyComponentImpl implements PolicyComponent
// Wild Card Feature // Wild Card Feature
private static final QName FEATURE_WILDCARD = QName.createQName(NamespaceService.DEFAULT_URI, "*"); private static final QName FEATURE_WILDCARD = QName.createQName(NamespaceService.DEFAULT_URI, "*");
// Try lock timeout (MNT-11371)
private long tryLockTimeout;
public void setTryLockTimeout(long tryLockTimeout)
{
this.tryLockTimeout = tryLockTimeout;
}
/** /**
* Construct * Construct
@@ -129,7 +137,8 @@ public class PolicyComponentImpl implements PolicyComponent
ParameterCheck.mandatory("Policy interface class", policy); ParameterCheck.mandatory("Policy interface class", policy);
PolicyDefinition definition = createPolicyDefinition(policy); PolicyDefinition definition = createPolicyDefinition(policy);
registeredPolicies.put(new PolicyKey(definition.getType(), definition.getName()), definition); registeredPolicies.put(new PolicyKey(definition.getType(), definition.getName()), definition);
ClassPolicyDelegate<P> delegate = new ClassPolicyDelegate<P>(dictionary, policy, getClassBehaviourIndex(definition.getName())); ClassPolicyDelegate<P> delegate = new ClassPolicyDelegate<P>(dictionary, policy, getClassBehaviourIndex(definition.getName()), tryLockTimeout);
if (logger.isInfoEnabled()) if (logger.isInfoEnabled())
logger.info("Registered class policy " + definition.getName() + " (" + definition.getPolicyInterface() + ")"); logger.info("Registered class policy " + definition.getName() + " (" + definition.getPolicyInterface() + ")");
@@ -152,7 +161,7 @@ public class PolicyComponentImpl implements PolicyComponent
ParameterCheck.mandatory("Policy interface class", policy); ParameterCheck.mandatory("Policy interface class", policy);
PolicyDefinition definition = createPolicyDefinition(policy); PolicyDefinition definition = createPolicyDefinition(policy);
registeredPolicies.put(new PolicyKey(definition.getType(), definition.getName()), definition); registeredPolicies.put(new PolicyKey(definition.getType(), definition.getName()), definition);
PropertyPolicyDelegate<P> delegate = new PropertyPolicyDelegate<P>(dictionary, policy, getPropertyBehaviourIndex(definition.getName())); PropertyPolicyDelegate<P> delegate = new PropertyPolicyDelegate<P>(dictionary, policy, getPropertyBehaviourIndex(definition.getName()), tryLockTimeout);
if (logger.isInfoEnabled()) if (logger.isInfoEnabled())
logger.info("Registered property policy " + definition.getName() + " (" + definition.getPolicyInterface() + ")"); logger.info("Registered property policy " + definition.getName() + " (" + definition.getPolicyInterface() + ")");
@@ -170,7 +179,7 @@ public class PolicyComponentImpl implements PolicyComponent
ParameterCheck.mandatory("Policy interface class", policy); ParameterCheck.mandatory("Policy interface class", policy);
PolicyDefinition definition = createPolicyDefinition(policy); PolicyDefinition definition = createPolicyDefinition(policy);
registeredPolicies.put(new PolicyKey(definition.getType(), definition.getName()), definition); registeredPolicies.put(new PolicyKey(definition.getType(), definition.getName()), definition);
AssociationPolicyDelegate<P> delegate = new AssociationPolicyDelegate<P>(dictionary, policy, getAssociationBehaviourIndex(definition.getName())); AssociationPolicyDelegate<P> delegate = new AssociationPolicyDelegate<P>(dictionary, policy, getAssociationBehaviourIndex(definition.getName()), tryLockTimeout);
if (logger.isInfoEnabled()) if (logger.isInfoEnabled())
logger.info("Registered association policy " + definition.getName() + " (" + definition.getPolicyInterface() + ")"); logger.info("Registered association policy " + definition.getName() + " (" + definition.getPolicyInterface() + ")");
@@ -431,6 +440,7 @@ public class PolicyComponentImpl implements PolicyComponent
if (index == null) if (index == null)
{ {
index = new ClassBehaviourIndex<ClassBehaviourBinding>(behaviourFilter); index = new ClassBehaviourIndex<ClassBehaviourBinding>(behaviourFilter);
index.setTryLockTimeout(tryLockTimeout);
classBehaviours.put(policy, index); classBehaviours.put(policy, index);
} }
return index; return index;
@@ -449,6 +459,7 @@ public class PolicyComponentImpl implements PolicyComponent
if (index == null) if (index == null)
{ {
index = new ClassBehaviourIndex<ClassFeatureBehaviourBinding>(behaviourFilter); index = new ClassBehaviourIndex<ClassFeatureBehaviourBinding>(behaviourFilter);
index.setTryLockTimeout(tryLockTimeout);
propertyBehaviours.put(policy, index); propertyBehaviours.put(policy, index);
} }
return index; return index;
@@ -467,6 +478,7 @@ public class PolicyComponentImpl implements PolicyComponent
if (index == null) if (index == null)
{ {
index = new ClassBehaviourIndex<ClassFeatureBehaviourBinding>(behaviourFilter); index = new ClassBehaviourIndex<ClassFeatureBehaviourBinding>(behaviourFilter);
index.setTryLockTimeout(tryLockTimeout);
associationBehaviours.put(policy, index); associationBehaviours.put(policy, index);
} }
return index; return index;

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2010 Alfresco Software Limited. * Copyright (C) 2005-2014 Alfresco Software Limited.
* *
* This file is part of Alfresco * This file is part of Alfresco
* *
@@ -52,7 +52,7 @@ public class PropertyPolicyDelegate<P extends PropertyPolicy>
* @param index the behaviour index to query against * @param index the behaviour index to query against
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
/*package*/ PropertyPolicyDelegate(DictionaryService dictionary, Class<P> policyClass, BehaviourIndex<ClassFeatureBehaviourBinding> index) /*package*/ PropertyPolicyDelegate(DictionaryService dictionary, Class<P> policyClass, BehaviourIndex<ClassFeatureBehaviourBinding> index, long tryLockTimeout)
{ {
// Get list of all pre-registered behaviours for the policy and // Get list of all pre-registered behaviours for the policy and
// ensure they are valid. // ensure they are valid.
@@ -65,6 +65,7 @@ public class PropertyPolicyDelegate<P extends PropertyPolicy>
// Rely on cached implementation of policy factory // Rely on cached implementation of policy factory
// Note: Could also use PolicyFactory (without caching) // Note: Could also use PolicyFactory (without caching)
this.factory = new CachedPolicyFactory<ClassFeatureBehaviourBinding, P>(policyClass, index); this.factory = new CachedPolicyFactory<ClassFeatureBehaviourBinding, P>(policyClass, index);
this.factory.setTryLockTimeout(tryLockTimeout);
this.dictionary = dictionary; this.dictionary = dictionary;
} }