blueprint-osgi 相关问题

蓝图OSGi是一个向OSGi引入依赖注入并为OSGi包提供使用和提供服务的简单机制的规范。

在 OSGi 蓝图中使用 Camel JCachePolicy 和 Caffeine

我想在 OSGi Blueprint 中为 Caffeine 缓存应用camel-jcache 路由策略。 当我向蓝图中添加缓存配置时,如下所示: 我想在 OSGi 蓝图中为咖啡因缓存应用 camel-jcache 路由策略。 当我向蓝图中添加缓存配置时,如下所示: <reference id="cachingProvider" interface="javax.cache.spi.CachingProvider"/> <bean id="caffeineCacheManager" factory-ref="cachingProvider" factory-method="getCacheManager"/> <bean id="caffeineCache" factory-ref="caffeineCacheManager" factory-method="getCache"> <!-- see src/main/resources/application.conf for cache expiration policy --> <argument value="konfig-cache"/> </bean> <bean id="jCachePolicy" class="org.apache.camel.component.jcache.policy.JCachePolicy"> <property name="cache" ref="caffeineCache"/> <property name="keyExpression"> <bean class="org.apache.camel.model.language.SimpleExpression"> <property name="expression" value="${exchangeProperty.typNr}"/> </bean> </property> </bean> 然后蓝图包无法在 NullPointerException 处以 BeanRecipe.setProperties 开头。 我能够将其追溯到类加载器问题。我要求一个名为 konfig-cache 的缓存,但该缓存的配置位于捆绑资源中的文件 application.conf 中(Typesafe Config 中自定义配置的默认位置)。 OSGi 运行时无法使用默认类加载器加载该文件。 如何定义 Caffeine 底层 Typesafe Config 应该使用的类加载器来在 Blueprint 包的资源中定位配置文件? pom.xml中相关依赖: <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-jsonpath</artifactId> <version>${camel.version}</version> </dependency> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-jcache</artifactId> <version>${camel.version}</version> </dependency> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-caffeine</artifactId> <version>${camel.version}</version> </dependency> <dependency> <groupId>com.github.ben-manes.caffeine</g <artifactId>jcache</artifactId> <version>2.9.2</version> </dependency> 在我的 Karaf feature.xml: <feature version="${camel.version}">camel-jcache</feature> <feature version="${camel.version}">camel-caffeine</feature> <bundle>mvn:com.github.ben-manes.caffeine/jcache/2.9.2</bundle> <bundle>mvn:com.typesafe/config/1.4.2</bundle> 最后,我的src/main/resources/application.conf: # Configuration for camel-caffeine in HOCON format # see https://github.com/lightbend/config/blob/master/HOCON.md#hocon-human-optimized-config-object-notation # see https://github.com/lightbend/config#standard-behavior # see https://github.com/ben-manes/caffeine/blob/master/jcache/src/main/resources/reference.conf # see example https://github.com/ben-manes/caffeine/blob/master/jcache/src/test/resources/application.conf caffeine.jcache { konfig-cache { key-type = java.lang.String value-type = java.lang.Object # The eviction policy for automatically removing entries from the cache policy { # The expiration threshold before lazily evicting an entry. This single threshold is reset on # every operation where a duration is specified. As expected by the specification, if an entry # expires but is not accessed and no resource constraints force eviction, then the expired # entry remains in place. lazy-expiration { # The duration before a newly created entry is considered expired. If set to 0 then the # entry is considered to be already expired and will not be added to the cache. May be # a time duration or "eternal" to indicate no expiration. creation = 60m # The duration before a updated entry is considered expired. If set to 0 then the entry is # considered immediately expired. May be a time duration, null to indicate no change, or # "eternal" to indicate no expiration. update = 60m # The duration before a read of an entry is considered expired. If set to 0 then the entry # is considered immediately expired. May be a time duration, null to indicate no change, or # "eternal" to indicate no expiration. access = null } # The expiration thresholds before eagerly evicting an entry. These settings correspond to the # expiration supported natively by Caffeine where expired entries are collected during # maintenance operations. #eager-expiration { # Specifies that each entry should be automatically removed from the cache once a fixed # duration has elapsed after the entry's creation, or the most recent replacement of its # value. This setting cannot be combined with the variable configuration. #after-write = null # Specifies that each entry should be automatically removed from the cache once a fixed # duration has elapsed after the entry's creation, the most recent replacement of its value, # or its last read. Access time is reset by all cache read and write operation. This setting # cannot be combined with the variable configuration. #after-access = null # The expiry class to use when calculating the expiration time of cache entries. This # setting cannot be combined with after-write or after-access configurations. #variable = null } # The threshold before an entry is eligible to be automatically refreshed when the first stale # request for an entry occurs. This setting is honored only when combined with the # read-through configuration. #refresh { # Specifies that active entries are eligible for automatic refresh once a fixed duration has # elapsed after the entry's creation or the most recent replacement of its value. #after-write = 30s #} # The maximum bounding of the cache based upon its logical size maximum { # The maximum number of entries that can be held by the cache. This setting cannot be # combined with the weight configuration. size = 10 } } } CaffeineCachingProvider 允许将类加载器传递给 CachingProvider.getCacheManager(URI uri, ClassLoader classLoader)。 预期的 URI 只是 CaffeineCachingProvider 的 FQCN。 现在是类加载器。在 OSGi 蓝图中,我们可以确定蓝图包的类加载器并将其传递给 getCacheManager。蓝图规范定义了许多具有预定义参考名称的环境管理器,其中包括蓝图包本身,其名称为blueprintBundle。 因为无论如何我们都在使用 Camel,所以我们可以使用 Camel 的 BundleDelegatingClassLoader 来简化对包的类加载器的访问: <bean id="caffeineCacheManager" factory-ref="cachingProvider" factory-method="getCacheManager"> <argument value="com.github.benmanes.caffeine.jcache.spi.CaffeineCachingProvider"/> <argument> <bean class="org.apache.camel.core.osgi.utils.BundleDelegatingClassLoader"> <argument ref="blueprintBundle"/> </bean> </argument> </bean>

回答 1 投票 0

MethodInvokingFactoryBean返回自身而不是所需的对象

我正在尝试使用MethodInvokingFactoryBean获取com.amazonaws.regions.Region的实例,以用于配置com.amazonaws.services.kinesis.AmazonKinesisClient。我正在...

回答 1 投票 0

使用在蓝图中定义但在Camel Java DSL中解析的类型化默认属性占位符

我在Karaf中使用蓝图引导CamelContext的启动,该启动又配置了Java DSL(Camel版本2.21.2)中定义的路由。在blueprint.xml中,我定义了一些...

回答 1 投票 0

如何使用bnd-maven-plugin嵌入maven依赖项

我从使用embed-Dependency提供“便捷”配置的maven-bundle-plugin迁移,但是当使用...时,我似乎需要以bnd格式“手动”指定我的Embed Dependency。

回答 1 投票 2

CamelBlueprintTest中的模拟OSGi参考无效

我目前正在使用CamelBlueprintTestSupport设置测试。在我的blueprint.xml中,我尝试了以下实现: ...

回答 1 投票 0

如何调试在Karaf中运行的Aries Blueprint中缺少的NamespaceHandler?

我已经反复讨论了这个问题。归结为:如何调试在Apache Karaf内部运行的Aries Blueprint?我最终得到来自diag的输出,该输出仅暗示以下事实:...

回答 1 投票 0

如何替换在blueprint / context.xml中加载的cfg文件中的文本值

我正在我的context.xml文件中的OSGi-inf / blueprint /下的我的context.xml中加载一个cfg文件:... ] >>

回答 1 投票 0

由于未解决的依赖关系而无法启动蓝图

我是骆驼和蓝图的新手。试图在Jboss保险丝中安装我的应用程序,但出现错误-org.apache.aries.blueprint.container中的java.util.concurrent.TimeoutException。...

回答 1 投票 0

使用CamelBlueprintTestSupport从端点测试某些组件失败

我想测试使用Blueprint-XML实现的骆驼路线。当尝试使用简单的“直接”-从端点测试路由时,一切正常。但是将“从”端点更改为净值...

回答 1 投票 0

捆绑正在等待名称空间处理程序

我正在尝试将我的应用程序部署在保险丝容器中,但出现错误-捆绑包正在等待名称空间处理程序[http://camel.apache.org/schema/blueprint、http://aries.apache.org/蓝图/ XMLNS / ...

回答 1 投票 0

端点上没有可用的使用者:端点[direct:// LookUpRoute]

我是骆驼新手。我试图将交换从Java方法发送到路由,但它给我“原因:org.apache.camel.component.direct.DirectConsumerNotAvailableException:没有可用的消费者...

回答 1 投票 0

使用XML在Apache Camel中设置属性

我是新来的骆驼。在下面需要帮助。我有2条路线。从路由A,我仅使用方法调用将1个属性发送到另一条路由。像

回答 1 投票 0

如何修复:“状态:GracePeriod蓝图缺少依赖项:(&(objectClass = org.apache.aries.blueprint.NamespaceHandler)”

我使用camel-archetype-blueprint构建了一个bundle。但是在部署到ServiceMix之后,它还没有运行并保持在GracePeriod状态。 log:display中没有错误。调用bundle:diag导致:...

回答 1 投票 0

保险丝7.1.0 - 蓝图 - 捆绑进入宽限期:缺少依赖性错误:cxf-rt-transports-http-jetty

我的包正在进入宽限期,出现以下错误:karaf @ root()> bundle:diag BundleNameXYZ [bundle-name-xyz](228)状态:GracePeriod Blueprint 2/15/19 4:31 PM缺少依赖项:(&。 ..

回答 1 投票 0

发送请求后如何处理错误(camel-http)?

我想根据http代码响应处理错误。我还想知道如何在我的路线上启用* throwExceptionOnFailure *。例如,如果响应代码为500x,则发送消息...

回答 1 投票 0

Karaf Pax考试因未知协议而失败:换行

嗨我的pax考试失败,出现错误未知协议:wrap org.apache.karaf.features.internal.util.MultiException:org.apache.karaf.features.internal.download.impl.MavenDownloadManager $ ...

回答 1 投票 0

Red Hat Fuse 7.2单元测试产生令人困惑的RuntimeException-即“从bundle中等待BlueprintContainer”

问题:下面提供的单元测试失败并显示消息:java.lang.RuntimeException:从bundle“RouteXmlTest”中等待BlueprintContainer异常是模糊的,没有...

回答 1 投票 -1

如何集成osgi-blueprint和apache camel,任何示例代码?

我正在设置osgi-bluprint和apache camel项目,我想知道如何集成这两个组件。

回答 2 投票 0

如何将一个blueprint.xml中的单个bean注入一个单独的blueprint.xml?

我有一个Java类,它作为表示实体的多个其他类的注册表(在我的例子中,各种各样的苹果)。这有两个主要步骤:实体定义在......

回答 1 投票 0

_locateMapperViaProvider在使用Aries Felix,Aries Blueprint和CXF-RS时是否有效?

为什么@Provider注释不起作用? (目标是将模块附加到ObjectMapper单例)根据JavaDocs,默认构造函数,通常在提供者自动使用时...

回答 1 投票 1

© www.soinside.com 2019 - 2024. All rights reserved.