1 Reply Latest reply on May 17, 2011 8:50 AM by David Bosschaert

    Asynchronous execution in JBOSGi

    David Bosschaert Expert

      What is the best way to asynchronously execute a piece of code in JBOSGi? Simply using an executor (I see that most plugins extend the AbstractExecutorService class) or does MSC provide some functionality for this too?

        • 1. Re: Asynchronous execution in JBOSGi
          David Bosschaert Expert

          Answering my own question, it seems that MSC can help here in that you can create a service on the fly and install that. Like this:

           

          {code}ServiceBuilder<Void> builder = serviceTarget.addService(serviceName, new AbstractService<Void>() {

              public void start(StartContext context) throws StartException {

                  // do some async stuff

              }

          });

          builder.addDependencies(...deps...); // optional

          builder.install(); // kick it off{code}

          am I correct?