Search in sources :

Example 31 with PipeLine

use of nl.nn.adapterframework.core.PipeLine in project iaf by ibissource.

the class AbstractPipe method getForwards.

@Override
public Map<String, PipeForward> getForwards() {
    Map<String, PipeForward> forwards = new Hashtable<String, PipeForward>(pipeForwards);
    PipeLine pipeline = getPipeLine();
    if (pipeline == null) {
        return null;
    }
    // Omit global pipeline-forwards and only return local pipe-forwards
    List<IPipe> pipes = pipeline.getPipes();
    for (int i = 0; i < pipes.size(); i++) {
        String pipeName = pipes.get(i).getName();
        if (forwards.containsKey(pipeName))
            forwards.remove(pipeName);
    }
    return forwards;
}
Also used : Hashtable(java.util.Hashtable) PipeLine(nl.nn.adapterframework.core.PipeLine) PipeForward(nl.nn.adapterframework.core.PipeForward) IPipe(nl.nn.adapterframework.core.IPipe)

Example 32 with PipeLine

use of nl.nn.adapterframework.core.PipeLine in project iaf by ibissource.

the class WsdlGeneratorPipe method createPipeLineFromXsdFile.

private PipeLine createPipeLineFromXsdFile(File xsdFile) throws ConfigurationException {
    PipeLine pipeLine = new PipeLine();
    EsbSoapValidator inputValidator;
    inputValidator = createValidator(xsdFile, null, null, 1, 1, pipeLine);
    pipeLine.setInputValidator(inputValidator);
    String countRoot = null;
    try {
        String countRootXPath = "count(*/*[local-name()='element'])";
        TransformerPool tp = TransformerPool.getInstance(XmlUtils.createXPathEvaluatorSource(countRootXPath, OutputType.TEXT));
        Resource xsdResource = Resource.getResource(xsdFile.getPath());
        countRoot = tp.transform(xsdResource.asSource());
        if (StringUtils.isNotEmpty(countRoot)) {
            log.debug("counted [" + countRoot + "] root elements in xsd file [" + xsdFile.getName() + "]");
            int cr = Integer.parseInt(countRoot);
            if (cr > 1) {
                EsbSoapValidator outputValidator;
                outputValidator = createValidator(xsdFile, null, null, 2, 1, pipeLine);
                pipeLine.setOutputValidator(outputValidator);
            }
        }
    } catch (Exception e) {
        throw new ConfigurationException(e);
    }
    return pipeLine;
}
Also used : ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) Resource(nl.nn.adapterframework.core.Resource) PipeLine(nl.nn.adapterframework.core.PipeLine) TransformerPool(nl.nn.adapterframework.util.TransformerPool) PipeRunException(nl.nn.adapterframework.core.PipeRunException) IOException(java.io.IOException) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException)

Example 33 with PipeLine

use of nl.nn.adapterframework.core.PipeLine in project iaf by ibissource.

the class ApiTestBase method registerAdapter.

protected void registerAdapter(TestConfiguration configuration) throws Exception {
    Adapter adapter = configuration.createBean(Adapter.class);
    adapter.setName("dummyAdapter");
    try {
        PipeLine pipeline = new PipeLine();
        PipeLineExit exit = new PipeLineExit();
        exit.setPath("EXIT");
        exit.setState(ExitState.SUCCESS);
        pipeline.registerPipeLineExit(exit);
        EchoPipe pipe = new EchoPipe();
        pipe.setName("myPipe");
        pipeline.addPipe(pipe);
        adapter.setPipeLine(pipeline);
        configuration.registerAdapter(adapter);
    } catch (ConfigurationException e) {
        e.printStackTrace();
        fail("error registering adapter [" + adapter + "] " + e.getMessage());
    }
    configuration.getConfigurationWarnings().add((Object) null, log, "hello I am a configuration warning!");
}
Also used : ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) EchoPipe(nl.nn.adapterframework.pipes.EchoPipe) Adapter(nl.nn.adapterframework.core.Adapter) PipeLine(nl.nn.adapterframework.core.PipeLine) PipeLineExit(nl.nn.adapterframework.core.PipeLineExit)

Example 34 with PipeLine

use of nl.nn.adapterframework.core.PipeLine in project iaf by ibissource.

the class InputOutputPipeProcessorTest method setUp.

@Before
public void setUp() {
    processor = new InputOutputPipeProcessor();
    PipeProcessor chain = new PipeProcessor() {

        @Override
        public PipeRunResult processPipe(PipeLine pipeLine, IPipe pipe, Message message, PipeLineSession pipeLineSession) throws PipeRunException {
            return pipe.doPipe(message, pipeLineSession);
        }

        @Override
        public PipeRunResult validate(PipeLine pipeLine, IValidator validator, Message message, PipeLineSession pipeLineSession, String messageRoot) throws PipeRunException {
            return validator.validate(message, pipeLineSession, messageRoot);
        }
    };
    processor.setPipeProcessor(chain);
    pipeLine = new PipeLine();
    Adapter owner = new Adapter();
    owner.setName("PipeLine owner");
    pipeLine.setOwner(owner);
    session = new PipeLineSession();
}
Also used : Message(nl.nn.adapterframework.stream.Message) IValidator(nl.nn.adapterframework.core.IValidator) PipeLineSession(nl.nn.adapterframework.core.PipeLineSession) Adapter(nl.nn.adapterframework.core.Adapter) PipeLine(nl.nn.adapterframework.core.PipeLine) IPipe(nl.nn.adapterframework.core.IPipe) Before(org.junit.Before)

Example 35 with PipeLine

use of nl.nn.adapterframework.core.PipeLine in project iaf by ibissource.

the class ClassLoaderManagerTest method createAdapter4ServiceClassLoader.

private static void createAdapter4ServiceClassLoader(String config4Adaptername) throws ConfigurationException {
    // Mock a configuration with an adapter in it
    IbisManager ibisManager = spy(new DefaultIbisManager());
    ibisManager.setIbisContext(ibisContext);
    Configuration configuration = new TestConfiguration();
    configuration.setName("dummyConfiguration");
    configuration.setVersion("1");
    configuration.setIbisManager(ibisManager);
    Adapter adapter = spy(new Adapter());
    adapter.setName(config4Adaptername);
    PipeLine pl = new PipeLine();
    pl.setFirstPipe("dummy");
    EchoPipe pipe = new EchoPipe();
    pipe.setName("dummy");
    pl.addPipe(pipe);
    PipeLineExit ple = new PipeLineExit();
    ple.setPath("success");
    ple.setState(ExitState.SUCCESS);
    pl.registerPipeLineExit(ple);
    adapter.setPipeLine(pl);
    doAnswer(new Answer<PipeLineResult>() {

        @Override
        public PipeLineResult answer(InvocationOnMock invocation) throws Throwable {
            PipeLineSession session = (PipeLineSession) invocation.getArguments()[2];
            URL file = this.getClass().getResource(JAR_FILE);
            session.put("configurationJar", Misc.streamToBytes(file.openStream()));
            return new PipeLineResult();
        }
    }).when(adapter).processMessage(anyString(), any(Message.class), any(PipeLineSession.class));
    adapter.setConfiguration(configuration);
    configuration.registerAdapter(adapter);
    ibisManager.addConfiguration(configuration);
    when(ibisContext.getIbisManager()).thenReturn(ibisManager);
}
Also used : DefaultIbisManager(nl.nn.adapterframework.unmanaged.DefaultIbisManager) TestConfiguration(nl.nn.adapterframework.testutil.TestConfiguration) Message(nl.nn.adapterframework.stream.Message) EchoPipe(nl.nn.adapterframework.pipes.EchoPipe) TestConfiguration(nl.nn.adapterframework.testutil.TestConfiguration) PipeLineSession(nl.nn.adapterframework.core.PipeLineSession) Adapter(nl.nn.adapterframework.core.Adapter) URL(java.net.URL) InvocationOnMock(org.mockito.invocation.InvocationOnMock) PipeLineResult(nl.nn.adapterframework.core.PipeLineResult) PipeLine(nl.nn.adapterframework.core.PipeLine) DefaultIbisManager(nl.nn.adapterframework.unmanaged.DefaultIbisManager) PipeLineExit(nl.nn.adapterframework.core.PipeLineExit)

Aggregations

PipeLine (nl.nn.adapterframework.core.PipeLine)43 Adapter (nl.nn.adapterframework.core.Adapter)19 Test (org.junit.Test)17 XmlValidatorTest (nl.nn.adapterframework.pipes.XmlValidatorTest)12 IPipe (nl.nn.adapterframework.core.IPipe)10 PipeLineExit (nl.nn.adapterframework.core.PipeLineExit)8 MessageSendingPipe (nl.nn.adapterframework.pipes.MessageSendingPipe)8 IOException (java.io.IOException)6 IValidator (nl.nn.adapterframework.core.IValidator)6 XmlValidator (nl.nn.adapterframework.pipes.XmlValidator)6 Configuration (nl.nn.adapterframework.configuration.Configuration)5 PipeForward (nl.nn.adapterframework.core.PipeForward)5 PipeRunResult (nl.nn.adapterframework.core.PipeRunResult)5 Message (nl.nn.adapterframework.stream.Message)5 AbstractXmlValidator (nl.nn.adapterframework.validation.AbstractXmlValidator)5 JavaxXmlValidator (nl.nn.adapterframework.validation.JavaxXmlValidator)5 XercesXmlValidator (nl.nn.adapterframework.validation.XercesXmlValidator)5 ArrayList (java.util.ArrayList)4 Iterator (java.util.Iterator)4 ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)4