-
1. Re: How to get the jbpm context ?
cocampo Dec 14, 2006 10:25 AM (in response to yegaofei888)I believe that, once you get a JbpmConfiguration instance and after you created a context with that instance, you can actually use getCurrentJbpmContext.
Test this code:JbpmConfiguration config = JbpmConfiguration.getInstance(); JbpmContext context = config.createJbpmContext(); assertEquals(context, config.getCurrentJbpmContext());
Let me know if that works for you.
Regards. -
2. Re: How to get the jbpm context ?
yegaofei888 Dec 18, 2006 12:07 AM (in response to yegaofei888)Hi cocampo,
I mean if theJbpmContext.getCurrentJbpmContext()
will work -
3. Re: How to get the jbpm context ?
cpob Dec 18, 2006 10:28 AM (in response to yegaofei888)You have to create the jbpm context first with
JbpmConfiguration.getInstance().createJbpmContext();
before you can get the current. Once you have created it, then you can get the current withJbpmContext.getCurrentJbpmContext()
You've got to create something before you can get the current instance of it :) -
4. Re: How to get the jbpm context ?
yangdaolin Dec 18, 2006 7:46 PM (in response to yegaofei888)JbpmContext.getCurrentJbpmContext() is thread safe.
When you call context object with:JbpmConfiguration.getInstance().createJbpmContext();
You can get context object in current Thread only. -
5. Re: How to get the jbpm context ?
yegaofei888 Dec 19, 2006 8:04 AM (in response to yegaofei888)Thank you !
Now I change the code UserBean.java like this:public class UserBean { String userName; static{ JbpmConfiguration.getInstance().createJbpmContext(); } ......... public String login() { JbpmContext.getCurrentJbpmContext().setActorId(userName); return "home"; } public List getUsers() { Session session = JbpmContext.getCurrentJbpmContext().getSession(); IdentitySession identitySession = new IdentitySession(session); return identitySession.getUsers(); } ..............
I am not sure if this code will work fine when muilt users login at the same time -
6. Re: How to get the jbpm context ?
yegaofei888 Dec 19, 2006 8:07 AM (in response to yegaofei888)Sorry, I shall not put the code createing jbpm instantce into static block.
I move it to constructorpublic UserBean(){ JbpmConfiguration.getInstance().createJbpmContext(); }
-
7. Re: How to get the jbpm context ?
yegaofei888 Dec 19, 2006 8:17 AM (in response to yegaofei888)Hi all,
My question is that in HomeBean.java, how to get the jbpm context, which was created in UserBean?
As in UserBean.java, it set the actorId, so I have to get the same jbpm context, and then I can get the same actor Id, not null value.
Shall I put this actor Id into portlet session, not jbpm context ? -
8. Re: How to get the jbpm context ?
yangdaolin Dec 19, 2006 9:07 AM (in response to yegaofei888)If you can make sure that you use the HomeBean only in a thread, your codes is safe, otherwise you can't get current JbpmContext. you should put these into your porlet session. I want to know when you close JbpmContext.
-
9. Re: How to get the jbpm context ?
morpheus_jboss Feb 8, 2007 10:12 AM (in response to yegaofei888)"yegaofei888@sohu.com" wrote:
I am converting the jbpm websales to jportal portlet.
Hi, I am doing the same thing. I am insterested in the questions asked here in this thread before. Namely, ActorId in portlet session or JbpmContext?
More generally, I know the portlet context is an extension of servlet context. but what is their relation to the jbpmContext if the jbpm Webapp is deployed as a portlet?