I guess one of the ways you can handle it via
a) Create a CustomHttpServletRequestWrapper (serializable class) that implements
HttpServletRequest.
b) Before you insert this wrapper class in drools session through your POJO, pass
the values you need from your actual request object like - parameter map , attribute map
(make sure attributes are serializable) through constructor to the wrapper class- and
provide the implementation of only those methods that you will need in service or the ones
that are related to parameter map /attributes such as
i.
getAttribute<http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servl...
name)
ii.
getAttributeNames<http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/...
iii.
getParameter<http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servl...
name)
iv.
getParameterMap<http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/se...
v.
getParameterNames<http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/...
vi.
getParameterValues<http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax...
name)
vii.
removeAttribute<http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/se...
name)
viii.
setAttribute<http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servl...
name, java.lang.Object o)
c) Either leave all other methods as empty or throw
java.lang.UnsupportedOperationException
I hope there is not too much of dependency on request object in your service class.
________________________________
From: Pardeep.Ruhil(a)lntinfotech.com [mailto:Pardeep.Ruhil@lntinfotech.com]
Sent: Thursday, November 19, 2009 1:35 AM
To: Vijay K Pandey
Cc: kris.verlaenen(a)cs.kuleuven.be; rules-users(a)lists.jboss.org
Subject: RE: [rules-users] Drools Flow :Persistence Problem : Restore
StatefulKnowledgeSession from database
Hi, Vijay,
I am not doing this to store request object.
loadSession.insert(request);
What I am doing is I created a pojo class having setter and getter method of
HttpServletRequest and some other class objects and declare this(request) as transient.
So because of that this will not get store into the database and rest of the variables of
pojo class gets way into the database.
What you are telling to take the request map and insert that , I have done that part.
But I have a service written in my project which takes request object as a parameter ,
which I have called in the ActionWorkItemHandler (custom Action Work Item made to execute
my service).
Now inside the exceute(WorkITem workItem, WorkItemManager manager) method of
ActionWorkItemHandler when I am trying to
retrieve the request object after loading session from the database.
I am getting it as null, which is obvious as it was not stored in the database.
So I just want to know if I have a non serilizable object , how can I pass that into the
process and use this in a custom ActionWorkItemHandler.
Please let me know if you understand what I am saying.
Thanks & Regards
Pardeep Ruhil
L&T Infotech Ltd
Mumbai
Ph: +919820283884
Larsen & Toubro Infotech Ltd.
www.Lntinfotech.com<http://www.lntinfotech.com/>
This Document is classified as:
L&T Infotech Proprietary L&T Infotech Confidential L&T Infotech
Internal Use Only L&T Infotech General Business
This Email may contain confidential or privileged information for the intended recipient
(s) If you are not the intended recipient, please do not use or disseminate the
information, notify the sender and delete it from your system.
Vijay K Pandey <VPandey(a)mdes.ms.gov>
11/19/2009 10:44 AM
To
"Pardeep.Ruhil(a)lntinfotech.com" <Pardeep.Ruhil(a)lntinfotech.com>,
"rules-users(a)lists.jboss.org" <rules-users(a)lists.jboss.org>
cc
"kris.verlaenen(a)cs.kuleuven.be" <kris.verlaenen(a)cs.kuleuven.be>
Subject
RE: [rules-users] Drools Flow :Persistence Problem : Restore StatefulKnowledgeSession from
database
I don't understand what you meant by storing the HttpServletRequest object? With the
default marshalling strategy for JPA in place I don't think you can insert a non
serializable object? How come this piece of code is working fine at your end?
loadSession.insert(request);
Which set of objects are you looking from the request? May be you want to get hold of the
request parameter map -- or create a list of attribute map and insert those instead of
HttpServletRequest object
Am I missing something of what you meant in your email?
________________________________
From: Pardeep.Ruhil(a)lntinfotech.com [mailto:Pardeep.Ruhil@lntinfotech.com]
Sent: Wednesday, November 18, 2009 10:15 PM
To: Vijay K Pandey; rules-users(a)lists.jboss.org
Cc: kris.verlaenen(a)cs.kuleuven.be
Subject: RE: [rules-users] Drools Flow :Persistence Problem : Restore
StatefulKnowledgeSession from database
Hi Vijay,
Thanks for your reply.
The problem is that object that I am inserting it into the session object is NOT
serializable, as you know HttpServletRequest object is not serializable.
So because of this I am not able to store this object into the database.
So that's why I am asking how can i do this if my object is not serilizable.
Thanks & Regards
Pardeep Ruhil
nt (s) If you are not the intended recipient, please do not use or disseminate the
information, notify the sender and delete it from your system.
Vijay K Pandey <VPandey(a)mdes.ms.gov>
11/18/2009 10:56 PM
To
"Pardeep.Ruhil(a)lntinfotech.com" <Pardeep.Ruhil(a)lntinfotech.com>,
"rules-users(a)lists.jboss.org" <rules-users(a)lists.jboss.org>
cc
"kris.verlaenen(a)cs.kuleuven.be" <kris.verlaenen(a)cs.kuleuven.be>
Subject
RE: [rules-users] Drools Flow :Persistence Problem : Restore StatefulKnowledgeSession from
database
You have to load the same 'StatefulKnowledgeSession' in which you have inserted
your objects. The inserted objects are serialized and stored in the column
"rules_byte_array" of the session_info table.
So you have to load the same session - to get to your inserted objects.
There is a difference the way process map objects are handled - such as
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("x", "hello");
parameters.put("y", "hey I am y");
ksession.startProcess( "myprocess", parameters );
In the above case the parameters are not stored as part of the "session info"
table. These are stored separately like in "process instance info" table +
(some/other tables if you use variable persistence strategy)- so if you don't have the
rules which are based on the objects you are inserting - you can get the same done through
process parameters in which case you can get hold of the process instance through any new
session or the same session and then its parameters.
Vijay
________________________________
From: Pardeep.Ruhil(a)lntinfotech.com [mailto:Pardeep.Ruhil@lntinfotech.com]
Sent: Wednesday, November 18, 2009 12:38 AM
To: rules-users(a)lists.jboss.org
Cc: kris.verlaenen(a)cs.kuleuven.be; Vijay K Pandey
Subject: Re: [rules-users] Drools Flow :Persistence Problem : Restore
StatefulKnowledgeSession from database
Hi Kris,
Thanks for you valuable input and Vijay of course clearing some of my doubts by asking
question on this.
Much of my doubt are clear except one.
When we are reloading the StatefulKnowledgeSession from the database using the below line
StatefulKnowledgeSession loadSession= JPAKnowledgeService.loadStatefulKnowledgeSession(id,
kbase, null, env);
This session object is different from the one that is created when we first created
StatefulknowledgeSession object using
StatefulKnowledgeSession initialSession=
JPAKnowledgeService.newStatefulKnowledgeSession(kbase, null, env);
Am I right ?
Now In my case I have a HumanWorkItemHandler class for handling the humantask and there is
ActionWorkITemHandler for my customAction workItem, which both are initailsed with the
initialSession object.
Now when I load the session from the database to complete the HumanWorkItemHandler task I
got a different session object i.e. loadSession.
Now when I insert something in the loadsession using loadSession.insert(request); So that
I can use the same in ActionWorkItemHandler to exceute the action for the request.
I am not able to retrieve the same request object i.e. (HttpServletRequest) from the
session in ActionWorkItemHandler
as when i do
Collection obj = loadSession.getObject();
I get request as null. Because this loadSession is different from the one I have
inserted.
Kindly help in this, or I have misunderstood the concept.
Thanks & Regards
Pardeep Ruhil
Kris Verlaenen <kris.verlaenen(a)cs.kuleuven.be>
11/17/2009 04:17 PM
To
Rules Users List <rules-users(a)lists.jboss.org>, Vijay K Pandey
<VPandey(a)mdes.ms.gov>
cc
"Pardeep.Ruhil(a)lntinfotech.com" <Pardeep.Ruhil(a)lntinfotech.com>
Subject
Re: [rules-users] Drools Flow :Persistence Problem : Restore StatefulKnowledgeSession from
database
Preferably you should cache the session itself as well (so you don't
have to recreate it all the time) and reuse that across you application.
Or you could have multiple independent sessions as well. If you store
the key of the session somewhere, you can easily restore this session
(or sessions) after failure.
Kris
Quoting Vijay K Pandey <VPandey(a)mdes.ms.gov>:
Let's say where we don't need timers - in those cases one can
create
(create only if its not there) a global session (create the
sessioninfo at the drools startup - store the session primary key
somewhere) - reuse this session across everywhere?
Vijay
-----Original Message-----
From: rules-users-bounces(a)lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Kris
Verlaenen
Sent: Monday, November 16, 2009 5:12 PM
To: Rules Users List; Pardeep.Ruhil(a)lntinfotech.com
Subject: Re: [rules-users] Drools Flow :Persistence Problem : Restore
StatefulKnowledgeSession from database
Pardeep,
The behavior you are describing is indeed correct. The session in
this
case is a global session, meaning that it will be used for all
process
instances. Note however that, unless you are using timers, all
other
state (process instance state, work items, etc.) is persisted
separately
and the session state will basically be empty.
It is also possible to have one session per process instance (or
whatever partitioning you like). A session has a unique id (which
you
can specify when reloading the session). You'll then have to load
the
right session before continuing the execution of your process
instance.
Kris
Quoting Pardeep.Ruhil(a)lntinfotech.com:
> Hi Salaboy,
> Thanks for you replying.
> Yes, of course it is storing multiple process instance Id in the
> database.
> But, what I feel is that it will fail when I am trying to run two
> workflow
> at the same time simultaneously, using the same code by
dynamically
> providing the workflow name and the parameters for each of them.
> Ideally there should be two entries for the
StatfulKnowledgeSession
> object
> because when I try to load the StatefulKnowledgeSession object
from
> the
> database it will give me the session object of the workflow which
is
> last
> executed.
>
> For example lets suppose I have two workflow 1 and 2 having two
> humantask
> in each of them . So when I finish the first Human Task of both
> workflow
> one by one. SessionInfo present in the database is of workflow 2
> (if 2
> is executed last). Because there is no field in the sessioninfo
> entity of
> the database regarding to which workflow it belongs to. Am I right
?
> So when I try to finish the 1st workflow by executing the 2nd
> humantask
> left in it , I need to reload the StatfulKnowledgeSession object
from
> the
> database. As there is no way of distinguishing that the session
> object
> store in the database is of which workflow , there might be a
problem
> as I
> may get the ksession object of 2nd workflow.
>
> In case of Process Instance it is fine , because there is a field
> 'processId' which will distinguish which processInstanceId belongs
to
>
> which worklowId or processId.
> But in case of Session , there is noting as such.
> I don't what I am saying is handled in drools persistence. Please
let
> me
> know if it there or not.
>
> Thanks & Regards
>
> Pardeep Ruhil
>
>
>
______________________________________________________________________
Disclaimer:
http://www.kuleuven.be/cwis/email_disclaimer.htm
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
Disclaimer:
http://www.kuleuven.be/cwis/email_disclaimer.htm
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________