org.citrusframework.jmx.model.JmxMarshaller Maven / Gradle / Ivy
/*
* Copyright the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.citrusframework.jmx.model;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import jakarta.xml.bind.JAXBException;
import org.citrusframework.exceptions.CitrusRuntimeException;
import org.citrusframework.spi.Resources;
import org.citrusframework.xml.Jaxb2Marshaller;
import org.citrusframework.xml.Marshaller;
import org.citrusframework.xml.Unmarshaller;
/**
* @since 2.5
*/
public class JmxMarshaller implements Marshaller, Unmarshaller {
private final Jaxb2Marshaller marshaller;
public JmxMarshaller() {
this.marshaller = new Jaxb2Marshaller(
Resources.fromClasspath("org/citrusframework/schema/citrus-jmx-message.xsd"), ManagedBeanInvocation.class, ManagedBeanResult.class);
}
public void marshal(Object graph, Result result) {
try {
marshaller.marshal(graph, result);
} catch (JAXBException e) {
throw new CitrusRuntimeException("Failed to marshal object graph", e);
}
}
public Object unmarshal(Source source) {
try {
return marshaller.unmarshal(source);
} catch (JAXBException e) {
throw new CitrusRuntimeException("Failed to unmarshal source", e);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy