| <!-- |
| /*************************************************************************************************************************** |
| * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file |
| * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file |
| * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance |
| * with the License. You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an |
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the |
| * specific language governing permissions and limitations under the License. |
| ***************************************************************************************************************************/ |
| --> |
| |
| Children |
| |
| <p> |
| Child Resources are REST servlets or objects that are linked to parent resources through the |
| {@link oajr.annotation.Rest#children() @Rest(children)} annotation. |
| </p> |
| <h5 class='figure'>Example:</h5> |
| <p class='bpcode w800'> |
| <jd>/** Parent Resource */</jd> |
| <ja>@Rest</ja>( |
| path=<js>"/parent"</js>, |
| children={FooResource.<jk>class</jk>} |
| ) |
| <jk>public</jk> MyResource <jk>extends</jk> BasicRestServlet {...} |
| </p> |
| <p class='bpcode w800'> |
| <jd>/** Child Resource */</jd> |
| <ja>@Rest</ja>( |
| path=<js>"/foo"</js> <jc>// Path relative to parent resource.</jc> |
| ) |
| <jk>public</jk> FooResource {...} <jc>// Note that we don't need to extend from RestServlet.</jc> |
| </p> |
| <p> |
| The path of the child resource gets appended to the path of the parent resource. |
| So in the example above, the child resource is accessed through the URL <l>/parent/foo</l>. |
| </p> |
| <p> |
| A HUGE advantage of using child resources is that they do not need to be declared in the JEE <l>web.xml</l> |
| file. |
| Initialization of and access to the child resources occurs through the parent resource. |
| Children can be nested arbitrary deep to create complex REST interfaces with a single top-level REST servlet. |
| </p> |
| <ul class='seealso'> |
| <li class='jf'>{@link oajr.RestContext#REST_children} |
| </ul> |