AnsweredAssumed Answered

Use of PropertyPlaceholderConfigurer in Alfresco Modules

Question asked by darryl_staflund on Nov 12, 2010
Latest reply on Nov 19, 2010 by darryl_staflund
Hi there,

I have spent the last couple of days moving some important configuration values out of the Spring context modules of my Alfresco AMPs into some property files.  But when I try to make use of them using a PropertyPlaceholderConfigurer bean, the values defined in the files aren't found.  I am not sure what's going on here.  Why don't these beans make the values defined in my property files available to Spring when it's processing the context file?

For example, in one AMP that I've created, I have moved the following configuration values into a property file:


#   Frequency of Minor Correction Workflow report.
my_module_id.job.workflow_report.minor_correction.cron=0 0/5 * * * ? *

#   Frequency of Final Author Review Workflow report.
my_module_id.job.workflow_report.final_author_review.cron=0 0/5 * * * ? *

#   Frequency of Minor / Exam Revision Workflow report.
my_module_id.job.workflow_report.minor_exam_revision.cron=0 0/5 * * * ? *

#   Frequency of Records Management Audit report.
my_module_id.job.rm_audit_report.cron=0 0/2 * * * ?

#   Should Minor Correction Request workflow be re-deployed on application start-up?
#   Will result in new versions of the workflow being created in Alfresco.
#
#      Dev Environments = true
#      QA Environments = true
#      UAT Environments = true
#      Staging Environments = false
#      Production = false
my_module_id.workflow.minor_correction_request.model.reploy_on_startup=true

#   Should Final Author Review workflow be re-deployed on application start-up?
#   Will result in new versions of the workflow being created in Alfresco.
#
#      Dev Environments = true
#      QA Environments = true
#      UAT Environments = true
#      Staging Environments = false
#      Production = false
my_module_id.workflow.final_author_review.model.reploy_on_startup=true

#   Should Minor / Exam Revision workflow be re-deployed on application start-up?
#   Will result in new versions of the workflow being created in Alfresco.
#
#      Dev Environments = true
#      QA Environments = true
#      UAT Environments = true
#      Staging Environments = false
#      Production = false
my_module_id.workflow.minor_exam_revision.model.reploy_on_startup=true

#   Maximum number of courses to display in My Courses dashlet at any one time.
#   The smaller the value, the greater the performance.
my_module_id.dashlet.courses.max_items=25

#   The name of the Alfresco datalist used to generate the RM Audit Report.
#   Should never need to be changed.
my_module_id.rm.audit.datalist=Records Management Change Log

I then substitute reference their values in beans that look like this:


    <!–
        #############################################################################
        Job:            Workflow Summary Report (Minor Correction)
        Description:    Generates a DCMP workflow summary report.
        #############################################################################
    –>
    <bean id="requestMinorCorrectionActivityReportJobDetail" class="org.springframework.scheduling.quartz.JobDetailBean">
        <property name="jobClass" value="my.package.bi.components.report.jobs.WorkflowActivityReport" />
        <property name="jobDataAsMap">
            <map>
                <entry key="callbackCommand" value-ref="workflowActivityReportCallbackCommand" />
                <entry key="transactionService" value-ref="TransactionService" />
                <entry key="workflowModel">
                    <util:constant static-field="my.package.common.models.wf.DcmpWorkflowModel.MinorCorrection" />
                </entry>
            </map>
        </property>
    </bean>
       
    <bean
        id="requestMinorCorrectionActivityReportTrigger"
        class="org.alfresco.util.CronTriggerBean"
        depends-on="module_id_1.modelBootstrap">
        <property name="jobDetail" ref="requestMinorCorrectionActivityReportJobDetail" />
        <property name="scheduler" ref="schedulerFactory" />
        <property name="cronExpression" value="${my_module_id.job.workflow_report.minor_correction.cron}" />
    </bean>

and then read the properties into Spring using the following bean:


    <bean id="module_id_properties" parent="common-placeholder-configurer">
        <property name="ignoreUnresolvablePlaceholders" value="false" />
        <property name="properties" ref="global-properties" />
        <property name="localOverride" value="false" />
        <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_NEVER" />
        <property name="locations">
            <list>
                <value>classpath:alfresco/module/module_id/module_id.properties</value>
            </list>
        </property>
    </bean>   

In my mind this should work.  But when I start Alfresco, I get an error due to the fact that Spring has not substituted '${}' property references with the corresponding values.

What am I doing wrong?

Thanks,
Darryl

Outcomes