View Javadoc

1   /*
2    * $Id: KeyGenerator.java 22607 2011-08-08 02:13:54Z pablo.kraan $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  package org.mule.cache.keygenerator;
11  
12  import org.mule.api.MuleEvent;
13  
14  import java.io.NotSerializableException;
15  import java.io.Serializable;
16  
17  /**
18   * Defines a way to generate cache keys for {@link MuleEvent} instances.
19   */
20  public interface KeyGenerator
21  {
22  
23      /**
24       * Generates a key for an event.
25       * <p/>
26       * The generation algorithm should return the same key value for all the
27       * events that are considered equals.
28       *
29       * @param event the event to generate the key for
30       * @return the generated key
31       * @throws NotSerializableException if the generated key is not {@link Serializable}
32       */
33      Serializable generateKey(MuleEvent event) throws NotSerializableException;
34  }