Camunda-Bpm-OSGI-Platform-Blueprint

Hello All,

I am following the (Camunda Guide) on github and successfully able to start my Process_1 by using @PostDeploy method in my ExampleProcessApplication class.

Now i don’t want to execute this process when i start this bundle,I want to execute this process from another client bundle so i add an interface RuntimeEngine and i have RuntimeEngineimpl class in same package as follows:

RuntimeEngine Interface:
package com.ericsson.bss.rm.engine;

import java.util.Map;
public interface RuntimeEngine {
boolean createInstance(Map<String, Object> variables);
}

RuntimeEngineimpl class:
public class RuntimeEngineImpl implements RuntimeEngine {

private final Logger LOGGER = Logger.getLogger(RuntimeEngine.class.getName());
private RuntimeService runtimeService;
public boolean createInstance(Map<String, Object> variables) {
	LOGGER.severe("Inside createInstance" + variables);
	if (Objects.isNull(runtimeService)) {
		runtimeService = BpmPlatform.getDefaultProcessEngine().getRuntimeService();
	}
	ProcessInstance instance = runtimeService.startProcessInstanceByKey("Process_1", variables);
	LOGGER.severe("Executed : " + instance.getProcessDefinitionId());
return instance.isEnded();
}

}

In my client bundle i have an activator class as follows:

public class Activator implements BundleActivator {

public void start(final BundleContext context) throws Exception {
	System.out.println("blueprint bundle activator called");
}

public void stop(final BundleContext context) throws Exception {
}
private RuntimeEngine runtime;

public void onBindService(RuntimeEngine aRuntime) {
	runtime = aRuntime;
Map<String, Object> variables = new HashMap<String, Object>();
	runtime.createInstance(variables);

}
public void onUnbindService(RuntimeEngine aRuntime) {
}

}
context.xml:





when i start my client bundle in karaf it went in graceperiod and shows missing dependencies as RuntimeEngine is not available.

Any Help is appreciated :slight_smile:
Awaiting for reply .

Thanking you
Keshav kumar taparia

Dear Keshav,

could you please show more of your context.xml? Or is it basically empty?
Why do you need the indirection with the RuntimeEngine? Does anything prevent you from directly using the ProcessEngine?

Cheers,
Ronny

Dear Ronny,

Thanks for your prompt reply.I am sorry somehow i missed this part,my context.xml is as follows.

context.xml (595 Bytes)

When i use @PostDeploy in my ExampleProcessApplication class,then when i start my process-application Process_1 was successfully executed.

I want to use same ProcessEngine in my client bundle and want to execute my Process_1 only when i start my client bundle in karaf.So i was trying to use Blueprint service here.

If there is any other way (Example will be helpful) then please let me know.

Thanking you,
keshav Taparia

Dear Keshav,

in your context.xml you are missing the part where you instantiate your RuntimeEngine.
You need something like
<bean id="runtimeEngine" class="com.ericsson.bss.rm.application.RuntimeEngineImpl"/> <service ref="runtimeEngine" interface="com.ericsson.bss.rm.engine.RuntimeEngine" />

You cannot just use a reference without ever having somebody register the service.
Additionally, the registration of your reference-listener seems wrong to me. If you take a look at this example [1], they configure it a little bit differently. E.g. you never specified an interface, how should the listener know what to search for?

Finally, if you only expect one RuntimeEngine to appear, a listener is overkill. You could directly set the RuntimeEngine into your Activator (of course you have to add a setter method then).
<bean id="bundle-activator" class="com.ericsson.bss.rm.application.client.Activator"> <property name="runtimeEngine" ref="runtimeEngine"/> </bean>

Cheers,
Ronny

[1] http://www.ibm.com/developerworks/library/os-osgiblueprint/

2 Likes

Dear Ronny sir,

I truly appreciate your time and effort.i will try to apply both methods and will let you the results in later comment.

For reference listener i followed this example(http://www.hascode.com/2012/04/wiring-made-easy-using-osgi-blueprint-and-apache-karaf/) in which they don’t use any interface.

Thanking You,
Keshav Kumar Taparia

Dear Ronny Sir,

I have register that service inside my process-application bundle so i don’t need to add this in my client bundle.

I hope now it will work fine.

Thanking You,
Keshav kumar taparia

Dear Ronny Sir,

We can directly use ProcessEngine in client bundle,there is no need of using RuntimeEngine and bind it as an OSGI Service.

I truly appreciate your time and effort.

Thanking you,
Keshav Kumar Taparia