cancel
Showing results for 
Search instead for 
Did you mean: 

Associating delegate class at Runtime

kanchan
Champ in-the-making
Champ in-the-making
Hi all,

I am evaluating activiti engine for our project. I want to know is there any provision for associating delegate class at Runtime in activiti engine ?

Thanking in advance,
Kanchan
5 REPLIES 5

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi Kanchan,

I want to know is there any provision for associating delegate class at Runtime in activiti engine ?
yes.
e.g. create delegate class which invokes execute method on another class through reflection API.

Regards
Martin

kanchan
Champ in-the-making
Champ in-the-making
Hi Martin,

Which reflection APIs you are talking about ? I couldn't find it in user guide. Would you please elaborate more ?

Quote:
"
create delegate class which invokes execute method on another class
"
Do you mean I have to invoke execute method of dynamic delegate class through execute method of static delegate class ?
e.g. :
Suppose there are two delegate classes T1 and T2, out of which I want to associate T2 class at runtime. As per your suggestion I have to call it like,
serviceTask id="servicetask3" name="Service Task" activiti:class="T1"></serviceTask>

public class T1 implements JavaDelegate {

public void execute(DelegateExecution execution) throws Exception {
  T2=new T2();
                T2.execute(execution);
}
}

Something like this?
Please correct me if I'm wrong.

Thanks,
Kanchan

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,
Which reflection APIs you are talking about ?
http://docs.oracle.com/javase/tutorial/reflect/

something like:

public class T1 implements JavaDelegate {

  Expression t2Expression; //get/setters

public void execute(DelegateExecution execution) throws Exception {
  JavaDelegate t2 = (JavaDelegate) t2Expression.getValue(execution); // here you  can use reflection API instead
t2.execute(execution);
}
}

Another possibility is to use scripts.

Regards
Martin

kanchan
Champ in-the-making
Champ in-the-making
Hi Martin,

Something like this,

Class t2=Class.forName("MultithreadServiceTask2");

??

Thanks,
KAnchan

martin_grofcik
Confirmed Champ
Confirmed Champ
Yes,
It could be one possibility.

I would prefer Scripts or Expression instead.

Regards
Martin