2014-10-30 64 views
1

如何在启动Alfresco服务器时启动我的调度程序? Liferay提供onstartup服务器事件。在Alfresco中是否有类似的功能可以在Alfresco服务器启动时启动我的Cron作业?如何在启动露天服务器时启动我的cron作业?

+0

Alfresco内置了自己的(集群感知)调度。您究竟想要做什么? – 2014-10-30 12:23:14

+0

感谢您的回复我有一些任务,我只想在服务器启动时,例如创建表,并输入启动时间。以及类的东西。在cron工作的帮助下。 – 2014-10-30 14:03:47

回答

0

为了满足您的需求,您可以通过将其附加到户外启动脚本来启动您的工作执行。

编辑: /etc/init.d/alfresco

投入 “开始” 部分你的工作,例如:

case $1 in 
    start) 
    sh YOUR_CRON_JOB 
    [....] 
    ;; 
+0

谢谢答案我正在使用Windows系统。究竟哪个脚本需要修改。我没有太多经验在Alfresco.Thanks.I使用社区版4.2 – 2014-10-30 12:36:40

+0

我不是Windows专家对不起。尝试找到在Windows中启动服务时如何链接脚本或操作。您可以尝试使用服务属性(RUN >> services.msc)更改它,然后单击有关服务上的属性 – 2014-10-30 13:57:42

3

它没有意义的,使用cron或者类似的服务,如果你想在启动时运行自定义代码。将从org.springframework.extensions.surf.util.AbstractLifecycleBean派生的自定义Spring管理bean添加到文件tomcat/shared/classes/alfresco/extension/startup-context.xml(或等效项)。把你的代码放在onBootstrap方法中。

1

另一个好办法是扩展AbstractModuleComponent实现方法executeInternal并在Spring配置中将executeOnlyOnce设置为false。 通过这种方式,您的自定义代码将在每次Alfresco启动时执行。

以下Spring配置的一个例子:

<bean id="initJobsComponent" class="com.sourcesense.alfresco.component.InitJobsComponent" parent="module.baseComponent" > 
    <property name="moduleId" value="myModuleId" /> 
    <property name="name" value="initComponent" /> 
    <property name="description" value="You description" /> 
    <property name="sinceVersion" value="1.0" /> 
    <property name="appliesFromVersion" value="1.0" /> 
    <property name="executeOnceOnly" value="false"/> 
</bean> 

你的Java类必须扩展AbstractModuleComponent:

public class InitJobsComponent extends AbstractModuleComponent { 

...

@Override 
protected void executeInternal() throws Throwable { 

//put here your custom code  

} 

... }

希望这有助于。

相关问题