Xwiki 重新加载组件 jar [英] Xwiki reload component jar

查看:22
本文介绍了Xwiki 重新加载组件 jar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据指南,向 XWiki 添加新组件包括将 jar 文件放入 XE_WAR_HOME/WEB-INF/lib.但是,在使用新组件之前,我似乎需要重新启动 tomcat.有没有办法解决这个重启?组件管理器可以在不重启 tomcat 的情况下从存储库安装新组件,因此原则上似乎是可能的...

According to the guide, adding new components to XWiki involves putting the jar file into XE_WAR_HOME/WEB-INF/lib. However I seem to then need to restart tomcat before I can use the new component. Is there a way around this restart? The component manager manages to install new components from a repository without restarting tomcat, so it seems possible in principle...

在相关的一点上,如果我用具有相同名称的更新版本替换 jar,即使重新启动 tomcat 似乎也不会更新现有组件.那么在这种情况下我可以明确触发重新加载吗?

On a related point, even restarting tomcat doesn't appear to update an existing component if I replace a jar with an updated version with the same name. So can I explicitly trigger a reload in this case?

推荐答案

同时更新了指南并展示了如何操作.

The guide has been updated in the mean time and show how todo this.

注意:目前在使用jetty作为容器时以下不工作;查看错误报告:http://jira.xwiki.org/browse/XWIKI-12781

Note: Currently the following does not work when using jetty as container; see bug report at: http://jira.xwiki.org/browse/XWIKI-12781

简而言之:将您的本地 Maven 存储库添加到 xwiki.properties:

In a nutshell: add your local maven repo to the xwiki.properties:

extension.repositories=local:maven:file://${sys:user.home}/.m2/repository
extension.repositories=maven-xwiki:maven:http://nexus.xwiki.org/nexus/content/groups/public
extension.repositories=extensions.xwiki.org:xwiki:http://extensions.xwiki.org/xwiki/rest/ 

(另外两行需要重新添加默认"repos)

(the other two lines are needed to re-add the "default" repos)

在 Wiki UI 中,安装 Extension Tweak

In the Wiki UI, install the Extension Tweak

然后对于每个构建周期:

Then for each build cycle:

  • 通过 mvn install
  • 构建您的扩展
  • 转到 Wiki 中的扩展部分
  • 在高级搜索"中查找您的扩展程序(您的本地 maven 存储库不可搜索,因此您需要提供完整的 id - 即 my.extension.group:my-extension-id和版本 - 即 0.1-SNAPSHOT)
  • 删除当前安装的扩展
  • 通过/xwiki/bin/view/Admin/InstalledExtensionsTweak 刷新缓存
  • 再次在高级搜索"中查找您的扩展程序,然后安装

因为我不想将我的答案限制在复制指南中的Howto",这里有一个小脚本应该执行重新安装"部分(即在运行 mvn install) 给你:

Because I didn't want to limit my answer to copying the "Howto" in the guide, here is a small script that should do the "reinstall" part (i.e. use it after running mvn install) for you:

# "config" section:

# variables should be URL encoded; '%3A' is ':' 
EXTENSION_ID=org.xwiki.contrib%3Aapplication-mocca-calendar-ui
VERSION=2.5-SNAPSHOT
BASE_URL=http://localhost:8080/xwiki

# of course you can use curl here if you prefer
WGET="wget -q -O /dev/null --auth-no-challenge --http-user=Admin --http-password=admin"
# alternative for debugging
#WGET="wget -S -O - --auth-no-challenge --http-user=Admin --http-password=admin"

QUERY="extensionId=${EXTENSION_ID}&extensionVersion=${VERSION}&extensionNamespace=wiki%3Axwiki&form_token=dummy"

set -o errexit

# first remove the old version of the extension
$WGET "${BASE_URL}/bin/get/XWiki/AddExtensions?basicauth=1&extensionAction=uninstall&${QUERY}"

# confirm uninstall
sleep 1
$WGET "${BASE_URL}/bin/get/XWiki/AddExtensions?basicauth=1&extensionAction=continue&${QUERY}"
# confirm uninstall again (this time to "remove unused pages") 
sleep 1
$WGET "${BASE_URL}/bin/get/XWiki/AddExtensions?basicauth=1&extensionAction=continue&${QUERY}"

# flush the cache
$WGET "${BASE_URL}/bin/get/Admin/InstalledExtensionsTweak?basicauth=1&eaction=clean_confirm"

# add new version
$WGET "${BASE_URL}/bin/get/XWiki/AddExtensions?basicauth=1&extensionAction=install&${QUERY}"

# confirm: start adding
sleep 1
$WGET "${BASE_URL}/bin/get/XWiki/AddExtensions?basicauth=1&extensionAction=continue&${QUERY}"

# just in case we get a conflict: overwrite with new version
sleep 1.5
$WGET "${BASE_URL}/bin/get/XWiki/AddExtensions?basicauth=1&extensionAction=continue&autoResolve=true&versionToKeep=NEXT&${QUERY}"

如果你想使用这个脚本,你必须在 xwiki.properties 中通过设置:csrf.enabled = false 来禁用 CSRF-Protection.(或者,您可以通过从响应中的 HTML 读取 csrf-token 来修改脚本.)

If you want to use this script, your must disable CSRF-Protection in xwiki.properties by setting: csrf.enabled = false. (Alternatively you could modify the script by reading the csrf-token from the HTML in the response.)

脚本没有错误处理.如果您在执行后看不到更新,请执行上述步骤以找出问题所在.

The script has no error handling. If you see no update after executing it, perform the steps outlined above to figure out what went wrong.

这篇关于Xwiki 重新加载组件 jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆