Chris Melas [
http://community.jboss.org/people/melc] created the discussion
"Re: How to Complete a WorkItem using REST API"
To view the discussion, visit:
http://community.jboss.org/message/631386#631386
--------------------------------------------------------------
Hi,
I'm very glad to have assisted in any way and thank you very much for your kind
words.
If you use jbpm-gwt-console-server then you should use the knowledge session provided by
the console-server, as you have noticed.
At first glance things are not very flexible, but there is a way of extending them in a
little dirty approach.
To understand the context, the jbpm-gwt-console-server provides a REST API by
communicating with the jbpm5 API through some integration classes.
The REST API classes as you have spoted are inside the jbpm-gwt-console-server.war and the
integration classes are in org.jbpm.integration.console package of the jbpm5 sources. So
in your case inside ProcessMgmtFacade (from the REST API) there is a field
processManagement of type org.jboss.bpm.console.server.integration.ProcessManagement,
which has another field called delegate of type org.jbpm.integration.console.Delegate. The
delegate field initialises all jbpm5 knowledge related objects, such as the ksession
(StatefulKnowledgeSession). So this is what you need....
The proble is that it's private and all accessors are either private or not really
what we could use to extend and somehow get hold of delegate and ksession etc.
So the approaches are,
1. Edit the other classes , or inherit from them (i.e. the integration classes) and expose
the field/methods that would provide what is needed. Then provide the new implementations
in the already edited ProcessMgmtFacade .
2. Create your own implementation/use of all i.e. your own web services, instantiated as
in jbpm-gwt-console-server etc so in other words create your own little system with
jbpm-gwt-console-server as a reference implementation.
3. Use the dirty old reflection in an inappropriate manner .... as i show below :)
So the dirty approach is to use reflection accessing private method/fields :0
i.e.
//inside ProcessMgmtFacade in your web method (this is the idea, haven't tested this
code i write it here directly....)
Field fields[] =this.getClass().getDeclaredFields();
for(Field field : fields){
if(field.getName().equals("delegate")){
field.setAccessible(true);
field.get(this);//this will return the delegate object, so you can do the same to retrieve
the ksession field
}
}
Generally, if there is no other way of doing it properly i.e. via inheritance, or
accessing some other object that will eventually give access to ksession , then the author
of this code did not intend to give such access and one has to provide his own
implementation, possibly by reusing code etc as stated in approaches 1 and 2.
--------------------------------------------------------------
Reply to this message by going to Community
[
http://community.jboss.org/message/631386#631386]
Start a new discussion in jBPM at Community
[
http://community.jboss.org/choose-container!input.jspa?contentType=1&...]