Uploaded image for project: 'OpenMRS Core'
  1. OpenMRS Core
  2. TRUNK-1366

Auto registration of Handler Components

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Should
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: OpenMRS 1.5.0
    • Component/s: None
    • Labels:
      None

      Description

      There are a large number of "Handler"-type classes which are registered within Spring. For example, we have:

      • Validator (handles Objects)
      • ReportRenderer (handles ReportSchemas)
      • CohortDefinitionPersister (handles CohortDefinitions)
      • CohortDefinitionEvaluator (handles CohortDefinitions)
      • FieldGenHandler (handles Object)
      • etc.

      Each of these "Handlers" has methods which accept a broadly typed parameter (for example, Object), but for which only a small subset of classes that implement this type are valid (for example, a PatientIdentifierValidator has a validate(Object) method, but only is able to successfully operate on a PatientIdentifier parameter.

      Often, we have solved this problem through repetitive and error-prone XML configuration. For example, to register ReportRenderers, we have XML that looks like this:<br/>

      <property name="renderers">
        <map>
          <entry>
            <key><value>org.openmrs.report.impl.TsvReportRenderer</value></key>
            <bean class="org.openmrs.report.impl.TsvReportRenderer"/>
          </entry>
          <entry>
            <key><value>org.openmrs.report.impl.CsvReportRenderer</value></key>
            <bean class="org.openmrs.report.impl.CsvReportRenderer"/>
          </entry>
        </map>
      </property>
      

      This XML is unnecessary - we should be able to introspect our codebase to identify the ReportRenderers that are available there.

      Spring contains a facility for doing just this. See the attached patch for the proposed addition.

        Attachments

          Activity

            People

            Assignee:
            mseaton Mike Seaton
            Reporter:
            mseaton Mike Seaton
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: