use of org.apache.camel.spi.Registry in project camel by apache.
the class EjbComponent method createEndpoint.
@Override
protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
EjbEndpoint answer = new EjbEndpoint(uri, this);
answer.setBeanName(remaining);
// plugin registry to lookup in jndi for the EJBs
Registry registry = new JndiRegistry(getContext());
// and register the bean as a holder on the endpoint
BeanHolder holder = new EjbRegistryBean(registry, getCamelContext(), answer.getBeanName());
answer.setBeanHolder(holder);
return answer;
}
use of org.apache.camel.spi.Registry in project camel by apache.
the class CamelContextFactoryBean method initCustomRegistry.
@Override
protected void initCustomRegistry(BlueprintCamelContext context) {
Registry registry = getBeanForType(Registry.class);
if (registry != null) {
LOG.info("Using custom Registry: " + registry);
context.setRegistry(registry);
}
}
use of org.apache.camel.spi.Registry in project camel by apache.
the class BeanInfo method createParameterMappingStrategy.
public static ParameterMappingStrategy createParameterMappingStrategy(CamelContext camelContext) {
// lookup in registry first if there is a user define strategy
Registry registry = camelContext.getRegistry();
ParameterMappingStrategy answer = registry.lookupByNameAndType(BeanConstants.BEAN_PARAMETER_MAPPING_STRATEGY, ParameterMappingStrategy.class);
if (answer == null) {
// no then use the default one
answer = new DefaultParameterMappingStrategy();
}
return answer;
}
use of org.apache.camel.spi.Registry 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());
}
use of org.apache.camel.spi.Registry in project camel by apache.
the class CompositeRegistry method lookupByNameAndType.
public <T> T lookupByNameAndType(String name, Class<T> type) {
T answer = null;
RuntimeCamelException ex = null;
for (Registry registry : registryList) {
try {
answer = registry.lookupByNameAndType(name, type);
} catch (Throwable e) {
// do not double wrap the exception
if (e instanceof NoSuchBeanException) {
ex = (NoSuchBeanException) e;
} else {
ex = new NoSuchBeanException(name, "Cannot lookup: " + name + " from registry: " + registry + " with expected type: " + type + " due: " + e.getMessage(), e);
}
}
if (answer != null) {
return answer;
}
}
if (ex != null) {
throw ex;
} else {
return answer;
}
}
Aggregations