Alfresco java-backend web-script

Alfresco web-script 功能强大,不需重启应用。这里提供一个例子列出我项目中基于Alfresco java-backend web-script的应用。

在扩展的Alfresco项目中(规定死了目录结构),提供web-script的描述文件和freemarker模板。
searchArticle.get.desc.xml
<webscript>
	<shortname>Search Articles</shortname>
	<description>Search My Articles</description>
	<url>/tsgrp/articles/search/{condition}/{args}</url>
	<format default="xml">argument</format>
	<authentication>guest</authentication>
</webscript>


searchArticle.get.xml.ftl
<?xml version="1.0" encoding="UTF-8"?>
<articles>
	<#list articles as articleInstance>
	<article>
		<id>${articleInstance.id}</id>
		<authors>
			<#assign authorInstance = articleInstance.authors>
			<#list authorInstance as authorInfo>
				<author>
					<firstName>${authorInfo.firstName}</firstName>
					<lastName>${authorInfo.lastName}</lastName>
				</author>
......
......
</articles>



java-backend web-script control class:
public class Searcher extends DeclarativeWebScript {
@Override
	protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
		Map<String, String> vars = req.getServiceMatch().getTemplateVars();
      Map<String, Object> results;
....
....
        //results  returns a map which contains a sources list for freemarker rendering
	return results;
	}


Spring扩展的module-context.xml
<bean id="....searchArticle.get" class=".....Searcher" parent="webscript"> 
</bean> 


module-context.xml中id对应web-script的desc描述文件地址,class对应web-script的逻辑控制处理类。

你可能感兴趣的:(java,spring,Web,freemarker,xml)