ace-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marcel Offermans <marcel.offerm...@luminis.nl>
Subject Re: ACE client
Date Thu, 20 Jun 2013 12:04:58 GMT
On Jun 20, 2013, at 11:42 AM, <Wilfried.Sibla@bosch-si.com> wrote:

> But nevertheless, I will write a small bundle including the bndrun file and use the bundle
start method to test something...

That works. If you want a bit more flexibility, you can write a shell command, by making an
Activator that does something like this:

public class Activator extends DependencyActivatorBase {
    @Override
    public void init(BundleContext context, DependencyManager manager) throws Exception {
      Properties props = new Properties();
      props.put(CommandProcessor.COMMAND_SCOPE, "myscope");
      props.put(CommandProcessor.COMMAND_FUNCTION, new String[] { "test", "two" });
        manager.add(createComponent()
            .setInterface(Object.class.getName(), props)
            .setImplementation(Commands.class)
        );
    }

    @Override
    public void destroy(BundleContext context, DependencyManager manager) throws Exception
{
    }
}

and a Commands class with commands that do something like this:

public class Commands {
    public void test() {
    	System.out.println("test command executing");
    }
    
    public void two() throws Exception {
    	throw new RuntimeException("I throw an exception.");
    }
}

Of course your commands should do something useful, and you might want to inject certain service
dependencies into that class, but this is the idea. From the shell you can then simply type:
"test" (or "myscope:test" if there exists more than one "test" command in different scopes).

Greetings, Marcel


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message