* conversion of the method call into the broadcasting of an event instance.
* @param clazz a descendant interface of EventProducer
* @return the EventProducer instance
*/
protected EventProducer createProxyFor(Class clazz) {
final EventProducerModel producerModel = getEventProducerModel(clazz);
if (producerModel == null) {
throw new IllegalStateException("Event model doesn't contain the definition for "
+ clazz.getName());
}
return (EventProducer)Proxy.newProxyInstance(clazz.getClassLoader(),
new Class[] {clazz},
new InvocationHandler() {
public Object invoke(Object proxy, Method method, Object[] args)
throws Throwable {
String methodName = method.getName();
EventMethodModel methodModel = producerModel.getMethod(methodName);
String eventID = producerModel.getInterfaceName() + "." + methodName;
if (methodModel == null) {
throw new IllegalStateException(
"Event model isn't consistent"
+ " with the EventProducer interface. Please rebuild FOP!"
+ " Affected method: "