Skip to content

Commit eb22c80

Browse files
committed
Fixed rest demo
1 parent 0728a9d commit eb22c80

3 files changed

Lines changed: 10 additions & 7 deletions

File tree

‎showcase/multi-domain/src/main/java/com/ocpsoft/rewrite/showcase/domain/DomainRewriteConfiguration.java‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,14 @@ public Configuration getConfiguration(final ServletContext context)
4949
.andNot(QueryString.parameterExists("disableDomainRewrite")))
5050
.perform(Invoke.binding(El.retrievalMethod("#{domains.load}")))
5151

52+
.addRule(Join.path("/").to("/index.xhtml").withInboundCorrection())
53+
5254
/**
5355
* Access http://{domain}.example.com:8080/context/literal and you should see a FileNotFoundException or
5456
* * 404 for "/{domain}.xhtml", where "{domain}" matches the sub-domain of example.com
5557
*/
56-
.addRule(Join.path("/literal").to("/{domain}.xhtml").when(Domain.matches("{domain}.example.com")));
58+
.addRule(Join.path("/literal").to("/{domain}.xhtml")
59+
.when(Domain.matches("{domain}.example.com")));
5760
}
5861

5962
@Override

‎showcase/rest-ws/src/main/java/com/ocpsoft/rewrite/showcase/rest/ProductRegistry.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ public class ProductRegistry
3333

3434
public ProductRegistry()
3535
{
36-
products.add(new Product("Football Ticket", "Tickets to see your favorite football team. We know your favorite.",
36+
add(new Product("Football Ticket", "Tickets to see your favorite football team. We know your favorite.",
3737
65.99));
38-
products.add(new Product("Baseball Cap", "Always stylish, sometimes practical; forward use only.", 15.99));
39-
products.add(new Product("Snug-fit Swim Trunks", "Somehow not as interesting as the female counterpart.", 20.99));
40-
products.add(new Product("Purple 2-Piece Bikini", "Who doesn't like purple?", 30.99));
38+
add(new Product("Baseball Cap", "Always stylish, sometimes practical; forward use only.", 15.99));
39+
add(new Product("Snug-fit Swim Trunks", "Somehow not as interesting as the female counterpart.", 20.99));
40+
add(new Product("Purple 2-Piece Bikini", "Who doesn't like purple?", 30.99));
4141
}
4242

4343
public Product getById(final int id)

‎showcase/rest-ws/src/main/java/com/ocpsoft/rewrite/showcase/rest/RestRewriteConfiguration.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ public void performHttp(final HttpServletRewrite event, final EvaluationContext
6969
* bindings such as {@link El}, the value will be bound directly to the type of the referenced
7070
* property type, and this array downcast is not necessary.
7171
*/
72-
Object[] product = (Object[]) Evaluation.property("pid").retrieve(event, context);
72+
Product product = (Product) Evaluation.property("pid").retrieve(event, context);
7373

7474
/**
7575
* Marshal the Product into XML using JAXB. This has been extracted into a utility class.
7676
*/
7777
try {
78-
XMLUtil.streamFromObject(Product.class, (Product) product[0], event.getResponse()
78+
XMLUtil.streamFromObject(Product.class, product, event.getResponse()
7979
.getOutputStream());
8080
}
8181
catch (IOException e) {

0 commit comments

Comments
 (0)