如何加快Alfresco Share的发展

时间:2013-01-11 14:27:38

标签: share development-environment alfresco

我正在开发并在Share上执行一些自定义。我的IDE是Eclipse Juno,工作区由下一个元素组成:

  • alfresco web project
  • 扩展Java项目
  • 分享网络项目

露天和共享Web项目都部署在单独的Tomcat实例中,这样我只需重新启动部署了Share的Tomcat实例,就可以略微加快我的开发任务。

我的扩展Java项目与Alfresco提出的Eclipse项目具有相同的结构。提供的Ant任务用于编译,压缩JavaScript文件,在Tomcat中打包和部署生成的JAR文件。

我正在开发一些新的JavaScript客户端小部件,这意味着每次我做出更改时都必须停止Tomcat,启动Ant构建脚本并重新启动,因为我必须经常这样做,你可以猜到它正在变得痛苦。我只是想知道是否有任何方法可以加速Share上的开发任务。 Alfresco开发团队如何做到这一点?他们建立了什么样的环境?

我正在考虑创建一个新的Ant目标,该目标将扩展项目的内容热部署到已部署的Share Web项目中,同时考虑到路径;该机制必须允许反向操作。那可行吗?我们的想法是拥有与开发常规Web项目时类似的部署机制:当您进行任何更改时,只需按“发布”按钮,更改就会填充到服务器中。

我想了解一些提示和想法,特别是Alfresco开发团队,如果可能的话。

PS:我已阅读https://forums.alfresco.com/en/viewtopic.php?f=47&t=44850https://forums.alfresco.com/en/viewtopic.php?f=48&t=18749

4 个答案:

答案 0 :(得分:8)

两件事加速了很多事情:

  • 投资jrebel许可证,无需重启服务器即可重新加载课程http://zeroturnaround.com/software/jrebel/

  • 构建将网页脚本复制到目标文件夹的ant任务,并在必要时使用curl重新加载网页脚本。

重新加载Alfresco Share webscript的任务示例:

<target name="deploy-share-webscripts" depends="Share: Copy files" description="Refreshes the list of webscripts">
    <exec executable="curl">
    <arg value="-d"/>
    <arg value="reset=on"/>
    <arg value="http://admin:admin@${share.web.url}/page/console?reset=webscripts"/>
    </exec>
</target>

附加ant任务的复制部分(src-dirs在构建文件的开头声明为属性):              

    <echo message="- Copying java classes" />
    <copy todir="${warWebappTargetClasses}" overwrite="false" verbose="true">
        <fileset dir="${warTargetJavaDir}" />
    </copy>

    <echo message="- Copying resource files" />
    <copy todir="${warWebappTargetClasses}" overwrite="false" verbose="true">
        <fileset dir="${warSrcResourcesDir}" >
            <include name="**/model/*"/>
            <include name="**/templates/**/*"/>
            <include name="**/custom-model-context.xml"/>
            <include name="**/web-client-config-custom.xml"/>
            <include name="**/webclient.properties"/>
            <include name="**/aka-model-resourcebundle*"/>
            <include name="log4j.properties"/>
        </fileset>
    </copy>

    <echo message="- Copying resource files from amp into war for quick deployment." />
    <copy todir="${warWebappTargetClasses}" overwrite="false" verbose="true">
        <fileset dir="${projectAmpResourcesSrcDir}" />
        <fileset dir="${projectAmpClassesDir}" />

        <fileset dir="${listmanagerAmpResourcesSrcDir}" />

    </copy>

    <echo message="- Copying config files from amp into war for quick deployment." />
    <copy todir="${warWebappTargetClasses}\alfresco\module\Project-amp\" overwrite="false" verbose="true">

        <fileset dir="${projectAmpConfigSrcDir}" />


    </copy>
</target>

我使用maven alfresco生命周期http://wiki.alfresco.com/wiki/Managing_Alfresco_Lifecyle_with_Maven进行设置,这也加快了速度。我确定可以在这个主题中添加很多内容。

答案 1 :(得分:3)

您可以通过为tomcats共享类加载器配置其他路径来避免将webscripts复制到tomcat。这是tomcat/conf/catalina.properties中的设置。我将它直接设置为项目源目录,因此不需要编译步骤。

shared.loader=${catalina.home}/shared/classes,${catalina.home}/shared/lib/*.jar,\
/path/to/my/dashlet/src/main/resources,\

我在shared/classes/alfresco/web-extension/share-config-custom.xml中也有以下设置,可以自动刷新模板和网页脚本。

<alfresco-config>
    <!-- Global config section -->
    <config replace="true">
        <flags>
            <!-- Developer debugging setting - DEBUG mode for client scripts in the browser -->
            <client-debug>true</client-debug>

            <!-- LOGGING can be toggled at runtime when in DEBUG mode (Ctrl, Ctrl, Shift, Shift).
                 This flag automatically activates logging on page load. -->
            <client-debug-autologging>false</client-debug-autologging>
        </flags>
    </config>

    <config evaluator="string-compare" condition="WebFramework">
        <web-framework>
            <!-- Autowire Runtime Settings -->
            <autowire>
                <!--
                    Developers can set mode to 'production' or 'development' (to disable; SpringSurf caches,
                    FreeMarker template caching and Rhino JavaScript compilation.)
                -->
                <mode>development</mode>
            </autowire>
        </web-framework>
    </config>
</alfresco-config>

答案 2 :(得分:2)

这就是我预期的100%工作的解决方案。我在@ erik-b和@ jorn-horstmann的答案之后想出了这个,并考虑了我读过的一些帖子。

所以基本上我有下一个Ant目标,它热部署我的Share扩展Java项目的内容:

<!--
    Hot copy individual files into appropriate deployment folder (e.g. $TOMCAT_HOME/webapps/share)
-->
<target name="hotdeploy-tomcat-share" depends="clean, prepare, build-jar" description="Hot copy individual files into appropriate deployment folder (e.g. $TOMCAT_HOME/webapps/share)">
    <echo message="Generating and deploying JAR file with custom configuration files" />
    <jar destfile="${dist.dir}/${jar.name}">
        <!-- Only including configuration XML files such as share-config-custom.xml -->
        <fileset dir="${build.jar.dir}" includes="**/META-INF/*.xml" />
    </jar>
    <copy todir="${tomcat.share.deployment.path}/WEB-INF/lib">
        <fileset file="${dist.dir}/${jar.name}" />
    </copy>

    <echo message="Hot deploying Share files" />
    <copy todir="${tomcat.share.deployment.path}/WEB-INF/classes" includeEmptyDirs="false">
        <fileset dir="${build.jar.dir}">
            <patternset refid="hotdeploy-tomcat-patternset" />
        </fileset>
    </copy>
</target>

必须禁用自动重新加载模块功能,否则每次执行上述Ant目标时,Tomcat都会重新加载Share和部署的其他Web应用程序。另外,我相信也可以在$ TOMCAT_HOME / shared /目录中进行热部署,但我还没有尝试过。

我用于开发扩展的Java项目是这个模型项目:http://code.google.com/p/share-extras/wiki/SampleProject。有完整的构建脚本,需要其他目标。

我也在我的share-config-custom.xml中使用它:

   <!-- Global config section -->
   <config replace="true">
      <flags>
         <!--
            Developer debugging setting to turn on DEBUG mode for client scripts in the browser
         -->
         <client-debug>true</client-debug>

         <!--
            LOGGING can always be toggled at runtime when in DEBUG mode (Ctrl, Ctrl, Shift, Shift).
            This flag automatically activates logging on page load.
         -->
         <client-debug-autologging>false</client-debug-autologging>
      </flags>
   </config>

   <config evaluator="string-compare" condition="WebFramework">
      <web-framework>
         <!-- SpringSurf Autowire Runtime Settings -->
         <!-- 
              Developers can set mode to 'development' to disable; SpringSurf caches,
              FreeMarker template caching and Rhino JavaScript compilation.
         -->
         <autowire>
            <!-- Pick the mode: "production" or "development" -->
            <mode>development</mode>
         </autowire>

         <!-- Allows extension modules with <auto-deploy> set to true to be automatically deployed -->
         <module-deployment>
            <mode>manual</mode>
            <enable-auto-deploy-modules>true</enable-auto-deploy-modules>
         </module-deployment>
      </web-framework>
   </config>

例如,最后一个XML代码段可以避免在FTL页面上执行任何更改后刷新网页脚本。

我还使用JRebel进行了一些测试,但根据我的经验,我会说它对共享开发没有太大帮助。

下一篇文章中也有一些有趣的内容:

http://blogs.alfresco.com/wp/kevinr/2010/04/07/developer-tips-for-alfresco-share-33/

http://techblog.zabuchy.net/2012/debugging-javascript-in-alfresco/

希望它可以帮助他人。

答案 3 :(得分:1)

我通常在私人实例上工作,因此我可以负担得起运行爆炸式应用程序,因此任何更改都可以立即显示给我。我只需要在更改数据模型时重新启动tomcat,部署一些新的java支持的模块或webscripts或类似的。即使其中一些也可以重新加载。