Java源码示例:org.apache.camel.spi.ModelToXMLDumper
示例1
@Test
public void testJaxbDumpModelAsXML() throws Exception {
ModelCamelContext camelctx = new DefaultCamelContext();
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start")
.routeId("route-1")
.to("log:test");
}
});
camelctx.start();
try {
ModelToXMLDumper dumper = camelctx.adapt(ExtendedCamelContext.class).getModelToXMLDumper();
String xml = dumper.dumpModelAsXml(camelctx, camelctx.getRouteDefinition("route-1"));
Assert.assertTrue(xml.contains("log:test"));
} finally {
camelctx.close();
}
}
示例2
public RuntimeValue<CamelContext> createContext(
RuntimeValue<Registry> registry,
RuntimeValue<TypeConverterRegistry> typeConverterRegistry,
RuntimeValue<ModelJAXBContextFactory> contextFactory,
RuntimeValue<XMLRoutesDefinitionLoader> xmlLoader,
RuntimeValue<ModelToXMLDumper> xmlModelDumper,
RuntimeValue<FactoryFinderResolver> factoryFinderResolver,
BeanContainer beanContainer,
String version,
CamelConfig config) {
FastCamelContext context = new FastCamelContext(
factoryFinderResolver.getValue(),
version,
xmlLoader.getValue(),
xmlModelDumper.getValue());
context.setDefaultExtension(RuntimeCamelCatalog.class, () -> new CamelRuntimeCatalog(config.runtimeCatalog));
context.setRegistry(registry.getValue());
context.setTypeConverterRegistry(typeConverterRegistry.getValue());
context.setLoadTypeConverters(false);
context.setModelJAXBContextFactory(contextFactory.getValue());
context.build();
context.addLifecycleStrategy(new CamelLifecycleEventBridge());
context.getManagementStrategy().addEventNotifier(new CamelManagementEventBridge());
// register to the container
beanContainer.instance(CamelProducers.class).setContext(context);
return new RuntimeValue<>(context);
}
示例3
protected void dumpRoutes(CamelContext context, RoutesDefinition definition) {
if (!LOGGER.isInfoEnabled()) {
return;
}
try {
ExtendedCamelContext extendedCamelContext = context.adapt(ExtendedCamelContext.class);
ModelToXMLDumper dumper = extendedCamelContext.getModelToXMLDumper();
LOGGER.info("Routes: \n{}", dumper.dumpModelAsXml(context, definition));
} catch (Exception e) {
LOGGER.warn("Unable to dump routes as XML", e);
}
}
示例4
public static void dumpRoutes(CamelContext context, RoutesDefinition definition) {
if (!LOGGER.isInfoEnabled()) {
return;
}
try {
ExtendedCamelContext extendedCamelContext = context.adapt(ExtendedCamelContext.class);
ModelToXMLDumper dumper = extendedCamelContext.getModelToXMLDumper();
LOGGER.info("Routes: \n{}", dumper.dumpModelAsXml(context, definition));
} catch (Exception e) {
LOGGER.warn("Unable to dump route definition as XML");
LOGGER.debug("Error encountered while dumping route definition as XML", e);
}
}
示例5
public RuntimeValue<ModelToXMLDumper> newJaxbModelToXMLDumper() {
return new RuntimeValue<>(new JaxbModelToXMLDumper());
}
示例6
public CamelModelToXMLDumperBuildItem(RuntimeValue<ModelToXMLDumper> value) {
this.value = value;
}
示例7
public RuntimeValue<ModelToXMLDumper> getValue() {
return value;
}
示例8
public RuntimeValue<ModelToXMLDumper> newDisabledModelToXMLDumper() {
return new RuntimeValue<>(new DisabledModelToXMLDumper());
}