Package org.alfresco.repo.policy
Class PolicyComponentImpl
- java.lang.Object
-
- org.alfresco.repo.policy.PolicyComponentImpl
-
- All Implemented Interfaces:
PolicyComponent
public class PolicyComponentImpl extends java.lang.Object implements PolicyComponent
Policy Component Implementation.- Author:
- David Caruana
-
-
Constructor Summary
Constructors Constructor Description PolicyComponentImpl(org.alfresco.service.cmr.dictionary.DictionaryService dictionary)Construct
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BehaviourDefinition<ServiceBehaviourBinding>bindAssociationBehaviour(org.alfresco.service.namespace.QName policy, java.lang.Object service, Behaviour behaviour)Bind a Service specific behaviour to an Association-level PolicyBehaviourDefinition<ClassFeatureBehaviourBinding>bindAssociationBehaviour(org.alfresco.service.namespace.QName policy, org.alfresco.service.namespace.QName className, Behaviour behaviour)Bind an Association specific behaviour to an Association-level Policy (for all associations of a Class)BehaviourDefinition<ClassFeatureBehaviourBinding>bindAssociationBehaviour(org.alfresco.service.namespace.QName policy, org.alfresco.service.namespace.QName className, org.alfresco.service.namespace.QName assocName, Behaviour behaviour)Bind an Association specific behaviour to an Association-level PolicyBehaviourDefinition<ServiceBehaviourBinding>bindClassBehaviour(org.alfresco.service.namespace.QName policy, java.lang.Object service, Behaviour behaviour)Bind a Service behaviour to a Class-level PolicyBehaviourDefinition<ClassBehaviourBinding>bindClassBehaviour(org.alfresco.service.namespace.QName policy, org.alfresco.service.namespace.QName classRef, Behaviour behaviour)Bind a Class specific behaviour to a Class-level Policy.BehaviourDefinition<ServiceBehaviourBinding>bindPropertyBehaviour(org.alfresco.service.namespace.QName policy, java.lang.Object service, Behaviour behaviour)Bind a Service specific behaviour to a Property-level PolicyBehaviourDefinition<ClassFeatureBehaviourBinding>bindPropertyBehaviour(org.alfresco.service.namespace.QName policy, org.alfresco.service.namespace.QName className, Behaviour behaviour)Bind a Property specific behaviour to a Property-level Policy (for all properties of a Class)BehaviourDefinition<ClassFeatureBehaviourBinding>bindPropertyBehaviour(org.alfresco.service.namespace.QName policy, org.alfresco.service.namespace.QName className, org.alfresco.service.namespace.QName propertyName, Behaviour behaviour)Bind a Property specific behaviour to a Property-level Policyjava.util.Collection<PolicyDefinition>getRegisteredPolicies()Gets all registered PoliciesPolicyDefinitiongetRegisteredPolicy(PolicyType policyType, org.alfresco.service.namespace.QName policy)Gets the specified registered PolicybooleanisRegisteredPolicy(PolicyType policyType, org.alfresco.service.namespace.QName policy)Determine if the specified policy has been registered<P extends AssociationPolicy>
AssociationPolicyDelegate<P>registerAssociationPolicy(java.lang.Class<P> policy)Register a Association-level Policy<P extends ClassPolicy>
ClassPolicyDelegate<P>registerClassPolicy(java.lang.Class<P> policy)Register a Class-level Policy<P extends PropertyPolicy>
PropertyPolicyDelegate<P>registerPropertyPolicy(java.lang.Class<P> policy)Register a Property-level PolicyvoidremoveClassDefinition(BehaviourDefinition<ClassBehaviourBinding> definition)Unbind behaviourvoidsetBehaviourFilter(BehaviourFilter filter)Sets the behaviour filtervoidsetTenantService(org.alfresco.repo.tenant.TenantService tenantService)Sets the tenant servicevoidsetTransactionInvocationHandlerFactory(TransactionInvocationHandlerFactory factory)Sets the transaction-based policy invocation handlervoidsetTryLockTimeout(long tryLockTimeout)
-
-
-
Method Detail
-
setTryLockTimeout
public void setTryLockTimeout(long tryLockTimeout)
-
setBehaviourFilter
public void setBehaviourFilter(BehaviourFilter filter)
Sets the behaviour filter- Parameters:
filter- BehaviourFilter
-
setTenantService
public void setTenantService(org.alfresco.repo.tenant.TenantService tenantService)
Sets the tenant service- Parameters:
tenantService- TenantService
-
setTransactionInvocationHandlerFactory
public void setTransactionInvocationHandlerFactory(TransactionInvocationHandlerFactory factory)
Sets the transaction-based policy invocation handler- Parameters:
factory- TransactionInvocationHandlerFactory
-
registerClassPolicy
public <P extends ClassPolicy> ClassPolicyDelegate<P> registerClassPolicy(java.lang.Class<P> policy)
Description copied from interface:PolicyComponentRegister a Class-level Policy- Specified by:
registerClassPolicyin interfacePolicyComponent- Type Parameters:
P- the policy interface- Parameters:
policy- the policy interface class- Returns:
- A delegate for the class-level policy (typed by the policy interface)
-
removeClassDefinition
public void removeClassDefinition(BehaviourDefinition<ClassBehaviourBinding> definition)
Description copied from interface:PolicyComponentUnbind behaviour- Specified by:
removeClassDefinitionin interfacePolicyComponent
-
registerPropertyPolicy
public <P extends PropertyPolicy> PropertyPolicyDelegate<P> registerPropertyPolicy(java.lang.Class<P> policy)
Description copied from interface:PolicyComponentRegister a Property-level Policy- Specified by:
registerPropertyPolicyin interfacePolicyComponent- Type Parameters:
P- the policy interface- Parameters:
policy- the policy interface class- Returns:
- A delegate for the property-level policy (typed by the policy interface)
-
registerAssociationPolicy
public <P extends AssociationPolicy> AssociationPolicyDelegate<P> registerAssociationPolicy(java.lang.Class<P> policy)
Description copied from interface:PolicyComponentRegister a Association-level Policy- Specified by:
registerAssociationPolicyin interfacePolicyComponent- Type Parameters:
P- the policy interface- Parameters:
policy- the policy interface class- Returns:
- A delegate for the association-level policy (typed by the policy interface)
-
getRegisteredPolicies
public java.util.Collection<PolicyDefinition> getRegisteredPolicies()
Description copied from interface:PolicyComponentGets all registered Policies- Specified by:
getRegisteredPoliciesin interfacePolicyComponent- Returns:
- the collection of registered policy definitions
-
getRegisteredPolicy
public PolicyDefinition getRegisteredPolicy(PolicyType policyType, org.alfresco.service.namespace.QName policy)
Description copied from interface:PolicyComponentGets the specified registered Policy- Specified by:
getRegisteredPolicyin interfacePolicyComponent- Parameters:
policyType- the policy typepolicy- the policy name- Returns:
- the policy definition (or null, if it has not been registered)
-
isRegisteredPolicy
public boolean isRegisteredPolicy(PolicyType policyType, org.alfresco.service.namespace.QName policy)
Description copied from interface:PolicyComponentDetermine if the specified policy has been registered- Specified by:
isRegisteredPolicyin interfacePolicyComponent- Parameters:
policyType- the policy typepolicy- the fully qualified name of the policy- Returns:
- true => registered, false => not yet
-
bindClassBehaviour
public BehaviourDefinition<ClassBehaviourBinding> bindClassBehaviour(org.alfresco.service.namespace.QName policy, org.alfresco.service.namespace.QName classRef, Behaviour behaviour)
Description copied from interface:PolicyComponentBind a Class specific behaviour to a Class-level Policy.So when the named policy, happens on the specified aspect or type, the specified behaviour is executed.
Example of calling this method
this.policyComponent.bindClassBehaviour( NodeServicePolicies.BeforeUpdateNodePolicy.QNAME, ContentModel.ASPECT_LOCKABLE, new JavaBehaviour(this, "beforeUpdateNode"));- Specified by:
bindClassBehaviourin interfacePolicyComponent- Parameters:
policy- the fully qualified policy nameclassRef- the qualified name of a type or aspect that the policy is bound tobehaviour- the behaviour. What gets executed by the policy- Returns:
- the registered behaviour definition
-
bindClassBehaviour
public BehaviourDefinition<ServiceBehaviourBinding> bindClassBehaviour(org.alfresco.service.namespace.QName policy, java.lang.Object service, Behaviour behaviour)
Description copied from interface:PolicyComponentBind a Service behaviour to a Class-level Policy- Specified by:
bindClassBehaviourin interfacePolicyComponent- Parameters:
policy- the fully qualified policy nameservice- the service (any object, in fact)behaviour- the behaviour. What gets executed by the policy- Returns:
- the registered behaviour definition
-
bindPropertyBehaviour
public BehaviourDefinition<ClassFeatureBehaviourBinding> bindPropertyBehaviour(org.alfresco.service.namespace.QName policy, org.alfresco.service.namespace.QName className, org.alfresco.service.namespace.QName propertyName, Behaviour behaviour)
Description copied from interface:PolicyComponentBind a Property specific behaviour to a Property-level Policy- Specified by:
bindPropertyBehaviourin interfacePolicyComponent- Parameters:
policy- the fully qualified policy nameclassName- the qualified name of the class (type or aspect) to bind againstpropertyName- the name of the property to bind againstbehaviour- the behaviour. What gets executed by the policy- Returns:
- the registered behaviour definition
-
bindPropertyBehaviour
public BehaviourDefinition<ClassFeatureBehaviourBinding> bindPropertyBehaviour(org.alfresco.service.namespace.QName policy, org.alfresco.service.namespace.QName className, Behaviour behaviour)
Description copied from interface:PolicyComponentBind a Property specific behaviour to a Property-level Policy (for all properties of a Class)- Specified by:
bindPropertyBehaviourin interfacePolicyComponent- Parameters:
policy- the fully qualified policy nameclassName- the name of the class (type or aspect) to bind againstbehaviour- the behaviour, what gets executed by the policy- Returns:
- the registered behaviour definition
-
bindPropertyBehaviour
public BehaviourDefinition<ServiceBehaviourBinding> bindPropertyBehaviour(org.alfresco.service.namespace.QName policy, java.lang.Object service, Behaviour behaviour)
Description copied from interface:PolicyComponentBind a Service specific behaviour to a Property-level Policy- Specified by:
bindPropertyBehaviourin interfacePolicyComponent- Parameters:
policy- the fully qualified policy nameservice- the binding servicebehaviour- the behaviour- Returns:
- the registered behaviour definition
-
bindAssociationBehaviour
public BehaviourDefinition<ClassFeatureBehaviourBinding> bindAssociationBehaviour(org.alfresco.service.namespace.QName policy, org.alfresco.service.namespace.QName className, org.alfresco.service.namespace.QName assocName, Behaviour behaviour)
Description copied from interface:PolicyComponentBind an Association specific behaviour to an Association-level PolicyFor example, before a rule folder association is created.
policyComponent.bindAssociationBehaviour( NodeServicePolicies.OnCreateChildAssociationPolicy.QNAME, RuleModel.ASPECT_RULES, RuleModel.ASSOC_RULE_FOLDER, new JavaBehaviour(this, "OnCreateChildAssociation"));- Specified by:
bindAssociationBehaviourin interfacePolicyComponent- Parameters:
policy- the policy nameclassName- the name of the class (type or aspect) to bind againstassocName- the name of the association to bind againstbehaviour- the behaviour. What gets executed by the policy- Returns:
- the registered behaviour definition
-
bindAssociationBehaviour
public BehaviourDefinition<ClassFeatureBehaviourBinding> bindAssociationBehaviour(org.alfresco.service.namespace.QName policy, org.alfresco.service.namespace.QName className, Behaviour behaviour)
Description copied from interface:PolicyComponentBind an Association specific behaviour to an Association-level Policy (for all associations of a Class)- Specified by:
bindAssociationBehaviourin interfacePolicyComponent- Parameters:
policy- the policy nameclassName- the name of the class (type or aspect) to bind againstbehaviour- the behaviour. What gets executed by the policy- Returns:
- the registered behaviour definition
-
bindAssociationBehaviour
public BehaviourDefinition<ServiceBehaviourBinding> bindAssociationBehaviour(org.alfresco.service.namespace.QName policy, java.lang.Object service, Behaviour behaviour)
Description copied from interface:PolicyComponentBind a Service specific behaviour to an Association-level Policy- Specified by:
bindAssociationBehaviourin interfacePolicyComponent- Parameters:
policy- the policy nameservice- the binding servicebehaviour- the behaviour. What gets executed by the policy- Returns:
- the registered behaviour definition
-
-