如何将Java内设置骆驼背景和注册表 [英] How to setup camel context and registry within java

查看:183
本文介绍了如何将Java内设置骆驼背景和注册表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建一个独立的CAMEL应用。我希望只使用Java的(因为编译器会告诉什么是错)。
为了使我的code少耦合,并通过试验可重复使用的,我想脱钩环境和注册表来分隔类的创建。
我刚开始延长 DefaultCamelContext - 这是一个好主意,或者我应该扩展/实现一些其它的类?
在这一类我想用我自己的注册表(它结合了一些bean实例)类。我找到方法setRegistry(org.apache.camel.spi.Registry)。

I am creating a stand alone camel application. I want to use only java (because the compiler tells whats wrong). To make my code less coupled and reusable by tests i want to decouple the creation of context and registry to separate classes. I just started to extend DefaultCamelContext - is this a good idea or should i extend/implement some other class? Within this class i want to use my own registry (it binds some bean instances) class. I found method setRegistry(org.apache.camel.spi.Registry).

但如何实现这样的注册表?有也有defaultRegistry? (对于测试有一个createRegistry(),有测试之外的东西呢?)

But how to implement such an registry? Is there also a "defaultRegistry"? (for tests there is an createRegistry(), is there something for outside the tests?)

目前我想使用依赖注入(吉斯)粘合全体员工一起结束:注册表将注入豆的情况下,注册表然后在上下文注入和上下文是我的主级注入比创建主 ,设置背景和run()的S吧。

At the end i want to use dependency injection (guice) to glue all stuff together: the registry will inject bean-instances, the registry is then injected in context and context is injected in my main-class than creates "main", sets context and "run()"s it.

推荐答案

骆驼支持可插拔注册表的策略 ...所以你应该能够实现org.apache.camel.spi.Registry接口并调用setRegistry(myImpl)...

Camel supports a pluggable registry strategy...so you should be able to implement the org.apache.camel.spi.Registry interface and call setRegistry(myImpl)...

有几个(简单,JNDI等)所支持的注册表可能会满足您的需要或作为一个例子...

there are several (Simple, Jndi, etc) registries that are supported that might meet your needs or serve as an example...

例如,这里是SimpleRegistry实现类...

for example, here is the SimpleRegistry implementation class...

<一个href=\"https://git-wip-us.apache.org/repos/asf?p=camel.git;a=blob_plain;f=camel-core/src/main/java/org/apache/camel/impl/SimpleRegistry.java;h=d2a4a21c9f9fbc70f45fd485d1c46c8a20b9afea;hb=HEAD\" rel=\"nofollow\">https://git-wip-us.apache.org/repos/asf?p=camel.git;a=blob_plain;f=camel-core/src/main/java/org/apache/camel/impl/SimpleRegistry.java;h=d2a4a21c9f9fbc70f45fd485d1c46c8a20b9afea;hb=HEAD

这篇关于如何将Java内设置骆驼背景和注册表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆