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