}
}
private NullableObject<InternalEventRouterPreprocessor> initialize(EventType eventType)
{
EventTypeSPI eventTypeSPI = (EventTypeSPI) eventType;
List<InternalEventRouterEntry> desc = new ArrayList<InternalEventRouterEntry>();
// determine which ones to process for this types, and what priority and drop
Set<String> eventPropertiesWritten = new HashSet<String>();
for (Map.Entry<UpdateDesc, IRDescEntry> entry : descriptors.entrySet())
{
boolean applicable = entry.getValue().getEventType() == eventType;
if (!applicable)
{
if (eventType.getDeepSuperTypes() != null)
{
for (Iterator<EventType> it = eventType.getDeepSuperTypes(); it.hasNext();)
{
if (it.next() == entry.getValue().getEventType())
{
applicable = true;
break;
}
}
}
}
if (!applicable)
{
continue;
}
int priority = 0;
boolean isDrop = false;
Annotation[] annotations = entry.getValue().getAnnotations();
for (int i = 0; i < annotations.length; i++)
{
if (annotations[i] instanceof Priority)
{
priority = ((Priority) annotations[i]).value();
}
if (annotations[i] instanceof Drop)
{
isDrop = true;
}
}
List<String> properties = new ArrayList<String>();
ExprNode[] expressions = new ExprNode[entry.getKey().getAssignments().size()];
for (int i = 0; i < entry.getKey().getAssignments().size(); i++)
{
OnTriggerSetAssignment assignment = entry.getKey().getAssignments().get(i);
expressions[i] = assignment.getExpression();
properties.add(assignment.getVariableName());
eventPropertiesWritten.add(assignment.getVariableName());
}
EventBeanWriter writer = eventTypeSPI.getWriter(properties.toArray(new String[properties.size()]));
desc.add(new InternalEventRouterEntry(priority, isDrop, entry.getKey().getOptionalWhereClause(), expressions, writer, entry.getValue().getWideners(), entry.getValue().getOutputView(), entry.getValue().getAgentInstanceLock(), entry.getValue().hasSubselect));
}
EventBeanCopyMethod copyMethod = eventTypeSPI.getCopyMethod(eventPropertiesWritten.toArray(new String[eventPropertiesWritten.size()]));
if (copyMethod == null)
{
return new NullableObject<InternalEventRouterPreprocessor>(null);
}
return new NullableObject<InternalEventRouterPreprocessor>(new InternalEventRouterPreprocessor(copyMethod, desc));