org.apache.camel.spi.TypeConverterRegistry Java Examples
The following examples show how to use
org.apache.camel.spi.TypeConverterRegistry.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CustomTypeConverterLoader.java From camel-quarkus with Apache License 2.0 | 5 votes |
@Override public void load(TypeConverterRegistry registry) throws TypeConverterLoaderException { registry.addTypeConverter( MyPair.class, String.class, new SimpleTypeConverter(false, (type, exchange, value) -> MyPair.fromString((String) value))); }
Example #2
Source File: CamelContextRecorder.java From camel-quarkus with Apache License 2.0 | 5 votes |
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); }
Example #3
Source File: CamelRecorder.java From camel-quarkus with Apache License 2.0 | 5 votes |
public void addTypeConverterLoader(RuntimeValue<TypeConverterRegistry> registry, Class<? extends TypeConverterLoader> loader) { try { loader.getConstructor().newInstance().load(registry.getValue()); } catch (Exception e) { throw new RuntimeException(e); } }
Example #4
Source File: StaticDummyFallbackConverter.java From camel-spring-boot with Apache License 2.0 | 5 votes |
@FallbackConverter public static Object convertTo(Class<?> type, Exchange exchange, Object value, TypeConverterRegistry registry) { if (TimeZone.class.isAssignableFrom(value.getClass())) { return "Time talks"; } return null; }
Example #5
Source File: CamelTypeConverterRegistryBuildItem.java From camel-quarkus with Apache License 2.0 | 4 votes |
public CamelTypeConverterRegistryBuildItem(RuntimeValue<TypeConverterRegistry> value) { this.value = value; }
Example #6
Source File: CamelTypeConverterRegistryBuildItem.java From camel-quarkus with Apache License 2.0 | 4 votes |
public RuntimeValue<TypeConverterRegistry> getRegistry() { return value; }
Example #7
Source File: CamelRecorder.java From camel-quarkus with Apache License 2.0 | 4 votes |
public RuntimeValue<TypeConverterRegistry> createTypeConverterRegistry() { return new RuntimeValue<>(new FastTypeConverter()); }
Example #8
Source File: CamelRecorder.java From camel-quarkus with Apache License 2.0 | 4 votes |
public void addTypeConverterLoader(RuntimeValue<TypeConverterRegistry> registry, RuntimeValue<TypeConverterLoader> loader) { loader.getValue().load(registry.getValue()); }
Example #9
Source File: CloudEventTypeConverterLoader.java From camel-k-runtime with Apache License 2.0 | 4 votes |
@Override public void load(TypeConverterRegistry registry) throws TypeConverterLoaderException { registerConverters(registry); }
Example #10
Source File: CloudEventTypeConverterLoader.java From camel-k-runtime with Apache License 2.0 | 4 votes |
private void registerConverters(TypeConverterRegistry registry) { addTypeConverter(registry, org.apache.camel.component.knative.spi.CloudEvent.class, java.lang.String.class, false, (type, exchange, value) -> org.apache.camel.component.knative.spi.CloudEventTypeConverter.fromSpecVersion((java.lang.String) value)); }
Example #11
Source File: CloudEventTypeConverterLoader.java From camel-k-runtime with Apache License 2.0 | 4 votes |
private static void addTypeConverter(TypeConverterRegistry registry, Class<?> toType, Class<?> fromType, boolean allowNull, SimpleTypeConverter.ConversionMethod method) { registry.addTypeConverter(toType, fromType, new SimpleTypeConverter(allowNull, method)); }
Example #12
Source File: TypeConverterRegistryTest.java From wildfly-camel with Apache License 2.0 | 4 votes |
@Test public void testRegistryContent() throws Exception { CamelContext camelctx = new DefaultCamelContext(); TypeConverterRegistry registry = camelctx.getTypeConverterRegistry(); Assert.assertTrue("More than 180 type converters", 180 <= registry.size()); }