/**
 * DefaultMessageKeyGenerator.java
 * Created Jun 8, 2006
 * Copyright (C) Tandberg Television 2006
 */
package com.tandbergtv.workflow.message.util;

import org.jbpm.graph.exe.Token;

import com.tandbergtv.workflow.message.IMessageKey;
import com.tandbergtv.workflow.message.MessageKeyImpl;

/**
 * Generates a unique key that is meant to be associated with a message emitted by the workflow
 * system. The default implementation uses the database primary key of the Token that emits the
 * message.
 * 
 * @author Sahil Verma
 */
public final class DefaultMessageKeyGenerator implements IMessageKeyGenerationStrategy {
	
	/**
	 * Creates a DefaultMessageKeyGenerator
	 */
	public DefaultMessageKeyGenerator() {
	}

	/* (non-Javadoc)
	 * @see com.tandbergtv.workflow.message.util.IMessageKeyGenerationStrategy#generate(org.jbpm.graph.exe.Token)
	 */
	public IMessageKey generate(Token token) {
		return new MessageKeyImpl(token.getId());
	}
}
