我正在關注java支持webscripts的alfresco維基指南,並且無法使其工作。更糟的是,我無法在日誌或其他方面產生錯誤,或者在/ alfresco/service/index/all中列出webscript。java支持webscript根本不顯示
除了這個wiki的例子,我沒有使用AMP,而是爲我的課程使用了一個jar。這是因爲我必須將我的web腳本添加到當前構建到jar中的現有應用程序中。
據我瞭解,有在創建Java支持webscript三個主要步驟:
- 創建Java類
- 註冊豆
- 將描述符
我執行如下。文件位置相對於jar的根目錄。 NL /標記/露天/爲MyService/webscript/GetFooTypes.java
package nl.mark.alfresco.myservice.webscript;
import java.util.HashMap;
import java.util.Map;
import org.springframework.extensions.webscripts.DeclarativeWebScript;
import org.springframework.extensions.webscripts.Status;
import org.springframework.extensions.webscripts.WebScriptRequest;
public class GetFooTypes extends DeclarativeWebScript {
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status) {
Map<String, Object> model = new HashMap<String, Object>();
model.put("types", "[\"foo\", \"bar\"]");
return model;
}
}
露天/擴展/模板/ webscripts/NL /標記/ cacher的/ footype.desc.xml
<webscript>
<shortname>Retrieve a list of foo types associated to a bar type.</shortname>
<description>Returns an empty JSON array or a JSON array filled with foo types as Strings, named 'types'.</description>
<url>/mark/cacher/footype?typecode={code}</url>
<authentication>user</authentication>
<family>Mark cacher</family>
</webscript>
露天/擴展/標記的context.xml
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
<!-- Java backed webscripts -->
<bean id="webscript.nl.mark.cacher.footype.get" class="nl.mark.alfresco.myservice.webscript.GetFooTypes"
parent="webscript">
</bean>
</beans>
這mark-context.xml
文件也包含其他註冊,它們都被正確拾取。
最後,將此jar放在露天的WEB-INF/lib文件夾中,然後重新啓動服務器。但是,webscript在其URL(404)下不可用,並且我發現沒有提及(awefully clean)日誌中的任何相關內容。它也沒有在webscripts索引中列出,甚至沒有加載失敗。我覺得我在搞亂文件位置。
快速猜測(有沒有正在運行的露天這裏):重命名描述爲「footype.get.desc.xml」 –