Search in sources :

Example 1 with FactoryRegistry

use of org.apache.camel.dataformat.bindy.format.factories.FactoryRegistry in project camel by apache.

the class BindyAbstractDataFormat method tryToGetFactoryRegistry.

private FactoryRegistry tryToGetFactoryRegistry() {
    Function<CamelContext, Registry> f = CamelContext::getRegistry;
    Function<Registry, Set<FactoryRegistry>> g = r -> r.findByType(FactoryRegistry.class);
    Function<Set<FactoryRegistry>, FactoryRegistry> h = factoryRegistries -> {
        if (factoryRegistries.size() > 1) {
            LOGGER.warn("Number of registered {}: {}", FactoryRegistry.class.getCanonicalName(), factoryRegistries.size());
        }
        if (factoryRegistries.iterator().hasNext()) {
            return factoryRegistries.iterator().next();
        } else {
            return new DefaultFactoryRegistry();
        }
    };
    return Optional.ofNullable(camelContext).map(f).map(g).map(h).orElse(new DefaultFactoryRegistry());
}
Also used : CamelContext(org.apache.camel.CamelContext) CamelContext(org.apache.camel.CamelContext) CamelContextAware(org.apache.camel.CamelContextAware) Arrays(java.util.Arrays) Logger(org.slf4j.Logger) Registry(org.apache.camel.spi.Registry) DefaultFactoryRegistry(org.apache.camel.dataformat.bindy.format.factories.DefaultFactoryRegistry) LoggerFactory(org.slf4j.LoggerFactory) Set(java.util.Set) HashMap(java.util.HashMap) Field(java.lang.reflect.Field) Function(java.util.function.Function) ArrayList(java.util.ArrayList) FactoryRegistry(org.apache.camel.dataformat.bindy.format.factories.FactoryRegistry) DataFormatName(org.apache.camel.spi.DataFormatName) Link(org.apache.camel.dataformat.bindy.annotation.Link) DataFormat(org.apache.camel.spi.DataFormat) List(java.util.List) Map(java.util.Map) Optional(java.util.Optional) ServiceSupport(org.apache.camel.support.ServiceSupport) FormatFactoryInterface(org.apache.camel.dataformat.bindy.format.factories.FormatFactoryInterface) FormatFactories(org.apache.camel.dataformat.bindy.annotation.FormatFactories) Collections(java.util.Collections) DefaultFactoryRegistry(org.apache.camel.dataformat.bindy.format.factories.DefaultFactoryRegistry) Set(java.util.Set) DefaultFactoryRegistry(org.apache.camel.dataformat.bindy.format.factories.DefaultFactoryRegistry) FactoryRegistry(org.apache.camel.dataformat.bindy.format.factories.FactoryRegistry) Registry(org.apache.camel.spi.Registry) DefaultFactoryRegistry(org.apache.camel.dataformat.bindy.format.factories.DefaultFactoryRegistry) FactoryRegistry(org.apache.camel.dataformat.bindy.format.factories.FactoryRegistry)

Example 2 with FactoryRegistry

use of org.apache.camel.dataformat.bindy.format.factories.FactoryRegistry in project camel by apache.

the class BindyAbstractDataFormat method createFormatFactory.

private FormatFactory createFormatFactory() {
    FormatFactory formatFactory = new FormatFactory();
    FactoryRegistry factoryRegistry = createFactoryRegistry();
    formatFactory.setFactoryRegistry(factoryRegistry);
    return formatFactory;
}
Also used : DefaultFactoryRegistry(org.apache.camel.dataformat.bindy.format.factories.DefaultFactoryRegistry) FactoryRegistry(org.apache.camel.dataformat.bindy.format.factories.FactoryRegistry)

Aggregations

DefaultFactoryRegistry (org.apache.camel.dataformat.bindy.format.factories.DefaultFactoryRegistry)2 FactoryRegistry (org.apache.camel.dataformat.bindy.format.factories.FactoryRegistry)2 Field (java.lang.reflect.Field)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Function (java.util.function.Function)1 CamelContext (org.apache.camel.CamelContext)1 CamelContextAware (org.apache.camel.CamelContextAware)1 FormatFactories (org.apache.camel.dataformat.bindy.annotation.FormatFactories)1 Link (org.apache.camel.dataformat.bindy.annotation.Link)1 FormatFactoryInterface (org.apache.camel.dataformat.bindy.format.factories.FormatFactoryInterface)1 DataFormat (org.apache.camel.spi.DataFormat)1 DataFormatName (org.apache.camel.spi.DataFormatName)1 Registry (org.apache.camel.spi.Registry)1