Package eu.admire.dispel.parser.v4.builder

Examples of eu.admire.dispel.parser.v4.builder.WithAssertionStrategy


    {
        InMemoryAdmireRegistry registry = new InMemoryAdmireRegistry();
        registry.registerProcessingElement("a.A");
        registry.registerProcessingElement("eu.admire.Results");
        DISPELCompiler compiler = new DISPELCompiler();
        DISPELGraphBuilder builder =
            new DISPELGraphBuilder(registry, new SimpleDispelOptimiser());
        compiler.setRequestBuilder(builder);
        compiler.addErrorListener(new ErrorListener()
        {
            @Override
            public void error(int line, int column, Throwable cause)
            {
                System.out.println("(" + line + ", " + column + ")");
                cause.printStackTrace();
            }
            @Override
            public void error(int line, int column, String message)
            {
                System.out.println("(" + line + ", " + column + "): " + message);
            }
        });
        compiler.parse("use a.A; " +
            "A a1 = new A; A a2 = new A; " +
            "a1.output => a2.input; a1.output => a2.input; " +
            "submit a1;");
        Collection<Graph> submitted = builder.getSubmittedGraphs();
        assertFalse("Compilation failed", submitted.isEmpty());
        Graph graph = submitted.iterator().next();
        System.out.println(graph);
        ExchangeFactory factory = new TestExchangeFactory();
        ProcessingElementMapper mapper = new SimpleProcessingElementMapper();
View Full Code Here


        {
            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());
    }
View Full Code Here

    {
        compiler.addErrorListener(errorListener);
    }
    compiler.addErrorListener(this);
   
    DISPELGraphBuilder builder = new DISPELGraphBuilder(
        mAdmireRegistry, mDispelOptimiser);
    compiler.setRequestBuilder(builder);
    compiler.parse(dispelCode);
   
    if (mHaveCompilerErrors)
    {
        throw new CompilationException();
    }
   
    // ignore register objects
   
    // 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());
}
View Full Code Here

    }
   
    private void configProcessingElements(File configFile) throws IOException
    {
        DISPELCompiler compiler = new DISPELCompiler();
        DISPELGraphBuilder builder =
            new DISPELGraphBuilder(this, new SimpleDispelOptimiser());
        compiler.setRequestBuilder(builder);
        compiler.addErrorListener(new LoggingErrorListener());
        compiler.parse(new FileReader(configFile));
        Map<String, RegisteredObject> registered = builder.getRegistered();
        for (RegisteredObject object : registered.values())
        {
            if (object.getObject() instanceof ProcessingElementType)
            {
                registerProcessingElement((ProcessingElementType)object.getObject());
View Full Code Here

TOP

Related Classes of eu.admire.dispel.parser.v4.builder.WithAssertionStrategy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.