| <!-- |
| /*************************************************************************************************************************** |
| * 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. |
| ***************************************************************************************************************************/ |
| --> |
| |
| URIs |
| |
| <p> |
| As mention earlier {@doc juneau-marshall.URIs here}, Juneau serializers have sophisticated support for transforming relative URIs to absolute form. |
| </p> |
| <p> |
| The following example shows a REST method that returns a list of URIs of various forms: |
| </p> |
| <p class='bpcode w800'> |
| <ja>@RestResource</ja>( |
| uriAuthority=<js>"http://foo.com:123"</js>, |
| uriContext=<js>"/myContext"</js> |
| ) |
| <jk>public class</jk> MyResource { |
| |
| <ja>@RestMethod</ja> |
| <jk>public</jk> URI[] getURIs() { |
| <jk>return new</jk> URI[] { |
| URI.<jsm>create</jsm>(<js>"http://www.apache.org/f1a"</js>), |
| URI.<jsm>create</jsm>(<js>"/f1b"</js>), |
| URI.<jsm>create</jsm>(<js>"/f1c/x/y"</js>), |
| URI.<jsm>create</jsm>(<js>"f1d"</js>), |
| URI.<jsm>create</jsm>(<js>"f1e/x/y"</js>), |
| URI.<jsm>create</jsm>(<js>""</js>), |
| URI.<jsm>create</jsm>(<js>"context:/f2a/x"</js>), |
| URI.<jsm>create</jsm>(<js>"context:/f2b"</js>), |
| URI.<jsm>create</jsm>(<js>"context:/"</js>), |
| URI.<jsm>create</jsm>(<js>"context:/.."</js>), |
| URI.<jsm>create</jsm>(<js>"servlet:/f3a/x"</js>), |
| URI.<jsm>create</jsm>(<js>"servlet:/f3b"</js>), |
| URI.<jsm>create</jsm>(<js>"servlet:/"</js>), |
| URI.<jsm>create</jsm>(<js>"servlet:/.."</js>), |
| URI.<jsm>create</jsm>(<js>"request:/f4a/x"</js>), |
| URI.<jsm>create</jsm>(<js>"request:/f4b"</js>), |
| URI.<jsm>create</jsm>(<js>"request:/"</js>), |
| URI.<jsm>create</jsm>(<js>"request:/.."</js>) |
| }; |
| } |
| } |
| </p> |
| <p> |
| When requested as JSON, it produces the following result: |
| </p> |
| <p class='bpcode w800'> |
| { |
| <jok>f1a</jok>:<jov>'http://www.apache.org/f1a'</jov>, |
| <jok>f1b</jok>:<jov>'http://foo.com:123/f1b'</jov>, |
| <jok>f1c</jok>:<jov>'http://foo.com:123/f1c/x/y'</jov>, |
| <jok>f1d</jok>:<jov>'http://foo.com:123/myContext/myServlet/f1d'</jov>, |
| <jok>f1e</jok>:<jov>'http://foo.com:123/myContext/myServlet/f1e/x/y'</jov>, |
| <jok>f1f</jok>:<jov>'http://foo.com:123/myContext/myServlet'</jov>, |
| <jok>f2a</jok>:<jov>'http://foo.com:123/myContext/f2a/x'</jov>, |
| <jok>f2b</jok>:<jov>'http://foo.com:123/myContext/f2b'</jov>, |
| <jok>f2c</jok>:<jov>'http://foo.com:123/myContext'</jov>, |
| <jok>f2d</jok>:<jov>'http://foo.com:123'</jov>, |
| <jok>f3a</jok>:<jov>'http://foo.com:123/myContext/myServlet/f3a/x'</jov>, |
| <jok>f3b</jok>:<jov>'http://foo.com:123/myContext/myServlet/f3b'</jov>, |
| <jok>f3c</jok>:<jov>'http://foo.com:123/myContext/myServlet'</jov>, |
| <jok>f3d</jok>:<jov>'http://foo.com:123/myContext'</jov>, |
| <jok>f4a</jok>:<jov>'http://foo.com:123/myContext/myServlet/myPath/f4a/x'</jov>, |
| <jok>f4b</jok>:<jov>'http://foo.com:123/myContext/myServlet/myPath/f4b'</jov>, |
| <jok>f4c</jok>:<jov>'http://foo.com:123/myContext/myServlet/myPath'</jov>, |
| <jok>f4d</jok>:<jov>'http://foo.com:123/myContext/myServlet'</jov> |
| } |
| </p> |
| <p> |
| URI resolution is controlled by the following settings: |
| </p> |
| <ul class='javatree'> |
| <li class='jc'>{@link oajr.RestContext} |
| <ul> |
| <li class='jf'>{@link oajr.RestContext#REST_uriAuthority REST_uriAuthority} |
| <li class='jf'>{@link oajr.RestContext#REST_uriContext REST_uriContext} |
| <li class='jf'>{@link oajr.RestContext#REST_uriRelativity REST_uriRelativity} |
| <li class='jf'>{@link oajr.RestContext#REST_uriResolution REST_uriResolution} |
| </ul> |
| </ul> |
| |
| <p> |
| URIs are resolved by both regular and part serializers. |
| </p> |
| |