public List<EventBean> poll(Object[] lookupValues) { List<EventBean> rowResult = null; try { Object invocationResult = method.invoke(null, lookupValues); if (invocationResult != null) { if (isArray) { int length = Array.getLength(invocationResult); if (length > 0) { rowResult = new ArrayList<EventBean>(); for (int i = 0; i < length; i++) { Object value = Array.get(invocationResult, i); if (value == null) { log.warn( "Expected non-null return result from method '" + method.getName() + "', but received null value"); continue; } EventBean theEvent; if (useMapType) { if (!(value instanceof Map)) { log.warn( "Expected Map-type return result from method '" + method.getName() + "', but received type '" + value.getClass() + "'"); continue; } Map mapValues = (Map) value; theEvent = eventAdapterService.adapterForTypedMap(mapValues, eventType); } else { theEvent = eventAdapterService.adapterForBean(value); } rowResult.add(theEvent); } } } else { rowResult = new LinkedList<EventBean>(); EventBean theEvent; if (useMapType) { if (!(invocationResult instanceof Map)) { log.warn( "Expected Map-type return result from method '" + method.getName() + "', but received type '" + invocationResult.getClass() + "'"); } else { Map mapValues = (Map) invocationResult; theEvent = eventAdapterService.adapterForTypedMap(mapValues, eventType); rowResult.add(theEvent); } } else { theEvent = eventAdapterService.adapterForBean(invocationResult); rowResult.add(theEvent); } } } } catch (InvocationTargetException ex) { throw new EPException( "Method '" + method.getName() + "' of class '" + method.getJavaMethod().getDeclaringClass().getName() + "' reported an exception: " + ex.getTargetException(), ex.getTargetException()); } return rowResult; }