问题描述
我想在OSGi容器中两次安装两个相同的软件包或相同的软件包.我正在使用的OSGi容器是FUSE ESB.这是捆绑包信息:
I want to install two identical bundle or the same bundle twice in OSGi container. The OSGi container I am using is FUSE ESB. Here is the bundle information:
pom.xml:
<groupId>com.helloworldbundle</groupId>
<artifactId>HelloWorldBundle</artifactId>
<version>1.0.0-SNAPSHOT</version>
蓝图:
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
<bean id="helloworldbundlecopybean"
class="com.helloworldbundle.HelloWorld"
init-method="init" destroy-method="destroy">
</bean>
</blueprint>
首次安装成功.当我尝试再次安装它时,它失败了.然后,我复制该项目并对其进行修改:
The first installation is successful. When I try to install it again, it failed. Then I make a copy of the project and modify it:
将项目文件夹名称更改为HelloWorldBundleCopy
change project folder name to HelloWorldBundleCopy
将工件更改为
<artifactId>HelloWorldBundleCopy</artifactId>
将bean的ID更改为
change bean id to
<bean id="helloworldbundlecopybeancopy"
但是我仍然无法安装修改后的捆绑软件:
But still I cannot install the modified bundle:
Error executing command: Error installing bundles:
Unable to install bundle /home/li/Documents/Java/HelloWorldBundleCopy/target/HelloWorldBundleCpoy-1.0.0-SNAPSHOT.jar
更新我的问题:
这是我的情况:
我有3个主机:Host1,Host2和Host3
I have three hosts: Host1, Host2 and Host3
FUSE ESB OSGi容器已安装在Host3中.我需要在Host1和Host2上都运行服务,例如HelloWorld.并且此服务已在Host3上的FUSE ESB中注册.
FUSE ESB OSGi container is installed in Host3.I need to run a service, for example HelloWorld on both Host1 and Host2. And this service is registered with FUSE ESB which is on Host3.
这就是为什么我需要向FUSE ESB注册两次相同的捆绑软件.
That is why I need to register the same bundle twice with FUSE ESB.
这是我的问题:
-
是否可以在容器外部运行捆绑软件,例如在一台主机上运行HelloWorld捆绑软件,但将其注册到另一台主机上的FUSE ESB?以及如何做?我之前做过的实验是通过以下方式将服务捆绑包注册到同一台计算机上的FUSE ESB中:
Is it possible to run a bundle outside the container, like running HelloWorld bundle on one host but register it to FUSE ESB on a different host? And how to do it? The experiment I have done before is to register a service bundle to FUSE ESB on the same machine by:
FuseESB:karaf @ root>安装文件:/home/li/Documents/Java/HelloWorldBundle/target/HelloWorldBundle-1.0.0-SNAPSHOT.jar
FuseESB:karaf@root> install file:/home/li/Documents/Java/HelloWorldBundle/target/HelloWorldBundle-1.0.0-SNAPSHOT.jar
2.如何修改现有的maven项目以使其能够重新安装而不创建新的maven项目?
2.How to modify the existing maven project to enable install it again without creating a new maven project?
推荐答案
在OSGi中,Bundle-SymbolicName
和Bundle-Version
的组合就像捆绑软件的主键"……您不能安装两个具有完全相同的捆绑软件的捆绑软件.相同的符号名称和版本.
In OSGi the combination of Bundle-SymbolicName
and Bundle-Version
is like the "primary key" of the bundle... you cannot install two bundles having exactly the same symbolic name and version.
在您的问题中,您将工具与运行时问题混在一起,因此很难说出实际情况……无论如何,您已经更改了Maven中的artifactId
,但我不知道这可能会对Bundle产生什么影响- SymbolicName,这是OSGi关心的.如果您更改该标头,则可以安装两次该捆绑软件.
In your question you have mixed up tooling with runtime issues so it's hard to tell what's really happening... anyway, you have changed the artifactId
in Maven but I have no idea what effect that might have on the Bundle-SymbolicName, which is what OSGi cares about. You can install this bundle twice if you change that header.
但这引出了一个问题,为什么您要两次安装相同的捆绑软件?这很少有用.请说明为什么要这样做;可能有更好的解决方案来解决您的潜在问题.
However this begs the question, why do you want to install the same bundle twice? This is very rarely useful. Please explain why you want to do this; it's likely there is a better solution to your underlying problem.
这篇关于OSGi如何安装两个相同的捆绑包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!