Package org.jvnet.hk2.config

Examples of org.jvnet.hk2.config.IndentingXMLStreamWriter


            // write to the temporary file
            XMLStreamWriter writer = null;
            OutputStream fos = getOutputStream(f);
            try {
                writer = xmlFactory.createXMLStreamWriter(new BufferedOutputStream(fos));
                IndentingXMLStreamWriter indentingXMLStreamWriter = new IndentingXMLStreamWriter(writer);
                doc.writeTo(indentingXMLStreamWriter);
                indentingXMLStreamWriter.close();
            }
            catch (XMLStreamException e) {
                String msg = localStrings.getLocalString("TmpFileNotSaved",
                                "Configuration could not be saved to temporary file");
                logger.log(Level.SEVERE, msg, e);
View Full Code Here


    public String serializeConfigBean(ConfigBeanProxy configBean) {
        if (configBean == null) return null;
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        XMLOutputFactory xmlFactory = XMLOutputFactory.newInstance();
        XMLStreamWriter writer = null;
        IndentingXMLStreamWriter indentingXMLStreamWriter = null;
        String s = null;
        try {
            writer = xmlFactory.createXMLStreamWriter(new BufferedOutputStream(bos));
            indentingXMLStreamWriter = new IndentingXMLStreamWriter(writer);
            Dom configBeanDom = Dom.unwrap(configBean);
            configBeanDom.writeToXml();
            configBeanDom.writeTo(configBeanDom.model.getTagName(), indentingXMLStreamWriter);
            indentingXMLStreamWriter.flush();
            s = bos.toString();
        } catch (XMLStreamException e) {
            return s;
        } finally {
            try {
                if (bos != null)
                    bos.close();
                if (writer != null)
                    writer.close();
                if (indentingXMLStreamWriter != null)
                    indentingXMLStreamWriter.close();
            } catch (IOException e) {
                e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
            } catch (XMLStreamException e) {
                e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
            }
View Full Code Here

            // write to the temporary file
            XMLStreamWriter writer = null;
            OutputStream fos = getOutputStream(f);
            try {
                writer = xmlFactory.createXMLStreamWriter(new BufferedOutputStream(fos));
                IndentingXMLStreamWriter indentingXMLStreamWriter = new IndentingXMLStreamWriter(writer);
                doc.writeTo(indentingXMLStreamWriter);
                indentingXMLStreamWriter.close();
            }
            catch (XMLStreamException e) {
                String msg = localStrings.getLocalString("TmpFileNotSaved",
                                "Configuration could not be saved to temporary file");
                logger.log(Level.SEVERE, msg, e);
View Full Code Here

            // write to the temporary file
            XMLStreamWriter writer = null;
            OutputStream fos = getOutputStream(f);
            try {
                writer = xmlFactory.createXMLStreamWriter(new BufferedOutputStream(fos));
                IndentingXMLStreamWriter indentingXMLStreamWriter = new IndentingXMLStreamWriter(writer);
                doc.writeTo(indentingXMLStreamWriter);
                indentingXMLStreamWriter.close();
            }
            catch (XMLStreamException e) {
                String msg = localStrings.getLocalString("TmpFileNotSaved",
                                "Configuration could not be saved to temporary file");
                logger.log(Level.SEVERE, msg, e);
View Full Code Here

    }
   
    protected static XMLStreamWriter getXmlWriter(final OutputStream os, boolean indent) throws XMLStreamException {
        XMLStreamWriter wr = XML_FACTORY.createXMLStreamWriter(os, Constants.ENCODING);
        if (indent) {
            wr = new IndentingXMLStreamWriter(wr);
        }
        return wr;
    }
View Full Code Here

        if (configBean == null) return null;
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        XMLOutputFactory xmlFactory = XMLOutputFactory.newInstance();
        try {
            XMLStreamWriter writer = xmlFactory.createXMLStreamWriter(new BufferedOutputStream(bos));
            IndentingXMLStreamWriter indentingXMLStreamWriter = new IndentingXMLStreamWriter(writer);
            Dom configBeanDom = Dom.unwrap(configBean);
            configBeanDom.writeTo(configBeanDom.model.getTagName(), indentingXMLStreamWriter);
            indentingXMLStreamWriter.close();
        } catch (XMLStreamException e) {
            return null;
        }
        return bos.toString();
    }
View Full Code Here

    public String serializeConfigBean(ConfigBeanProxy configBean) {
        if (configBean == null) return null;
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        XMLOutputFactory xmlFactory = XMLOutputFactory.newInstance();
        XMLStreamWriter writer = null;
        IndentingXMLStreamWriter indentingXMLStreamWriter = null;
        String s = null;
        try {
            writer = xmlFactory.createXMLStreamWriter(new BufferedOutputStream(bos));
            indentingXMLStreamWriter = new IndentingXMLStreamWriter(writer);
            Dom configBeanDom = Dom.unwrap(configBean);
            configBeanDom.writeToXml();
            configBeanDom.writeTo(configBeanDom.model.getTagName(), indentingXMLStreamWriter);
            indentingXMLStreamWriter.flush();
            s = bos.toString();
        } catch (XMLStreamException e) {
            LOG.log(Level.FINE, "Cannot serialize the configbean: " + configBean.toString(), e);
            return null;
        } finally {
            try {
                if (bos != null)
                    bos.close();
                if (writer != null)
                    writer.close();
                if (indentingXMLStreamWriter != null)
                    indentingXMLStreamWriter.close();
            } catch (IOException e) {
                LOG.log(Level.FINE, "Cannot serialize the configbean: " + configBean.toString(), e);
            } catch (XMLStreamException e) {
                LOG.log(Level.FINE, "Cannot serialize the configbean: " + configBean.toString(), e);
            }
View Full Code Here

                    }
                    for (final Map.Entry<Object, Object> entry : props.entrySet()) {
                        ConfigBeanProxy child = (ConfigBeanProxy) component;
                        try {
                            ConfigBeanProxy cc = child.createChild(itemType);
                            new InjectionManager().inject(cc, itemType, new InjectionResolver<Attribute>(Attribute.class) {

                                @Override
                                public boolean isOptional(AnnotatedElement annotated, Attribute annotation) {
                                    return true;   
                                }
View Full Code Here

                try {
                    boolean wasAdded = ports.add(Integer.parseInt(val));

                    if (!wasAdded) //TODO unit test
                        throw new TransactionFailure(Strings.get("PortUtils.duplicate_port", val, server.getName()));
                }
                catch(TransactionFailure tf) {
                    // don't re-wrap the same Exception type!
                    throw tf;
                }
                catch (Exception e) {  //TODO unit test
                    throw new TransactionFailure(Strings.get("PortUtils.non_int_port", val, server.getName()));
                }
            }
        }
        checkForLegalPorts(ports, server.getName());
    }
View Full Code Here

     * @return a message if error, nu8ll means A-OK
     */
    private static void checkForLegalPorts(Set<Integer> ports, String serverName) throws TransactionFailure {
        for (int port : ports)
            if (!NetUtils.isPortValid(port))
                throw new TransactionFailure(Strings.get("PortUtils.illegal_port_number", port, serverName, MAX_PORT));
    }
View Full Code Here

TOP

Related Classes of org.jvnet.hk2.config.IndentingXMLStreamWriter

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.