8 Replies Latest reply: Aug 6, 2012 6:25 AM by SantoshVaza RSS

    Issue in reading multiple time properties file

    ruzz
      Use Case:
      I have a page in which i have to show some Outage Messages on page. So I have configured outage message in properties files. This message should me rendered each time when it finds that properties file in class path or it finds the values w.r.t their keys.
      So what I decide that I shall write java method and call this method on Loading the page but here what happen is that whenever that page is load each time that reader file will call , that will create memory leak .

      So, anyone help me on this. What will be the best approach for that reading multiple times properties file?

      I will be grateful for any help you can provide
      Thanks
        • 1. Re: Issue in reading multiple time properties file
          Timo Hahn
          You use case isn't clear to me. You want to read the file each time you load the page, but you don'T want to read it each time the page gets loaded. This doesn't sound right to me.

          Please elaborate on your use case and don't forget to mention your JDev version.

          Sometimes it helps if you post some of your code.

          Timo
          • 2. Re: Issue in reading multiple time properties file
            Arunkumar Ramamoorthy-Oracle
            Ruzz,

            +1 to Timo's reply. Always mention your JDev version, technologies used, clear usecase along with some code snippets (if needed) and expected result.

            I would probably think about using [url http://docs.oracle.com/cd/E17904_01/web.1111/b31974/adv_ads.htm]ADS for this scenario.

            -Arun
            • 3. Re: Issue in reading multiple time properties file
              ruzz
              Thanks for ur reply timo,

              I am using jdev 11g 1.5 version.

              May this will help you to understand my use case:

              I have property file in which I want to render their messages on some page whenever the login page is call . There is some condition on that if the file does not exist or if there should be no values against keys. Then I have to not render anything on page.

              What is the best approach.

              ruzz.

              Edited by: ruzz on Aug 6, 2012 2:44 AM
              • 4. Re: Issue in reading multiple time properties file
                SantoshVaza
                Hi,

                have a bean at applicationScope, somewhat like this
                import java.util.HashMap;
                
                
                public class ApplnProperties {
                    private HashMap _propMap;
                
                    public HashMap getPropMap() {
                        if(_propMap == null){
                            //read the properties file and populate _propMap
                        }
                        return _propMap;
                    }
                   
                }
                here we put condition _propMap == null so it would be called only once during application lifecycle.

                and on page you can refer the prop map like following
                #{beanName.propMap['KEY1']}
                Regards,
                • 5. Re: Issue in reading multiple time properties file
                  ruzz
                  thanks for ur reply , santosh

                  i don't want to call once in application scope, reading the values from file should always.

                  If i am keeping it on page load, then it 'll hit the performance issue. B'coz of IO operation.

                  SO, if u can suggest other best apporach for that.
                  • 6. Re: Issue in reading multiple time properties file
                    SantoshVaza
                    Hi,
                    So what I decide that I shall write java method and call this method on Loading the page but here what happen is that whenever that page is load each time that reader file will call , that will create memory leak .
                    It won't if you close the stream after reading it..

                    i don't want to call once in application scope, reading the values from file should always.
                    Why?


                    Regards,
                    • 7. Re: Issue in reading multiple time properties file
                      ruzz
                       i don't want to call once in application scope, reading the values from file should always.
                      B'coz my requirement is like that they don’t want to redeploy the application. So, if it finds the property file or values from property file, it read and display on page. This can be done always calling the IO operation method whenever the page is load.

                      Or if you would have some better approach for that.


                      thanks
                      ruzz
                      • 8. Re: Issue in reading multiple time properties file
                        SantoshVaza
                        B'coz my requirement is like that they don’t want to redeploy the application. So, if it finds the property file or values from property file, it read and display on page. This can be done always calling the IO operation >method whenever the page is load.
                        you can check timestamp(last modified) of the file and decide whether to read the file or not..
                        after reading file store timestamp on applicationscope, at each invoke compare both if it differs then read it again and populate it in appln scope as i have told in my previois post.


                        Regards,

                        Edited by: Santosh Vaza on Aug 6, 2012 4:55 PM