I've got 2 bundles. One registers the service via blueprint. And another one
is command bundle. Command bundle injects registered service with command
lifecycle annotation. The problem is when I update service bundle command
disappears until I restart Karaf.

package biz.lorien.niichi.command;

import biz.lorien.niichi.api.model.entity.Player;
import biz.lorien.niichi.api.service.PlayerService;
import org.apache.karaf.shell.api.action.Action;
import org.apache.karaf.shell.api.action.Argument;
import org.apache.karaf.shell.api.action.Command;
import org.apache.karaf.shell.api.action.lifecycle.Reference;
import org.apache.karaf.shell.api.action.lifecycle.Service;

@Service
@Command(scope = "niichi", name = "add-player")
public class AddPlayerCommand implements Action {

    @Reference
    private PlayerService playerService;

    @Argument(index = 0, name = "id", required = true, multiValued = false)
    private String id;

    @Argument(index = 1, name = "name", required = true, multiValued =
false)
    private String name;

    @Override
    public Object execute() throws Exception {
        Player player = new Player();
        player.setId(id);
        player.setName(name);
        player.setNiichi(true);
        playerService.addPlayer(player);
        return player;
    }

}




--
View this message in context: 
http://karaf.922171.n3.nabble.com/Karaf-4-command-bundle-using-service-tp4042065.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Reply via email to