statementName = options.getStatementNameResolver() != null ? options.getStatementNameResolver().getStatementName(ctx) : null;
userObject = options.getStatementUserObjectResolver() != null ? options.getStatementUserObjectResolver().getUserObject(ctx) : null;
}
try {
EPStatement stmt;
if (optionalStatementIdGenerator == null) {
if (options.getIsolatedServiceProvider() == null) {
stmt = epService.createEPL(item.getExpression(), statementName, userObject);
}
else {
EPServiceProviderIsolated unit = statementIsolationService.getIsolationUnit(options.getIsolatedServiceProvider(), -1);
stmt = unit.getEPAdministrator().createEPL(item.getExpression(), statementName, userObject);
}
}
else {
String statementId = optionalStatementIdGenerator.getNextStatementId();
if (options.getIsolatedServiceProvider() == null) {
stmt = epService.createEPLStatementId(item.getExpression(), statementName, userObject, statementId);
}
else {
EPServiceProviderIsolated unit = statementIsolationService.getIsolationUnit(options.getIsolatedServiceProvider(), -1);
EPAdministratorIsolatedSPI spi = (EPAdministratorIsolatedSPI) unit.getEPAdministrator();
stmt = spi.createEPLStatementId(item.getExpression(), statementName, userObject, statementId);
}
}
statementNames.add(new DeploymentInformationItem(stmt.getName(), stmt.getText()));
statements.add(stmt);
String[] types = statementEventTypeRef.getTypesForStatementName(stmt.getName());
if (types != null) {
eventTypesReferenced.addAll(Arrays.asList(types));
}
}
catch (EPException ex) {
exceptions.add(new DeploymentItemException(ex.getMessage(), item.getExpression(), ex, item.getLineNumber()));
if (options.isFailFast()) {
break;
}
}
}
if (!exceptions.isEmpty()) {
if (options.isRollbackOnFail()) {
log.debug("Rolling back intermediate statements for deployment");
for (EPStatement stmt : statements) {
try {
stmt.destroy();
}
catch (Exception ex) {
log.debug("Failed to destroy created statement during rollback: " + ex.getMessage(), ex);
}
}
EPLModuleUtil.undeployTypes(eventTypesReferenced, statementEventTypeRef, eventAdapterService, filterService);
}
String text = "Deployment failed";
if (options.isValidateOnly()) {
text = "Validation failed";
}
throw buildException(text, module, exceptions);
}
if (options.isValidateOnly()) {
log.debug("Rolling back created statements for validate-only");
for (EPStatement stmt : statements) {
try {
stmt.destroy();
}
catch (Exception ex) {
log.debug("Failed to destroy created statement during rollback: " + ex.getMessage(), ex);
}
}