-
1. Re: getting node Class type when getting process definition
gregoiredx Jul 6, 2006 8:46 AM (in response to gregoiredx)Sorry I did post before finishing...
Hello,
I'm testing jBPM and it really is a good product.
But I'm stuck with a problem when trying to identify node "real" Class type when the process definition is retrieve from datablase.
More practicallly :
JbpmContext jbpmContext = JbpmConfiguration.getInstance().createJbpmContext();
try {
ProcessInstance processInstance = jbpmContext.loadProcessInstanceForUpdate(processInstanceId);
processInstance.getRootToken().getNode().getClass();
<= this always has org.jbpm.graph.def.Node$$EnhancerByCGLIB$$a35a6dd8 as value
How could I get the real type (TaskNode, StartState,...)?
(without using the xml definition)
thank you -
2. Re: getting node Class type when getting process definition
tom.baeyens Jul 6, 2006 10:43 AM (in response to gregoiredx)just a thought:
Class clazz = processInstance.getRootToken().getNode().getClass(); if (clazz.getName().startsWith(clazz.getSuperClass().getName()) { clazz = clazz.getSuperClass(); }
another idea might beObject o = processInstance.getRootToken().getNode(); if (o.getClass()==o.getClass().getSuperClass()) { // it must be a proxy }
-
3. Re: getting node Class type when getting process definition
tom.baeyens Jul 6, 2006 10:45 AM (in response to gregoiredx)forget the last one... it's a wrong combination of constructs i used once to implement the equals method of proxyable objects.
-
4. Re: getting node Class type when getting process definition
msynovic Jul 6, 2006 10:48 AM (in response to gregoiredx)I asked the same question a week ago and didn't get a response. So as far as I know the API doesn't expose this information. The only way we've been able to get that information is to use Hibernate getClass method.
Exampleif( Hibernate.getClass(processInstance.getRootToken().getNode()).equals(State.class)) { ... }
-
5. Re: getting node Class type when getting process definition
gregoiredx Jul 10, 2006 4:47 AM (in response to gregoiredx)thank you, this work just fine.
-
6. Re: getting node Class type when getting process definition
faizal.rashid Jul 25, 2006 3:05 AM (in response to gregoiredx)this help. but it still not allow me to cast it to the real object. so after looking around, this is the solution that i found :
if (node instanceof HibernateProxy) { node = (Node) ((HibernateProxy) node).getHibernateLazyInitializer() .getImplementation(); }
then i can do something like :if (node instanceof TaskNode) { taskNode = (TaskNode) node; }