Uploaded image for project: 'VIVO (LEGACY)'
  1. VIVO (LEGACY)
  2. VIVO-1247

Remove duplicate code, based on improvements in ConfigurationBeanLoader

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed (View Workflow)
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: v1.10
    • Component/s: Architecture
    • Labels:
      None
    • Attachments:
      0
    • Comments:
      0

      Description

      Vitro code contains 50 uses of the edu.cornell.mannlib.vitro.webapp.utils.configurationProperty annotation, and most of them use boiler-plate code in this pattern:

      @Property(uri = "http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationSetup#threadPoolSize")
      public void setThreadPoolSize(String size) {
          if (threadPoolSize == null) {
              threadPoolSize = Integer.parseInt(size);
          } else {
              throw new IllegalStateException(
                      "Configuration includes multiple values for threadPoolSize: "
                              + threadPoolSize + ", and " + size);
          }
      }
      
      @Validation
      public void validate() throws Exception {
          if (threadPoolSize == null) {
              throw new IllegalStateException(
                      "Configuration did not include a value for threadPoolSize.");
          } else {
              this.pool = new WorkerThreadPool(threadPoolSize);
          }
      }
      

      Use the cardinality specifiers to improve this code:

      @Property(uri = "http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationSetup#threadPoolSize" minOccurs=1 maxOccurs=1)
      public void setThreadPoolSize(String size) {
              threadPoolSize = Integer.parseInt(size);
              this.pool = new WorkerThreadPool(threadPoolSize);
      }
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              j2blake Jim Blake
              Reporter:
              j2blake Jim Blake
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: