You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Vikrant Sharma <xb...@yahoo.com> on 2006/06/30 14:40:21 UTC

How can we pass objects created in one beanshell sampler to another

Hi all,

Question on beanshell sampler -

How can we pass objects created in one beanshell sampler to another. 
I have two beanshells in my script.
I created an object in first beanshell and want to invoke the methods on the same object in the second beanshell. 

Is there a way we can pass the object created in one beanshell to another  beanshell.

Please let me know if the problem is not clear. will add some more details...

Any help is greatly appreciated...

Thanks  & Regards
Vikrant 

 		
---------------------------------
Do you Yahoo!?
 Next-gen email? Have it all with the  all-new Yahoo! Mail Beta.

Re: How can we pass objects created in one beanshell sampler to another

Posted by sebb <se...@gmail.com>.
It should be possible to pass objects between sampler in the same
thread using JMeter variables.

However, JMeter variables can only be strings when using get() and put().

You need to use putObject() and getObject() to work with other classes.

e.g.

vars.putObject("date",new Date()):
...
vars.getObject("date");


On 30/06/06, Vikrant Sharma <xb...@yahoo.com> wrote:
> Hi Vitalie,
>
> Thanks for the reply.
>
> When i try to store the object into a variable (in first beanshell) using vars.put("varname", "value"); method, it does not complain about anything.
> But when I get it (in second beanshell) using vars.get("varname") method and try to cast it, it throws error.
> Further  when i dont cast it and try to print it. it just prints the name of that object as a normal String. SO I think when we set the object in the variable it is just set as a normal String and not as an object instance.
>
> For the second solution, yes i can serialize the object but as this is the performance script, storing and loading object's state will incur some more cost.
>
> Thanks & Regards
> Vikrant
>
> Vitalie Valache <Vi...@bnm.org> wrote: just some ideas..
> - maybe you can declare a global variable assign the object value to it and use it by casting in the second beanshell, not sure if jmeter variable can store objects but why not!
>
> or
> - save object  to a file using serialization if your object is supporting and load it from your second beanshell.
>
>
> --
> DISCLAIMER:
> Any e-mail messages from the National Bank of Moldova are sent in good faith, but shall not be binding nor construed as constituting any obligation on the part of the Bank.
> The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. If you received this in error, please contact the sender and delete the material from any computer.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>
>
>
> ---------------------------------
> Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2¢/min or less.
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: How can we pass objects created in one beanshell sampler to another

Posted by Vikrant Sharma <xb...@yahoo.com>.
Hi Vitalie,

Thanks for the reply. 

When i try to store the object into a variable (in first beanshell) using vars.put("varname", "value"); method, it does not complain about anything. 
But when I get it (in second beanshell) using vars.get("varname") method and try to cast it, it throws error. 
Further  when i dont cast it and try to print it. it just prints the name of that object as a normal String. SO I think when we set the object in the variable it is just set as a normal String and not as an object instance.

For the second solution, yes i can serialize the object but as this is the performance script, storing and loading object's state will incur some more cost.

Thanks & Regards
Vikrant

Vitalie Valache <Vi...@bnm.org> wrote: just some ideas..
- maybe you can declare a global variable assign the object value to it and use it by casting in the second beanshell, not sure if jmeter variable can store objects but why not!

or
- save object  to a file using serialization if your object is supporting and load it from your second beanshell.


-- 
DISCLAIMER:
Any e-mail messages from the National Bank of Moldova are sent in good faith, but shall not be binding nor construed as constituting any obligation on the part of the Bank.
The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. If you received this in error, please contact the sender and delete the material from any computer.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org



 		
---------------------------------
Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2¢/min or less.

Re: How can we pass objects created in one beanshell sampler to another

Posted by Vitalie Valache <Vi...@bnm.org>.
just some ideas..
- maybe you can declare a global variable assign the object value to it and use it by casting in the second beanshell, not sure if jmeter variable can store objects but why not!

or
- save object  to a file using serialization if your object is supporting and load it from your second beanshell.


-- 
DISCLAIMER:
Any e-mail messages from the National Bank of Moldova are sent in good faith, but shall not be binding nor construed as constituting any obligation on the part of the Bank.
The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. If you received this in error, please contact the sender and delete the material from any computer.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org