Details
-
Question
-
Status: Resolved
-
Major
-
Resolution: Not A Problem
-
4.0.9
-
None
-
None
-
smx 7.0.1 karaf 4.0.9
Description
Hi,
I have a karaf 2.2.2 bundle that I wear to karaf 4.0.9.
I rewrite everything.
I did not find how to make command with a bean injections.
I've old blueprint
with services reférences
<reference id="config" timeout="20000" interface="javax.sql.DataSource" filter="(name=config)" />
...
beans declarations
<bean id="fluxNameCompleter" class="fr.aphp.ati.eai.hermes.command.hermes.completer.FluxNameCompleter">
<property name="dataSource" ref="config" />
<property name="context" ref="blueprintBundleContext" />
</bean>
<bean id="conteneur" class="fr.aphp.ati.eai.hermes.command.db.service.Contener">
<argument ref="environnement" type="fr.aphp.ati.eai.hermes.services.environnement.Environnement"/>
</bean>
and commands
<command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.0.0">
<command name="hconfig/composants">
<action class="fr.aphp.ati.eai.hermes.command.hermes.command.ShowComposantsCommand">
<property name="conteneur" ref="conteneur" />
</action>
<completers>
<ref component-id="fluxNameCompleter" />
</completers>
</command>
</command-bundle>
in the completers or commands I use the beans defined in blueprint.
I have some command that also uses bundlecontext and session.
for context a simple injection is enough
<command name="hconfig/trace">
<action class="fr.aphp.ati.eai.hermes.command.hermes.command.TraceCommand">
<property name="context" ref="blueprintBundleContext" />
</action>
</command>
and for the session it is received as a parameter of the method executes
in karaf 4, the blueprint solution does not work
I've replaced xmlns="http://karaf.apache.org/xmlns/shell/v1.0.0" bye xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0"
I'vre removed all commands name
the comands can not be deployed.
ComponentDefinitionRegistryImpl.registerComponentDefinition return error invalid id for the component.
I've tried the annotations and Karaf-Commands=* in manifest
the simple command helloword works but no injections are made
i do not have any context no session no beans i declare in blueprint
in excute method of TraceCommand context and session are null.
in all command class and all completer class, all @Reference returns null
if I remove my beans like Contener, they are never instantiated.
how to define a command that uses a custom bean?
How to access the context and the session?
Where then how to make blueprint work?
A+JYT