cancel
Showing results for 
Search instead for 
Did you mean: 

run scheduled JS script using the classpath reference

cpenning
Champ in-the-making
Champ in-the-making
I want to setup a scheduled action that will execute a script, but the script I want to execute will not reside within the repository as in the example in the wiki.
http://wiki.alfresco.com/wiki/Scheduled_Actions#Script_Action_Example

My script will be deployed as part of an AMP module so that is why it will not reside with in the repository, but rather will be in the classpath for alfresco/module/<MY-MODULE-ID>/script/scheduled/somescript.js.

I had a look at the source of org.alfresco.repo.action.executer.ScriptActionExecuter and it appears the only parameter that can be passed is a 'script-ref' so I'm not sure if what I want to do is even possible. 

Any help would be appreciated.
thx
1 REPLY 1

jbarmash
Champ in-the-making
Champ in-the-making
A good example of how to do this is in Records Management Module (which is also packaged as an AMP).  

From file \modules\records-mgmt\config\alfresco\module\org.alfresco.module.RecordsManagement\context\script-context.xml. 


<!– Scheduled scripts –>
   
    <bean id="org_alfresco_module_RecordsManagement_scheduledCutoffJobDetail" class="org.springframework.scheduling.quartz.JobDetailBean">
        <property name="jobClass">
            <value>org.alfresco.repo.jscript.ExecuteScriptJob</value>
        </property>
        <property name="jobDataAsMap">
            <map>
                <entry key="scriptLocation">
                    <bean class="org.alfresco.repo.jscript.ClasspathScriptLocation">
                     <constructor-arg>
                        <value>alfresco/module/org.alfresco.module.RecordsManagement/script/scheduled/scheduled_cutoff.js</value>
                     </constructor-arg>
                  </bean>
                </entry>
                <entry key="scriptService">
                    <ref bean="ScriptService"/>
                </entry>
                <entry key="authenticationComponent">
                   <ref bean="authenticationComponent"/>
                </entry>
            </map>
        </property>
    </bean>
   
    <bean id="org_alfresco_module_RecordsManagement_scheduledCutoffTrigger" class="org.alfresco.util.CronTriggerBean">
        <property name="jobDetail">
            <ref bean="org_alfresco_module_RecordsManagement_scheduledCutoffJobDetail" />
        </property>
        <property name="scheduler">
            <ref bean="schedulerFactory" />
        </property>
        <property name="cronExpression">
            <!– Execute @ 2:30 am every day –>
            <value>0 * * * * ?</value>
        </property>
    </bean>