/*
 * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */
package org.opendaylight.controller.netconf.monitoring.xml;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.transform.dom.DOMResult;
import org.opendaylight.controller.netconf.monitoring.xml.model.NetconfState;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

public class JaxBSerializer {

    public Element toXml(final NetconfState monitoringModel) {
        final DOMResult res;
        try {
            final JAXBContext jaxbContext = JAXBContext.newInstance(NetconfState.class);
            final Marshaller marshaller = jaxbContext.createMarshaller();

            marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);

            res = new DOMResult();
            marshaller.marshal(monitoringModel, res);
        } catch (final JAXBException e) {
            throw new RuntimeException("Unable to serialize netconf state " + monitoringModel, e);
        }
        return ((Document)res.getNode()).getDocumentElement();
    }
}

@@ -680,14 +680,271 @@
 r %7B%0A
-%0A
     p
+rivate static final JAXBContext JAXB_CONTEXT;%0A%0A    static %7B%0A        try %7B%0A            JAXB_CONTEXT = JAXBContext.newInstance(NetconfState.class);%0A        %7D catch (JAXBException e) %7B%0A            throw new ExceptionInInitializerError(e);%0A        %7D%0A    %7D%0A%0A    p
 ubli
@@ -1043,97 +1043,8 @@
 ry %7B
-%0A            final JAXBContext jaxbContext = JAXBContext.newInstance(NetconfState.class);
 %0A   
@@ -1086,19 +1086,20 @@
 r = 
-jaxbContext
+JAXB_CONTEXT
 .cre

Fix netconf-monitoring not reusing JAXB context