{
compiler.addErrorListener(errorListener);
}
compiler.addErrorListener(this);
DISPELGraphBuilder builder = new DISPELGraphBuilder(
mAdmireRegistry, mDispelOptimiser);
compiler.setRequestBuilder(builder);
compiler.parse(dispel);
if (mHaveCompilerErrors)
{
throw new CompilationException();
}
// register objects
for (Entry<String, RegisteredObject> register : builder.getRegistered().entrySet())
{
String name = register.getKey();
LOG.debug("Creating DISPEL for '" + name + "'.");
DispelObject object = null;
try
{
object = new DispelObject(name, register.getValue().getObject());
object.annotations = register.getValue().getAnnotations();
if (LOG.isDebugEnabled()) LOG.debug("Registering " + object);
mAdmireRegistry.register(name, object);
LOG.debug("Successfully registered '" + name + "'.");
}
catch (RegistrationFailedException e)
{
LOG.debug("Registration of " + object + " failed.", e);
notifyListeners(name, new RegistrationFailedException(object, e));
}
catch (Throwable e)
{
LOG.debug("Registration of object named '" + name + "' failed.", e);
notifyListeners(name, new RegistrationFailedException(name, e));
}
}
// Apply logical optimisers to submitted graphs
List<Graph> submittedGraphs = new LinkedList<Graph>();
for (Graph graph : builder.getSubmittedGraphs())
{
if (mOptimisers != null)
{
for (Optimiser optimiser : mOptimisers)
{
graph = optimiser.transform(mRequestContext, graph);
}
}
submittedGraphs.add(graph);
}
return new SimpleDispelEngineResult(
submittedGraphs,
builder.getRegistered());
}