mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-08 14:51:49 +00:00
RM-1098: Refactor RM behaviours
* added BehaviourRegister interface and provided access to behaviour objects when named git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@58608 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -88,9 +88,10 @@ public class AnnotatedBehaviourPostProcessor implements BeanPostProcessor
|
||||
}
|
||||
|
||||
/**
|
||||
* Register behaviours.
|
||||
*
|
||||
* @param bean
|
||||
* @param beanName
|
||||
* @param bean bean
|
||||
* @param beanName bean name
|
||||
*/
|
||||
private void registerBehaviours(Object bean, String beanName)
|
||||
{
|
||||
@@ -115,11 +116,12 @@ public class AnnotatedBehaviourPostProcessor implements BeanPostProcessor
|
||||
}
|
||||
|
||||
/**
|
||||
* Register behaviour.
|
||||
*
|
||||
* @param behaviourBean
|
||||
* @param bean
|
||||
* @param beanName
|
||||
* @param method
|
||||
* @param behaviourBean behaviour bean annotation
|
||||
* @param bean bean
|
||||
* @param beanName bean name
|
||||
* @param method method
|
||||
*/
|
||||
private void registerBehaviour(BehaviourBean behaviourBean, Object bean, String beanName, Method method)
|
||||
{
|
||||
@@ -138,13 +140,13 @@ public class AnnotatedBehaviourPostProcessor implements BeanPostProcessor
|
||||
{
|
||||
if (behaviour.isService() == false)
|
||||
{
|
||||
logger.debug(" ... registering " + behaviour.kind() + " behaviour for " + beanName + "." + method.getName() +
|
||||
logger.debug(" ... binding " + behaviour.kind() + " behaviour for " + beanName + "." + method.getName() +
|
||||
" for policy " + policy.toString() +
|
||||
" and type " + type.toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.debug(" ... registering " + behaviour.kind() + " service behaviour for " + beanName + "." + method.getName() +
|
||||
logger.debug(" ... binding " + behaviour.kind() + " service behaviour for " + beanName + "." + method.getName() +
|
||||
" for policy " + policy.toString());
|
||||
}
|
||||
}
|
||||
@@ -152,6 +154,17 @@ public class AnnotatedBehaviourPostProcessor implements BeanPostProcessor
|
||||
// create java behaviour object
|
||||
JavaBehaviour javaBehaviour = new JavaBehaviour(bean, method.getName(), behaviour.notificationFrequency());
|
||||
|
||||
// determine whether we should register the behaviour
|
||||
if (bean instanceof BehaviourRegistry && behaviour.name().isEmpty() == false)
|
||||
{
|
||||
if (logger.isDebugEnabled() == true)
|
||||
{
|
||||
logger.debug(" ... adding behaviour to registry with name " + behaviour.name());
|
||||
}
|
||||
|
||||
((BehaviourRegistry)bean).registerBehaviour(behaviour.name(), javaBehaviour);
|
||||
}
|
||||
|
||||
// deal with class behaviours
|
||||
if (BehaviourKind.CLASS.equals(behaviour.kind()) == true)
|
||||
{
|
||||
|
@@ -34,6 +34,9 @@ import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
|
||||
@Retention(value = RetentionPolicy.RUNTIME)
|
||||
public @interface Behaviour
|
||||
{
|
||||
/** lookup name of the behaviour, if none specified behaviour is not recorded in the registry */
|
||||
String name() default "";
|
||||
|
||||
/** kind of behaviour */
|
||||
BehaviourKind kind();
|
||||
|
||||
|
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2013 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.policy.annotation;
|
||||
|
||||
import org.alfresco.repo.policy.Behaviour;
|
||||
|
||||
|
||||
/**
|
||||
* Interface for a behaviour registry.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.2
|
||||
*/
|
||||
public interface BehaviourRegistry
|
||||
{
|
||||
/**
|
||||
* Register a behaviour against a given name.
|
||||
*
|
||||
* @param behaviour behaviour
|
||||
*/
|
||||
void registerBehaviour(String name, org.alfresco.repo.policy.Behaviour behaviour);
|
||||
|
||||
/**
|
||||
* Gets the behaviour for a given name.
|
||||
*
|
||||
* @param name behaviour name
|
||||
* @return {@link Behaviour} behaviour, null otherwise
|
||||
*/
|
||||
org.alfresco.repo.policy.Behaviour getBehaviour(String name);
|
||||
}
|
Reference in New Issue
Block a user