Search in sources :

Example 1 with DefaultFactoryRegistry

use of org.apache.camel.dataformat.bindy.format.factories.DefaultFactoryRegistry 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 DefaultFactoryRegistry

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

the class BindyCarQuoteAndCommaDelimiterTest method setup.

@Before
public void setup() {
    PropertyPlaceholderDelegateRegistry registry = (PropertyPlaceholderDelegateRegistry) context.getRegistry();
    JndiRegistry reg = (JndiRegistry) registry.getRegistry();
    reg.bind("defaultFactoryRegistry", new DefaultFactoryRegistry());
}
Also used : JndiRegistry(org.apache.camel.impl.JndiRegistry) DefaultFactoryRegistry(org.apache.camel.dataformat.bindy.format.factories.DefaultFactoryRegistry) PropertyPlaceholderDelegateRegistry(org.apache.camel.impl.PropertyPlaceholderDelegateRegistry) Before(org.junit.Before)

Aggregations

DefaultFactoryRegistry (org.apache.camel.dataformat.bindy.format.factories.DefaultFactoryRegistry)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 FactoryRegistry (org.apache.camel.dataformat.bindy.format.factories.FactoryRegistry)1 FormatFactoryInterface (org.apache.camel.dataformat.bindy.format.factories.FormatFactoryInterface)1 JndiRegistry (org.apache.camel.impl.JndiRegistry)1 PropertyPlaceholderDelegateRegistry (org.apache.camel.impl.PropertyPlaceholderDelegateRegistry)1 DataFormat (org.apache.camel.spi.DataFormat)1