cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
100
Views
0
Helpful
0
Comments
cdnadmin
Community Member
This document was generated from CDN thread

Created by: null on 01-03-2006 10:39:03 PM
hi,

I know that there are only one instance of all Audium classes that serve user requests. I want to know if there is any way that I could set my own java object to application scope through Audium? I want to set this object to share data across all sessions.

shahid

Subject: RE: How to set a java object to application scope??
Replied by: Vance Vagell on 01-03-2006 10:55:43 PM
Hi Shahid,

You can share information across sessions of a single Audium application by using member variables in your custom classes. This works for the very reason you mentioned: each class is instantiated just once, and reused for all calls. The member variables act as though they were declared static, since each call accesses the same instance of the class.

Please note that since each request to Audium Call Services is handled in its own thread, thread-safety issues need to be kept in mind while accessing and using member variables. For more information about why we normally do not recommend using member variables in your custom classes, please refer to the following Audium Knowledge Base article:



Should you choose to use member variables for this purpose, we highly recommend that you perform extensive pre-production testing (including load tests) to ensure that your application behaves as expected and is thread-safe.

Regards,
Vance

Subject: RE: How to set a java object to application scope??
Replied by: null on 01-03-2006 11:11:49 PM
thanks a lot.

Subject: RE: How to set a java object to application scope??
Replied by: null on 13-03-2006 03:05:05 PM
How can I use a member class properties to set an element's configuration property? I have a class called A which has a property b of type String. This class is stored as a session object. Can I do something like this {Data.Session.A.b}?

Subject: RE: How to set a java object to application scope??
Replied by: Vance Vagell on 13-03-2006 09:30:29 PM
Hi Shahid,

There are many ways to use values from a custom class to configure the settings of callflow elements. Here are two common solutions:

[b:e279aad351]1) Create a Dynamic Configuration class.[/b:e279aad351]

At runtime, Dynamic Configuration classes configure the element they are assigned to. If the element already has some settings filled-in (these settings are called a base configuration), the settings may either be used as-is or replaced by new values as determined by the Dynamic Configuration class. The new setting values can be drawn from any location, such as a database, file, calculations, or previous caller input.

For more information about Dynamic Configuration classes, please refer to the following Audium Knowledge Base article:



Our Clock tutorial includes a Dynamic Configuration class, with full source code. Additionally, this tutorial includes step-by-step instructions for how to configure an element to use a Dynamic Configuration. You can find this tutorial in the following Audium Support Center post:



Additionally, we have a Java code template available for Dynamic Configuration classes. This template is fully commented, and has the sections you would need to modify clearly marked. It is part of the Audium Java Template Code.zip file which is attached to the following post:



[b:e279aad351]2) Create an Action element that sets the desired variables in element or session data, and reference these variables via substitution.[/b:e279aad351]

In your previous replies, you mentioned that you would like to store values in such a way that they are made available across all calls to an application. If you store these values in member variables of a custom Action element, the element can access these values at runtime, and copy them into the session or element data of a particular call.

Once this is done, the values would be available via substitution, and could be used in any element's configuration or elsewhere in your application. Note that we also have Java code templates available for custom Action elements, they are available in the same post that we mentioned in option 1.

Hope this helps,
Vance

Subject: RE: How to set a java object to application scope??
Replied by: null on 07-04-2006 02:19:33 PM
I have a custom class which extends StartCallInterface that gets called just before a call starts. I have a boolean member that is initially set to true, and when the first call comes in, I am setting this boolean value to false - inside the onStartCall(CallStartAPI) method. When the next call comes in the value is still true. I thought we can share member variables. Is it really true?? Or I am doing something wrong.

  • Shahid -

Subject: RE: How to set a java object to application scope??
Replied by: Vance Vagell on 10-04-2006 03:38:51 PM
Hi Shahid,

Please declare the member variables you wish to share as "static", this
will ensure that they retain their value across all calls to your custom
class. For example, a boolean might be declared as:

private static boolean myFlag;

Regards,
Vance
Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Quick Links