-
Notifications
You must be signed in to change notification settings - Fork 4
/
servlet-mappings.xml
115 lines (108 loc) · 3.77 KB
/
servlet-mappings.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<project name="servlet-mappings" default="servlet.mappings.update"
basedir="./" xmlns:antcontrib="antlib:net.sf.antcontrib">
<target name="servlet.fileservlet.install" if="exists.mappings.xml">
<xmltask source="${war.target.dir}/WEB-INF/web.xml" dest="${war.target.dir}/WEB-INF/web.xml">
<xmlcatalog refId="commonDTDs"/>
<insert path="web-app/servlet[1]" position="before">
<![CDATA[
<!-- railo file servlet -->
<servlet>
<servlet-name>FileServlet</servlet-name>
<description>File Servlet for simple files</description>
<servlet-class>railo.loader.servlet.FileServlet</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>FileServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
]]>
</insert>
</xmltask>
</target>
<target name="servlet.mappings.update" if="exists.mappings.xml">
<xmltask sourcebuffer="mappings.buff">
<xmlcatalog refId="commonDTDs"/>
<call path="mappings/*">
<param name="virtual" path="@virtual" default="NONE" />
<param name="physical" path="@physical" default="NONE" />
<actions>
<cfms-to-servlet-mapping physical="@{physical}" virtual="@{virtual}" />
</actions>
</call>
</xmltask>
</target>
<macrodef name="servlet-mapping">
<attribute name="physical" />
<attribute name="virtual" />
<attribute name="rest" default="false" />
<sequential>
<antcontrib:var unset="true" name="cfmlServletName" />
<antcontrib:if>
<equals arg1="@{rest}" arg2="true" />
<then>
<property name="cfmlServletName" value="RESTServlet" />
</then>
</antcontrib:if>
<antcontrib:if>
<equals arg1="${default.cfengine}" arg2="railo" />
<then>
<echo message="setting railo servlet mappings: ${default.cfengine} url-pattern:@{virtual}"/>
<property name="cfmlServletName" value="CFMLServlet" />
</then>
<else>
<echo message="setting acf servlet mappings: ${default.cfengine} url-pattern:@{virtual}"/>
<property name="cfmlServletName" value="CfmServlet" />
</else>
</antcontrib:if>
<antcontrib:var name="rule.exists" unset="true"/>
<xmltask source="${war.target.dir}/WEB-INF/web.xml"
dest="${war.target.dir}/WEB-INF/web.xml">
<xmlcatalog refId="commonDTDs"/>
<copy path="web-app/servlet-mapping[url-pattern='@{virtual}']/text()" attrValue="true" property="rule.exists"/>
<print path="web-app/servlet-mapping[url-pattern='@{virtual}']"/>
<replace path="web-app/servlet-mapping[url-pattern='@{virtual}']" if="rule.exists">
<![CDATA[
<servlet-mapping>
<servlet-name>${cfmlServletName}</servlet-name>
<url-pattern>@{virtual}</url-pattern>
</servlet-mapping>
]]>
</replace>
<insert path="web-app/servlet[last()]" position="after" unless="rule.exists">
<![CDATA[
<servlet-mapping>
<servlet-name>${cfmlServletName}</servlet-name>
<url-pattern>@{virtual}</url-pattern>
</servlet-mapping>
]]>
</insert>
</xmltask>
</sequential>
</macrodef>
<macrodef name="cfms-to-servlet-mapping">
<attribute name="physical" />
<attribute name="virtual" />
<sequential>
<antcontrib:trycatch property="errmsg">
<try>
<antcontrib:for param="file">
<fileset dir="@{physical}" includes="*.cfm *.cfc" excludes="Application.cfc Application.cfm"/>
<sequential>
<antcontrib:var name="cfmlfile" unset="true" />
<antcontrib:propertyregex property="cfmlfile"
input="@{file}"
regexp=".*[/|\\]+(.*)"
select="\1"
casesensitive="false" />
<servlet-mapping physical="@{physical}" virtual="@{virtual}/${cfmlfile}/*"/>
</sequential>
</antcontrib:for>
</try>
<catch>
<echo message="${errmsg}"/>
</catch>
</antcontrib:trycatch>
</sequential>
</macrodef>
</project>