11907

Managed-Bean best practice

Question:

I'm back to building my Managed-Bean of a hashMap. ( <a href="https://stackoverflow.com/questions/24663619/creating-a-hashmap-of-type-string-object" rel="nofollow">Creating a HashMap of type <String , Object></a> ) I have defined a class

public class AppProperties { private String appRepID; private String helpRepID; private String ruleRepID; private String filePath; private Vector formNames; private Database appDB; // all the getters and setters }

The managed bean will create an Application Scope variable of the hashMap. In the constructor of the Bean I build the the values for each Application (the key) by collecting all the info from a number of different places. The repIDs are pretty straight forward. My question/concern is it wise to store the appBD in the Application Scope variable. I have read that one should never store a Notes Object in a Scoped Variable would that be an issue here? Secondly, if that is the case I could add a method to the AppProperties that would open the DatabaseByReplicaID when ever the method to get the Application Database is called, which adds a fair bit of overhead to the process as the database object will get called many many time in the life cycle of the application.

Answer1:

Right, you shouldn't store Notes objects in scope variables and properties of beans.

Because They are not serializable (a must for certain scopes) and they will be recycled between lifecycles. More precisely, since they are based on C-handles, XSP engine creates Notes objects between request-response cycle and when response written back to the user, they are all going to be recycled. Trying to keep them in the memory will make them 'toxic' for your server.

You can define a method in your bean (like GetHelpDb()), create and return it whenever you need. It's not a huge performance cost. Because Domino server implements caching for databases. When you open a database over and over again will not generate additional disk I/O.

The best practice for interacting with Notes data in such situation would be caching. I frequently use this approach in my applications. You might get values in a single method, cache them into HashMap(s) and get them from the map when you need. Using getter method, you may also check a time-based value to handle time-outs.

Recommend

  • IP and domain create different session
  • Process.StartTime Access Denied
  • How to make Javascript generated checkboxes persist?
  • Avoiding dependencies is exploding the number of projects in my VS solution
  • Enterprise Architect - Cancel Connectors Bridges
  • How to exclude files in a custom clean task?
  • UI-GRID column summation on checkbox change
  • Replacing script src using jquery not executed
  • keeping track of nested ng-repeat index's
  • Using an STL Iterator without initialising it
  • custom string delimiters stringtemplate-4
  • Insertion large number of Entities into SQL Server 2012 [duplicate]
  • New Firebase failed: First argument must be a valid firebase URL and the path can't contain “.”
  • JSON encode and decode on PHP
  • Building Qt project for C++11 standard
  • Using $compile in a directive triggers AngularJS infinite digest error
  • Updating Dojo provide
  • netsh acl setting (need alternative method - registry settings?)
  • Why the SequenceFile is truncated?
  • How can I set a binding to a Combox in a UserControl?
  • Remove final comma from string in vb.net
  • Create DicomImage from scratch using Dcmtk
  • Jackson Parser: ignore deserializing for type mismatch
  • Atlas images wrong size on iPad iOS 9
  • Is it possible to access block's scope in method?
  • How to rebase a series of branches?
  • Xamarin Forms - UWP Fonts
  • Is there a javascript serializer for JSON.Net?
  • Where to put my custom functions in Wordpress?
  • Arrow is showed instead of the material design version hamburger icon. Why doesn't syncState in
  • Weird JavaScript statement, what does it mean?
  • How do you troubleshoot character encoding problems?
  • Arrays break string types in Julia
  • How to format a variable of double type
  • bootstrap to use multiple ng-app
  • Buffer size for converting unsigned long to string
  • python regex in pyparsing
  • Angular 2 constructor injection vs direct access
  • Binding checkboxes to object values in AngularJs
  • How to Embed XSL into XML