FORUM PLAN UPDATE
Date revision: This forum will remain open to new posts and responses until December 1, 2018. (After that date, you will still be able to view and search the forum.) Also, we're taking a second look at the best place to host future conversation. For now, keep using this forum, and stay tuned for more news.



Sep 29, 2011, 5:46 PM
57 Posts

How to update ApplicationScope variable Periodically

  • Category: Other
  • Platform: Windows
  • Release: 8.5.2
  • Role:
  • Tags: Application scope
  • Replies: 9
Hi
 
How to update ApplicationScope variable Periodically? (without using any of these)
1. PhaseListener
2. Agent making GET/POST to a page for value update
3. server pooling with client side script
 
As I remember there is a session in lotusSphere that some plugin can be installed, so server becomes self aware when for example when a document is added. Please point me to related material? Thanks
 
regards
wei
Oct 1, 2011, 8:01 AM
272 Posts
Re: How to update ApplicationScope variable Periodically
Hi,
 
may I ask you what you are trying to implement? If you just want to refresh some information which the clients , you could f.e. use a profile document (which can be easily accessed from every interface to domino)?
Or you could create a function for accessing the applicationScope which stores the timestamp of the last update, and then recalculate the applicationScope if expired?
 
Sven
Oct 1, 2011, 8:00 PM
57 Posts
Re: How to update ApplicationScope variable Periodically
This is what i am trying to do: use a applicationScope variable to hold the rss data, and update it every 15 minutes. so different sites can use that copy
 
Or you could create a function for accessing the applicationScope which stores the timestamp of the last update, and then recalculate the applicationScope if expired
 
its exactly what I want, but how can I trigger this function, without using any of these
 
1. PhaseListener
2. Agent making GET/POST to a page for value update
3. server pooling with client side script
 
Oct 2, 2011, 2:50 PM
272 Posts
Re: How to update ApplicationScope variable Periodically
You could try something like this:
 
function getRSSData(){
   var now = System.currentTimeMillis();
   if( now - applicationScope.lastUpdate > 15 * 60 * 1000 ){
      updateRSSData();
   }
   return applicationScope.RSSData;
}
 
function updateRSSData(){
   applicationScope.RSSData = "WHAT EVER TO DO HERE TO GET YOUR DATA"
   applicationScope.lastUpdate = System.currentTimeMillis();
}
 
 
In your applications, you are using only "getRSSData()" to get your RSS data. A periodic update is not required.
 
Hope this helps
Sven
 
 
 
 
Oct 2, 2011, 6:56 PM
57 Posts
Re: How to update ApplicationScope variable Periodically
Hi
 
thanks for your input, I am aware of such solution. What I want to achieve is do the same thing without writing ssjs or even making any HTTP request.
Like a scheduled agent
Oct 3, 2011, 1:48 AM
54 Posts
Re: How to update ApplicationScope variable Periodically
How about making an XAgent (XPage without any ui rendering) with a normal scheduled agent which would call this XAgent page periodically?
In the agent you can use e.g. Apache HttpClient Java class libraries to make the http call.
 
Oct 3, 2011, 2:09 PM
272 Posts
Re: How to update ApplicationScope variable Periodically
@weihang chen:
Do you mean an extension based on OSGi?
Oct 4, 2011, 1:25 AM
54 Posts
Re: How to update ApplicationScope variable Periodically
Sven: by "you" I assume you mean me? :)
 
No, XAgent is a normal XPages page where the rendering has set to false. Don't remember who "invented" the name XAgent anymore.
I saw somewhere an example where a normal scheduled agent called the XPage using HTTP and this was coded using the Apache HttpClient Java library.
Oct 4, 2011, 3:36 AM
272 Posts
Re: How to update ApplicationScope variable Periodically
@Rami:
Oh, I am Sorry! No, I wanted to respond to weihang chen. Seems that my browser had still cached the forum before I wrote my reply.
Oct 4, 2011, 8:51 AM
57 Posts
Re: How to update ApplicationScope variable Periodically
Hi guys, thanks for your suggestions...... xpages as servlet responding with data in any format is what xagent does.
http://www.roseindia.net/servlets/ServletContextListener-example.shtml
 
I am not smart enough to comprehend things like http://www.openntf.org/Projects/pmt.nsf/ProjectLookup/JAVADDIN
applicationscope variables is maintained by servlet container, dont know what kind of relationship it has with server task.
 
and Looks like ServletContextListener and prenty more others
http://www.examulator.com/moodle/mod/resource/view.php?id=460 are what I am after, an direct hit here

 
http://stackoverflow.com/questions/7092723/load-applicationscoped-bean-with-servletcontext
 

FORUM PLAN UPDATE
Date revision: This forum will remain open to new posts and responses until December 1, 2018. (After that date, you will still be able to view and search the forum.) Also, we're taking a second look at the best place to host future conversation. For now, keep using this forum, and stay tuned for more news.