Example usage for javax.xml.datatype Duration toString

List of usage examples for javax.xml.datatype Duration toString

Introduction

In this page you can find the example usage for javax.xml.datatype Duration toString.

Prototype

public String toString() 

Source Link

Document

Returns a String representation of this Duration Object .

Usage

From source file:Main.java

/**
 * Converts a duration in milliseconds to a lexical duration, as defined by XML Schema 1.0.
 * /*from  w ww  .  j av  a2  s  .c  o m*/
 * @param duration the duration
 * 
 * @return the lexical representation
 */
public static String longToDuration(long duration) {
    Duration xmlDuration = getDataTypeFactory().newDuration(duration);
    return xmlDuration.toString();
}

From source file:edu.internet2.middleware.shibboleth.common.config.SpringConfigurationUtils.java

/**
 * Converts a duration, either expressed as numerical time or or ISO8601 duration. If a numerical form is used a
 * warning message indicating that the new IS08601 duration form should be used will be written to the logs.
 * /*www .  j a  v  a2  s.co  m*/
 * This method will be removed once the deprecated numerical duration form is no longer allowed.
 * 
 * @param propertyName Name of the property carrying the duration. This is used in the warning log message if the
 *            duration is in numerical form.
 * @param duration the duration to be parsed
 * @param toMillisFactor used to convert a numerical duration to milliseconds, 0 indicates no conversion
 * 
 * @return the duration in milliseconds
 * 
 * @throws IllegalArgumentException thrown if the given duration is either an invalid number or ISO8601 duration or
 *             if the duration is negative
 */
@Deprecated
public static long parseDurationToMillis(String propertyName, String duration, int toMillisFactor)
        throws IllegalArgumentException {
    if (duration.startsWith("-")) {
        throw new IllegalArgumentException("Negative durations are not supported");
    }

    long millis = 0;
    if (duration.startsWith("P")) {
        Duration xmlDuration = XMLHelper.getDataTypeFactory().newDuration(duration);
        millis = xmlDuration.getTimeInMillis(new Date());
    } else {
        try {
            millis = Long.parseLong(duration);
            if (millis < 0) {
                throw new IllegalArgumentException("Negative durations are not supported");
            }
            if (toMillisFactor > 0) {
                millis *= toMillisFactor;
            }
            Duration xmlDuration = XMLHelper.getDataTypeFactory().newDuration(millis);
            log.warn(
                    "Numerical duration form is deprecated. The property {} should use the duration notation: {}",
                    propertyName, xmlDuration.toString());
        } catch (NumberFormatException e) {

        }
    }

    return millis;
}

From source file:org.activiti.engine.impl.bpmn.helper.NGSISubscribeContextClient.java

private void createRequestDuration() {
    Duration javaXMLDuration = startEventBehaviour.getDuration();
    if (javaXMLDuration != null) {
        String plainDuration = javaXMLDuration.toString();
        // I shiver.
        GDuration gDuration = new GDuration(plainDuration);
        subscribeContextRequest.setDuration(gDuration);
    }//from w w w.j av  a2s .c o m
}

From source file:it.cnr.icar.eric.server.persistence.rdb.FederationDAO.java

/**
 * Returns the SQL fragment string needed by insert or update statements 
 * within insert or update method of sub-classes. This is done to avoid code
 * duplication./*from   w ww.j a  v a 2s .  c o m*/
 */
protected String getSQLStatementFragment(Object ro) throws RegistryException {

    FederationType federation = (FederationType) ro;

    String stmtFragment = null;

    Duration replicationSyncLatency = federation.getReplicationSyncLatency();
    String replicationSyncLatencyString = (replicationSyncLatency == null) ? "P1D"
            : replicationSyncLatency.toString();

    //TODO: Need to persist Federation Members

    if (action == DAO_ACTION_INSERT) {
        stmtFragment = "INSERT INTO Federation " + super.getSQLStatementFragment(ro) + ", '"
                + replicationSyncLatencyString + "' ) ";
    } else if (action == DAO_ACTION_UPDATE) {
        stmtFragment = "UPDATE Federation SET " + super.getSQLStatementFragment(ro)
                + ", replicationSyncLatency='" + replicationSyncLatencyString + "' WHERE id = '"
                + ((RegistryObjectType) ro).getId() + "' ";
    } else if (action == DAO_ACTION_DELETE) {
        stmtFragment = super.getSQLStatementFragment(ro);
    }

    return stmtFragment;
}

From source file:it.cnr.icar.eric.server.persistence.rdb.RegistryDAO.java

/**
 * Returns the SQL fragment string needed by insert or update statements 
 * within insert or update method of sub-classes. This is done to avoid code
 * duplication./*from  w  w  w.  j av a 2 s.co  m*/
 */
protected String getSQLStatementFragment(Object ro) throws RegistryException {

    RegistryType registry = (RegistryType) ro;

    String stmtFragment = null;

    Duration catalogingSyncLatency = registry.getCatalogingLatency();
    String catalogingSyncLatencyString = (catalogingSyncLatency == null) ? "P1D"
            : catalogingSyncLatency.toString();

    String operator = registry.getOperator();

    Duration replicationSyncLatency = registry.getReplicationSyncLatency();
    String replicationSyncLatencyString = (replicationSyncLatency == null) ? "P1D"
            : replicationSyncLatency.toString();

    String specificationVersion = registry.getSpecificationVersion();
    String conformanceProfile = registry.getConformanceProfile();

    if (action == DAO_ACTION_INSERT) {
        stmtFragment = "INSERT INTO Registry " + super.getSQLStatementFragment(ro) + ", '"
                + catalogingSyncLatencyString + "', '" + conformanceProfile + "', '" + operator + "', '"
                + replicationSyncLatencyString + "', '" + specificationVersion + "' ) ";
    } else if (action == DAO_ACTION_UPDATE) {
        stmtFragment = "UPDATE Registry SET " + super.getSQLStatementFragment(ro) + ",  catalogingSyncLatency='"
                + catalogingSyncLatencyString + "', conformanceProfile='" + conformanceProfile + "', operator='"
                + operator + "', replicationSyncLatency='" + replicationSyncLatencyString
                + "', specificationVersion='" + specificationVersion + "' WHERE id = '"
                + ((RegistryObjectType) ro).getId() + "' ";
    } else if (action == DAO_ACTION_DELETE) {
        stmtFragment = super.getSQLStatementFragment(ro);
    }

    return stmtFragment;
}

From source file:edu.internet2.middleware.shibboleth.common.config.metadata.AbstractReloadingMetadataProviderBeanDefinitionParser.java

/**
 * Gets the maximum refresh delay for the metadata provider.
 * /*from w  w  w.  j  a  v  a 2  s. c  om*/
 * @param config provider configuration element
 * 
 * @return the maximum refresh delay, in milliseconds
 */
protected long getMaxRefreshDelay(Element config) {
    long maxRefreshDelay = 14400000L;

    if (config.hasAttributeNS(null, "cacheDuration")) {
        int cacheDuration = Integer.parseInt(config.getAttributeNS(null, "cacheDuration"));
        maxRefreshDelay = cacheDuration * 1000;
        log.warn("Metadata provider cacheDuration attribute is deprecated, use maxRefreshDelay=\"{}\" instead.",
                XMLHelper.getDataTypeFactory().newDuration(maxRefreshDelay).toString());
    }

    if (config.hasAttributeNS(null, "maxCacheDuration")) {
        int cacheDuration = Integer.parseInt(config.getAttributeNS(null, "maxCacheDuration"));
        Duration duration = XMLHelper.getDataTypeFactory().newDuration(cacheDuration * 1000);
        log.warn(
                "Metadata provider maxCacheDuration attribute is deprecated, use maxRefreshDelay=\"{}\" instead.",
                duration.toString());
    }

    if (config.hasAttributeNS(null, "maxRefreshDelay")) {
        String delayString = config.getAttributeNS(null, "maxRefreshDelay");
        try {
            maxRefreshDelay = SpringConfigurationUtils.parseDurationToMillis("maxRefreshDelay", delayString, 1);
        } catch (NumberFormatException e) {
            log.error("Metadata provider had invalid maxRefreshDelay value '{}', using default value",
                    delayString);
        }
    }

    if (maxRefreshDelay <= 0) {
        log.error("Metadata provider had invalid maxRefreshDelay value '{}', using default value",
                maxRefreshDelay);
        maxRefreshDelay = 14400000L;
    }

    return maxRefreshDelay;
}

From source file:it.cnr.icar.eric.server.persistence.rdb.SubscriptionDAO.java

/**
 * Returns the SQL fragment string needed by insert or update statements
 * within insert or update method of sub-classes. This is done to avoid code
 * duplication.//  ww w  . j a v  a 2s  . c om
 */
protected String getSQLStatementFragment(Object ro) throws RegistryException {

    SubscriptionType subscription = (SubscriptionType) ro;

    String stmtFragment = null;
    String selector = subscription.getSelector();

    XMLGregorianCalendar endTime = subscription.getEndTime();
    String endTimeAsString = null;

    if (endTime != null) {
        endTimeAsString = " '" + (new Timestamp(endTime.toGregorianCalendar().getTimeInMillis())) + "'";
    }

    Duration notificationInterval = subscription.getNotificationInterval();
    String notificationIntervalString = "";

    if (notificationInterval != null) {
        notificationIntervalString = "'" + notificationInterval.toString() + "'";
    }
    // xxx 120203 pa fix for missing XJC/JAXB generated default value for
    // duration
    else {
        notificationIntervalString = "'P1D'";
    }

    XMLGregorianCalendar startTime = subscription.getStartTime();
    String startTimeAsString = null;

    if (startTime != null) {
        startTimeAsString = " '" + (new Timestamp(startTime.toGregorianCalendar().getTimeInMillis())) + "'";
    }

    if (action == DAO_ACTION_INSERT) {
        stmtFragment = "INSERT INTO Subscription " + super.getSQLStatementFragment(ro) + ", '" + selector
                + "', " + endTimeAsString + ", " + notificationIntervalString + ", " + startTimeAsString
                + " ) ";
    } else if (action == DAO_ACTION_UPDATE) {
        stmtFragment = "UPDATE Subscription SET " + super.getSQLStatementFragment(ro) + ", selector='"
                + selector + "', endTime=" + endTimeAsString + ", notificationInterval="
                + notificationIntervalString + ", startTime=" + startTimeAsString + " WHERE id = '"
                + ((RegistryObjectType) ro).getId() + "' ";
    } else if (action == DAO_ACTION_DELETE) {
        stmtFragment = super.getSQLStatementFragment(ro);
    }

    return stmtFragment;
}

From source file:org.miloss.fgsms.services.rs.impl.reports.ws.MeanTimeBetweenFailureByService.java

/**
 * {@inheritDoc}//w ww .  j  ava  2s  .co  m
 */
@Override
public void generateReport(OutputStreamWriter data, List<String> urls, String path, List<String> files,
        TimeRange range, String currentuser, SecurityWrapper classification, WebServiceContext ctx)
        throws IOException {

    DefaultCategoryDataset set = new DefaultCategoryDataset();
    JFreeChart chart = null;
    data.append("<hr /><h2>").append(GetDisplayName()).append("</h2>");
    data.append(GetHtmlFormattedHelp() + "<br />");
    data.append(
            "<table class=\"table table-hover\"><tr><th>URL</th><th>MTBF (ms)</th><th>Timespan</th><th>XML Duration Value</th></tr>");

    for (int i = 0; i < urls.size(); i++) {
        if (!isPolicyTypeOf(urls.get(i), PolicyType.TRANSACTIONAL)) {
            continue;
        }
        //https://github.com/mil-oss/fgsms/issues/112
        if (!UserIdentityUtil.hasReadAccess(currentuser, "getReport", urls.get(i), classification, ctx)) {
            continue;
        }
        String url = Utility.encodeHTML(BaseReportGenerator.getPolicyDisplayName(urls.get(i)));
        try {
            long mtbf = meanTimeBetweenFailures(urls.get(i), range);
            Duration newDuration = df.newDuration(mtbf);
            data.append("<tr><td>").append(url).append("</td><td>");
            if (mtbf == -1 || mtbf == 0) {
                data.append("Never</td><td>0</td><td>0</d></tr>");
            } else {
                data.append(mtbf + "").append("ms</td><td>").append(Utility.durationToString(newDuration))
                        .append("</td><td>").append(newDuration.toString()).append("</td></tr>");
            }
            if (mtbf > 0) {
                set.addValue(mtbf, url, url);
            }

        } catch (Exception ex) {
            data.append("0 bytes</td></tr>");
            log.log(Level.ERROR, "Error opening or querying the database.", ex);
        }
    }
    chart = org.jfree.chart.ChartFactory.createBarChart(GetDisplayName(), "Service URL", "", set,
            PlotOrientation.HORIZONTAL, true, false, false);
    data.append("</table>");
    try {
        if (set.getRowCount() != 0) {
            ChartUtilities.saveChartAsPNG(new File(
                    path + getFilePathDelimitor() + "image_" + this.getClass().getSimpleName() + ".png"), chart,
                    1500, pixelHeightCalc(set.getRowCount()));
            data.append("<img src=\"image_").append(this.getClass().getSimpleName()).append(".png\">");
            files.add(path + getFilePathDelimitor() + "image_" + this.getClass().getSimpleName() + ".png");
        }
    } catch (IOException ex) {
        log.log(Level.ERROR, "Error saving chart image for request", ex);
    }

}

From source file:com.xqdev.jam.MLJAM.java

private static void sendXQueryResponse(HttpServletResponse res, Object o) throws IOException {
    // Make sure to leave the status code alone.  It defaults to 200, but sometimes
    // callers of this method will have set it to a custom code.
    res.setContentType("x-marklogic/xquery; charset=UTF-8");
    //res.setContentType("text/plain");
    Writer writer = res.getWriter(); // care to handle errors later?

    if (o == null) {
        writer.write("()");
    }/*from   ww w.  j  av a 2s  .c om*/

    else if (o instanceof byte[]) {
        writer.write("binary {'");
        writer.write(hexEncode((byte[]) o));
        writer.write("'}");
    }

    else if (o instanceof Object[]) {
        Object[] arr = (Object[]) o;
        writer.write("(");
        for (int i = 0; i < arr.length; i++) {
            sendXQueryResponse(res, arr[i]);
            if (i + 1 < arr.length)
                writer.write(", ");
        }
        writer.write(")");
    }

    else if (o instanceof String) {
        writer.write("'");
        writer.write(escapeSingleQuotes(o.toString()));
        writer.write("'");
    } else if (o instanceof Integer) {
        writer.write("xs:int(");
        writer.write(o.toString());
        writer.write(")");
    } else if (o instanceof Long) {
        writer.write("xs:integer(");
        writer.write(o.toString());
        writer.write(")");
    } else if (o instanceof Float) {
        Float flt = (Float) o;
        writer.write("xs:float(");
        if (flt.equals(Float.POSITIVE_INFINITY)) {
            writer.write("'INF'");
        } else if (flt.equals(Float.NEGATIVE_INFINITY)) {
            writer.write("'-INF'");
        } else if (flt.equals(Float.NaN)) {
            writer.write("fn:number(())"); // poor man's way to write NaN
        } else {
            writer.write(o.toString());
        }
        writer.write(")");
    } else if (o instanceof Double) {
        Double dbl = (Double) o;
        writer.write("xs:double(");
        if (dbl.equals(Double.POSITIVE_INFINITY)) {
            writer.write("'INF'");
        } else if (dbl.equals(Double.NEGATIVE_INFINITY)) {
            writer.write("'-INF'");
        } else if (dbl.equals(Double.NaN)) {
            writer.write("fn:number(())"); // poor man's way to write NaN
        } else {
            writer.write(o.toString());
        }
        writer.write(")");
    } else if (o instanceof Boolean) {
        writer.write("xs:boolean('");
        writer.write(o.toString());
        writer.write("')");
    } else if (o instanceof BigDecimal) {
        writer.write("xs:decimal(");
        writer.write(o.toString());
        writer.write(")");
    } else if (o instanceof Date) {
        // We want something like: 2006-04-30T01:28:30.499-07:00
        // We format to get:       2006-04-30T01:28:30.499-0700
        // Then we add in the colon
        writer.write("xs:dateTime('");
        String d = dateFormat.format((Date) o);
        writer.write(d.substring(0, d.length() - 2));
        writer.write(":");
        writer.write(d.substring(d.length() - 2));
        writer.write("')");
    } else if (o instanceof XMLGregorianCalendar) {
        XMLGregorianCalendar greg = (XMLGregorianCalendar) o;
        QName type = greg.getXMLSchemaType();
        if (type.equals(DatatypeConstants.DATETIME)) {
            writer.write("xs:dateTime('");
        } else if (type.equals(DatatypeConstants.DATE)) {
            writer.write("xs:date('");
        } else if (type.equals(DatatypeConstants.TIME)) {
            writer.write("xs:time('");
        } else if (type.equals(DatatypeConstants.GYEARMONTH)) {
            writer.write("xs:gYearMonth('");
        } else if (type.equals(DatatypeConstants.GMONTHDAY)) {
            writer.write("xs:gMonthDay('");
        } else if (type.equals(DatatypeConstants.GYEAR)) {
            writer.write("xs:gYear('");
        } else if (type.equals(DatatypeConstants.GMONTH)) {
            writer.write("xs:gMonth('");
        } else if (type.equals(DatatypeConstants.GDAY)) {
            writer.write("xs:gDay('");
        }
        writer.write(greg.toXMLFormat());
        writer.write("')");
    } else if (o instanceof Duration) {
        Duration dur = (Duration) o;
        /*
        // The following fails on Xerces
        QName type = dur.getXMLSchemaType();
        if (type.equals(DatatypeConstants.DURATION)) {
          writer.write("xs:duration('");
        }
        else if (type.equals(DatatypeConstants.DURATION_DAYTIME)) {
          writer.write("xdt:dayTimeDuration('");
        }
        else if (type.equals(DatatypeConstants.DURATION_YEARMONTH)) {
          writer.write("xdt:yearMonthDuration('");
        }
        */
        // If no years or months, must be DURATION_DAYTIME
        if (dur.getYears() == 0 && dur.getMonths() == 0) {
            writer.write("xdt:dayTimeDuration('");
        }
        // If has years or months but nothing else, must be DURATION_YEARMONTH
        else if (dur.getDays() == 0 && dur.getHours() == 0 && dur.getMinutes() == 0 && dur.getSeconds() == 0) {
            writer.write("xdt:yearMonthDuration('");
        } else {
            writer.write("xs:duration('");
        }
        writer.write(dur.toString());
        writer.write("')");
    }

    else if (o instanceof org.jdom.Element) {
        org.jdom.Element elt = (org.jdom.Element) o;
        writer.write("xdmp:unquote('");
        // Because "&lt;" in XQuery is the same as "<" I need to double escape any ampersands
        writer.write(new org.jdom.output.XMLOutputter().outputString(elt).replaceAll("&", "&amp;")
                .replaceAll("'", "''"));
        writer.write("')/*"); // make sure to return the root elt
    } else if (o instanceof org.jdom.Document) {
        org.jdom.Document doc = (org.jdom.Document) o;
        writer.write("xdmp:unquote('");
        writer.write(new org.jdom.output.XMLOutputter().outputString(doc).replaceAll("&", "&amp;")
                .replaceAll("'", "''"));
        writer.write("')");
    } else if (o instanceof org.jdom.Text) {
        org.jdom.Text text = (org.jdom.Text) o;
        writer.write("text {'");
        writer.write(escapeSingleQuotes(text.getText()));
        writer.write("'}");
    } else if (o instanceof org.jdom.Attribute) {
        // <fake xmlns:pref="http://uri.com" pref:attrname="attrvalue"/>/@*:attrname
        // <fake xmlns="http://uri.com" attrname="attrvalue"/>/@*:attrname
        org.jdom.Attribute attr = (org.jdom.Attribute) o;
        writer.write("<fake xmlns");
        if ("".equals(attr.getNamespacePrefix())) {
            writer.write("=\"");
        } else {
            writer.write(":" + attr.getNamespacePrefix() + "=\"");
        }
        writer.write(attr.getNamespaceURI());
        writer.write("\" ");
        writer.write(attr.getQualifiedName());
        writer.write("=\"");
        writer.write(escapeSingleQuotes(attr.getValue()));
        writer.write("\"/>/@*:");
        writer.write(attr.getName());
    } else if (o instanceof org.jdom.Comment) {
        org.jdom.Comment com = (org.jdom.Comment) o;
        writer.write("comment {'");
        writer.write(escapeSingleQuotes(com.getText()));
        writer.write("'}");
    } else if (o instanceof org.jdom.ProcessingInstruction) {
        org.jdom.ProcessingInstruction pi = (org.jdom.ProcessingInstruction) o;
        writer.write("processing-instruction ");
        writer.write(pi.getTarget());
        writer.write(" {'");
        writer.write(escapeSingleQuotes(pi.getData()));
        writer.write("'}");
    }

    else if (o instanceof QName) {
        QName q = (QName) o;
        writer.write("fn:expanded-QName('");
        writer.write(escapeSingleQuotes(q.getNamespaceURI()));
        writer.write("','");
        writer.write(q.getLocalPart());
        writer.write("')");
    }

    else {
        writer.write("error('XQuery tried to retrieve unsupported type: " + o.getClass().getName() + "')");
    }

    writer.flush();
}

From source file:fr.efl.chaine.xslt.GauloisPipe.java

/**
 * Launch the pipe.//from   ww w.  j a  v a 2 s  . c  o  m
 *
 * @throws fr.efl.chaine.xslt.InvalidSyntaxException If config's syntax is incorrect
 * @throws java.io.FileNotFoundException If a file is not found...
 * @throws net.sf.saxon.s9api.SaxonApiException If a SaxonApi problem occurs
 * @throws java.net.URISyntaxException Because MVN forces to have comments...
 */
@SuppressWarnings("ThrowFromFinallyBlock")
public void launch() throws InvalidSyntaxException, FileNotFoundException, SaxonApiException,
        URISyntaxException, IOException {
    initDebugDirectory();
    Runtime.getRuntime().addShutdownHook(new Thread(new ErrorCollector(errors)));
    long start = System.currentTimeMillis();
    errors = Collections.synchronizedList(new ArrayList<Exception>());
    documentCache = new DocumentCache(config.getMaxDocumentCacheSize());
    if (this.messageListenerclass != null) {
        try {
            this.messageListener = this.messageListenerclass.newInstance();
        } catch (InstantiationException | IllegalAccessException ex) {
            System.err.println("[WARN] Fail to instanciate " + this.messageListenerclass.getName());
            ex.printStackTrace(System.err);
        }
    }
    boolean retCode = true;
    try {
        Configuration saxonConfig = configurationFactory.getConfiguration();
        LOGGER.debug("configuration is a " + saxonConfig.getClass().getName());
        // this is now done in constructor
        // saxonConfig.setURIResolver(buildUriResolver(saxonConfig.getURIResolver()));
        processor = new Processor(saxonConfig);
        xsltCompiler = processor.newXsltCompiler();
        builder = processor.newDocumentBuilder();

        List<CfgFile> sourceFiles = config.getSources().getFiles();
        LOGGER.info("[" + instanceName + "] works on {} files", sourceFiles.size());

        if (config.getPipe().getTraceOutput() != null) {
            traceListener = buildTraceListener(config.getPipe().getTraceOutput());
        }

        if (config.getPipe().getNbThreads() > 1) {
            if (config.hasFilesOverMultiThreadLimit()) {
                List<ParametrableFile> files = new ArrayList<>(sourceFiles.size());
                for (CfgFile f : config.getSources()
                        .getFilesOverLimit(config.getPipe().getMultithreadMaxSourceSize())) {
                    files.add(resolveInputFile(f));
                }
                if (!files.isEmpty()) {
                    LOGGER.info("[" + instanceName + "] Running mono-thread for {} huge files", files.size());
                    retCode = executesPipeOnMultiThread(config.getPipe(), files, 1,
                            config.getSources().getListener());
                }
            }
            List<ParametrableFile> files = new ArrayList<>(sourceFiles.size());
            for (CfgFile f : config.getSources()
                    .getFilesUnderLimit(config.getPipe().getMultithreadMaxSourceSize())) {
                files.add(resolveInputFile(f));
            }
            if (!files.isEmpty() || config.getSources().getListener() != null) {
                LOGGER.info("[" + instanceName + "] Running multi-thread for {} regular-size files",
                        files.size());
                retCode = executesPipeOnMultiThread(config.getPipe(), files, config.getPipe().getNbThreads(),
                        config.getSources().getListener());
            }
        } else {
            List<ParametrableFile> files = new ArrayList<>(sourceFiles.size());
            for (CfgFile f : sourceFiles) {
                files.add(resolveInputFile(f));
            }
            LOGGER.info("[" + instanceName + "] Running mono-thread on all {} files", files.size());
            retCode = executesPipeOnMultiThread(config.getPipe(), files, 1, config.getSources().getListener());
        }

    } catch (Throwable e) {
        LOGGER.warn("[" + instanceName + "] " + e.getMessage(), e);
        // on sort avec des codes d'erreur non-zero
        throw e;
    } finally {
        if (!retCode) {
            throw new SaxonApiException("An error occurs. See previous logs.");
        }
    }
    try {
        if (config.getSources().getListener() == null) {
            long duration = System.currentTimeMillis() - start;
            Duration duree = DatatypeFactory.newInstance().newDuration(duration);
            LOGGER.info("[" + instanceName + "] Process terminated: " + duree.toString());
        }
    } catch (Exception ex) {
        LOGGER.info("[" + instanceName + "] Process terminated.");
    }
}