The karaf @Reference annotation is not only a special annotation. The karaf commands are run completely independent of the blueprint container. So the only way to use a blueprint bean from a command is to export it as a service. As the @Reference does not have a filter you should use a specific interface for this service that is unique.
Christian 2017-06-16 18:36 GMT+02:00 Martin Lichtin <[email protected]>: > Hi Achim > > Right, I can still use the "old"-style with Blueprint. But all this code > is marked as deprecated. > So I'm desparately trying to find a solution using the "new"-style Karaf > commands, as the old-style will disappear. > I would not spend time on this, if it wasn't marked deprecated. > > I could switch if BlueprintContainer.getComponentInstance("id") was > fixed, so I could use the ids as set in Blueprint cfg file. > > - Martin > > On 15.06.2017 10:03, Achim Nierbeck wrote: > >> Hi Martin, >> >> afaik you still can also use the "old" style with blueprint. >> As you are using blueprint anyway that shouldn't be much of a big deal. >> The idea about the new command way is to not depend on blueprint for >> Karaf internals. >> >> The @Reference annotation is actually a karaf own annotation, >> org.apache.karaf.shell.api.action.lifecycle.Reference >> There is no filtering available on that annotation. >> >> regards, Achim >> >> >> 2017-06-15 8:38 GMT+02:00 Martin Lichtin <[email protected] <mailto: >> [email protected]>>: >> >> So far I could not find a way to do this in the new Karaf command >> framework. >> A command is now instantiated each time it is invoked. >> It can use OSGi services (@Reference) but there doesn't seem to be a >> way to set a filter for it. >> I can access the BlueprintContainer (it's available as a service), >> but not the beans by their name. >> oh well.. >> >> >> >> On 02.06.2017 20 <tel:02.06.2017%2020>:23, Martin Lichtin wrote: >> >> In Karaf 3, a command can be defined in Blueprint as: >> >> <command> >> <action class="my.Cmd"> >> <property name="producerTemplate" ref="producerTemplate" >> /> >> </action> >> </command> >> >> where in my case "producerTemplate" comes from a CamelContext >> created in the same Blueprint context. >> >> Now in Karaf 4, how would I do the same, i.e. set the property? >> >> - Martin >> >> >> >> >> -- >> >> Apache Member >> Apache Karaf <http://karaf.apache.org/> Committer & PMC >> OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer >> & Project Lead >> blog <http://notizblog.nierbeck.de/> >> Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS> >> >> Software Architect / Project Manager / Scrum Master >> >> > -- -- Christian Schneider http://www.liquid-reality.de <https://owa.talend.com/owa/redir.aspx?C=3aa4083e0c744ae1ba52bd062c5a7e46&URL=http%3a%2f%2fwww.liquid-reality.de> Open Source Architect http://www.talend.com <https://owa.talend.com/owa/redir.aspx?C=3aa4083e0c744ae1ba52bd062c5a7e46&URL=http%3a%2f%2fwww.talend.com>
