catch (VariableDeclarationException ex)
{
throw new ExprValidationException("Cannot create variable: " + ex.getMessage(), ex);
}
final CreateVariableView createView = new CreateVariableView(statementContext.getStatementId(), services.getEventAdapterService(), services.getVariableService(), createDesc.getVariableName(), statementContext.getStatementResultService());
final int variableNum = services.getVariableService().getReader(createDesc.getVariableName()).getVariableNumber();
services.getVariableService().registerCallback(variableNum, createView);
statementContext.getStatementStopService().addSubscriber(new StatementStopCallback() {
public void statementStopped()
{
services.getVariableService().unregisterCallback(variableNum, createView);
}
});
// Create result set processor, use wildcard selection
statementSpec.getSelectClauseSpec().getSelectExprList().clear();
statementSpec.getSelectClauseSpec().add(new SelectClauseElementWildcard());
statementSpec.setSelectStreamDirEnum(SelectClauseStreamSelectorEnum.RSTREAM_ISTREAM_BOTH);
StreamTypeService typeService = new StreamTypeServiceImpl(new EventType[] {createView.getEventType()}, new String[] {"create_variable"}, new boolean[] {true}, services.getEngineURI(), false);
AgentInstanceContext agentInstanceContext = getDefaultAgentInstanceContext(statementContext);
ResultSetProcessorFactoryDesc resultSetProcessorPrototype = ResultSetProcessorFactoryFactory.getProcessorPrototype(
statementSpec, statementContext, typeService, null, new boolean[0], true, ContextPropertyRegistryImpl.EMPTY_REGISTRY, null);
ResultSetProcessor resultSetProcessor = EPStatementStartMethodHelperAssignExpr.getAssignResultSetProcessor(agentInstanceContext, resultSetProcessorPrototype);
// Attach output view
OutputProcessViewFactory outputViewFactory = OutputProcessViewFactoryFactory.make(statementSpec, services.getInternalEventRouter(), agentInstanceContext.getStatementContext(), resultSetProcessor.getResultEventType(), null);
OutputProcessViewBase outputView = outputViewFactory.makeView(resultSetProcessor, agentInstanceContext);
createView.addView(outputView);
services.getStatementVariableRefService().addReferences(statementContext.getStatementName(), Collections.singleton(createDesc.getVariableName()));
EPStatementDestroyMethod destroyMethod = new EPStatementDestroyMethod() {
public void destroy() {
try {