本文整理了Java中org.apache.camel.spi.Registry
类的一些代码示例,展示了Registry
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Registry
类的具体详情如下:
包路径:org.apache.camel.spi.Registry
类名称:Registry
暂无
代码示例来源:origin: org.openehealth.ipf.platform-camel/ipf-platform-camel-core
public static <T> T beanOrNull(Class<T> type, CamelContext camelContext) {
Set<T> beans = camelContext.getRegistry().findByType(type);
int count = beans.size();
if (count == 1) {
return beans.iterator().next();
} else if (count == 0) {
return null;
} else {
throw new IllegalArgumentException(
"Too many beans in the application context of type: "
+ type + ". Found: " + count);
}
}
代码示例来源:origin: org.apache.camel/camel-spring
@Override
public void afterPropertiesSet() {
if (endpoint == null) {
if (ObjectHelper.isNotEmpty(camelContextId)) {
camelContext = CamelContextResolverHelper.getCamelContextWithId(applicationContext, camelContextId);
endpoint = camelContext.getRegistry().lookupByNameAndType(getServiceRef(), Endpoint.class);
} else {
endpoint = camelContext.getEndpoint(getServiceUrl());
producer = endpoint.createProducer();
camelContext.addService(producer, true, true);
serviceProxy = ProxyHelper.createProxy(endpoint, bind, producer, getServiceInterface());
} catch (Exception e) {
代码示例来源:origin: org.apache.camel/camel-spring
@Override
public Object resolve(EvaluationContext context, String beanName) throws AccessException {
Object bean = null;
try {
bean = registry.lookupByName(beanName);
} catch (NoSuchBeanException e) {
// ignore
}
if (bean == null) {
throw new AccessException("Could not resolve bean reference against Registry");
}
return bean;
}
代码示例来源:origin: org.apache.camel/camel-metrics
MetricRegistry getMetricRegistryFromCamelRegistry(Registry camelRegistry, String registryName) {
MetricRegistry registry = camelRegistry.lookupByNameAndType(registryName, MetricRegistry.class);
if (registry != null) {
return registry;
} else {
Set<MetricRegistry> registries = camelRegistry.findByType(MetricRegistry.class);
if (registries.size() == 1) {
return registries.iterator().next();
}
}
return null;
}
代码示例来源:origin: org.apache.camel/camel-zipkin
@Override
protected void doStart() throws Exception {
ObjectHelper.notNull(camelContext, "CamelContext", this);
camelContext.getManagementStrategy().addEventNotifier(eventNotifier);
if (!camelContext.getRoutePolicyFactories().contains(this)) {
camelContext.addRoutePolicyFactory(this);
if (ObjectHelper.isNotEmpty(host) && ObjectHelper.isNotEmpty(port)) {
LOG.info("Auto-configuring Zipkin URLConnectionSender using host: {} and port: {}", host, port);
int num = camelContext.getTypeConverter().mandatoryConvertTo(Integer.class, port);
Set<Reporter> reporters = camelContext.getRegistry().findByType(Reporter.class);
if (reporters.size() == 1) {
spanReporter = reporters.iterator().next();
代码示例来源:origin: org.apache.camel/camel-blueprint
@Override
public Language resolveLanguage(String name, CamelContext context) {
try {
Object bean = context.getRegistry().lookupByName(".camelBlueprint.languageResolver." + name);
if (bean instanceof LanguageResolver) {
LOG.debug("Found language resolver: {} in registry: {}", name, bean);
return ((LanguageResolver) bean).resolveLanguage(name, context);
}
} catch (Exception e) {
LOG.trace("Ignored error looking up bean: " + name + " due: " + e.getMessage(), e);
}
return super.resolveLanguage(name, context);
}
代码示例来源:origin: org.apache.camel/camel-opentracing
@Override
protected void doStart() throws Exception {
ObjectHelper.notNull(camelContext, "CamelContext", this);
camelContext.getManagementStrategy().addEventNotifier(eventNotifier);
if (!camelContext.getRoutePolicyFactories().contains(this)) {
camelContext.addRoutePolicyFactory(this);
}
camelContext.addLogListener(logListener);
if (tracer == null) {
Set<Tracer> tracers = camelContext.getRegistry().findByType(Tracer.class);
if (tracers.size() == 1) {
tracer = tracers.iterator().next();
}
}
if (tracer == null) {
tracer = TracerResolver.resolveTracer();
}
if (tracer == null) {
// No tracer is available, so setup NoopTracer
tracer = NoopTracerFactory.create();
}
ServiceHelper.startServices(eventNotifier);
}
代码示例来源:origin: org.apache.camel/camel-zookeeper-master
@Override
protected void doStart() throws Exception {
ObjectHelper.notNull(camelContext, "CamelContext");
// attempt to lookup curator framework from registry using the name curator
if (curator == null) {
try {
CuratorFramework aCurator = getCamelContext().getRegistry().lookupByNameAndType("curator", CuratorFramework.class);
if (aCurator != null) {
LOG.debug("CuratorFramework found in CamelRegistry: {}", aCurator);
setCurator(aCurator);
}
} catch (Exception exception) {
// ignore
}
}
// will auto create curator if needed
managedGroupFactory = ManagedGroupFactoryBuilder.create(curator, getClass().getClassLoader(), getCamelContext().getClassResolver(), this);
}
代码示例来源:origin: io.syndesis.integration/integration-runtime
public JsonSimplePredicate(final String expression, final CamelContext context) {
final Language language = ObjectHelper.notNull(context.resolveLanguage("simple"), "simple language");
final String ognlExpression = convertSimpleToOGNLForMaps(expression);
predicate = language.createPredicate(expression);
ognlPredicate = language.createPredicate(ognlExpression);
final Registry registry = context.getRegistry();
final Set<ObjectMapper> mappers = registry.findByType(ObjectMapper.class);
if (mappers.size() != 1) {
mapper = MAPPER;
} else {
mapper = mappers.iterator().next();
}
}
代码示例来源:origin: org.apache.camel/camel-dozer
/**
* Lookup the dozer {@link Mapper} to be used.
*/
protected Map<String, Mapper> lookupDozerBeanMappers() {
return new HashMap<>(camelContext.getRegistry().findByTypeWithName(Mapper.class));
}
代码示例来源:origin: camelinaction/camelinaction
public OrderCreateTable(CamelContext camelContext) {
DataSource ds = camelContext.getRegistry().lookupByNameAndType("myDataSource", DataSource.class);
JdbcTemplate jdbc = new JdbcTemplate(ds);
try {
jdbc.execute("drop table riders_order");
} catch (Exception e) {
// ignore as the table may not already exists
}
jdbc.execute("create table riders_order "
+ "( customer_id varchar(10), ref_no varchar(10), part_id varchar(10), amount varchar(10) )");
}
代码示例来源:origin: com.googlecode.metridoc/metridoc-camel-core
DataSource getDataSource(Map<String, Object> parameters) {
String dataSourceReference = (String) parameters.remove("dataSource");
Assert.notEmpty(dataSourceReference, "the dataSource parameter must be provided when using the "
+ "liquibase component");
return getCamelContext().getRegistry().lookup(dataSourceReference, DataSource.class);
}
代码示例来源:origin: org.apache.camel/camel-jsonpath
private ObjectMapper resolveObjectMapper(Registry registry) {
Set<ObjectMapper> mappers = registry.findByType(ObjectMapper.class);
if (mappers.size() == 1) {
return mappers.iterator().next();
}
return defaultMapper;
}
代码示例来源:origin: OpenWiseSolutions/openhub-framework
@Override
public <T> T lookupByNameAndType(String name, Class<T> type) {
for (Registry registry : applicationContextsRegistry.values()) {
T result = registry.lookupByNameAndType(name, type);
if (result != null) {
return result;
}
}
return null;
}
代码示例来源:origin: net.sf.jabb/jabb-core
/**
* Looks up from all encapsulated Registry(s) one by one, and returns the first result found.<br>
* 按次序从所封装的Registry中查找,返回第一个找到的结果。
* <p>
* If no result can be found, null will be returned.
* <p>
* 如果全都找不到,则返回null。
*
* @see org.apache.camel.spi.Registry#lookup(java.lang.String, java.lang.Class)
*/
public <T> T lookup(String name, Class<T> type) {
T result = null;
for (Registry reg: registryList){
result = reg.lookup(name, type);
if (result != null){
break;
}
}
return result;
}
代码示例来源:origin: com.github.zed-platform/zed-camel
public static Map<String, Object> findBeansWithRestOperations(Registry registry) {
Map<String, Object> beans = new HashMap<>();
for (Map.Entry<String, Object> bean : registry.findByTypeWithName(Object.class).entrySet()) {
if (!findRestOperations(bean.getValue().getClass()).isEmpty()) {
beans.put(bean.getKey(), bean.getValue());
}
}
return beans;
}
代码示例来源:origin: org.milyn/milyn-smooks-all
public void start() throws Exception {
final SmooksFactory smooksFactory = (SmooksFactory) camelContext.getRegistry().lookupByName(SmooksFactory.class.getName());
if (smooksFactory != null) {
smooks = smooksFactory.createInstance(smooksConfig);
} else {
smooks = new Smooks(smooksConfig);
}
}
代码示例来源:origin: org.apache.camel/camel-dozer
/**
* Lookup the dozer {@link DozerBeanMapperConfiguration} to be used.
*/
protected Map<String, DozerBeanMapperConfiguration> lookupDozerBeanMapperConfigurations() {
return new HashMap<>(camelContext.getRegistry().findByTypeWithName(DozerBeanMapperConfiguration.class));
}
代码示例来源:origin: camelinaction/camelinaction2
public OrderCreateTable(CamelContext camelContext) {
DataSource ds = camelContext.getRegistry().lookupByNameAndType("myDataSource", DataSource.class);
JdbcTemplate jdbc = new JdbcTemplate(ds);
try {
jdbc.execute("drop table riders_order");
} catch (Exception e) {
// ignore as the table may not already exists
}
jdbc.execute("create table riders_order "
+ "( customer_id varchar(10), ref_no varchar(10), part_id varchar(10), amount varchar(10) )");
}
代码示例来源:origin: org.fusesource.eca/eca-core
protected Endpoint resolveEndpoint(String targetId) {
Endpoint result = getContext().getRegistry().lookup(targetId, Endpoint.class);
if (result == null) {
result = CamelContextHelper.getMandatoryEndpoint(getContext(), targetId);
}
return result;
}
内容来源于网络,如有侵权,请联系作者删除!