我正在使用侦听"控制路径"的自定义处理器动态创建路由.它根据发送到控制路由的消息内容创建路由.它用于由另一个系统动态创建FTP /文件端点.
我在ServiceMix和Hawtio中使用Camel作为蓝图包来控制路由的状态(例如暂停它们).
它工作正常,但(逻辑上)如果重新启动camel上下文,则无法识别这些路由,因为没有持久路由配置.
有关如何坚持路线的最佳做法吗?
我正在考虑通过读取文件端点的目录结构或使用数据库来保留路由及其状态来重新创建路由.
我正在使用ActiveMQ蓝图来设置JMS连接池.我还使用Camel来提供一些功能.
我使用它org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer来允许在设置文件时使用外部属性camel-context文件.
是否有使用蓝图的类似功能?
基本上,我想用以下配置中的属性文件中的属性替换$ {server.address}:
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0"
xmlns:amq="http://activemq.apache.org/schema/core">
<bean id="activemqConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL"
value="nio://${server.address}" />
</bean>
<bean id="pooledConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory">
<property name="maxConnections" value="8" />
<property name="connectionFactory" ref="activemqConnectionFactory" />
</bean>
<bean id="jmsConfig" class="org.apache.camel.component.jms.JmsConfiguration">
<property name="connectionFactory" ref="pooledConnectionFactory" />
<property name="concurrentConsumers" value="5" />
</bean>
<bean id="resourceManager" class="org.apache.activemq.pool.ActiveMQResourceManager"
init-method="recoverResource">
<property name="transactionManager" ref="transactionManager" />
<property name="connectionFactory" ref="activemqConnectionFactory" />
<property name="resourceName" value="activemq.localhost" />
</bean>
<bean id="xaConnectionFactory" class="org.apache.activemq.ActiveMQXAConnectionFactory">
<argument value="nio://${server.address}" />
</bean>
<bean id="connectionFactory" class="org.fusesource.jms.pool.JcaPooledConnectionFactory"
init-method="start" destroy-method="stop">
<property name="connectionFactory" ref="pooledConnectionFactory" />
<property …Run Code Online (Sandbox Code Playgroud) 我使用osgi和blueprint,我搜索如何读取我的包中的文件?如:mybundle
我想在myservice中读取file.json.
我正在从使用 Embed-Dependency 提供“方便”配置的 maven-bundle-plugin 迁移,但似乎我需要在使用bnd-maven-plugin. 我从旧包中添加了相同的包头,但它似乎没有包含实际依赖项的 jar 文件。有人有快速/简洁的方法吗?
我试图在我的blueprint.xml中的list属性中注入一个bean列表(类似于你在Spring配置中所做的):
blueprint.xml:
<blueprint
xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0
http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
<bean id="myBean" class="MyClass" />
<bean id="anotherBean" class="AnotherClass">
<property name="myClasses">
<list>
<ref bean="myBean" />
<list>
</property>
</bean>
</blueprint>
Run Code Online (Sandbox Code Playgroud)
AnotherClass:
public class AnotherClass {
private List<MyClass> myClasses;
public void setMyClasses(List<MyClass> classes) {
this.myClasses = classes;
}
}
Run Code Online (Sandbox Code Playgroud)
我看了一下Blueprint XML架构和R4.2企业规范(我们正在使用)并且没有找到合适的东西.但这只是一个明显的用例,我无法相信这是不可能的.
我在这里缺少什么建议以及如何做到这一点?
我想在骆驼蓝图中调用 POST 休息服务。我的蓝图xml文件如下:
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:camel="http://camel.apache.org/schema/blueprint"
xmlns:cxf="http://camel.apache.org/schema/blueprint/cxf"
xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd">
<bean class="org.apache.cxf.jaxrs.provider.json.JSONProvider" id="jsonProvider"/>
<cxf:rsClient address="http://jsonplaceholder.typicode.com/posts"
id="rsClient" loggingFeatureEnabled="true">
<cxf:providers>
<ref bean="jsonProvider" component-id="jsonProvider"/>
</cxf:providers>
</cxf:rsClient>
<camelContext id="RESTCamelContext" xmlns="http://camel.apache.org/schema/blueprint">
<route id="RESTRoute">
<from id="_from1" uri="timer:foor?repeatCount=1"/>
<to id="_to1" uri="log:body?level=INFO"/>
<setHeader headerName="Content-Type" id="_setHeader1">
<constant>application/json</constant>
</setHeader>
<setHeader headerName="Exchange.HTTP_METHOD" id="_setHeader2">
<constant>POST</constant>
</setHeader>
<to id="_to2" uri="cxfrs:bean:rsClient"/>
<to id="_to3" uri="log:body?level=INFO"/>
</route>
</camelContext>
Run Code Online (Sandbox Code Playgroud)
但我不知道如何在正文请求中传递 JSON 对象。
在我目前的应用程序中,我在几个地方遇到了这种模式:我在一个捆绑包中有两个服务接口,它们执行不同但相关的工作.
interface Service1 { ... }
interface Service2 { ... }
Run Code Online (Sandbox Code Playgroud)
并希望单独的组件实现两者,但找到每个需要对另一个的引用:
public class Service1Impl implements Service1 {
private Service2 service2;
...
}
public class Service2Impl implements Service2 {
private Service1 service1;
...
}
Run Code Online (Sandbox Code Playgroud)
三个OSGi组件模型中的哪一个(DS,Blueprint和iPOJO)允许这样:1)何时Service1Impl和Service2Impl在同一捆绑中; 2)当他们在不同的捆绑?
我有一个关于 OSGI 捆绑包部署的问题。
我有 7 个包,需要按照严格的顺序进行部署,否则我会收到 no class found 错误。部分包用作静态库,部分导出 OSGI 服务。
在OSGI应用程序中这个问题通常是如何解决的?
我正在尝试将依赖注入与 OSGI 蓝图结合使用。
我想通过在 XML DSL 中指定它来构造枚举对象。
在 Spring 上下文 XML 中,这看起来像 -
<bean id="MyTestEnum" class="com.foo.TestEnum"
factory-method="valueOf">
<constructor-arg>
<value>TYPEA</value>
</constructor-arg>
</bean>
Run Code Online (Sandbox Code Playgroud)
如何在 OSGI Blueprint XML 文件中实现这一点?我在标签处看到架构验证错误..
感谢任何指针!
谢谢。
我想知道是否有人尝试使用本机容器测试通过pax-exam工作的blueprint.xml公开的bean /服务.
我有一个包含两个包的项目 - a)config - 接口类b)config-impl - 包含实现并将bean公开为blueprint.xml中定义的服务.
我希望测试类中的@Inject类似于提到的方法@ https://ops4j1.jira.com/wiki/display/PAXEXAM3/Getting+Started+with+OSGi+Tests应该自动在@Inject中设置实例值ed变量,但它似乎没有工作.
发送到pax-exam的选项粘贴在下面.有没有机会,是否会有更多的捆绑加载,以便pax-exam开始识别blueprint.xml并启动服务?
return options(
systemProperty("osgi.console").value("6666"),
junitBundles(),
provision(
mavenBundle("org.osgilab.testing", "commons", "1.0.0"),
mavenBundle("org.apache.commons", "com.springsource.org.apache.commons.codec", "1.3.0"),
mavenBundle("org.codehaus.jackson", "jackson-core-asl", "1.9.12"),
mavenBundle("org.codehaus.jackson", "jackson-mapper-asl", "1.9.12"),
mavenBundle("com.umum.container", "container-config", "1.0.0"),
mavenBundle("com.umum.container", "container-config-impl", "1.0.0").start()),
systemProperty("pax.exam.service.timeout").value("160000"), systemTimeout(160000));
Run Code Online (Sandbox Code Playgroud) blueprint-osgi ×10
osgi ×6
apache-camel ×3
apache-karaf ×3
java ×2
apache-felix ×1
bnd ×1
bndtools ×1
ipojo ×1
jbossfuse ×1
json ×1
osgi-bundle ×1
pax-exam ×1
unit-testing ×1