/*
 * Copyright (C) 2005-2010 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 
* @param behaviour * @param definition * @param policyInterface * @return invocation handler */ public
InvocationHandler createHandler(Behaviour behaviour, PolicyDefinition
definition, P policyInterface) { return new TransactionHandler
(behaviour, definition, policyInterface); } /** * Transaction Invocation Handler. * * @param
policy interface */ private class TransactionHandler
implements InvocationHandler { private Behaviour behaviour; private PolicyDefinition
definition; private P policyInterface; /** * Construct */ public TransactionHandler(Behaviour behaviour, PolicyDefinition
 definition, P policyInterface)
        {
            this.behaviour = behaviour;
            this.definition = definition;
            this.policyInterface = policyInterface;
        }
        
        /* (non-Javadoc)
         * @see java.lang.reflect.InvocationHandler#invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
         */
        @SuppressWarnings("unchecked")
        public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
        {
            // Handle Object level methods
            if (method.getName().equals("toString"))
            {
                return policyInterface.toString();
            }
            else if (method.getName().equals("hashCode"))
            {
                return policyInterface.hashCode();
            }
            else if (method.getName().equals("equals"))
            {
                return policyInterface.equals(args[0]);
            }
            // Invoke policy based on its notification frequency
            Object result = null;
            if (behaviour.getNotificationFrequency().equals(NotificationFrequency.FIRST_EVENT))
            {
                Map 
     */
    private class ExecutionInstanceKey
    {
        public ExecutionInstanceKey(Behaviour behaviour, Arg[] argDefs, Object[] args)
        {
            this.behaviour = behaviour;
            
            for (int i = 0; i < argDefs.length; i++)
            {
                if (argDefs[i].equals(Arg.KEY))
                {
                    keys.add(args[i]);
                }
            }
        }
        
        Behaviour behaviour;
        ArrayList