Search in sources :

Example 6 with AbstractPipe

use of nl.nn.adapterframework.pipes.AbstractPipe in project iaf by ibissource.

the class Adapter method configure.

/*
	 * This function is called by Configuration.registerAdapter,
	 * to make configuration information available to the Adapter. <br/><br/>
	 * This method also performs
	 * a <code>Pipeline.configurePipes()</code>, as to configure the individual pipes.
	 * @see nl.nn.adapterframework.core.Pipeline#configurePipes
	 */
public void configure() throws ConfigurationException {
    configurationSucceeded = false;
    log.debug("configuring adapter [" + getName() + "]");
    messageKeeper = getMessageKeeper();
    statsMessageProcessingDuration = new StatisticsKeeper(getName());
    if (pipeline == null) {
        String msg = "No pipeline configured for adapter [" + getName() + "]";
        messageKeeper.add(msg, MessageKeeperMessage.ERROR_LEVEL);
        throw new ConfigurationException(msg);
    }
    try {
        pipeline.setAdapter(this);
        pipeline.configure();
        messageKeeper.add("Adapter [" + name + "] pipeline successfully configured");
        Iterator<IReceiver> it = receivers.iterator();
        while (it.hasNext()) {
            IReceiver receiver = it.next();
            configureReceiver(receiver);
        }
        configurationSucceeded = true;
    } catch (ConfigurationException e) {
        error(true, "error initializing pipeline", e);
    }
    List<String> hrs = new ArrayList<String>();
    for (IPipe pipe : pipeline.getPipes()) {
        if (pipe instanceof AbstractPipe) {
            AbstractPipe aPipe = (AbstractPipe) pipe;
            if (aPipe.getHideRegex() != null) {
                if (!hrs.contains(aPipe.getHideRegex())) {
                    hrs.add(aPipe.getHideRegex());
                }
            }
        }
    }
    StringBuilder sb = new StringBuilder();
    for (String hr : hrs) {
        if (sb.length() > 0) {
            sb.append("|");
        }
        sb.append("(");
        sb.append(hr);
        sb.append(")");
    }
    if (sb.length() > 0) {
        composedHideRegex = sb.toString();
    }
}
Also used : AbstractPipe(nl.nn.adapterframework.pipes.AbstractPipe) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) ArrayList(java.util.ArrayList) StatisticsKeeper(nl.nn.adapterframework.statistics.StatisticsKeeper)

Example 7 with AbstractPipe

use of nl.nn.adapterframework.pipes.AbstractPipe in project iaf by ibissource.

the class PipeLine method configure.

/**
 * Configures the pipes of this Pipeline and does some basic checks. It also
 * registers the <code>PipeLineSession</code> object at the pipes.
 * @see IPipe
 */
public void configure() throws ConfigurationException {
    INamedObject owner = getOwner();
    IAdapter adapter = null;
    if (owner instanceof IAdapter) {
        adapter = (IAdapter) owner;
    }
    if (cache != null) {
        cache.configure(owner.getName() + "-Pipeline");
    }
    for (int i = 0; i < pipes.size(); i++) {
        IPipe pipe = getPipe(i);
        log.debug("Pipeline of [" + owner.getName() + "] configuring Pipe [" + pipe.getName() + "]");
        // forward is defined, it is not overwritten by the globals
        for (String gfName : globalForwards.keySet()) {
            PipeForward pipeForward = globalForwards.get(gfName);
            pipe.registerForward(pipeForward);
        }
        if (pipe instanceof FixedForwardPipe) {
            FixedForwardPipe ffpipe = (FixedForwardPipe) pipe;
            if (ffpipe.findForward("success") == null) {
                int i2 = i + 1;
                if (i2 < pipes.size()) {
                    String nextPipeName = getPipe(i2).getName();
                    PipeForward pf = new PipeForward();
                    pf.setName("success");
                    pf.setPath(nextPipeName);
                    pipe.registerForward(pf);
                } else {
                    PipeLineExit plexit = findExitByState("success");
                    if (plexit != null) {
                        PipeForward pf = new PipeForward();
                        pf.setName("success");
                        pf.setPath(plexit.getPath());
                        pipe.registerForward(pf);
                    }
                }
            }
        }
        configure(pipe);
    }
    if (pipeLineExits.size() < 1) {
        throw new ConfigurationException("no PipeLine Exits specified");
    }
    if (this.firstPipe == null) {
        throw new ConfigurationException("no firstPipe defined");
    }
    if (getPipe(firstPipe) == null) {
        throw new ConfigurationException("no pipe found for firstPipe [" + firstPipe + "]");
    }
    IPipe inputValidator = getInputValidator();
    IPipe outputValidator = getOutputValidator();
    if (inputValidator != null && outputValidator == null && inputValidator instanceof IDualModeValidator) {
        outputValidator = ((IDualModeValidator) inputValidator).getResponseValidator();
        setOutputValidator(outputValidator);
    }
    if (inputValidator != null) {
        log.debug("Pipeline of [" + owner.getName() + "] configuring InputValidator");
        PipeForward pf = new PipeForward();
        pf.setName("success");
        inputValidator.registerForward(pf);
        inputValidator.setName(INPUT_VALIDATOR_NAME);
        configure(inputValidator);
    }
    if (outputValidator != null) {
        log.debug("Pipeline of [" + owner.getName() + "] configuring OutputValidator");
        PipeForward pf = new PipeForward();
        pf.setName("success");
        outputValidator.registerForward(pf);
        outputValidator.setName(OUTPUT_VALIDATOR_NAME);
        configure(outputValidator);
    }
    if (getInputWrapper() != null) {
        log.debug("Pipeline of [" + owner.getName() + "] configuring InputWrapper");
        PipeForward pf = new PipeForward();
        pf.setName("success");
        getInputWrapper().registerForward(pf);
        getInputWrapper().setName(INPUT_WRAPPER_NAME);
        configure(getInputWrapper());
    }
    if (getOutputWrapper() != null) {
        log.debug("Pipeline of [" + owner.getName() + "] configuring OutputWrapper");
        PipeForward pf = new PipeForward();
        pf.setName("success");
        if (getOutputWrapper() instanceof AbstractPipe && adapter instanceof Adapter) {
            ((AbstractPipe) getOutputWrapper()).setRecoverAdapter(((Adapter) adapter).isRecover());
        }
        getOutputWrapper().registerForward(pf);
        getOutputWrapper().setName(OUTPUT_WRAPPER_NAME);
        if (getOutputWrapper() instanceof EsbSoapWrapperPipe) {
            EsbSoapWrapperPipe eswPipe = (EsbSoapWrapperPipe) getOutputWrapper();
            boolean stop = false;
            Iterator<IReceiver> recIt = adapter.getReceiverIterator();
            if (recIt.hasNext()) {
                while (recIt.hasNext() && !stop) {
                    IReceiver receiver = recIt.next();
                    if (receiver instanceof ReceiverBase) {
                        ReceiverBase rb = (ReceiverBase) receiver;
                        IListener listener = rb.getListener();
                        try {
                            if (eswPipe.retrievePhysicalDestinationFromListener(listener)) {
                                stop = true;
                            }
                        } catch (JmsException e) {
                            throw new ConfigurationException(e);
                        }
                    }
                }
            }
        }
        configure(getOutputWrapper());
    }
    requestSizeStats = new SizeStatisticsKeeper("- pipeline in");
    if (isTransacted() && getTransactionTimeout() > 0) {
        String systemTransactionTimeout = Misc.getSystemTransactionTimeout();
        if (systemTransactionTimeout != null && StringUtils.isNumeric(systemTransactionTimeout)) {
            int stt = Integer.parseInt(systemTransactionTimeout);
            if (getTransactionTimeout() > stt) {
                ConfigurationWarnings configWarnings = ConfigurationWarnings.getInstance();
                String msg = "Pipeline of [" + owner.getName() + "] has a transaction timeout [" + getTransactionTimeout() + "] which exceeds the system transaction timeout [" + stt + "]";
                configWarnings.add(log, msg);
            }
        }
    }
    int txOption = this.getTransactionAttributeNum();
    if (log.isDebugEnabled())
        log.debug("creating TransactionDefinition for transactionAttribute [" + getTransactionAttribute() + "], timeout [" + getTransactionTimeout() + "]");
    txDef = SpringTxManagerProxy.getTransactionDefinition(txOption, getTransactionTimeout());
    log.debug("Pipeline of [" + owner.getName() + "] successfully configured");
}
Also used : ReceiverBase(nl.nn.adapterframework.receivers.ReceiverBase) EsbSoapWrapperPipe(nl.nn.adapterframework.extensions.esb.EsbSoapWrapperPipe) ConfigurationWarnings(nl.nn.adapterframework.configuration.ConfigurationWarnings) JmsException(nl.nn.adapterframework.jms.JmsException) SizeStatisticsKeeper(nl.nn.adapterframework.statistics.SizeStatisticsKeeper) ICacheAdapter(nl.nn.adapterframework.cache.ICacheAdapter) AbstractPipe(nl.nn.adapterframework.pipes.AbstractPipe) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) FixedForwardPipe(nl.nn.adapterframework.pipes.FixedForwardPipe)

Aggregations

AbstractPipe (nl.nn.adapterframework.pipes.AbstractPipe)7 StatisticsKeeper (nl.nn.adapterframework.statistics.StatisticsKeeper)5 ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)3 IExtendedPipe (nl.nn.adapterframework.core.IExtendedPipe)2 PipeRunException (nl.nn.adapterframework.core.PipeRunException)2 PipeRunResult (nl.nn.adapterframework.core.PipeRunResult)2 MessageSendingPipe (nl.nn.adapterframework.pipes.MessageSendingPipe)2 SizeStatisticsKeeper (nl.nn.adapterframework.statistics.SizeStatisticsKeeper)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 Transformer (javax.xml.transform.Transformer)1 TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)1 TransformerException (javax.xml.transform.TransformerException)1 ICacheAdapter (nl.nn.adapterframework.cache.ICacheAdapter)1 ConfigurationWarnings (nl.nn.adapterframework.configuration.ConfigurationWarnings)1 IAdapter (nl.nn.adapterframework.core.IAdapter)1 IPipe (nl.nn.adapterframework.core.IPipe)1 IPipeLineExitHandler (nl.nn.adapterframework.core.IPipeLineExitHandler)1 PipeForward (nl.nn.adapterframework.core.PipeForward)1