public synchronized void execute()

in partial-jnlp-ant-task/src/main/java/org/apache/easyant/tasks/JNLPTask.java [96:152]


    public synchronized void execute() throws BuildException {
        validate();
        log("JNLP modification...");
        try {
            DOMImplementationRegistry domRegistry = DOMImplementationRegistry
                    .newInstance();
            DOMImplementationLS domImpl = (DOMImplementationLS) domRegistry
                    .getDOMImplementation(DOM_IMPLEMENTATION);

            LSParser jnlpBuilder = domImpl.createLSParser(
                    DOMImplementationLS.MODE_SYNCHRONOUS, null);
            Document jnlpDoc = jnlpBuilder.parseURI(jnlpFile);

            Node root = null;
            for (int i = 0; i < jnlpDoc.getChildNodes().getLength(); i++) {
                if (jnlpDoc.getChildNodes().item(i).getNodeType() == Node.ELEMENT_NODE) {
                    root = jnlpDoc.getChildNodes().item(i);
                    break;
                }
            }
            NodeList nodeList = root.getChildNodes();

            if (nodeList.getLength() > 0) {
                for (int i = 0; i < nodeList.getLength(); i++) {
                    if (RESOURCES_ENTITY.equals(nodeList.item(i).getNodeName())) {
                        root.removeChild(nodeList.item(i));
                    }
                }
            }
            Element resourcesElement = jnlpDoc.createElement(RESOURCES_ENTITY);
            root.appendChild(resourcesElement);

            appendAllResources(jnlpDoc, resourcesElement);
            LSOutput lsOutput = domImpl.createLSOutput();
            lsOutput.setByteStream(new FileOutputStream(new File(tmpFile)));
            LSSerializer serializer = domImpl.createLSSerializer();
            serializer.getDomConfig().setParameter(PRETTY_PRINT_FORMAT, true);
            serializer.write(jnlpDoc, lsOutput);
            replaceFile(new File(tmpFile), new File(jnlpFile));
            log("JNLP modification done !");
        } catch (IOException e) {
            throw new BuildException(e.getMessage());
        } catch (ClassCastException e) {
            throw new BuildException(e.getMessage());
        } catch (ClassNotFoundException e) {
            throw new BuildException(e.getMessage());
        } catch (InstantiationException e) {
            throw new BuildException(e.getMessage());
        } catch (IllegalAccessException e) {
            throw new BuildException(e.getMessage());
        } catch (DOMException e) {
            throw new BuildException(e.getMessage());
        } catch (Exception e) {
            throw new BuildException(e.getMessage());
        }

    }