Repository: incubator-juneau Updated Branches: refs/heads/master bed066ee0 -> da2817b93
Simplify the bpIncludes and bpExcludes annotations. Project: http://git-wip-us.apache.org/repos/asf/incubator-juneau/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-juneau/commit/da2817b9 Tree: http://git-wip-us.apache.org/repos/asf/incubator-juneau/tree/da2817b9 Diff: http://git-wip-us.apache.org/repos/asf/incubator-juneau/diff/da2817b9 Branch: refs/heads/master Commit: da2817b939f8dc47735d918e81d73dfdef9dd664 Parents: bed066e Author: JamesBognar <[email protected]> Authored: Tue Jul 11 09:02:39 2017 -0400 Committer: JamesBognar <[email protected]> Committed: Tue Jul 11 09:02:39 2017 -0400 ---------------------------------------------------------------------- juneau-core/src/main/javadoc/overview.html | 21 +- .../juneau/examples/rest/PetStoreResource.java | 2 +- .../eclipse-preferences/user-dictionary.txt | 2 + .../juneau/rest/test/BpIncludesResource.java | 140 ---------- .../apache/juneau/rest/test/BpiResource.java | 140 ++++++++++ .../java/org/apache/juneau/rest/test/Root.java | 2 +- .../apache/juneau/rest/test/BpIncludesTest.java | 253 ------------------ .../org/apache/juneau/rest/test/BpiTest.java | 253 ++++++++++++++++++ .../java/org/apache/juneau/rest/CallMethod.java | 41 +-- .../java/org/apache/juneau/rest/RestConfig.java | 8 + .../org/apache/juneau/rest/RestContext.java | 17 +- .../org/apache/juneau/rest/RestRequest.java | 15 ++ .../org/apache/juneau/rest/RestResponse.java | 8 + .../apache/juneau/rest/annotation/HtmlDoc.java | 266 +++++++++++-------- .../juneau/rest/annotation/MethodSwagger.java | 10 +- .../juneau/rest/annotation/ResourceSwagger.java | 10 +- .../apache/juneau/rest/annotation/Response.java | 3 + .../juneau/rest/annotation/RestMethod.java | 26 +- .../juneau/rest/annotation/RestResource.java | 24 +- .../org/apache/juneau/rest/vars/FileVar.java | 4 +- 20 files changed, 688 insertions(+), 557 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/da2817b9/juneau-core/src/main/javadoc/overview.html ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/javadoc/overview.html b/juneau-core/src/main/javadoc/overview.html index b8c723e..c868d22 100644 --- a/juneau-core/src/main/javadoc/overview.html +++ b/juneau-core/src/main/javadoc/overview.html @@ -6929,8 +6929,6 @@ <li> Simplified the stylesheets and HTML code. <ul> - <li>Replaced <code><xt><h3</xt> <xa>class</xa>=<xs>'title'</xs><xt>></xt></code> with just <code><xt><header></xt>/<xt><h1></xt></code>. - <li>Replaced <code><xt><h5</xt> <xa>class</xa>=<xs>'description'</xs><xt>></xt></code> with just <code><xt><header></xt>/<xt><h2></xt></code>. <li>Replaced <code><xt><a</xt> <xa>class</xa>=<xs>'link'</xs><xt>></xt></code> with just <code><xt><nav></xt>/<xt><a></xt></code>. <li>The nav links are now an ordered list of elements. </ul> @@ -6994,11 +6992,11 @@ <li> Renamed widgets: <ul> - <li><code>PoweredByApacheWidget</code> -< <code>PoweredByApache</code> - <li><code>PoweredByJuneauWidget</code> -< <code>PoweredByJuneau</code> + <li><code>PoweredByApacheWidget</code> -> <code>PoweredByApache</code> + <li><code>PoweredByJuneauWidget</code> -> <code>PoweredByJuneau</code> </ul> <li> - New {@link org.apache.juneau.rest.widget.MenuItemWidget} can be used to create pull-down menu items. + New {@link org.apache.juneau.rest.widget.MenuItemWidget} can be used as a starting point for creatint pull-down menu items. <li> New {@link org.apache.juneau.rest.widget.ContentTypeMenuItem} widget that provides a pull-down menu with hyperlinks for all supported languages for that page: @@ -7069,12 +7067,19 @@ file from the classpath to populate the aside section of a page. <p class='bcode'> htmldoc=<ja>@HtmlDoc</ja>( - <js>// Pull in aside contents from file.</js> + <jc>// Pull in aside contents from file.</jc> aside=<js>"$F{resources/DockerRegistryResourceAside.html}"</js> ) </p> <li> New {@link org.apache.juneau.rest.ReaderResource#toCommentStrippedString()} method. + <li> + The <code>bpIncludes()</code> and <code>bpExcludes()</code> annotations on <ja>@RestMethod</ja> + has been replaced with the following: + <ul> + <li>{@link org.apache.juneau.rest.annotation.RestMethod#bpi() bpi()} - Now an array of simplified values instead of LAX JSON. + <li>{@link org.apache.juneau.rest.annotation.RestMethod#bpx() bpx()} - Now an array of simplified values instead of LAX JSON. + </ul> </ul> <h6 class='topic'>org.apache.juneau.rest.examples</h6> @@ -7370,8 +7375,8 @@ <ul> <li>{@link org.apache.juneau.rest.annotation.RestMethod#defaultQuery() defaultQuery()} <li>{@link org.apache.juneau.rest.annotation.RestMethod#defaultFormData() defaultFormData()} - <li>{@link org.apache.juneau.rest.annotation.RestMethod#bpIncludes() bpIncludes()} - <li>{@link org.apache.juneau.rest.annotation.RestMethod#bpExcludes() bpExcludes()} + <li><code><del>bpIncludes()</del></code> + <li><code><del>bpExcludes()</del></code> </ul> <li> Default values on header, query, and form-data annotations: http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/da2817b9/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/PetStoreResource.java ---------------------------------------------------------------------- diff --git a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/PetStoreResource.java b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/PetStoreResource.java index 84e6b26..42101cc 100644 --- a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/PetStoreResource.java +++ b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/PetStoreResource.java @@ -75,7 +75,7 @@ public class PetStoreResource extends ResourceJena { name="GET", path="/", summary="The complete list of pets in the store", - bpExcludes="{Pet:'breed,getsAlongWith'}", + bpx="Pet: breed,getsAlongWith", // Add our converter for POJO query support. converters=Queryable.class, http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/da2817b9/juneau-releng/eclipse-preferences/user-dictionary.txt ---------------------------------------------------------------------- diff --git a/juneau-releng/eclipse-preferences/user-dictionary.txt b/juneau-releng/eclipse-preferences/user-dictionary.txt index 44e7542..9a5cc4a 100644 --- a/juneau-releng/eclipse-preferences/user-dictionary.txt +++ b/juneau-releng/eclipse-preferences/user-dictionary.txt @@ -480,3 +480,5 @@ myalert onclick popup hyperlinked +bpx +bpi http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/da2817b9/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/BpIncludesResource.java ---------------------------------------------------------------------- diff --git a/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/BpIncludesResource.java b/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/BpIncludesResource.java deleted file mode 100644 index 8960870..0000000 --- a/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/BpIncludesResource.java +++ /dev/null @@ -1,140 +0,0 @@ -// *************************************************************************************************************************** -// * 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. * -// *************************************************************************************************************************** -package org.apache.juneau.rest.test; - -import org.apache.juneau.annotation.*; -import org.apache.juneau.rest.annotation.*; -import org.apache.juneau.rest.jena.*; - -/** - * JUnit automated testcase resource. - */ -@RestResource( - path="/testBpIncludes" -) -public class BpIncludesResource extends RestServletJenaDefault { - private static final long serialVersionUID = 1L; - - //==================================================================================================== - // Validates that the @RestMethod(bpIncludes,bpExcludes) properties work. - //==================================================================================================== - - @RestMethod(name="GET", path="/test/a1", bpIncludes="{MyBeanA:'a,_b'}") - public Object testA1() throws Exception { - return new MyBeanA().init(); - } - - @RestMethod(name="GET", path="/test/a2", bpIncludes="{MyBeanA:'a'}") - public Object testA2() throws Exception { - return new MyBeanA().init(); - } - - @RestMethod(name="GET", path="/test/a3", bpIncludes="{MyBeanA:'_b'}") - public Object testA3() throws Exception { - return new MyBeanA().init(); - } - - @RestMethod(name="GET", path="/test/a4", bpExcludes="{MyBeanA:'a'}") - public Object testA4() throws Exception { - return new MyBeanA().init(); - } - - @RestMethod(name="GET", path="/test/a5", bpExcludes="{MyBeanA:'_b'}") - public Object testA5() throws Exception { - return new MyBeanA().init(); - } - - @RestMethod(name="GET", path="/test/a6", bpExcludes="{MyBeanA:'a,_b'}") - public Object testA6() throws Exception { - return new MyBeanA().init(); - } - - @RestMethod(name="GET", path="/test/b1", bpIncludes="{MyBeanB:'a,_b'}") - public Object testB1() throws Exception { - return new MyBeanB().init(); - } - - @RestMethod(name="GET", path="/test/b2", bpIncludes="{MyBeanB:'a'}") - public Object testB2() throws Exception { - return new MyBeanB().init(); - } - - @RestMethod(name="GET", path="/test/b3", bpIncludes="{MyBeanB:'_b'}") - public Object testB3() throws Exception { - return new MyBeanB().init(); - } - - @RestMethod(name="GET", path="/test/b4", bpExcludes="{MyBeanB:'a'}") - public Object testB4() throws Exception { - return new MyBeanB().init(); - } - - @RestMethod(name="GET", path="/test/b5", bpExcludes="{MyBeanB:'_b'}") - public Object testB5() throws Exception { - return new MyBeanB().init(); - } - - @RestMethod(name="GET", path="/test/b6", bpExcludes="{MyBeanB:'a,_b'}") - public Object testB6() throws Exception { - return new MyBeanB().init(); - } - - @RestMethod(name="GET", path="/test/c1", bpIncludes="{*:'a'}") - public Object testC1() throws Exception { - return new MyBeanA().init(); - } - - @RestMethod(name="GET", path="/test/c2", bpIncludes="{org.apache.juneau.rest.test.BpIncludesResource$MyBeanA:'a'}") - public Object testC2() throws Exception { - return new MyBeanA().init(); - } - - // Should not match. - @RestMethod(name="GET", path="/test/d1", bpIncludes="{MyBean:'a'}") - public Object testD1() throws Exception { - return new MyBeanA().init(); - } - - // Should not match. - @RestMethod(name="GET", path="/test/d2", bpIncludes="{MyBean*:'a'}") - public Object testD2() throws Exception { - return new MyBeanA().init(); - } - - //------------------------------------------------------------------------------------------------------------------- - // Beans - //------------------------------------------------------------------------------------------------------------------- - - public static class MyBeanA { - public int a; - @BeanProperty("_b") public String b; - - MyBeanA init() { - a = 1; - b = "foo"; - return this; - } - } - - @Bean(properties="_b,a") - public static class MyBeanB { - public int a; - @BeanProperty("_b") public String b; - - MyBeanB init() { - a = 1; - b = "foo"; - return this; - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/da2817b9/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/BpiResource.java ---------------------------------------------------------------------- diff --git a/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/BpiResource.java b/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/BpiResource.java new file mode 100644 index 0000000..1aa5fa3 --- /dev/null +++ b/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/BpiResource.java @@ -0,0 +1,140 @@ +// *************************************************************************************************************************** +// * 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. * +// *************************************************************************************************************************** +package org.apache.juneau.rest.test; + +import org.apache.juneau.annotation.*; +import org.apache.juneau.rest.annotation.*; +import org.apache.juneau.rest.jena.*; + +/** + * JUnit automated testcase resource. + */ +@RestResource( + path="/testBpi" +) +public class BpiResource extends RestServletJenaDefault { + private static final long serialVersionUID = 1L; + + //==================================================================================================== + // Validates that the @RestMethod(bpIncludes,bpExcludes) properties work. + //==================================================================================================== + + @RestMethod(name="GET", path="/test/a1", bpi="MyBeanA: a,_b") + public Object testA1() throws Exception { + return new MyBeanA().init(); + } + + @RestMethod(name="GET", path="/test/a2", bpi="MyBeanA: a") + public Object testA2() throws Exception { + return new MyBeanA().init(); + } + + @RestMethod(name="GET", path="/test/a3", bpi="MyBeanA: _b") + public Object testA3() throws Exception { + return new MyBeanA().init(); + } + + @RestMethod(name="GET", path="/test/a4", bpi="MyBeanA: a") + public Object testA4() throws Exception { + return new MyBeanA().init(); + } + + @RestMethod(name="GET", path="/test/a5", bpi="MyBeanA: _b") + public Object testA5() throws Exception { + return new MyBeanA().init(); + } + + @RestMethod(name="GET", path="/test/a6", bpi="MyBeanA: a,_b") + public Object testA6() throws Exception { + return new MyBeanA().init(); + } + + @RestMethod(name="GET", path="/test/b1", bpi="MyBeanB: a,_b") + public Object testB1() throws Exception { + return new MyBeanB().init(); + } + + @RestMethod(name="GET", path="/test/b2", bpi="MyBeanB: a") + public Object testB2() throws Exception { + return new MyBeanB().init(); + } + + @RestMethod(name="GET", path="/test/b3", bpi="MyBeanB: _b") + public Object testB3() throws Exception { + return new MyBeanB().init(); + } + + @RestMethod(name="GET", path="/test/b4", bpi="MyBeanB: a") + public Object testB4() throws Exception { + return new MyBeanB().init(); + } + + @RestMethod(name="GET", path="/test/b5", bpi="MyBeanB: _b'") + public Object testB5() throws Exception { + return new MyBeanB().init(); + } + + @RestMethod(name="GET", path="/test/b6", bpi="MyBeanB: a,_b") + public Object testB6() throws Exception { + return new MyBeanB().init(); + } + + @RestMethod(name="GET", path="/test/c1", bpi="*: a") + public Object testC1() throws Exception { + return new MyBeanA().init(); + } + + @RestMethod(name="GET", path="/test/c2", bpi="org.apache.juneau.rest.test.BpIncludesResource$MyBeanA: a") + public Object testC2() throws Exception { + return new MyBeanA().init(); + } + + // Should not match. + @RestMethod(name="GET", path="/test/d1", bpi="MyBean: a") + public Object testD1() throws Exception { + return new MyBeanA().init(); + } + + // Should not match. + @RestMethod(name="GET", path="/test/d2", bpi="MyBean*: a") + public Object testD2() throws Exception { + return new MyBeanA().init(); + } + + //------------------------------------------------------------------------------------------------------------------- + // Beans + //------------------------------------------------------------------------------------------------------------------- + + public static class MyBeanA { + public int a; + @BeanProperty("_b") public String b; + + MyBeanA init() { + a = 1; + b = "foo"; + return this; + } + } + + @Bean(properties="_b,a") + public static class MyBeanB { + public int a; + @BeanProperty("_b") public String b; + + MyBeanB init() { + a = 1; + b = "foo"; + return this; + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/da2817b9/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/Root.java ---------------------------------------------------------------------- diff --git a/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/Root.java b/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/Root.java index a8ef199..3075e05 100644 --- a/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/Root.java +++ b/juneau-rest-test/src/main/java/org/apache/juneau/rest/test/Root.java @@ -22,7 +22,7 @@ import org.apache.juneau.rest.labels.*; children={ AcceptCharsetResource.class, BeanContextPropertiesResource.class, - BpIncludesResource.class, + BpiResource.class, CallbackStringsResource.class, CharsetEncodingsResource.class, ClientFuturesResource.class, http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/da2817b9/juneau-rest-test/src/test/java/org/apache/juneau/rest/test/BpIncludesTest.java ---------------------------------------------------------------------- diff --git a/juneau-rest-test/src/test/java/org/apache/juneau/rest/test/BpIncludesTest.java b/juneau-rest-test/src/test/java/org/apache/juneau/rest/test/BpIncludesTest.java deleted file mode 100644 index 7439d37..0000000 --- a/juneau-rest-test/src/test/java/org/apache/juneau/rest/test/BpIncludesTest.java +++ /dev/null @@ -1,253 +0,0 @@ -// *************************************************************************************************************************** -// * 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. * -// *************************************************************************************************************************** -package org.apache.juneau.rest.test; - -import static org.junit.Assert.*; - -import java.util.*; - -import org.apache.juneau.*; -import org.apache.juneau.msgpack.*; -import org.apache.juneau.rest.client.*; -import org.junit.*; -import org.junit.runner.*; -import org.junit.runners.*; - -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -@RunWith(Parameterized.class) -public class BpIncludesTest extends RestTestcase { - - @Parameterized.Parameters - public static Collection<Object[]> getParameters() { - return Arrays.asList(new Object[][] { - { /* 0 */ - "a1", - "{a:1,_b:'foo'}", - "<?xml version='1.0' encoding='UTF-8'?><object><a>1</a><_b>foo</_b></object>", - "<table><tr><td>a</td><td>1</td></tr><tr><td>_b</td><td>foo</td></tr></table>", - "(a=1,_b=foo)", - "a=1&_b=foo", - "{a:1,_b:'foo'}", - "<rdf:RDF>\n<rdf:Description>\n<jp:a>1</jp:a>\n<jp:_b>foo</jp:_b>\n</rdf:Description>\n</rdf:RDF>" - }, - { /* 1 */ - "a2", - "{a:1}", - "<?xml version='1.0' encoding='UTF-8'?><object><a>1</a></object>", - "<table><tr><td>a</td><td>1</td></tr></table>", - "(a=1)", - "a=1", - "{a:1}", - "<rdf:RDF>\n<rdf:Description>\n<jp:a>1</jp:a>\n</rdf:Description>\n</rdf:RDF>" - }, - { /* 2 */ - "a3", - "{_b:'foo'}", - "<?xml version='1.0' encoding='UTF-8'?><object><_b>foo</_b></object>", - "<table><tr><td>_b</td><td>foo</td></tr></table>", - "(_b=foo)", - "_b=foo", - "{_b:'foo'}", - "<rdf:RDF>\n<rdf:Description>\n<jp:_b>foo</jp:_b>\n</rdf:Description>\n</rdf:RDF>" - }, - { /* 3 */ - "a4", - "{_b:'foo'}", - "<?xml version='1.0' encoding='UTF-8'?><object><_b>foo</_b></object>", - "<table><tr><td>_b</td><td>foo</td></tr></table>", - "(_b=foo)", - "_b=foo", - "{_b:'foo'}", - "<rdf:RDF>\n<rdf:Description>\n<jp:_b>foo</jp:_b>\n</rdf:Description>\n</rdf:RDF>" - }, - { /* 4 */ - "a5", - "{a:1}", - "<?xml version='1.0' encoding='UTF-8'?><object><a>1</a></object>", - "<table><tr><td>a</td><td>1</td></tr></table>", - "(a=1)", - "a=1", - "{a:1}", - "<rdf:RDF>\n<rdf:Description>\n<jp:a>1</jp:a>\n</rdf:Description>\n</rdf:RDF>" - }, - { /* 5 */ - "a6", - "{}", - "<?xml version='1.0' encoding='UTF-8'?><object/>", - "<table></table>", - "()", - "", - "{}", - "<rdf:RDF>\n</rdf:RDF>" - }, - { /* 6 */ - "b1", - "{_b:'foo',a:1}", - "<?xml version='1.0' encoding='UTF-8'?><object><_b>foo</_b><a>1</a></object>", - "<table><tr><td>_b</td><td>foo</td></tr><tr><td>a</td><td>1</td></tr></table>", - "(_b=foo,a=1)", - "_b=foo&a=1", - "{_b:'foo',a:1}", - "<rdf:RDF>\n<rdf:Description>\n<jp:a>1</jp:a>\n<jp:_b>foo</jp:_b>\n</rdf:Description>\n</rdf:RDF>" - }, - { /* 7 */ - "b2", - "{a:1}", - "<?xml version='1.0' encoding='UTF-8'?><object><a>1</a></object>", - "<table><tr><td>a</td><td>1</td></tr></table>", - "(a=1)", - "a=1", - "{a:1}", - "<rdf:RDF>\n<rdf:Description>\n<jp:a>1</jp:a>\n</rdf:Description>\n</rdf:RDF>" - }, - { /* 8 */ - "b3", - "{_b:'foo'}", - "<?xml version='1.0' encoding='UTF-8'?><object><_b>foo</_b></object>", - "<table><tr><td>_b</td><td>foo</td></tr></table>", - "(_b=foo)", - "_b=foo", - "{_b:'foo'}", - "<rdf:RDF>\n<rdf:Description>\n<jp:_b>foo</jp:_b>\n</rdf:Description>\n</rdf:RDF>" - }, - { /* 9 */ - "b4", - "{_b:'foo'}", - "<?xml version='1.0' encoding='UTF-8'?><object><_b>foo</_b></object>", - "<table><tr><td>_b</td><td>foo</td></tr></table>", - "(_b=foo)", - "_b=foo", - "{_b:'foo'}", - "<rdf:RDF>\n<rdf:Description>\n<jp:_b>foo</jp:_b>\n</rdf:Description>\n</rdf:RDF>" - }, - { /* 10 */ - "b5", - "{a:1}", - "<?xml version='1.0' encoding='UTF-8'?><object><a>1</a></object>", - "<table><tr><td>a</td><td>1</td></tr></table>", - "(a=1)", - "a=1", - "{a:1}", - "<rdf:RDF>\n<rdf:Description>\n<jp:a>1</jp:a>\n</rdf:Description>\n</rdf:RDF>" - }, - { /* 11 */ - "b6", - "{}", - "<?xml version='1.0' encoding='UTF-8'?><object/>", - "<table></table>", - "()", - "", - "{}", - "<rdf:RDF>\n</rdf:RDF>" - }, - { /* 12 */ - "c1", - "{a:1}", - "<?xml version='1.0' encoding='UTF-8'?><object><a>1</a></object>", - "<table><tr><td>a</td><td>1</td></tr></table>", - "(a=1)", - "a=1", - "{a:1}", - "<rdf:RDF>\n<rdf:Description>\n<jp:a>1</jp:a>\n</rdf:Description>\n</rdf:RDF>" - }, - { /* 13 */ - "c2", - "{a:1}", - "<?xml version='1.0' encoding='UTF-8'?><object><a>1</a></object>", - "<table><tr><td>a</td><td>1</td></tr></table>", - "(a=1)", - "a=1", - "{a:1}", - "<rdf:RDF>\n<rdf:Description>\n<jp:a>1</jp:a>\n</rdf:Description>\n</rdf:RDF>" - }, - { /* 14 */ - "d1", - "{a:1,_b:'foo'}", - "<?xml version='1.0' encoding='UTF-8'?><object><a>1</a><_b>foo</_b></object>", - "<table><tr><td>a</td><td>1</td></tr><tr><td>_b</td><td>foo</td></tr></table>", - "(a=1,_b=foo)", - "a=1&_b=foo", - "{a:1,_b:'foo'}", - "<rdf:RDF>\n<rdf:Description>\n<jp:a>1</jp:a>\n<jp:_b>foo</jp:_b>\n</rdf:Description>\n</rdf:RDF>" - }, - { /* 15 */ - "d2", - "{a:1,_b:'foo'}", - "<?xml version='1.0' encoding='UTF-8'?><object><a>1</a><_b>foo</_b></object>", - "<table><tr><td>a</td><td>1</td></tr><tr><td>_b</td><td>foo</td></tr></table>", - "(a=1,_b=foo)", - "a=1&_b=foo", - "{a:1,_b:'foo'}", - "<rdf:RDF>\n<rdf:Description>\n<jp:a>1</jp:a>\n<jp:_b>foo</jp:_b>\n</rdf:Description>\n</rdf:RDF>" - } - }); - } - - private String label; - private String json, xml, html, uon, urlEnc, msgPack, rdfXml; - private RestClient client = TestMicroservice.DEFAULT_CLIENT; - - public BpIncludesTest(String label, String json, String xml, String html, String uon, String urlEnc, String msgPack, String rdfXml) { - this.label = label; - this.json = json; - this.xml = xml; - this.html = html; - this.uon = uon; - this.urlEnc = urlEnc; - this.msgPack = msgPack; - this.rdfXml = rdfXml; - } - - @Test - public void a01_json() throws Exception { - String r = client.doGet("/testBpIncludes/test/" + label).accept("text/json+simple").getResponseAsString(); - assertEquals(json, r); - } - - @Test - public void a02_xml() throws Exception { - String r = client.doGet("/testBpIncludes/test/" + label).accept("text/xml").getResponseAsString().replace('"', '\''); - assertEquals(xml, r); - } - - @Test - public void a03_html() throws Exception { - String r = client.doGet("/testBpIncludes/test/" + label).accept("text/html+stripped").getResponseAsString(); - assertEquals(html, r); - } - - @Test - public void a04_uon() throws Exception { - String r = client.doGet("/testBpIncludes/test/" + label).accept("text/uon").getResponseAsString(); - assertEquals(uon, r); - } - - @Test - public void a05_urlEnc() throws Exception { - String r = client.doGet("/testBpIncludes/test/" + label).accept("application/x-www-form-urlencoded").getResponseAsString(); - assertEquals(urlEnc, r); - } - - @Test - public void a06_msgPack() throws Exception { - String r = client.doGet("/testBpIncludes/test/" + label).accept("octal/msgpack").parser(MsgPackParser.DEFAULT).getResponse(ObjectMap.class).toString(); - assertEquals(msgPack, r); - } - - @Test - public void a07_rdfXml() throws Exception { - String r = client.doGet("/testBpIncludes/test/" + label).accept("text/xml+rdf+abbrev").getResponseAsString(); - r = r.replaceAll("<rdf:RDF[^>]*>", "<rdf:RDF>").replace('"', '\''); - TestUtils.assertEqualsAfterSort(rdfXml, r, "a07_rdfXml failed"); - } -} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/da2817b9/juneau-rest-test/src/test/java/org/apache/juneau/rest/test/BpiTest.java ---------------------------------------------------------------------- diff --git a/juneau-rest-test/src/test/java/org/apache/juneau/rest/test/BpiTest.java b/juneau-rest-test/src/test/java/org/apache/juneau/rest/test/BpiTest.java new file mode 100644 index 0000000..d78f59e --- /dev/null +++ b/juneau-rest-test/src/test/java/org/apache/juneau/rest/test/BpiTest.java @@ -0,0 +1,253 @@ +// *************************************************************************************************************************** +// * 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. * +// *************************************************************************************************************************** +package org.apache.juneau.rest.test; + +import static org.junit.Assert.*; + +import java.util.*; + +import org.apache.juneau.*; +import org.apache.juneau.msgpack.*; +import org.apache.juneau.rest.client.*; +import org.junit.*; +import org.junit.runner.*; +import org.junit.runners.*; + +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +@RunWith(Parameterized.class) +public class BpiTest extends RestTestcase { + + @Parameterized.Parameters + public static Collection<Object[]> getParameters() { + return Arrays.asList(new Object[][] { + { /* 0 */ + "a1", + "{a:1,_b:'foo'}", + "<?xml version='1.0' encoding='UTF-8'?><object><a>1</a><_b>foo</_b></object>", + "<table><tr><td>a</td><td>1</td></tr><tr><td>_b</td><td>foo</td></tr></table>", + "(a=1,_b=foo)", + "a=1&_b=foo", + "{a:1,_b:'foo'}", + "<rdf:RDF>\n<rdf:Description>\n<jp:a>1</jp:a>\n<jp:_b>foo</jp:_b>\n</rdf:Description>\n</rdf:RDF>" + }, + { /* 1 */ + "a2", + "{a:1}", + "<?xml version='1.0' encoding='UTF-8'?><object><a>1</a></object>", + "<table><tr><td>a</td><td>1</td></tr></table>", + "(a=1)", + "a=1", + "{a:1}", + "<rdf:RDF>\n<rdf:Description>\n<jp:a>1</jp:a>\n</rdf:Description>\n</rdf:RDF>" + }, + { /* 2 */ + "a3", + "{_b:'foo'}", + "<?xml version='1.0' encoding='UTF-8'?><object><_b>foo</_b></object>", + "<table><tr><td>_b</td><td>foo</td></tr></table>", + "(_b=foo)", + "_b=foo", + "{_b:'foo'}", + "<rdf:RDF>\n<rdf:Description>\n<jp:_b>foo</jp:_b>\n</rdf:Description>\n</rdf:RDF>" + }, + { /* 3 */ + "a4", + "{_b:'foo'}", + "<?xml version='1.0' encoding='UTF-8'?><object><_b>foo</_b></object>", + "<table><tr><td>_b</td><td>foo</td></tr></table>", + "(_b=foo)", + "_b=foo", + "{_b:'foo'}", + "<rdf:RDF>\n<rdf:Description>\n<jp:_b>foo</jp:_b>\n</rdf:Description>\n</rdf:RDF>" + }, + { /* 4 */ + "a5", + "{a:1}", + "<?xml version='1.0' encoding='UTF-8'?><object><a>1</a></object>", + "<table><tr><td>a</td><td>1</td></tr></table>", + "(a=1)", + "a=1", + "{a:1}", + "<rdf:RDF>\n<rdf:Description>\n<jp:a>1</jp:a>\n</rdf:Description>\n</rdf:RDF>" + }, + { /* 5 */ + "a6", + "{}", + "<?xml version='1.0' encoding='UTF-8'?><object/>", + "<table></table>", + "()", + "", + "{}", + "<rdf:RDF>\n</rdf:RDF>" + }, + { /* 6 */ + "b1", + "{_b:'foo',a:1}", + "<?xml version='1.0' encoding='UTF-8'?><object><_b>foo</_b><a>1</a></object>", + "<table><tr><td>_b</td><td>foo</td></tr><tr><td>a</td><td>1</td></tr></table>", + "(_b=foo,a=1)", + "_b=foo&a=1", + "{_b:'foo',a:1}", + "<rdf:RDF>\n<rdf:Description>\n<jp:a>1</jp:a>\n<jp:_b>foo</jp:_b>\n</rdf:Description>\n</rdf:RDF>" + }, + { /* 7 */ + "b2", + "{a:1}", + "<?xml version='1.0' encoding='UTF-8'?><object><a>1</a></object>", + "<table><tr><td>a</td><td>1</td></tr></table>", + "(a=1)", + "a=1", + "{a:1}", + "<rdf:RDF>\n<rdf:Description>\n<jp:a>1</jp:a>\n</rdf:Description>\n</rdf:RDF>" + }, + { /* 8 */ + "b3", + "{_b:'foo'}", + "<?xml version='1.0' encoding='UTF-8'?><object><_b>foo</_b></object>", + "<table><tr><td>_b</td><td>foo</td></tr></table>", + "(_b=foo)", + "_b=foo", + "{_b:'foo'}", + "<rdf:RDF>\n<rdf:Description>\n<jp:_b>foo</jp:_b>\n</rdf:Description>\n</rdf:RDF>" + }, + { /* 9 */ + "b4", + "{_b:'foo'}", + "<?xml version='1.0' encoding='UTF-8'?><object><_b>foo</_b></object>", + "<table><tr><td>_b</td><td>foo</td></tr></table>", + "(_b=foo)", + "_b=foo", + "{_b:'foo'}", + "<rdf:RDF>\n<rdf:Description>\n<jp:_b>foo</jp:_b>\n</rdf:Description>\n</rdf:RDF>" + }, + { /* 10 */ + "b5", + "{a:1}", + "<?xml version='1.0' encoding='UTF-8'?><object><a>1</a></object>", + "<table><tr><td>a</td><td>1</td></tr></table>", + "(a=1)", + "a=1", + "{a:1}", + "<rdf:RDF>\n<rdf:Description>\n<jp:a>1</jp:a>\n</rdf:Description>\n</rdf:RDF>" + }, + { /* 11 */ + "b6", + "{}", + "<?xml version='1.0' encoding='UTF-8'?><object/>", + "<table></table>", + "()", + "", + "{}", + "<rdf:RDF>\n</rdf:RDF>" + }, + { /* 12 */ + "c1", + "{a:1}", + "<?xml version='1.0' encoding='UTF-8'?><object><a>1</a></object>", + "<table><tr><td>a</td><td>1</td></tr></table>", + "(a=1)", + "a=1", + "{a:1}", + "<rdf:RDF>\n<rdf:Description>\n<jp:a>1</jp:a>\n</rdf:Description>\n</rdf:RDF>" + }, + { /* 13 */ + "c2", + "{a:1}", + "<?xml version='1.0' encoding='UTF-8'?><object><a>1</a></object>", + "<table><tr><td>a</td><td>1</td></tr></table>", + "(a=1)", + "a=1", + "{a:1}", + "<rdf:RDF>\n<rdf:Description>\n<jp:a>1</jp:a>\n</rdf:Description>\n</rdf:RDF>" + }, + { /* 14 */ + "d1", + "{a:1,_b:'foo'}", + "<?xml version='1.0' encoding='UTF-8'?><object><a>1</a><_b>foo</_b></object>", + "<table><tr><td>a</td><td>1</td></tr><tr><td>_b</td><td>foo</td></tr></table>", + "(a=1,_b=foo)", + "a=1&_b=foo", + "{a:1,_b:'foo'}", + "<rdf:RDF>\n<rdf:Description>\n<jp:a>1</jp:a>\n<jp:_b>foo</jp:_b>\n</rdf:Description>\n</rdf:RDF>" + }, + { /* 15 */ + "d2", + "{a:1,_b:'foo'}", + "<?xml version='1.0' encoding='UTF-8'?><object><a>1</a><_b>foo</_b></object>", + "<table><tr><td>a</td><td>1</td></tr><tr><td>_b</td><td>foo</td></tr></table>", + "(a=1,_b=foo)", + "a=1&_b=foo", + "{a:1,_b:'foo'}", + "<rdf:RDF>\n<rdf:Description>\n<jp:a>1</jp:a>\n<jp:_b>foo</jp:_b>\n</rdf:Description>\n</rdf:RDF>" + } + }); + } + + private String label; + private String json, xml, html, uon, urlEnc, msgPack, rdfXml; + private RestClient client = TestMicroservice.DEFAULT_CLIENT; + + public BpiTest(String label, String json, String xml, String html, String uon, String urlEnc, String msgPack, String rdfXml) { + this.label = label; + this.json = json; + this.xml = xml; + this.html = html; + this.uon = uon; + this.urlEnc = urlEnc; + this.msgPack = msgPack; + this.rdfXml = rdfXml; + } + + @Test + public void a01_json() throws Exception { + String r = client.doGet("/testBpi/test/" + label).accept("text/json+simple").getResponseAsString(); + assertEquals(json, r); + } + + @Test + public void a02_xml() throws Exception { + String r = client.doGet("/testBpi/test/" + label).accept("text/xml").getResponseAsString().replace('"', '\''); + assertEquals(xml, r); + } + + @Test + public void a03_html() throws Exception { + String r = client.doGet("/testBpi/test/" + label).accept("text/html+stripped").getResponseAsString(); + assertEquals(html, r); + } + + @Test + public void a04_uon() throws Exception { + String r = client.doGet("/testBpi/test/" + label).accept("text/uon").getResponseAsString(); + assertEquals(uon, r); + } + + @Test + public void a05_urlEnc() throws Exception { + String r = client.doGet("/testBpi/test/" + label).accept("application/x-www-form-urlencoded").getResponseAsString(); + assertEquals(urlEnc, r); + } + + @Test + public void a06_msgPack() throws Exception { + String r = client.doGet("/testBpi/test/" + label).accept("octal/msgpack").parser(MsgPackParser.DEFAULT).getResponse(ObjectMap.class).toString(); + assertEquals(msgPack, r); + } + + @Test + public void a07_rdfXml() throws Exception { + String r = client.doGet("/testBpi/test/" + label).accept("text/xml+rdf+abbrev").getResponseAsString(); + r = r.replaceAll("<rdf:RDF[^>]*>", "<rdf:RDF>").replace('"', '\''); + TestUtils.assertEqualsAfterSort(rdfXml, r, "a07_rdfXml failed"); + } +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/da2817b9/juneau-rest/src/main/java/org/apache/juneau/rest/CallMethod.java ---------------------------------------------------------------------- diff --git a/juneau-rest/src/main/java/org/apache/juneau/rest/CallMethod.java b/juneau-rest/src/main/java/org/apache/juneau/rest/CallMethod.java index 1658dd9..1718dff 100644 --- a/juneau-rest/src/main/java/org/apache/juneau/rest/CallMethod.java +++ b/juneau-rest/src/main/java/org/apache/juneau/rest/CallMethod.java @@ -142,7 +142,6 @@ class CallMethod implements Comparable<CallMethod> { private Response[] responses; private Map<String,Widget> htmlWidgets; - @SuppressWarnings({ "unchecked", "rawtypes" }) private Builder(Object servlet, java.lang.reflect.Method method, RestContext context) throws RestServletException { String sig = method.getDeclaringClass().getName() + '.' + method.getName(); @@ -201,8 +200,8 @@ class CallMethod implements Comparable<CallMethod> { UrlEncodingParserBuilder uepb = null; if (m.serializers().length > 0 || m.parsers().length > 0 || m.properties().length > 0 || m.flags().length > 0 - || m.beanFilters().length > 0 || m.pojoSwaps().length > 0 || m.bpIncludes().length() > 0 - || m.bpExcludes().length() > 0) { + || m.beanFilters().length > 0 || m.pojoSwaps().length > 0 || m.bpi().length > 0 + || m.bpx().length > 0) { sgb = new SerializerGroupBuilder(); pgb = new ParserGroupBuilder(); uepb = new UrlEncodingParserBuilder(urlEncodingParser.createPropertyStore()); @@ -264,20 +263,32 @@ class CallMethod implements Comparable<CallMethod> { sgb.property(p1.name(), p1.value()); for (String p1 : m.flags()) sgb.property(p1, true); - if (! m.bpIncludes().isEmpty()) - try { - sgb.includeProperties((Map)JsonParser.DEFAULT.parse(m.bpIncludes(), Map.class, String.class, String.class)); - } catch (ParseException e) { - throw new RestServletException( - "Invalid format for @RestMethod.bpIncludes() on method ''{0}''. Must be a valid JSON object. \nValue: {1}", sig, m.bpIncludes()); + if (m.bpi().length > 0) { + Map<String,String> bpiMap = new LinkedHashMap<String,String>(); + for (String s : m.bpi()) { + for (String s2 : split(s, ';')) { + int i = s2.indexOf(':'); + if (i == -1) + throw new RestServletException( + "Invalid format for @RestMethod.bpi() on method ''{0}''. Must be in the format \"ClassName: comma-delimited-tokens\". \nValue: {1}", sig, s); + bpiMap.put(s2.substring(0, i).trim(), s2.substring(i+1).trim()); + } } - if (! m.bpExcludes().isEmpty()) - try { - sgb.excludeProperties((Map)JsonParser.DEFAULT.parse(m.bpExcludes(), Map.class, String.class, String.class)); - } catch (ParseException e) { - throw new RestServletException( - "Invalid format for @RestMethod.bpExcludes() on method ''{0}''. Must be a valid JSON object. \nValue: {1}", sig, m.bpExcludes()); + sgb.includeProperties(bpiMap); + } + if (m.bpx().length > 0) { + Map<String,String> bpxMap = new LinkedHashMap<String,String>(); + for (String s : m.bpx()) { + for (String s2 : split(s, ';')) { + int i = s2.indexOf(':'); + if (i == -1) + throw new RestServletException( + "Invalid format for @RestMethod.bpx() on method ''{0}''. Must be in the format \"ClassName: comma-delimited-tokens\". \nValue: {1}", sig, s); + bpxMap.put(s2.substring(0, i).trim(), s2.substring(i+1).trim()); + } } + sgb.excludeProperties(bpxMap); + } sgb.beanFilters(m.beanFilters()); sgb.pojoSwaps(m.pojoSwaps()); } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/da2817b9/juneau-rest/src/main/java/org/apache/juneau/rest/RestConfig.java ---------------------------------------------------------------------- diff --git a/juneau-rest/src/main/java/org/apache/juneau/rest/RestConfig.java b/juneau-rest/src/main/java/org/apache/juneau/rest/RestConfig.java index 38ec9f5..4ccc292 100644 --- a/juneau-rest/src/main/java/org/apache/juneau/rest/RestConfig.java +++ b/juneau-rest/src/main/java/org/apache/juneau/rest/RestConfig.java @@ -1086,6 +1086,7 @@ public class RestConfig implements ServletConfig { * * <p> * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>). + * <br>See {@link RestContext#getVarResolver()} for the list of supported variables. * * <p> * This is the programmatic equivalent to the {@link HtmlDoc#header() @HtmlDoc.header()} annotation. @@ -1110,6 +1111,7 @@ public class RestConfig implements ServletConfig { * * <p> * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>). + * <br>See {@link RestContext#getVarResolver()} for the list of supported variables. * * <p> * A value of <js>"NONE"</js> can be used to force no value. @@ -1145,6 +1147,7 @@ public class RestConfig implements ServletConfig { * * <p> * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>). + * <br>See {@link RestContext#getVarResolver()} for the list of supported variables. * * <p> * A value of <js>"NONE"</js> can be used to force no value. @@ -1171,6 +1174,7 @@ public class RestConfig implements ServletConfig { * * <p> * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>). + * <br>See {@link RestContext#getVarResolver()} for the list of supported variables. * * <p> * A value of <js>"NONE"</js> can be used to force no value. @@ -1197,6 +1201,7 @@ public class RestConfig implements ServletConfig { * * <p> * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>). + * <br>See {@link RestContext#getVarResolver()} for the list of supported variables. * * <p> * A value of <js>"NONE"</js> can be used to force no value. @@ -1220,6 +1225,7 @@ public class RestConfig implements ServletConfig { * * <p> * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>). + * <br>See {@link RestContext#getVarResolver()} for the list of supported variables. * * <p> * A value of <js>"NONE"</js> can be used to force no value. @@ -1250,6 +1256,7 @@ public class RestConfig implements ServletConfig { * <p> * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>) and can use URL protocols defined * by {@link UriResolver}. + * <br>See {@link RestContext#getVarResolver()} for the list of supported variables. * * <p> * This is the programmatic equivalent to the {@link HtmlDoc#stylesheet() @HtmlDoc.stylesheet()} annotation. @@ -1270,6 +1277,7 @@ public class RestConfig implements ServletConfig { * * <p> * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>). + * <br>See {@link RestContext#getVarResolver()} for the list of supported variables. * * <p> * A value of <js>"NONE"</js> can be used to force no value. http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/da2817b9/juneau-rest/src/main/java/org/apache/juneau/rest/RestContext.java ---------------------------------------------------------------------- diff --git a/juneau-rest/src/main/java/org/apache/juneau/rest/RestContext.java b/juneau-rest/src/main/java/org/apache/juneau/rest/RestContext.java index 116bd79..f335985 100644 --- a/juneau-rest/src/main/java/org/apache/juneau/rest/RestContext.java +++ b/juneau-rest/src/main/java/org/apache/juneau/rest/RestContext.java @@ -724,7 +724,7 @@ public final class RestContext extends Context { * <js>"editLevel: servlet:/editLevel?logger=$A{attribute.name, OFF}"</js> * } * header={ - * "<h1>$L{MyLocalizedPageTitle}"</js> + * <js>"<h1>$L{MyLocalizedPageTitle}</h1>"</js> * }, * aside={ * <js>"$F{resources/AsideText.html}"</js> @@ -737,20 +737,25 @@ public final class RestContext extends Context { * <p> * The following is the default list of supported variables: * <ul> - * <li><code>$S{systemProperty[,defaultValue]}</code> - System property. See {@link SystemPropertiesVar}. - * <li><code>$E{envVar[,defaultValue]}</code> - Environment variable. See {@link EnvVariablesVar}. * <li><code>$C{key[,defaultValue]}</code> - Config file entry. See {@link ConfigFileVar}. - * <li><code>$F{key[,defaultValue]}</code> - File resource. See {@link FileVar}. + * <li><code>$E{envVar[,defaultValue]}</code> - Environment variable. See {@link EnvVariablesVar}. + * <li><code>$F{path[,defaultValue]}</code> - File resource. See {@link FileVar}. + * <li><code>$I{name[,defaultValue]}</code> - Servlet init parameter. See {@link ServletInitParamVar}. * <li><code>$L{key[,args...]}</code> - Localized message. See {@link LocalizationVar}. * <li><code>$R{key[,args...]}</code> - Request variable. See {@link RequestVar}. + * <li><code>$S{systemProperty[,defaultValue]}</code> - System property. See {@link SystemPropertiesVar}. * <li><code>$SA{contentType,key[,defaultValue]}</code> - Serialized request attribute. See {@link SerializedRequestAttrVar}. - * <li><code>$I{key[,defaultValue]}</code> - Servlet init parameter. See {@link ServletInitParamVar}. * <li><code>$U{uri}</code> - URI resolver. See {@link UrlVar}. * <li><code>$UE{uriPart}</code> - URL-Encoder. See {@link UrlEncodeVar}. * <li><code>$W{widgetName}</code> - HTML widget variable. See {@link WidgetVar}. + * </ul> + * + * <p> + * The following syntax variables are also provided: + * <ul> * <li><code>$IF{booleanArg,thenValue[,elseValue]}</code> - If/else variable. See {@link IfVar}. * <li><code>$SW{stringArg(,pattern,thenValue)+[,elseValue]}</code> - Switch variable. See {@link SwitchVar}. - * <p> + * </ul> * * <p> * The list of variables can be extended using the {@link RestConfig#addVars(Class...)} method. http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/da2817b9/juneau-rest/src/main/java/org/apache/juneau/rest/RestRequest.java ---------------------------------------------------------------------- diff --git a/juneau-rest/src/main/java/org/apache/juneau/rest/RestRequest.java b/juneau-rest/src/main/java/org/apache/juneau/rest/RestRequest.java index b54cdd5..b98ec6d 100644 --- a/juneau-rest/src/main/java/org/apache/juneau/rest/RestRequest.java +++ b/juneau-rest/src/main/java/org/apache/juneau/rest/RestRequest.java @@ -794,6 +794,21 @@ public final class RestRequest extends HttpServletRequestWrapper { * Returns the localized site name. * * <p> + * The site name is intended to be a title that can be applied to the entire site. + * + * <p> + * One possible use is if you want to add the same title to the top of all pages by defining a header on a + * common parent class like so: + * <p class='bcode'> + * htmldoc=<ja>@HtmlDoc</ja>( + * header={ + * <js>"<h1>$R{siteName}</h1>"</js>, + * <js>"<h2>$R{servletTitle}</h2>"</js> + * } + * ) + * </p> + * + * <p> * Equivalent to calling {@link RestInfoProvider#getSiteName(RestRequest)} with this object. * * @return The localized servlet label. http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/da2817b9/juneau-rest/src/main/java/org/apache/juneau/rest/RestResponse.java ---------------------------------------------------------------------- diff --git a/juneau-rest/src/main/java/org/apache/juneau/rest/RestResponse.java b/juneau-rest/src/main/java/org/apache/juneau/rest/RestResponse.java index e252285..dd997c5 100644 --- a/juneau-rest/src/main/java/org/apache/juneau/rest/RestResponse.java +++ b/juneau-rest/src/main/java/org/apache/juneau/rest/RestResponse.java @@ -452,6 +452,7 @@ public final class RestResponse extends HttpServletResponseWrapper { * * <p> * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>). + * <br>See {@link RestContext#getVarResolver()} for the list of supported variables. * * <p> * This is the programmatic equivalent to the {@link HtmlDoc#header() @HtmlDoc.header()} annotation. @@ -483,6 +484,7 @@ public final class RestResponse extends HttpServletResponseWrapper { * * <p> * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>). + * <br>See {@link RestContext#getVarResolver()} for the list of supported variables. * * <p> * A value of <js>"NONE"</js> can be used to force no value. @@ -525,6 +527,7 @@ public final class RestResponse extends HttpServletResponseWrapper { * * <p> * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>). + * <br>See {@link RestContext#getVarResolver()} for the list of supported variables. * * <p> * A value of <js>"NONE"</js> can be used to force no value. @@ -559,6 +562,7 @@ public final class RestResponse extends HttpServletResponseWrapper { * * <p> * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>). + * <br>See {@link RestContext#getVarResolver()} for the list of supported variables. * * <p> * A value of <js>"NONE"</js> can be used to force no value. @@ -593,6 +597,7 @@ public final class RestResponse extends HttpServletResponseWrapper { * * <p> * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>). + * <br>See {@link RestContext#getVarResolver()} for the list of supported variables. * * <p> * A value of <js>"NONE"</js> can be used to force no value. @@ -624,6 +629,7 @@ public final class RestResponse extends HttpServletResponseWrapper { * * <p> * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>). + * <br>See {@link RestContext#getVarResolver()} for the list of supported variables. * * <p> * A value of <js>"NONE"</js> can be used to force no value. @@ -662,6 +668,7 @@ public final class RestResponse extends HttpServletResponseWrapper { * <p> * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>) and can use URL protocols defined * by {@link UriResolver}. + * <br>See {@link RestContext#getVarResolver()} for the list of supported variables. * * <p> * This is the programmatic equivalent to the {@link HtmlDoc#stylesheet() @HtmlDoc.stylesheet()} annotation. @@ -690,6 +697,7 @@ public final class RestResponse extends HttpServletResponseWrapper { * * <p> * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>). + * <br>See {@link RestContext#getVarResolver()} for the list of supported variables. * * <p> * A value of <js>"NONE"</js> can be used to force no value. http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/da2817b9/juneau-rest/src/main/java/org/apache/juneau/rest/annotation/HtmlDoc.java ---------------------------------------------------------------------- diff --git a/juneau-rest/src/main/java/org/apache/juneau/rest/annotation/HtmlDoc.java b/juneau-rest/src/main/java/org/apache/juneau/rest/annotation/HtmlDoc.java index 955c2d8..936eb65 100644 --- a/juneau-rest/src/main/java/org/apache/juneau/rest/annotation/HtmlDoc.java +++ b/juneau-rest/src/main/java/org/apache/juneau/rest/annotation/HtmlDoc.java @@ -97,19 +97,24 @@ public @interface HtmlDoc { * ) * </p> * - * <p> - * A value of <js>"NONE"</js> can be used to force no header. - * - * <p> - * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>). - * See {@link RestContext#getVarResolver()} for the list of supported variables. - * - * <p> - * Multiple values are combined with newlines into a single string. - * - * <p> - * The programmatic equivalent to this annotation are the - * {@link RestConfig#setHtmlHeader(String)}/{@link RestResponse#setHtmlHeader(Object)} methods. + * <h6 class='topic'>Other Notes</h6> + * <ul class='spaced-list'> + * <li> + * A value of <js>"NONE"</js> can be used to force no header. + * <li> + * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>). + * <br>See {@link RestContext#getVarResolver()} for the list of supported variables. + * <li> + * Multiple values are combined with newlines into a single string. + * <li> + * The programmatic equivalent to this annotation are the + * {@link RestConfig#setHtmlHeader(String)} and {@link RestResponse#setHtmlHeader(Object)} methods. + * <li> + * On methods, this value is inherited from the <ja>@HtmlDoc</ja> annotation on the servlet/resource class. + * <li> + * On servlet/resource classes, this value is inherited from the <ja>@HtmlDoc</ja> annotation on the + * parent class. + * </ul> */ String[] header() default {}; @@ -139,19 +144,24 @@ public @interface HtmlDoc { * ) * </p> * - * <p> - * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>). - * See {@link RestContext#getVarResolver()} for the list of supported variables. - * - * <p> - * A value of <js>"NONE"</js> can be used to force no value. - * - * <p> - * This field can also use URIs of any support type in {@link UriResolver}. - * - * <p> - * The programmatic equivalent to this annotation are the - * {@link RestConfig#setHtmlLinks(String[])}/{@link RestResponse#setHtmlLinks(String[])} methods. + * <h6 class='topic'>Other Notes</h6> + * <ul class='spaced-list'> + * <li> + * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>). + * <br>See {@link RestContext#getVarResolver()} for the list of supported variables. + * <li> + * A value of <js>"NONE"</js> can be used to force no value. + * <li> + * This field can also use URIs of any support type in {@link UriResolver}. + * <li> + * The programmatic equivalent to this annotation are the + * {@link RestConfig#setHtmlLinks(String[])} and {@link RestResponse#setHtmlLinks(String[])} methods. + * <li> + * On methods, this value is inherited from the <ja>@HtmlDoc</ja> annotation on the servlet/resource class. + * <li> + * On servlet/resource classes, this value is inherited from the <ja>@HtmlDoc</ja> annotation on the + * parent class. + * </ul> */ String[] links() default {}; @@ -178,22 +188,26 @@ public @interface HtmlDoc { * ) * </p> * - * <p> - * When a value is specified, the {@link #links()} value will be ignored. - * - * <p> - * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>). - * See {@link RestContext#getVarResolver()} for the list of supported variables. - * - * <p> - * A value of <js>"NONE"</js> can be used to force no value. - * - * <p> - * Multiple values are combined with newlines into a single string. - * - * <p> - * The programmatic equivalent to this annotation are the - * {@link RestConfig#setHtmlNav(String)}/{@link RestResponse#setHtmlNav(Object)} methods. + * <h6 class='topic'>Other Notes</h6> + * <ul class='spaced-list'> + * <li> + * When a value is specified, the {@link #links()} value will be ignored. + * <li> + * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>). + * <br>See {@link RestContext#getVarResolver()} for the list of supported variables. + * <li> + * A value of <js>"NONE"</js> can be used to force no value. + * <li> + * Multiple values are combined with newlines into a single string. + * <li> + * The programmatic equivalent to this annotation are the + * {@link RestConfig#setHtmlNav(String)} and {@link RestResponse#setHtmlNav(Object)} methods. + * <li> + * On methods, this value is inherited from the <ja>@HtmlDoc</ja> annotation on the servlet/resource class. + * <li> + * On servlet/resource classes, this value is inherited from the <ja>@HtmlDoc</ja> annotation on the + * parent class. + * </ul> */ String[] nav() default {}; @@ -217,19 +231,24 @@ public @interface HtmlDoc { * ) * </p> * - * <p> - * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>). - * See {@link RestContext#getVarResolver()} for the list of supported variables. - * - * <p> - * A value of <js>"NONE"</js> can be used to force no value. - * - * <p> - * Multiple values are combined with newlines into a single string. - * - * <p> - * The programmatic equivalent to this annotation are the - * {@link RestConfig#setHtmlAside(String)}/{@link RestResponse#setHtmlAside(Object)} methods. + * <h6 class='topic'>Other Notes</h6> + * <ul class='spaced-list'> + * <li> + * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>). + * <br>See {@link RestContext#getVarResolver()} for the list of supported variables. + * <li> + * A value of <js>"NONE"</js> can be used to force no value. + * <li> + * Multiple values are combined with newlines into a single string. + * <li> + * The programmatic equivalent to this annotation are the + * {@link RestConfig#setHtmlAside(String)} and {@link RestResponse#setHtmlAside(Object)} methods. + * <li> + * On methods, this value is inherited from the <ja>@HtmlDoc</ja> annotation on the servlet/resource class. + * <li> + * On servlet/resource classes, this value is inherited from the <ja>@HtmlDoc</ja> annotation on the + * parent class. + * </ul> */ String[] aside() default {}; @@ -253,19 +272,24 @@ public @interface HtmlDoc { * ) * </p> * - * <p> - * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>). - * See {@link RestContext#getVarResolver()} for the list of supported variables. - * - * <p> - * A value of <js>"NONE"</js> can be used to force no value. - * - * <p> - * Multiple values are combined with newlines into a single string. - * - * <p> - * The programmatic equivalent to this annotation are the - * {@link RestConfig#setHtmlFooter(String)}/{@link RestResponse#setHtmlFooter(Object)} methods. + * <h6 class='topic'>Other Notes</h6> + * <ul class='spaced-list'> + * <li> + * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>). + * <br>See {@link RestContext#getVarResolver()} for the list of supported variables. + * <li> + * A value of <js>"NONE"</js> can be used to force no value. + * <li> + * Multiple values are combined with newlines into a single string. + * <li> + * The programmatic equivalent to this annotation are the + * {@link RestConfig#setHtmlFooter(String)} and {@link RestResponse#setHtmlFooter(Object)} methods. + * <li> + * On methods, this value is inherited from the <ja>@HtmlDoc</ja> annotation on the servlet/resource class. + * <li> + * On servlet/resource classes, this value is inherited from the <ja>@HtmlDoc</ja> annotation on the + * parent class. + * </ul> */ String[] footer() default {}; @@ -287,19 +311,24 @@ public @interface HtmlDoc { * ) * </p> * - * <p> - * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>). - * See {@link RestContext#getVarResolver()} for the list of supported variables. - * - * <p> - * A value of <js>"NONE"</js> can be used to force no value. - * - * <p> - * Multiple values are combined with newlines into a single string. - * - * <p> - * The programmatic equivalent to this annotation are the - * {@link RestConfig#setHtmlStyle(String)}/{@link RestResponse#setHtmlStyle(Object)} methods. + * <h6 class='topic'>Other Notes</h6> + * <ul class='spaced-list'> + * <li> + * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>). + * <br>See {@link RestContext#getVarResolver()} for the list of supported variables. + * <li> + * A value of <js>"NONE"</js> can be used to force no value. + * <li> + * Multiple values are combined with newlines into a single string. + * <li> + * The programmatic equivalent to this annotation are the + * {@link RestConfig#setHtmlStyle(String)} and {@link RestResponse#setHtmlStyle(Object)} methods. + * <li> + * On methods, this value is inherited from the <ja>@HtmlDoc</ja> annotation on the servlet/resource class. + * <li> + * On servlet/resource classes, this value is inherited from the <ja>@HtmlDoc</ja> annotation on the + * parent class. + * </ul> */ String[] style() default {}; @@ -324,14 +353,21 @@ public @interface HtmlDoc { * ) * </p> * - * <p> - * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>) and can use URL protocols defined - * by {@link UriResolver}. - * See {@link RestContext#getVarResolver()} for the list of supported variables. - * - * <p> - * The programmatic equivalent to this annotation are the - * {@link RestConfig#setHtmlStylesheet(String)}/{@link RestResponse#setHtmlStylesheet(Object)} methods. + * <h6 class='topic'>Other Notes</h6> + * <ul class='spaced-list'> + * <li> + * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>) and can use URL protocols + * defined by {@link UriResolver}. + * <br>See {@link RestContext#getVarResolver()} for the list of supported variables. + * <li> + * The programmatic equivalent to this annotation are the + * {@link RestConfig#setHtmlStylesheet(String)}/{@link RestResponse#setHtmlStylesheet(Object)} methods. + * <li> + * On methods, this value is inherited from the <ja>@HtmlDoc</ja> annotation on the servlet/resource class. + * <li> + * On servlet/resource classes, this value is inherited from the <ja>@HtmlDoc</ja> annotation on the + * parent class. + * </ul> */ String stylesheet() default ""; @@ -352,19 +388,24 @@ public @interface HtmlDoc { * ) * </p> * - * <p> - * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>). - * See {@link RestContext#getVarResolver()} for the list of supported variables. - * - * <p> - * A value of <js>"NONE"</js> can be used to force no value. - * - * <p> - * Multiple values are combined with newlines into a single string. - * - * <p> - * The programmatic equivalent to this annotation are the - * {@link RestConfig#setHtmlScript(String)}/{@link RestResponse#setHtmlScript(Object)} methods. + * <h6 class='topic'>Other Notes</h6> + * <ul class='spaced-list'> + * <li> + * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>). + * <br>See {@link RestContext#getVarResolver()} for the list of supported variables. + * <li> + * A value of <js>"NONE"</js> can be used to force no value. + * <li> + * Multiple values are combined with newlines into a single string. + * <li> + * The programmatic equivalent to this annotation are the + * {@link RestConfig#setHtmlScript(String)} and {@link RestResponse#setHtmlScript(Object)} methods. + * <li> + * On methods, this value is inherited from the <ja>@HtmlDoc</ja> annotation on the servlet/resource class. + * <li> + * On servlet/resource classes, this value is inherited from the <ja>@HtmlDoc</ja> annotation on the + * parent class. + * </ul> */ String[] script() default {}; @@ -388,9 +429,17 @@ public @interface HtmlDoc { * By default, uses {@link HtmlDocTemplateBasic} to render the contents, although you can provide your own custom * renderer or subclasses from the basic class to have full control over how the page is rendered. * - * <p> - * The programmatic equivalent to this annotation are the - * {@link RestConfig#setHtmlTemplate(Class)}/{@link RestResponse#setHtmlTemplate(Class)} methods. + * <h6 class='topic'>Other Notes</h6> + * <ul class='spaced-list'> + * <li> + * The programmatic equivalent to this annotation are the + * {@link RestConfig#setHtmlTemplate(Class)} and {@link RestResponse#setHtmlTemplate(Class)} methods. + * <li> + * On methods, this value is inherited from the <ja>@HtmlDoc</ja> annotation on the servlet/resource class. + * <li> + * On servlet/resource classes, this value is inherited from the <ja>@HtmlDoc</ja> annotation on the + * parent class. + * </ul> */ Class<? extends HtmlDocTemplate> template() default HtmlDocTemplate.class; @@ -398,8 +447,11 @@ public @interface HtmlDoc { * Defines widgets that can be used in conjunction with string variables of the form <js>"$W{name}"</js>to quickly * generate arbitrary replacement HTML. * - * <p> - * Widgets are inherited from parent to child, but can be overridden by reusing the widget name. + * <h6 class='topic'>Other Notes</h6> + * <ul class='spaced-list'> + * <li> + * Widgets are inherited from parent to child, but can be overridden by reusing the widget name. + * </ul> */ Class<? extends Widget>[] widgets() default {}; } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/da2817b9/juneau-rest/src/main/java/org/apache/juneau/rest/annotation/MethodSwagger.java ---------------------------------------------------------------------- diff --git a/juneau-rest/src/main/java/org/apache/juneau/rest/annotation/MethodSwagger.java b/juneau-rest/src/main/java/org/apache/juneau/rest/annotation/MethodSwagger.java index 66c6bd4..2b45609 100644 --- a/juneau-rest/src/main/java/org/apache/juneau/rest/annotation/MethodSwagger.java +++ b/juneau-rest/src/main/java/org/apache/juneau/rest/annotation/MethodSwagger.java @@ -51,7 +51,7 @@ public @interface MethodSwagger { * * <p> * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>). - * See {@link RestContext#getVarResolver()} for the list of supported variables. + * <br>See {@link RestContext#getVarResolver()} for the list of supported variables. * * <p> * Corresponds to the swagger field <code>/paths/{path}/{method}/externalDocs</code>. @@ -84,7 +84,7 @@ public @interface MethodSwagger { * * <p> * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>). - * See {@link RestContext#getVarResolver()} for the list of supported variables. + * <br>See {@link RestContext#getVarResolver()} for the list of supported variables. * * <p> * Corresponds to the swagger field <code>/paths/{path}/{method}/tags</code>. @@ -113,7 +113,7 @@ public @interface MethodSwagger { * * <p> * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>). - * See {@link RestContext#getVarResolver()} for the list of supported variables. + * <br>See {@link RestContext#getVarResolver()} for the list of supported variables. * * <p> * Corresponds to the swagger field <code>/paths/{path}/{method}/deprecated</code>. @@ -160,7 +160,7 @@ public @interface MethodSwagger { * * <p> * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>). - * See {@link RestContext#getVarResolver()} for the list of supported variables. + * <br>See {@link RestContext#getVarResolver()} for the list of supported variables. * * <p> * Corresponds to the swagger field <code>/paths/{path}/{method}/parameters</code>. @@ -208,7 +208,7 @@ public @interface MethodSwagger { * * <p> * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>). - * See {@link RestContext#getVarResolver()} for the list of supported variables. + * <br>See {@link RestContext#getVarResolver()} for the list of supported variables. */ Response[] responses() default {}; } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/da2817b9/juneau-rest/src/main/java/org/apache/juneau/rest/annotation/ResourceSwagger.java ---------------------------------------------------------------------- diff --git a/juneau-rest/src/main/java/org/apache/juneau/rest/annotation/ResourceSwagger.java b/juneau-rest/src/main/java/org/apache/juneau/rest/annotation/ResourceSwagger.java index 366f40a..442ec42 100644 --- a/juneau-rest/src/main/java/org/apache/juneau/rest/annotation/ResourceSwagger.java +++ b/juneau-rest/src/main/java/org/apache/juneau/rest/annotation/ResourceSwagger.java @@ -30,7 +30,7 @@ public @interface ResourceSwagger { * * <p> * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>). - * See {@link RestContext#getVarResolver()} for the list of supported variables. + * <br>See {@link RestContext#getVarResolver()} for the list of supported variables. * * <p> * Corresponds to the swagger field <code>/info/termsOfService</code>. @@ -73,7 +73,7 @@ public @interface ResourceSwagger { * * <p> * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>). - * See {@link RestContext#getVarResolver()} for the list of supported variables. + * <br>See {@link RestContext#getVarResolver()} for the list of supported variables. * * <p> * Corresponds to the swagger field <code>/info/contact</code>. @@ -114,7 +114,7 @@ public @interface ResourceSwagger { * * <p> * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>). - * See {@link RestContext#getVarResolver()} for the list of supported variables. + * <br>See {@link RestContext#getVarResolver()} for the list of supported variables. * * <p> * Corresponds to the swagger field <code>/info/license</code>. @@ -136,7 +136,7 @@ public @interface ResourceSwagger { * * <p> * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>). - * See {@link RestContext#getVarResolver()} for the list of supported variables. + * <br>See {@link RestContext#getVarResolver()} for the list of supported variables. * * <p> * Corresponds to the swagger field <code>/info/version</code>. @@ -183,7 +183,7 @@ public @interface ResourceSwagger { * * <p> * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>). - * See {@link RestContext#getVarResolver()} for the list of supported variables. + * <br>See {@link RestContext#getVarResolver()} for the list of supported variables. * * <p> * Corresponds to the swagger field <code>/tags</code>. http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/da2817b9/juneau-rest/src/main/java/org/apache/juneau/rest/annotation/Response.java ---------------------------------------------------------------------- diff --git a/juneau-rest/src/main/java/org/apache/juneau/rest/annotation/Response.java b/juneau-rest/src/main/java/org/apache/juneau/rest/annotation/Response.java index 2080b2a..e124651 100644 --- a/juneau-rest/src/main/java/org/apache/juneau/rest/annotation/Response.java +++ b/juneau-rest/src/main/java/org/apache/juneau/rest/annotation/Response.java @@ -17,6 +17,8 @@ import static java.lang.annotation.RetentionPolicy.*; import java.lang.annotation.*; +import org.apache.juneau.rest.*; + /** * Annotation used in conjunction with {@link MethodSwagger#responses()} to identify possible responses by the method. * @@ -58,6 +60,7 @@ public @interface Response { * * <p> * This field can contain variables (e.g. "$L{my.localized.variable}"). + * <br>See {@link RestContext#getVarResolver()} for the list of supported variables. * * <p> * Corresponds to the swagger field <code>/paths/{path}/{method}/responses/{code}/description</code>. http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/da2817b9/juneau-rest/src/main/java/org/apache/juneau/rest/annotation/RestMethod.java ---------------------------------------------------------------------- diff --git a/juneau-rest/src/main/java/org/apache/juneau/rest/annotation/RestMethod.java b/juneau-rest/src/main/java/org/apache/juneau/rest/annotation/RestMethod.java index ea20632..146552a 100644 --- a/juneau-rest/src/main/java/org/apache/juneau/rest/annotation/RestMethod.java +++ b/juneau-rest/src/main/java/org/apache/juneau/rest/annotation/RestMethod.java @@ -346,27 +346,30 @@ public @interface RestMethod { * } * * <jc>// Only render "id" property.</jc> - * <ja>@RestMethod</ja>(name=<js>"GET"</js>, path=<js>"/mybeans"</js>, bpIncludes=<js>"{MyBean:'id'}"</js>) + * <ja>@RestMethod</ja>(name=<js>"GET"</js>, path=<js>"/mybeans"</js>, bpi=<js>"MyBean: id"</js>) * <jk>public</jk> List<MyBean> getBeanSummary(); * * <jc>// Only render "a" and "b" properties.</jc> - * <ja>@RestMethod</ja>(name=<js>"GET"</js>, path=<js>"/mybeans/{id}"</js>, bpIncludes=<js>"{MyBean:'a,b'}"</js>) + * <ja>@RestMethod</ja>(name=<js>"GET"</js>, path=<js>"/mybeans/{id}"</js>, bpi=<js>"MyBean: a,b"</js>) * <jk>public</jk> MyBean getBeanDetails(<ja>@Path</ja> String id); * </p> * * <p> - * The format of this value is a lax JSON object. + * The format of each value is: <js>"Key: comma-delimited-tokens". * <br>Keys can be fully-qualified or short class names or <js>"*"</js> to represent all classes. * <br>Values are comma-delimited lists of bean property names. * <br>Properties apply to specified class and all subclasses. + * + * <p> + * Semicolons can be used as an additional separator for multiple values: <code>bpi="Bean1: foo; Bean2: bar,baz"</code> */ - String bpIncludes() default ""; + String[] bpi() default {}; /** * Shortcut for specifying the {@link BeanContext#BEAN_excludeProperties} property on all serializers. * * <p> - * Same as {@link #bpIncludes()} except you specify a list of bean property names that you want to exclude from + * Same as {@link #bpi()} except you specify a list of bean property names that you want to exclude from * serialization. * * <p> @@ -384,7 +387,7 @@ public @interface RestMethod { * } * * <jc>// Don't show "a" and "b" properties.</jc> - * <ja>@RestMethod</ja>(name=<js>"GET"</js>, path=<js>"/mybeans"</js>, bpExcludes=<js>"{MyBean:'a,b'}"</js>) + * <ja>@RestMethod</ja>(name=<js>"GET"</js>, path=<js>"/mybeans"</js>, bpx=<js>"MyBean: a,b"</js>) * <jk>public</jk> List<MyBean> getBeanSummary(); * * <jc>// Render all properties.</jc> @@ -393,12 +396,15 @@ public @interface RestMethod { * </p> * * <p> - * The format of this value is a lax JSON object. + * The format of each value is: <js>"Key: comma-delimited-tokens". * <br>Keys can be fully-qualified or short class names or <js>"*"</js> to represent all classes. * <br>Values are comma-delimited lists of bean property names. * <br>Properties apply to specified class and all subclasses. + * + * <p> + * Semicolons can be used as an additional separator for multiple values: <code>bpi="Bean1: foo; Bean2: bar,baz"</code> */ - String bpExcludes() default ""; + String[] bpx() default {}; /** * Specifies default values for request headers. @@ -501,7 +507,7 @@ public @interface RestMethod { * * <p> * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>). - * See {@link RestContext#getVarResolver()} for the list of supported variables. + * <br>See {@link RestContext#getVarResolver()} for the list of supported variables. * * <p> * Corresponds to the swagger field <code>/paths/{path}/{method}/summary</code>. @@ -529,7 +535,7 @@ public @interface RestMethod { * * <p> * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>). - * See {@link RestContext#getVarResolver()} for the list of supported variables. + * <br>See {@link RestContext#getVarResolver()} for the list of supported variables. * * <p> * Corresponds to the swagger field <code>/paths/{path}/{method}/description</code>. http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/da2817b9/juneau-rest/src/main/java/org/apache/juneau/rest/annotation/RestResource.java ---------------------------------------------------------------------- diff --git a/juneau-rest/src/main/java/org/apache/juneau/rest/annotation/RestResource.java b/juneau-rest/src/main/java/org/apache/juneau/rest/annotation/RestResource.java index 0d24ac4..d5fa611 100644 --- a/juneau-rest/src/main/java/org/apache/juneau/rest/annotation/RestResource.java +++ b/juneau-rest/src/main/java/org/apache/juneau/rest/annotation/RestResource.java @@ -422,12 +422,26 @@ public @interface RestResource { * Optional site name. * * <p> - * Used as a label for the overall site. + * The site name is intended to be a title that can be applied to the entire site. + * + * <p> * This value can be retrieved programmatically through the {@link RestRequest#getSiteName()} method. * * <p> + * One possible use is if you want to add the same title to the top of all pages by defining a header on a + * common parent class like so: + * <p class='bcode'> + * htmldoc=<ja>@HtmlDoc</ja>( + * header={ + * <js>"<h1>$R{siteName}</h1>"</js>, + * <js>"<h2>$R{servletTitle}</h2>"</js> + * } + * ) + * </p> + * + * <p> * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>). - * See {@link RestContext#getVarResolver()} for the list of supported variables. + * <br>See {@link RestContext#getVarResolver()} for the list of supported variables. * * <p> * The programmatic equivalent to this annotation is the {@link RestInfoProvider#getSiteName(RestRequest)} method. @@ -447,7 +461,7 @@ public @interface RestResource { * * <p> * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>). - * See {@link RestContext#getVarResolver()} for the list of supported variables. + * <br>See {@link RestContext#getVarResolver()} for the list of supported variables. * * <p> * Corresponds to the swagger field <code>/info/title</code>. @@ -470,7 +484,7 @@ public @interface RestResource { * * <p> * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>). - * See {@link RestContext#getVarResolver()} for the list of supported variables. + * <br>See {@link RestContext#getVarResolver()} for the list of supported variables. * * <p> * Corresponds to the swagger field <code>/info/description</code>. @@ -488,7 +502,7 @@ public @interface RestResource { * * <p> * This field can contain variables (e.g. <js>"$L{my.localized.variable}"</js>). - * See {@link RestContext#getVarResolver()} for the list of supported variables. + * <br>See {@link RestContext#getVarResolver()} for the list of supported variables. * * <p> * The programmatic equivalent to this annotation is the {@link RestConfig#setConfigFile(ConfigFile)} method. http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/da2817b9/juneau-rest/src/main/java/org/apache/juneau/rest/vars/FileVar.java ---------------------------------------------------------------------- diff --git a/juneau-rest/src/main/java/org/apache/juneau/rest/vars/FileVar.java b/juneau-rest/src/main/java/org/apache/juneau/rest/vars/FileVar.java index d728ca8..66c773e 100644 --- a/juneau-rest/src/main/java/org/apache/juneau/rest/vars/FileVar.java +++ b/juneau-rest/src/main/java/org/apache/juneau/rest/vars/FileVar.java @@ -45,6 +45,8 @@ import org.apache.juneau.utils.*; * <li><js>"MyResource.txt"</js> * </ol> * + * <p> + * Example: * <p class='bcode'> * <ja>@RestResource</ja>( * htmldoc=<ja>@HtmlDoc</ja>( @@ -54,7 +56,7 @@ import org.apache.juneau.utils.*; * </p> * * <p> - * Files of type HTML, JSON, Javascript, or CSS will be stripped of comments. + * Files of type HTML, XHTML, XML, JSON, Javascript, and CSS will be stripped of comments. * This allows you to place license headers in files without them being serialized to the output. * * @see org.apache.juneau.svl
