Application Scope Objects and Multithreading

I will be creating a set of interlinking objects in application scope that are intended for read only. The objects will be accessed every time a user makes a request to the servlet which will be on every link of the site since the servlet is a controller.
I am pretty sure that there are no concurrency issues here - that all requests will be able to access the objects quickly. Can someone confirm this for me.

As long as the threads only read information from the objects and do not update them then you should be ok.

Similar Messages

  • Is Weblogic Cluster  supports Application scope Objects?

              Our Application is mainly depends on Application scope objects. On one m/c, it
              is perfect.
              Now, we want to support the failover , load balancing ... (High Availability).
              I know, weblogic cluster supports HttpSessions, EjbObjects ... etc. What about
              Application scope objects.
              we are planning for weblogic server which supports the our requirements.
              If not, what is the solution to make it work by using Weblogic server.
              for eg: I can give what type of application we are developing --- similar to
              textchat.
              our application is real time application.
              

    Even a singleton is not good enough as singletons are good only in the VM they were
              created it. One way is to have a distributed object such as a stateful session bean of
              which only one instance exists. U can create it at startup and store its handle in
              some persistent storage as well as a singleton. This ensures that even if the
              singleton doesnt contain it the refgerence to it can be obtained.
              There will be some problems with this setup as people should not allow it to create
              instances of it . Any such endeavor will lead to a CacheFullException.
              But essentially that seems possible.
              Even the 2.3 Servlet specification mandates that ServletContext and Application level
              object is only valid inside the JVM which created it. HttpSessions are replicated
              SessionContexts are not and are not likely to be in any J2EE application server
              Sameer
              Devi wrote:
              > One more comment from my side,
              > U mentioned "EXCEPT FOR JNDI" , if this is possible, how can we acheive?
              > Can U give brief description ? Take textchat example itself? since, our application
              > is almost have same mechanism. If it is < 1 sec delay means acceptable for this
              > release.
              >
              > Thanks,
              > Devi
              >
              > "Cameron Purdy" <[email protected]> wrote:
              > >Weblogic doesn't support replicated / synchronized app scope objects
              > >across
              > >a cluster except for JNDI, which is probably not a good solution for
              > >what
              > >you are describing.
              > >
              > >If you need a real-time shared fault-tolerant fail-overable high-performance
              > >load-balanced high-scale data store, then let me know when you find one
              > >;-)
              > >.... seriously, there are not a whole lot of good general purpose solutions
              > >in this space. There are some things to look at but they are all expensive:
              > >
              > >Persistent PowerTier on top of Oracle - a caching entity EJB server
              > >Jasmine (or whatever it is called this week) - an object oriented
              > >distributed data store
              > >....
              > >
              > >Peace,
              > >
              > >--
              > >Cameron Purdy
              > >Tangosol Inc.
              > ><< Tangosol Server: How Weblogic applications are customized >>
              > ><< Download now from http://www.tangosol.com/download.jsp >>
              > >
              > >
              > >"Devi" <[email protected]> wrote in message
              > >news:[email protected]...
              > >>
              > >> Our Application is mainly depends on Application scope objects. On
              > >one
              > >m/c, it
              > >> is perfect.
              > >> Now, we want to support the failover , load balancing ... (High
              > >Availability).
              > >>
              > >> I know, weblogic cluster supports HttpSessions, EjbObjects ... etc.
              > > What
              > >about
              > >> Application scope objects.
              > >> we are planning for weblogic server which supports the our requirements.
              > >>
              > >> If not, what is the solution to make it work by using Weblogic server.
              > >> for eg: I can give what type of application we are developing ---
              > >similar to
              > >> textchat.
              > >> our application is real time application.
              > >>
              > >
              > >
              

  • Application scope objects(opinions wanted)

    Hi All
    Looking for educated opinions on the pros/cons of application scope objects. I am thinking about creating a read-only application scope hashmap representation of some static data in my database. When queried at the database level it can cause relatively long delays (3-4 seconds) and sometimes must be stored in many sessions on the server. I am thinking just one read-only object stored at app scope will cut down on the waste of memory, as well as skyrocket the speed of retrieving this data.
    Please give me your opinions!!! I can tell you a little more about the app if you need more info to make an educated statement...
    Thanks
    Greg B

    You can use the Properties Object for static data that can be persisted on a filesystem. Also, I assume that you can hold quite a bit of data too. A file read should be faster than a database query. Also if you do the connect once and save the connection for several reads, that works too. The only real slow operation, outside of large resultsets, would be the initial connect.
    I always design up two or three possible solutions and sometimes I protpotype each one. Sometimes one of the tests will prove to be the exact opposite choice of the one you thought would work.
    Now that I have written your response, I think that you could create a custom class to hold data, but would that not just be a copy of the properties object. If it's key/value you need, that's the choice.
    Stand back and ask, "What is the data type of the high level objects?"
    Also, SUN has good articles on almost everything in the JDK.
    David Whitehurst
    [email protected]

  • Singleton vs ServletContext for storing application scope objects

    Hi all,
    I would like to share some bean objects between all sessions inside the same web application, i.e. all users should access the same beans.
    Which is the best way, to store the beans, use a singleton ore put them into the ServletContent vs get/setAttribute?
    How about large objects, are there any limitations?
    Thanks
    Mert
    Edited by: mahmut1 on Oct 22, 2009 3:32 AM

    I must confess I am a heretic. I would use a singleton. I try to use as few servlet services as possible when working with servlets; that way the code has a fighting chance of being reusable outside the servlet system.
    As to "singletons are evil": well, if we are talking about ServletContext.setAttribute(), that is a singleton. It is a singleton hash table. The difference between the attribute hash table and a hash table singleton you write yourself is with attributes you don't automatically see the source code that defines the singleton, so you get to pretend you are not using a singleton.
        protected Hashtable myAttributes;Haha! There, I just showed how the singleton hash table is implemented in a popular web server!

  • Application implicit object - undefined Variable!!??

              Hi!
              Is anybody able to access
              the "application" implicit object and
              the "pageContext" implicit object from
              a jspInit() method when an application is deployed as a War file?
              Thanks.
              

    what is an application implicit Object ?

  • Objects of application scope and clustering.

              I understand that weblogic 6.1 replicates session data to a secondary server in a
              cluster. This replication should include objects declared with <jsp:useBean ...
              scope="session"/> as well as objects that are explicitly maintained in the session
              with setAttribute().
              However, what about objects with application scope? Are they replicated to a secondary
              server when a cluster is in use?
              Thanks,
              -Dave.
              

    David Vazquez <[email protected]> wrote:
              > I understand that weblogic 6.1 replicates session data to a secondary server in a
              > cluster. This replication should include objects declared with <jsp:useBean ...
              > scope="session"/> as well as objects that are explicitly maintained in the session
              > with setAttribute().
              > However, what about objects with application scope? Are they replicated to a secondary
              > server when a cluster is in use?
              No, they are not replicated in the cluster. To implement replication you can use JavaGroups:
              http://sourceforge.net/projects/javagroups/ or Cameron's Coherence product:
              http://www.tangosol.com/products-clustering.jsp for example.
              > Thanks,
              > -Dave.
              Dimitri
              

  • Locking when using a component as an object in the application scope...

    I have a component that I am building right now that hold
    application settings that are stored in a database table. The
    settings are maintained in a structure "variables.settings" within
    the component and can only be accessed by get and set methods. I
    use the following to create the instance of the object:
    <cfset application.settings =
    createObject("settings","component").init() />
    Now when getting a setting I do not think locking is needed
    as its just reading the value and I am not really concerned with a
    race condition...
    But when using the set method which will update the value of
    the setting.... should I be locking that as technically the object
    is in a shared variable scope? Or is it safe because its within the
    cfc/object?
    If locking is needed, would I need to lock when using the set
    method? or can I just build the lock into the set method so that
    its always there?

    To disagree with craigkaminsky, I think you only need to lock
    if you are
    concerned about race conditions and what could happen during
    a 'dirty
    read' and|or conflicting writes.
    A lot of developers have an old impression of ColdFusion that
    one *must*
    lock all shared scope variable access to maintain a stable
    application.
    This dates from the ColdFusion 4.5 days where there where
    bugs in
    ColdFusion that could cause memory leaks and eventual
    application
    instability if one did not lock shared scope reads and
    writes. This has
    long been fixed, but the advice persists.
    So now it is only a matter of your data and what would happen
    if one
    user read an old value while it was in the process of being
    updated by
    another user. Or could two users be updating the same value
    at the same
    time and cause conflict. If either of those two statements
    are true,
    then yes you should use locking as required by your
    application.
    But if they are both false and it does not matter that user A
    might get
    the old value microseconds before user B changes it. Or there
    is no
    concern with user A changing it once and user B changing it
    again to
    something different moments later without knowing the user A
    has already
    changed it. Then locking is probably unnecessary.
    There can be a cost to over locking shared variable writes
    and|or reads.
    Every time one creates a lock, one is single threading some
    portion of
    ones code. Depending on how the locking is done, this single
    threading
    may only apply to individual users or it may apply to every
    single user
    on the entire server. Either way, too much of this in the
    wrong places
    can create a significant bottle necks in ones application if
    too many
    user requests start piling up waiting for their turn through
    the locked
    block of code.

  • Component in Application Scope and cflock

    Hi,
    I have an CFC that I set in application scope in the
    onApplicationStart method which contains some system parameters,
    one of which is a flag saying whether the site is currently
    "Online". I call a method on this CFC in the Application.cfc
    "onRequest" method to see if the flag value has changed.
    This method looks up a parameter set in the database that
    says whether the site is "online" or "offline". If the site is
    currently online, I want to only redo the query every 5 mins.
    However if the site is offline, I want to check more frequently
    (every 5 secs) as to whether the flag has changed back.
    What I am not sure of, is whether I need to be using
    <cflock> when I change from "online" to "offline"? There is
    only a single instance of this object, but what happens if multiple
    requests are calling the "isSiteOnline" method simultaneously? Is
    this "safe"?
    Some code snippets are attached to illustrate.
    Any advice would be greatly appreciated.
    Regards,
    Andrew.

    > <!--- DO I NEED TO USE CFLOCK HERE???? --->
    No, in either situation.
    Ask yourself... what would the ramifications be of two
    requests hitting
    that line of code "simultaneously"? The end result is that
    both of them
    are setting the variable to the same static value... so
    that's what's going
    to end up happening: variables.instance.cacheInterval is
    going to be set to
    300 (or 5) in each situation.
    You could well with to lock a block of code which - if called
    simultaneously via more than one request - could act on
    shared storage
    space (server, application or session data) differently and
    incorrectly
    than is intended.
    eg:
    <!--- application bootstrap process --->
    <cfif not structKeyExists(application, isInitialised and
    not
    application.isInitialised>
    <!--- initialisation process, whatever it is --->
    <cfif allOK>
    <cfset application.isInitialised = true>
    <cfelse>
    <cfset application.isInitialised = false>
    </cfif>
    </cfif>
    So a sequence of events could be (say the user is hitting the
    site with two
    different browsers):
    REQUEST1: application.isInitialised doesn't exist
    REQUEST1: starts the init process
    REQUEST2: application.isInitialised STILL doesn't exist
    REQUEST2: starts the init process *again*
    REQUEST1: sets the application.isInitialised value
    REQUEST2: sets the application.isInitialised value
    Obviously one does not want two request running the
    initialisation code.
    note this is a slightly contrived example, as if one has an
    OnApplicationStart() method, then it will only run once, and
    that's where
    one would have the init code, but it demonstrates the issue.
    Google "race condition". Those are the situations in which
    one needs to
    lock blocks of code.
    Adam

  • What are the pros and cons of storing heavely used CFCs in the application scope?

    I've been storing all the required CFCs for a site in the application scope. During onApplicationStart I do something like this application.objSomeCfc =CreateObject('component', 'com.someCfc').init().
    Here is my reasoning.
    Get the CFCs initialized once and stored in memory for better performance.
    Using CreateObject several times on each page load can have a negative impact on performance.
    Having one place to create application scoped CFCs makes it easier to manage code.
    So is my thinking flawed? Are there any additional pros or cons for dealing with CFCs? Is there any docs, articles, blogs, videos, frameworks, ...... that I should check that may change my perspective on how I'm doing this?
    Thanks

    Your approach is fine, depending on how many and what type of CFCs you are talking about. If they are "singletons" - that is, only one instance of each CFC is needed to be in memory and can be reused/shared from multiple parts of your application - caching them in the application scope is common.  Just make sure they are thread safe ("var" or local.* all your method variables).
    You might consider taking advantage of a dependency injection framework, such as DI/1 (part of the FW/1 MVC framework), ColdSpring, or WireBox (a module of the ColdBox platform that can be used independently).  They have mechanisms for handling and caching singletons.  Then you wouldn't have to go to the application scope to get your CFC instances.
    -Carl V.

  • Create Object and Subject for Application Log

    Hello Experts,
    Could anyone tell me how to create the Z Object and subobject for the Application Log.
    ie) <b>BALOBJ_D & BALSUBOBJ</b>
    Could you please tell me the Tcode for that.
    Since I have to save the application in the new object so that it can be displayed using this Key.
    Thanks & Regards,
    Vasanth

    Hello Vasanth
    The transaction is SLG0 (Object Maintenance).
    Regards
       Uwe

  • I tRounding the Total Scores for Objectives and Competencies in Application

    Hello
    Where does one change the format of the total scores for the Overall Ratings and Comments - Objectives and Competencies in the front end /application?
    Currently the total scores are in the format Objectives: Total Score 3.375
    Competencies Total Score 2.69230769230769
    HR want to show the Total Scores as rounded to 2 decimal places in the application so 3.375 becomes 3.38 and
    2.69230769230769 becomes 2.70
    Now i know how to do this in Toad using a select on the TOTAL_SCORE column in the hr.per_assessments table, but this is not i want to do here. Here i want to change the format in the FRONT END, not in the back end.
    I tried the fast formulas but they dont seem to work unless i am missing something
    Edited by: iandekoker on Apr 2, 2009 2:53 PM

    in case anyone wondered you use the package called apps.hr_appraisals_util_ss. Inside the package you can add round(,2) to obtain the result

  • Data objects and code objects in oracle application

    Hi,
    can any one please help me out with following question?
    1. what are data objects and code objects in oracle apps and why is that difference?
    2. How does the objects gets created in Oracle Applications, like during the installation which part is responsible for creating objects and after the installtion later point of time, how the new objects gets created in oracle applications?
    3. what are the ways to find out if my 11i application is OATM enabled ?
    Thanks in advance

    Hello,
    I managed to find answer for question 1, yet to find answer for 2 and 3.
    Answer for question 1 --
    Data objects : store and access business data (tables, indexes, sequences, index-organized tables, etc);
    Code objects : process data objects but them don't contains business data (functions, procedures, packages, views, synonyms);
    Now, here i have a question - under which objects queues are considered ?

  • SAP Cloud Application Studio Create Custom Web Service From Custom Business Object and Consume in External System

    Hi Experts,
    I have requirement to create custom business object and create Web Service for that and use in external system (SAP ECC / SAP CRM / Third Party).
    1) Is it possible to create custom object web service and used in external system ?
    2) When we create the Web service from custom business object what the necessary steps(action : Create , Read , Update) require?
    3) Sample Scenario :
    My Custom Business Object
    businessobject Custom_Integration {
      element EP_VAL1 : LANGUAGEINDEPENDENT_MEDIUM_Text;
      element EP_VAL2 : LANGUAGEINDEPENDENT_MEDIUM_Text;
      element IP_RES : LANGUAGEINDEPENDENT_MEDIUM_Text;
    I have created the Web Service using this custom business object.
    3) How i can use this web service in external system? what are the prerequisite steps in external system to consume this service in it?
    Please anyone have idea about this how to do this and how to achieve this using SDK and custom business object.
    Many Thanks
    Mithun

    Hello Mithun,
    Does this section in the documentation help you:
    SAP Cloud Applications Studio Help -> Developers Desktop -> Web Services
    The entry "Task -> Create a Web Service" describes how to create a Web Service on your own BO
    The entry "Task -> Test a Web Service" helps you how you can use it in a foreign tool / application.
    HTH,
       Horst

  • Query on using Collection object in Multithreading

    All,
    I have a query on multithreading, I have a collection object-eg. HashMap which needs to be shared
    among threads, I my have 3 options
    1st option is to synchronize the method which does some manipulation on the collection object,
    2nd option is to hold a lock on that object like
    synchronized(object){
    //do some work
    3rd option - to make use of class ConcurrentHashMap available in java.util.concurrent package; which claims to be
    Thread safe but also says the following in the API - They do not throw ConcurrentModificationException. However,
    iterators are designed to be used by only one thread at a time
    My queston is - how do I choose between these 3?
    I know the decison needs to be taken by keeping performance issue in mind and also the number of times the values in HashMap will be updated by the threads. Can some one explain to me when/under what circumstances do I use options 1 || 2 || 3

    My application has actually gone live now - after doing some load/performance testing
    and comming to the conclusion that performance is satisfactory [I am designing a SMS gateway
    that receives/buffers/stores/sends SMS]
    Initially I used Hashmap and a LinkedList to store objects in memory and I had a mixture
    of places where some times I made the entire method that modifies the LinkedList & hashmap
    synchronized and some places where I held a lock on the object alone (I wasnt too sure which to use where)
    Then upon movin to 1.5 I rechanged the the data structure to use ConcurrentLinkedQueue & ConcurrenthashMap.
    But i have places where I still hold synchronized locks over those objects (which i think is unnecessary and removing the locks may improve the performance)
    So can i come to the conclusion that classes in java.util.concurrent are all threadsafe and we can stop holding locks on the objects and let java take care of itself [or should I still hold a lock when doing structural modification] [though the APi states that a oncurrentmodificationexception will not be thrown & iterators are designed to be used by only one thread at a time]

  • Destroy in JavaBean with application scope?

    Hi,
    I am using a java bean in my jsp application with scope "application". I know that this java bean will be terminated only when the server stops or shuts down (Apache Tomcat 5.5).
    I need to cleanup something manually when the server shuts down. Can anyone tell me what method will be called, or that I can override, to clean up?
    I tried finalize and valueUnbound (implements HttpSessionBindingListener) with no luck... I just can't find a equivalent to destroy in Servlets (I can't use servlets, must use javabeans+jsp)...
    Any sugestion?
    thanks in advance for your time

    There is an indirect way if you know servlets. The "application" implicit object that you use in your JSP is the javax.servlet.ServletContext object. Instead of declaring your bean using the jsp:useBean tag, directly put your objects into the ServletContext using ServletContext.putAttribute() method. Objects put in the ServletCOntext are available to all pages in the application. Just use the ServletContext.getAttribute() method to retrieve this bean in any other page.
    To "kill the bean", just reset the value of this object to null by calling putAttribute(null).

Maybe you are looking for

  • Batch input problem in SM35

    Dear all, I am uploading the bank statements using manual bank statements through Z transaction, Once uploaded system is generating the batch input session for the same. When i run the batch input session system not clearing outgoing payment automati

  • Flash Builder 4 profiler doesn't seem to work with Flash Player 10.0

    Hi, I've been trying to get the profiler to work with Flash Builder 4, but when trying to profile on Flash Player 10.1, 11 or 11.1, Flash Builder doesn't connect to the profiled SWF. Changing my Flash Player to an old, debug version of 10.0.45 works

  • Cant get my wifi working on ipad?

    had my ipad over a year now, been working fine, all of a sudden no wifi? cant find it cant get it back on therefore cant download anything? any help please would be appreciated

  • With holding Tax for Interested paid to bank

    Dear Gurus, User making payment to bank ( which include interest), he want to withheld TDS @22.44% on interest amount. How we can map into SAP. Regards, Venkat

  • Authorization management

    Hi Can anyone detail me about the Authorization management done in t-code PFCG. and Provide me a word, PDF document Cheers Maruthi Ram