Application scope variables ... an easier way or not ?

Instead of sharing application scope variables through the
          servletContext()/application I am using a normal singleton class (or maybe
          static class) to share all my application varaiable. It works fine and it
          takes a lot less code to write.
          It seamed logical to do this a static classes or singletons are shared
          within a single servletContext/application (which there seems to be only one
          per WL instance anyway). (singleton is quite nice pattern coz. all
          jsp:useBeans with the application scope are by definition singletons)
          Has anoyne tried something similar or maybe know of the problem with this
          approach. I assume that server will never reinitialise application level
          variables ...... hope the assumption is correct. ....
          

When you specify application scope, the JSP stores/retrieves the value
          into/from the servlet context. You may already know this, but it sounded
          like what you thought you were somehow avoiding.
          Cameron Purdy
          http://www.tangosol.com
          "Bohinc D" <[email protected]> wrote in message
          news:[email protected]..
          > Instead of sharing application scope variables through the
          > servletContext()/application I am using a normal singleton class (or maybe
          > static class) to share all my application varaiable. It works fine and it
          > takes a lot less code to write.
          >
          > It seamed logical to do this a static classes or singletons are shared
          > within a single servletContext/application (which there seems to be only
          one
          > per WL instance anyway). (singleton is quite nice pattern coz. all
          > jsp:useBeans with the application scope are by definition singletons)
          >
          > Has anoyne tried something similar or maybe know of the problem with this
          > approach. I assume that server will never reinitialise application level
          > variables ...... hope the assumption is correct. ....
          >
          >
          >
          

Similar Messages

  • Accessing Application Scope from an EJB

    I'm not sure of the best way of doing this:
    The set up:
    We have a rather large J2EE application that is composed of only servlets and JSPs at the moment (When the application began development EJB was in its infancy and not feasible for the development of the app). Some of the new deployments of the app involve distributed webserver over 4 JVMs and 2 machines. When a user connects the servers load balancing decides which particular JVM they should be connected to. We perform large data caching into the servlet application scope to avoid having to access the database every time a change is made by a user to certain tables in our database. The data caches are stored in hashtables in the servlet application scope.We seem to have no way to determine what other JVMs are running or which JVM a user is currently connected to.
    The problem:
    Apparently the application scope is for a particular JVM. This means that when a user makes a change to a data cache the change doesn't effect users in the other 3 JVMs of the application, only the users who, due to load balancing, happened to be connected to the same JVM as the one where the change was made.
    Our possible solution:
    We were thinking that we could set up a queue (such as MQSeries from IBM) and any time a change is made to one of these data caches put a message on the stack saying that the particular table had been updated. Then a MDB would be listening asynchronously and digest the message from the Queue and recache the tables from the database.
    So here are my questions:
    1. Would this work? Would putting a MDB in the EJB Container give each JVM the MDB in the first place, or would this mean it would pick one of the JVMs to deploy the MDB on and still not fix our problem.
    2. If this does work, how do I access the hashtables stored in the Servlet Application scope from the MDB. I can't seem to find any method available to the MDB (or any EJBs for that matter) that can access the servlets Application scope.
    3. Is this the best way to do this? Or is there a better way to share data between seperate JVMs that I don't have a URL to (It's all ambiguous and handled by the server as to which JVM actually gets the connection.)
    Just in case this is needed:
    We are running IBM WebSphere 5 Application Server and the database could be anything from DB2 to Oracle.
    Thanks in advance for any possible help.

    You wont get any api for directly accessing Servlet application objects from any ejb. I dont think MDB either solves your problem directly. Indirectly you can place a request to some servlet (should be there for each JVM and web application ) and update your application scope variable. I would suggest you to cache the data in database if the size of cache is large. otherwise any open caching tools may help you.

  • Is there an easy way to create 2 page imposed PDFs with a background?

    I have figured out a way to create a suitable imposed single page PDF using the 'import as layer' action, the action only understands a single paged background PDF.
    In other words, I have a PDF that has the suitable marks on it with the pages marked 'Page 1' & 'Page 2'. This is the background PDF.
    I open this PDF in Acrobat and run the action that places another PDF (the 'Source' PDF) on multiple layers with different offsets.
    The original (template) PDF is 2 pages & the Source PDF for imposition is 2 pages, and even though the 'import as layer' understands that the source PDF being imposed is 2 pages, it does not seem to allow the original (template) PDF to be seen as 2 pages.
    There is a 'Target page number' option in the Preview area, but that is grayed out at 1.
    So...other than commercial applications, is there an easy way to build a 2 page PDF imposition file??
    Maybe a script?

    Sabian,
    Yes, the Quite software would be perfect, especially the 'Hot'. Tested & works great for us, but the price tag for the 'Hot' is rather steep for our relatively simple process......background template with a 'step & repeat' of the 'live' document.
    As I mentioned in the original post, to do this with a single page PDF is simple enough using an action that places the 'live' doc multiple times, but the vast majority of our publications are 2 pages.
    Currently runing the action twice for each job. I would save a bit of time if this could be automated to do both sides with one action, or one script.

  • 300 requests per hour reading from Application scope Good/Bad idea

    I am saving some html in application scope & reading with
    <cflock readonly.
    Will it be a problem if more than 5 requests are made per
    second?
    Does deadlocks occurs with readonly-cflock?
    Thanks

    While creating/changing application scope variables in a
    lock, I think there must be an exclusive lock. You must be careful
    not to set any shared variable such as application inside a read
    only cflock tag.
    I also would suggest to check the usage of Application.cfc
    and onApplicationStart method. You can set application default
    variables and constants in onApplicationStart method in your
    Application.cfc.

  • Application Scope within onSessionEnd

    Hi,
    Can someone enlighten me as to why application scope variables cannot be directly referenced from onSessionEnd?  I can understand session variables being unavailable in onSessionEnd, but shouldn't application scope vars still be available?  Why do we need to pass them as arguments into onSessionEnd?

    Dave Watts wrote:
    If onSessionEnd is single-threaded, the value of Application will be the same throughout the function unless the function itself changes it. So, again, no, there's no coarse- vs fine-grained distinction to be made here.
    OnSessionEnd can not be single-threaded, at least, not in this respect. I don't need Adobe to tell me that.
    Think about it. One thousand user sessions could end at the same time. Single-threading onSessionEnd would mean forcing them into a queue and killing them, one after the other. Absurd.
    If onSessionEnd is not single-threaded, and code within there can manipulate the Application scope via Arguments.appScope, there is a documentation issue as nothing in the documentation mentions locking Arguments.appScope.
    The documentation does mention locking arguments.appScope.
    And the practice of passing an event object to an event handler is hardly "universal software best practice". First, it only makes sense within a context where events happen. Second, it only makes sense within a context in which you have event objects - which means you have objects, which means you have OO. In any case, CF isn't passing an event object anywhere, because no such thing exists in CF. So clearly, CF itself is not following the best practices which you use to justify why CF is doing what it's doing! The concept of events in CF is very new and immature, which makes sense since web server programs aren't really event-driven - they're more like batch programs. And there are plenty of examples that arguably point to failure to follow best practices in OO design in CF since its introduction in CFMX - the first iteration of CFCs was very primitive from an OO perspective.
    Unlike you, I do believe that one may talk loosely of objects in Coldfusion even without implying strict objected-oriented semantics. I also believe that what occurs in Coldfusion to invoke onSessionEnd might rightly be called an event. I'll consider this a difference of opinion and leave it at that.

  • Best Performance? - having a single stateless java pojo as delegate- give it application scope?

    I'm curious about which is best from a performance standpoint -<br /><br />All of our flex calls access a single java pojo. In my remoting-config.xml I'm currently declaring the destination a property scope of 'application': <br /><br /><destination id="UIServicesDelegate"><br />    <channels><br />      <channel ref="my-amf"/><br />      <channel ref="my-local-amf"/ <br />    </channels> <br />     <properties><br />        <factory>spring</factory><br />        <source>uiServicesDelegateBean</source><br />        <scope>application</scope><br />    </properties><br /></destination><br /><br />All of the UIServiceDelegate methods are stateless however, so I'm wondering if I'm gaining anything by giving it scope session. Since their all stateless I"m assuming application scope would be the best from a performance standpoint? I'm assuming in this case only one object will ever be instantiated? <br /><br />Assuming it was between Session and Request scope, is there a lot of overhead instantiating the new server side object each time? I would assume performance would be better using the Session in this case, with the only draw back of some server-side ram being chewed up storing the object in the Session. <br /><br />If you want "singleton" type approach, I figure just using application scope is the preferred approach?

    You wont get any api for directly accessing Servlet application objects from any ejb. I dont think MDB either solves your problem directly. Indirectly you can place a request to some servlet (should be there for each JVM and web application ) and update your application scope variable. I would suggest you to cache the data in database if the size of cache is large. otherwise any open caching tools may help you.

  • Initializing application scope beans on startup

    Hi All,
    I need to initialize an application scope managed bean on startup, and not have to wait for it to be referenced the first time.
    I was thinking of using ContextListener, but you dont have access to the faces context in the listener.
    And you cant even extend FacesServlet, since its final.
    Any ideas on how this can be achieved.
    Thanks for your help!!

    Try with FacesContext.getCurrentInstance() or http://www.jsffaq.com/Wiki.jsp?ptitle=How+to+access+FacesContext+from+the+Filter+or+Servlet%3F&page=HowToAccessFacesContextFromTheFilterOrServlet

  • I want to burn a blu ray disc from PP CC 2014 and do not have the Encore application. Is there a way to do that?

    I want to burn a blu ray disc from PP CC 2014 and do not have the Encore application. Is there a way to do that?

    Here's a free non-Adobe solution as well.  It's definitely got a steep learning curve compared to Encore, but from my understanding so far, it may also be more capable.  (And it's still being developed, unlike Encore which is dead software.)
    Easy BD Authoring, Blu-ray Authoring and Reauthoring | DVDLogic Software

  • Is there an easy way to generate a site map of an APEX application ?

    Hi.
    Is there an easy way to generate a site map of an APEX application ?
    Thanks.

    Depends on your definition of "easy"...
    Patrick Wolf provided one way to do this a few years ago.

  • HT1473 Sometimes when I copy a CD into iTunes all of the songs do not show y up in one album, but mutiple albums, all with the same name. Is there an easy way to get all of the songs into one album.

    Sometimes when I copy a CD into iTunes all of the songs do not show y up in one album, but mutiple albums, all with the same name. Is there an easy way to get all of the songs into one album.

    Generally adding a common album artist will fix things.
    tt2

  • HT1689 I allow a friend to use my credit card (cc) to buy applications.  Is there a way to use the cc once and not to be saved in to iTunes?

    I allow a friend to use my credit card to buy applications. 
    Is there a way that the cc information not to be stored in his iTunes?

    As I understand it you'd have to go in and remove it from the iTunes account. And if it's his account he'll have to go in and do it.
    If I were you? If you have iTunes gift cards handy just get one of those. I set up my iTUnes years ago and all I use are gift cards. Yeah, the remainder of the $15 dollars sits there, but if anyone gets into my iTunes that's all they can get, whatever balance I have.

  • HT1399 When I import a CD to itunes, it splits the album in to multiple entries. I have changed the info on some but others just will not merge. Is there an easy way to do this and can I stop them from splitting in future? Thanks

    When I import a CD to itunes, it splits the album in to multiple entries. I have changed the info on some but others just will not merge. Is there an easy way to do this and can I stop them from splitting in future? Thanks

    Okay this is what fixed my problem. Some kind of error/glitch occured half-way through importing that third cd that prevented further imports from any other cd. Once I completely removed the half-imported cd album from my library I could further import cd's without any problems.

  • OC4J- NamingException: Not in an application scope

    I have a JMS program(ResourceAdapter) which I am deploying on OC4J 10g (10.0.3.0.0) .
    The program first creates InitialContext object and and then looks for the JMS connection factory and JMS queue in the "start" method of resource adapter. When I deploy this program everything works fine first, but later when I bounce oc4j, I start
    getting "javax.naming.NamingException: Not in an application scope"
    exception. Can someone suggest me what could be causing this?
    I have tried restarting the oc4j with userThreads option but it doesn't help.
    Program code:
    try{
    mContext = new InitialContext();
    System.out.println("**************1**********");
    mQueueCF =
    (QueueConnectionFactory)mContext.lookup("ojmsjra/MyQCF");
    System.out.println("**************2************");
    mQueue= (Queue)mContext.lookup("ojmsjra/QUEUE");
    System.out.println("**************3*********");
    }catch(Exception ex){
    ex.printStackTrace();
    After oc4j is restart only "**1**" gets printed and the following exception(lookup fails)
    04/09/27 15:56:15 javax.naming.NamingException: Not in an application scope - start Orion with the -userThreads switch if using user-created threads
    04/09/27 15:56:15 at com.evermind.server.PreemptiveApplicationContext.getContext(PreemptiveApplicationContext.java:29)
    04/09/27 15:56:15 at
    com.evermind.naming.FilterContext.lookup(FilterContext.java:127)
    04/09/27 15:56:15 at
    com.evermind.server.PreemptiveApplicationContext.lookup(PreemptiveApplicationContext.java:48)
    04/09/27 15:56:15 at
    javax.naming.InitialContext.lookup(InitialContext.java:347)
    04/09/27 15:56:15 at
    oracle.panama.messaging.driver.DriverResourceAdapter.<init>(DriverResourceAdapter.java:40)
    04/09/27 15:56:15 at
    sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    04/09/27 15:56:15 at
    sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    04/09/27 15:56:15 at
    sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    04/09/27 15:56:15 at
    java.lang.reflect.Constructor.newInstance(Constructor.java:274)
    04/09/27 15:56:15 at java.lang.Class.newInstance0(Class.java:306)
    04/09/27 15:56:15 at java.lang.Class.newInstance(Class.java:259)
    04/09/27 15:56:15 at
    com.evermind.server.connector.deployment.ConnectorArchive.createJavaBeanInstance(ConnectorArchive.java:462)
    04/09/27 15:56:15 at
    com.evermind.server.connector.deployment.ConnectorArchive.start(ConnectorArchive.java:360)
    04/09/27 15:56:15 at
    com.evermind.server.Application.initConnectors(Application.java:444)
    04/09/27 15:56:15 at
    com.evermind.server.Application.postInit(Application.java:681)
    04/09/27 15:56:15 at
    com.evermind.server.Application.setConfig(Application.java:201)
    04/09/27 15:56:15 at
    com.evermind.server.Application.setConfig(Application.java:170)
    04/09/27 15:56:15 at
    com.evermind.server.ApplicationServer.initializeApplications(ApplicationServer.java:1708)
    04/09/27 15:56:15 at
    com.evermind.server.ApplicationServer.setConfig(ApplicationServer.java:1412)
    04/09/27 15:56:15 at
    com.evermind.server.ApplicationServerLauncher.run(ApplicationServerLauncher.java:93)
    04/09/27 15:56:15 at java.lang.Thread.run(Thread.java:536)

    Gedomir,
    Thanks for the reply. But unfortunately it did not work. I was using the default initial context. I tried setting the properties as well. Even then it did not work.
    I am trying this with oc4j_extended.
    Thanks again.

  • Facing error as Not in an application scope - start Orion with the -userThr

    hi all,
    iam facing this error when an jsp which is in Oracle portal(emebedded in iframe code) is updating a flag in database through a datasource configured on portal side.
    Naming Service=Not in an application scope - start Orion with the -userThreads switch if using user-created threads
    regards,
    Ravi

    I encounter the same issues when using the TimerTask to access the JNDI tree. I have found success when I move my business logic to an EJB and call my EJB from my TimerTask. It's a bit more work, but not much. The EJB inherits it's identity based on it's configuration and has no trouble accessing the JNDI tree whenever it's called. Try this and see if your problem doesn't go away.
    Hope this helps,
    Perry Tew

  • TS1363 is there an easier way to connect my ipods and phones so that my devices are recognised in my itunes?as i am not ver good with pcs..thanks

    i am having trouble with my laptop/itunes finding my devices?i am unable to transfer anything from my itunes to devices as i dont really no what i am doing?is there an easier way to sort this so that my devices can be found and recognised?thankyou

    Rather than creating your report directly from a SQL statement use the "Sql Query (PL/SQL Function Body returning Sql Query)" option and re-write your code in PL/SQL. PL/SQL gives you greater control and allows you to test the "null" values and add where clauses to your SQL query based on whether or not a value was selected in the SELECT list.
    For example, I have a report parameter screen that has a state drop down list that returns a value of -1 if no state is selected. I can, therefore, code:
    IF :P6_STATE_CODE != -1 THEN
    query := query + " WHERE state_code = ' ||
    :P6_STATE_CODE ;
    END IF ;
    I have a more complete example if you would like to send me an email ([email protected])
    Jeff

Maybe you are looking for