Hi Paul,
it depends of the xmlns version that you use.
With shell xmlns 1.0.0, you have to use
<command name="command/doSomething"/>
where command corresponds to the scope and doSomething to the name.
In Karaf 3.0.0, with namespace 1.1.0, you can use just <command/>, the
scope and name are "extracted" from the command class.
Regards
JB
On 01/14/2014 05:54 PM, Paul Spencer wrote:
Karaf 2.3.3
Karaf 2.3.3
What is the Blueprint syntax to instantiate and initialize object properties
when the command is executed?
The XML below will define the command and contains a reference to the interface
of the service the command will use. I would like the syntax to instantiate
and initialize the property MyService for an MyCommand object when the command
is executed by a user.
***
* blueprint.xml
***
<command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.0.0">
<command name=“command/doSomething”>
<action class=“com.foo.MyCommand" />
</command>
</command-bundle>
<reference id=“Service” interface=“com.foo.MyService” />
***
* MyCommand.java
***
package com.foo;
import org.apache.felix.gogo.commands.Command;
import org.apache.karaf.shell.console.OsgiCommandSupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Command(scope = “command”, name = “doSomething”, description = "Example
Command")
public class MyCommand extends OsgiCommandSupport {
private MyService _myService;
private static Logger _logger = LoggerFactory.getLogger(MyCommand.class);
protected Object doExecute() throws Exception {
_logger.info(“Command ‘command:doSomething’ executed and returned “ +
_myService.doSomething());
return void;
}
MyService getMyService() {
return _myService;
}
void setMyService( MyService service) {
_myService = service;
}
--
Jean-Baptiste Onofré
[email protected]
http://blog.nanthrax.net
Talend - http://www.talend.com