You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

propertyhelper.html 4.0 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <!DOCTYPE html>
  2. <!--
  3. Licensed to the Apache Software Foundation (ASF) under one or more
  4. contributor license agreements. See the NOTICE file distributed with
  5. this work for additional information regarding copyright ownership.
  6. The ASF licenses this file to You under the Apache License, Version 2.0
  7. (the "License"); you may not use this file except in compliance with
  8. the License. You may obtain a copy of the License at
  9. https://www.apache.org/licenses/LICENSE-2.0
  10. Unless required by applicable law or agreed to in writing, software
  11. distributed under the License is distributed on an "AS IS" BASIS,
  12. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. See the License for the specific language governing permissions and
  14. limitations under the License.
  15. -->
  16. <html lang="en">
  17. <head>
  18. <link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
  19. <title>PropertyHelper Task</title>
  20. </head>
  21. <body>
  22. <h2>PropertyHelper</h2>
  23. <p><em>Since Ant 1.8.0</em></p>
  24. <h3>Description</h3>
  25. <p>This task is provided for the purpose of allowing the user to <strong>(a)</strong> install a
  26. different <code>PropertyHelper</code> at run time, or <strong>(b)</strong> (hopefully more often)
  27. install one or more <code class="code">PropertyHelper</code> Delegates into
  28. the <code class="code">PropertyHelper</code> active on the
  29. current <code class="code">Project</code>. This is somewhat advanced Apache Ant usage and assumes a
  30. working familiarity with the modern Ant APIs. See the description of
  31. Ant's <a href="../properties.html#propertyHelper">Property Helper</a> for more information.</p>
  32. <h3>Parameters specified as nested elements</h3>
  33. <h4>PropertyHelper</h4>
  34. <p>You may specify exactly one configured <code>org.apache.tools.ant.PropertyHelper</code>
  35. instance.</p>
  36. <h4>PropertyHelper.Delegate</h4>
  37. <p>You may specify, either in conjunction with a new <code class="code">PropertyHelper</code> or
  38. not, one or more configured implementations of
  39. the <code class="code">org.apache.tools.ant.PropertyHelper.Delegate</code> interface. A deeper
  40. understanding of the API is required here, however, as <code class="code">Delegate</code> is a
  41. marker interface only: the nested arguments must implement a <code class="code">Delegate</code>
  42. subinterface in order to do anything meaningful.</p>
  43. <h4>delegate</h4>
  44. <p>A generic <code>&lt;delegate&gt;</code> element which can use project references is also
  45. provided:</p>
  46. <h5>Parameters</h5>
  47. <table class="attr">
  48. <tr>
  49. <th scope="col">Attribute</th>
  50. <th scope="col">Description</th>
  51. <th scope="col">Required</th>
  52. </tr>
  53. <tr>
  54. <td>refid</td>
  55. <td>The <var>id</var> of a <code>PropertyHelper.Delegate</code> to install.</td>
  56. <td>Yes</td>
  57. </tr>
  58. </table>
  59. <h3>Examples</h3>
  60. <p>Install a completely different <code class="code">PropertyHelper</code> implementation
  61. (assuming <code class="code">MyPropertyHelper extends PropertyHelper</code>):</p>
  62. <pre>
  63. &lt;componentdef classname="org.example.MyPropertyHelper"
  64. name="mypropertyhelper"/>
  65. &lt;propertyhelper>
  66. &lt;mypropertyhelper/>
  67. &lt;/propertyhelper>
  68. </pre>
  69. <p>Add a new <code class="code">PropertyEvaluator</code> delegate
  70. (assuming <code class="code">MyPropertyEvaluator implements
  71. PropertyHelper.PropertyEvaluator</code>). Note that <code class="code">PropertyHelper</code> uses
  72. the configured delegates in LIFO order. I.e. the delegate added by this task will be consulted
  73. before any previously defined delegate and in particular before the built-in ones.</p>
  74. <pre>
  75. &lt;componentdef classname="org.example.MyPropertyEvaluator"
  76. name="mypropertyevaluator"/>
  77. &lt;propertyhelper>
  78. &lt;mypropertyevaluator/>
  79. &lt;/propertyhelper>
  80. </pre>
  81. <p>Add a new <code class="code">PropertyEvaluator</code> delegate using the <var>refid</var>
  82. syntax:</p>
  83. <pre>
  84. &lt;typedef classname="org.example.MyPropertyEvaluator"
  85. name="mypropertyevaluator"/>
  86. &lt;mypropertyevaluator id="evaluator"/>
  87. &lt;propertyhelper>
  88. &lt;delegate refid="evaluator"/>
  89. &lt;/propertyhelper>
  90. </pre>
  91. </body>
  92. </html>