public EPStatementStartMethodCreateGraph(StatementSpecCompiled statementSpec, EPServicesContext services, StatementContext statementContext) {
super(statementSpec, services, statementContext);
}
public EPStatementStartResult startInternal(boolean isNewStatement, boolean isRecoveringStatement, boolean isRecoveringResilient) throws ExprValidationException, ViewProcessingException {
final CreateDataFlowDesc createGraphDesc = statementSpec.getCreateGraphDesc();
final AgentInstanceContext agentInstanceContext = getDefaultAgentInstanceContext();
// define output event type
String typeName = "EventType_Graph_" + createGraphDesc.getGraphName();
EventType resultType = services.getEventAdapterService().createAnonymousMapType(typeName, Collections.<String, Object>emptyMap());
services.getGraphService().addStartGraph(createGraphDesc, statementContext, services, agentInstanceContext, isNewStatement);
EPStatementStopMethod stopMethod = new EPStatementStopMethod() {
public void stop() {
services.getGraphService().stopGraph(createGraphDesc.getGraphName());
}
};
EPStatementDestroyMethod destroyMethod = new EPStatementDestroyMethod() {
public void destroy() {
services.getGraphService().removeGraph(createGraphDesc.getGraphName());
}
};
return new EPStatementStartResult(new ZeroDepthStream(resultType), stopMethod, destroyMethod);
}