Skip to content

Commit ac7b73e

Browse files
committed
Updated for latest RestExpress release.
1 parent e0e0c3e commit ac7b73e

File tree

11 files changed

+72
-73
lines changed

11 files changed

+72
-73
lines changed

benchmark/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<dependency>
2121
<groupId>com.strategicgains</groupId>
2222
<artifactId>RestExpress</artifactId>
23-
<version>0.11.2</version>
23+
<version>0.11.3</version>
2424
</dependency>
2525
<dependency>
2626
<groupId>junit</groupId>

blogging/pom.xml

+10-10
Original file line numberDiff line numberDiff line change
@@ -30,52 +30,52 @@
3030
<dependency>
3131
<groupId>com.strategicgains</groupId>
3232
<artifactId>RestExpress</artifactId>
33-
<version>0.11.0</version>
33+
<version>0.11.3</version>
3434
</dependency>
3535
<dependency>
3636
<groupId>com.strategicgains</groupId>
3737
<artifactId>HyperExpressPlugin</artifactId>
38-
<version>2.3</version>
38+
<version>2.6</version>
3939
</dependency>
4040
<dependency>
4141
<groupId>com.strategicgains.plugin-express</groupId>
4242
<artifactId>CacheControlPlugin</artifactId>
43-
<version>0.3.0</version>
43+
<version>0.3.3</version>
4444
</dependency>
4545
<dependency>
4646
<groupId>com.strategicgains.plugin-express</groupId>
4747
<artifactId>SwaggerPlugin</artifactId>
48-
<version>0.3.0</version>
48+
<version>0.3.3</version>
4949
</dependency>
5050
<dependency>
5151
<groupId>com.strategicgains.plugin-express</groupId>
5252
<artifactId>MetricsPlugin</artifactId>
53-
<version>0.3.0</version>
53+
<version>0.3.3</version>
5454
</dependency>
5555
<dependency>
5656
<groupId>com.strategicgains.plugin-express</groupId>
5757
<artifactId>CORSPlugin</artifactId>
58-
<version>0.3.0</version>
58+
<version>0.3.3</version>
5959
</dependency>
6060
<dependency>
6161
<groupId>com.strategicgains</groupId>
6262
<artifactId>Syntaxe</artifactId>
63-
<version>0.4.9</version>
63+
<version>1.0</version>
6464
</dependency>
6565
<dependency>
6666
<groupId>com.strategicgains.repoexpress</groupId>
6767
<artifactId>repoexpress-mongodb</artifactId>
68-
<version>0.4.5</version>
68+
<version>0.4.8</version>
6969
</dependency>
7070
<dependency>
7171
<groupId>com.strategicgains.domain-eventing</groupId>
7272
<artifactId>domain-eventing-core</artifactId>
73-
<version>0.4.5</version>
73+
<version>1.0</version>
7474
</dependency>
7575
<dependency>
7676
<groupId>io.dropwizard.metrics</groupId>
7777
<artifactId>metrics-graphite</artifactId>
78-
<version>3.1.0</version>
78+
<version>3.1.2</version>
7979
</dependency>
8080
<dependency>
8181
<groupId>junit</groupId>

blogging/src/main/java/org/restexpress/example/blogging/controller/BlogController.java

+6-22
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package org.restexpress.example.blogging.controller;
22

33
import static com.strategicgains.repoexpress.adapter.Identifiers.UUID;
4-
import io.netty.handler.codec.http.HttpMethod;
54

65
import java.util.List;
76

@@ -17,15 +16,16 @@
1716
import org.restexpress.query.QueryOrders;
1817
import org.restexpress.query.QueryRanges;
1918

20-
import com.strategicgains.hyperexpress.HyperExpress;
21-
import com.strategicgains.hyperexpress.builder.TokenBinder;
22-
import com.strategicgains.hyperexpress.builder.TokenResolver;
19+
import com.strategicgains.hyperexpress.builder.DefaultTokenResolver;
20+
import com.strategicgains.hyperexpress.builder.DefaultUrlBuilder;
2321
import com.strategicgains.hyperexpress.builder.UrlBuilder;
2422
import com.strategicgains.syntaxe.ValidationEngine;
2523

24+
import io.netty.handler.codec.http.HttpMethod;
25+
2626
public class BlogController
2727
{
28-
private static final UrlBuilder LOCATION_BUILDER = new UrlBuilder();
28+
private static final UrlBuilder LOCATION_BUILDER = new DefaultUrlBuilder();
2929
private BlogRepository blogs;
3030

3131
public BlogController(BlogRepository blogRepository)
@@ -43,12 +43,9 @@ public Blog create(Request request, Response response)
4343
// Construct the response for create...
4444
response.setResponseCreated();
4545

46-
// Bind the resource with link URL tokens, etc. here...
47-
TokenResolver resolver = HyperExpress.bind(Constants.Url.BLOG_ID_PARAMETER, UUID.format(saved.getUuid()));
48-
4946
// Include the Location header...
5047
String locationPattern = request.getNamedUrl(HttpMethod.GET, Constants.Routes.BLOG_ENTRY_READ_ROUTE);
51-
response.addLocationHeader(LOCATION_BUILDER.build(locationPattern, resolver));
48+
response.addLocationHeader(LOCATION_BUILDER.build(locationPattern, new DefaultTokenResolver()));
5249

5350
// Return the newly-created item...
5451
return saved;
@@ -59,9 +56,6 @@ public Blog read(Request request, Response response)
5956
String id = request.getHeader(Constants.Url.BLOG_ID_PARAMETER, "No Blog ID supplied");
6057
Blog entity = blogs.read(UUID.parse(id));
6158

62-
// enrich the resource with links, etc. here...
63-
HyperExpress.bind(Constants.Url.BLOG_ID_PARAMETER, UUID.format(entity.getUuid()));
64-
6559
return entity;
6660
}
6761

@@ -73,16 +67,6 @@ public List<Blog> readAll(Request request, Response response)
7367
List<Blog> entities = blogs.readAll(filter, range, order);
7468
response.setCollectionResponse(range, entities.size(), blogs.count(filter));
7569

76-
// Bind the resources in the collection with link URL tokens, etc. here...
77-
HyperExpress.tokenBinder(new TokenBinder<Blog>()
78-
{
79-
@Override
80-
public void bind(Blog entity, TokenResolver resolver)
81-
{
82-
resolver.bind(Constants.Url.BLOG_ID_PARAMETER, UUID.format(entity.getUuid()));
83-
}
84-
});
85-
8670
return entities;
8771
}
8872

blogging/src/main/java/org/restexpress/example/blogging/controller/BlogEntryController.java

+6-26
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package org.restexpress.example.blogging.controller;
22

33
import static com.strategicgains.repoexpress.adapter.Identifiers.UUID;
4-
import io.netty.handler.codec.http.HttpMethod;
54

65
import java.util.List;
76

@@ -20,16 +19,17 @@
2019
import org.restexpress.query.QueryOrders;
2120
import org.restexpress.query.QueryRanges;
2221

23-
import com.strategicgains.hyperexpress.HyperExpress;
24-
import com.strategicgains.hyperexpress.builder.TokenBinder;
25-
import com.strategicgains.hyperexpress.builder.TokenResolver;
22+
import com.strategicgains.hyperexpress.builder.DefaultTokenResolver;
23+
import com.strategicgains.hyperexpress.builder.DefaultUrlBuilder;
2624
import com.strategicgains.hyperexpress.builder.UrlBuilder;
2725
import com.strategicgains.repoexpress.util.UuidConverter;
2826
import com.strategicgains.syntaxe.ValidationEngine;
2927

28+
import io.netty.handler.codec.http.HttpMethod;
29+
3030
public class BlogEntryController
3131
{
32-
private static final UrlBuilder LOCATION_BUILDER = new UrlBuilder();
32+
private static final UrlBuilder LOCATION_BUILDER = new DefaultUrlBuilder();
3333
private BlogEntryRepository blogEntries;
3434
private BlogRepository blogs;
3535

@@ -52,13 +52,9 @@ public BlogEntry create(Request request, Response response)
5252
// Construct the response for create...
5353
response.setResponseCreated();
5454

55-
// Bind the resource with link URL tokens, etc. here...
56-
TokenResolver resolver = HyperExpress.bind(Constants.Url.BLOG_ENTRY_ID_PARAMETER, UUID.format(saved.getUuid()))
57-
.bind(Constants.Url.BLOG_ID_PARAMETER, UUID.format(saved.getBlogId()));
58-
5955
// Include the Location header...
6056
String locationPattern = request.getNamedUrl(HttpMethod.GET, Constants.Routes.BLOG_ENTRY_READ_ROUTE);
61-
response.addLocationHeader(LOCATION_BUILDER.build(locationPattern, resolver));
57+
response.addLocationHeader(LOCATION_BUILDER.build(locationPattern, new DefaultTokenResolver()));
6258

6359
// Return the newly-created item...
6460
return saved;
@@ -68,11 +64,6 @@ public BlogEntry read(Request request, Response response)
6864
{
6965
String id = request.getHeader(Constants.Url.BLOG_ENTRY_ID_PARAMETER, "No BlogEntry ID supplied");
7066
BlogEntry entity = blogEntries.read(UUID.parse(id));
71-
72-
// enrich the resource with links, etc. here...
73-
HyperExpress.bind(Constants.Url.BLOG_ENTRY_ID_PARAMETER, UUID.format(entity.getUuid()))
74-
.bind(Constants.Url.BLOG_ID_PARAMETER, UUID.format(entity.getBlogId()));
75-
7667
return entity;
7768
}
7869

@@ -87,17 +78,6 @@ public List<BlogEntry> readAll(Request request, Response response)
8778
List<BlogEntry> results = blogEntries.readAll(filter, range, order);
8879
response.setCollectionResponse(range, results.size(), blogEntries.count(filter));
8980

90-
// Bind the resources in the collection with link URL tokens, etc. here...
91-
HyperExpress.tokenBinder(new TokenBinder<BlogEntry>()
92-
{
93-
@Override
94-
public void bind(BlogEntry entity, TokenResolver resolver)
95-
{
96-
resolver.bind(Constants.Url.BLOG_ENTRY_ID_PARAMETER, UUID.format(entity.getUuid()))
97-
.bind(Constants.Url.BLOG_ID_PARAMETER, UUID.format(entity.getBlogId()));
98-
}
99-
});
100-
10181
return results;
10282
}
10383

blogging/src/main/java/org/restexpress/example/blogging/controller/CommentController.java

+7-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package org.restexpress.example.blogging.controller;
22

33
import static com.strategicgains.repoexpress.adapter.Identifiers.UUID;
4-
import io.netty.handler.codec.http.HttpMethod;
54

65
import java.util.List;
76

@@ -23,15 +22,18 @@
2322
import org.restexpress.query.QueryRanges;
2423

2524
import com.strategicgains.hyperexpress.HyperExpress;
25+
import com.strategicgains.hyperexpress.builder.DefaultUrlBuilder;
2626
import com.strategicgains.hyperexpress.builder.TokenBinder;
2727
import com.strategicgains.hyperexpress.builder.TokenResolver;
2828
import com.strategicgains.hyperexpress.builder.UrlBuilder;
2929
import com.strategicgains.repoexpress.util.UuidConverter;
3030
import com.strategicgains.syntaxe.ValidationEngine;
3131

32+
import io.netty.handler.codec.http.HttpMethod;
33+
3234
public class CommentController
3335
{
34-
private static final UrlBuilder LOCATION_BUILDER = new UrlBuilder();
36+
private static final UrlBuilder LOCATION_BUILDER = new DefaultUrlBuilder();
3537
private CommentRepository comments;
3638
private BlogEntryRepository entries;
3739
private BlogRepository blogs;
@@ -59,9 +61,7 @@ public Comment create(Request request, Response response)
5961
response.setResponseCreated();
6062

6163
// Bind the resource with link URL tokens, etc. here...
62-
TokenResolver resolver = HyperExpress.bind(Constants.Url.COMMENT_ID_PARAMETER, UUID.format(saved.getUuid()))
63-
.bind(Constants.Url.BLOG_ID_PARAMETER, UUID.format(blog.getUuid()))
64-
.bind(Constants.Url.BLOG_ENTRY_ID_PARAMETER, UUID.format(saved.getBlogEntryId()));
64+
TokenResolver resolver = HyperExpress.bind(Constants.Url.BLOG_ID_PARAMETER, UUID.format(blog.getUuid()));
6565

6666
// Include the Location header...
6767
String locationPattern = request.getNamedUrl(HttpMethod.GET, Constants.Routes.COMMENT_READ_ROUTE);
@@ -81,9 +81,7 @@ public Comment read(Request request, Response response)
8181
Comment entity = comments.read(UUID.parse(id));
8282

8383
// Bind the resource with link URL tokens, etc. here...
84-
HyperExpress.bind(Constants.Url.COMMENT_ID_PARAMETER, UUID.format(entity.getUuid()))
85-
.bind(Constants.Url.BLOG_ID_PARAMETER, UUID.format(blog.getUuid()))
86-
.bind(Constants.Url.BLOG_ENTRY_ID_PARAMETER, UUID.format(entity.getBlogEntryId()));
84+
HyperExpress.bind(Constants.Url.BLOG_ID_PARAMETER, UUID.format(blog.getUuid()));
8785

8886
return entity;
8987
}
@@ -109,9 +107,7 @@ public List<Comment> readAll(Request request, Response response)
109107
@Override
110108
public void bind(Comment entity, TokenResolver resolver)
111109
{
112-
resolver.bind(Constants.Url.COMMENT_ID_PARAMETER, UUID.format(entity.getUuid()))
113-
.bind(Constants.Url.BLOG_ID_PARAMETER, UUID.format(blog.getUuid()))
114-
.bind(Constants.Url.BLOG_ENTRY_ID_PARAMETER, UUID.format(entity.getBlogEntryId()));
110+
resolver.bind(Constants.Url.BLOG_ID_PARAMETER, UUID.format(blog.getUuid()));
115111
}
116112
});
117113

blogging/src/main/java/org/restexpress/example/blogging/domain/Blog.java

+7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
package org.restexpress.example.blogging.domain;
22

33
import org.mongodb.morphia.annotations.Entity;
4+
import org.restexpress.example.blogging.Constants;
5+
import org.restexpress.example.blogging.serialization.UuidFormatter;
46

7+
import com.strategicgains.hyperexpress.annotation.BindToken;
8+
import com.strategicgains.hyperexpress.annotation.TokenBindings;
59
import com.strategicgains.syntaxe.annotation.StringValidation;
610

711
@Entity("blogs")
12+
@TokenBindings({
13+
@BindToken(value=Constants.Url.BLOG_ID_PARAMETER, field="id", formatter=UuidFormatter.class)
14+
})
815
public class Blog
916
extends AbstractEntity
1017
{

blogging/src/main/java/org/restexpress/example/blogging/domain/BlogEntry.java

+8
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,24 @@
44

55
import org.mongodb.morphia.annotations.Entity;
66
import org.mongodb.morphia.annotations.Indexed;
7+
import org.restexpress.example.blogging.Constants;
8+
import org.restexpress.example.blogging.serialization.UuidFormatter;
79

10+
import com.strategicgains.hyperexpress.annotation.BindToken;
11+
import com.strategicgains.hyperexpress.annotation.TokenBindings;
812
import com.strategicgains.syntaxe.annotation.Required;
913
import com.strategicgains.syntaxe.annotation.StringValidation;
1014

1115
@Entity("blog_entries")
16+
@TokenBindings({
17+
@BindToken(value=Constants.Url.BLOG_ENTRY_ID_PARAMETER, field="id", formatter=UuidFormatter.class)
18+
})
1219
public class BlogEntry
1320
extends AbstractEntity
1421
{
1522
@Indexed
1623
@Required("Blog ID")
24+
@BindToken(value=Constants.Url.BLOG_ID_PARAMETER, formatter=UuidFormatter.class)
1725
private UUID blogId;
1826

1927
@StringValidation(name="Title", required=true)

blogging/src/main/java/org/restexpress/example/blogging/domain/Comment.java

+8
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,27 @@
66
import org.mongodb.morphia.annotations.Index;
77
import org.mongodb.morphia.annotations.Indexed;
88
import org.mongodb.morphia.annotations.Indexes;
9+
import org.restexpress.example.blogging.Constants;
10+
import org.restexpress.example.blogging.serialization.UuidFormatter;
911

12+
import com.strategicgains.hyperexpress.annotation.BindToken;
13+
import com.strategicgains.hyperexpress.annotation.TokenBindings;
1014
import com.strategicgains.syntaxe.annotation.Required;
1115
import com.strategicgains.syntaxe.annotation.StringValidation;
1216

1317
@Entity("comments")
1418
@Indexes({
1519
@Index("createdAt")
1620
})
21+
@TokenBindings({
22+
@BindToken(value=Constants.Url.COMMENT_ID_PARAMETER, field="id", formatter=UuidFormatter.class)
23+
})
1724
public class Comment
1825
extends AbstractEntity
1926
{
2027
@Indexed
2128
@Required("Blog Entry ID")
29+
@BindToken(value=Constants.Url.BLOG_ENTRY_ID_PARAMETER, formatter=UuidFormatter.class)
2230
private UUID blogEntryId;
2331

2432
@StringValidation(name="Author", required=true)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package org.restexpress.example.blogging.serialization;
2+
3+
import java.util.UUID;
4+
5+
import com.strategicgains.hyperexpress.annotation.TokenFormatter;
6+
import com.strategicgains.repoexpress.util.UuidConverter;
7+
8+
public class UuidFormatter
9+
implements TokenFormatter
10+
{
11+
@Override
12+
public String format(Object field)
13+
{
14+
return UuidConverter.format((UUID) field);
15+
}
16+
}

echo/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<dependency>
2121
<groupId>com.strategicgains</groupId>
2222
<artifactId>RestExpress</artifactId>
23-
<version>0.11.1-SNAPSHOT</version>
23+
<version>0.11.3</version>
2424
</dependency>
2525
</dependencies>
2626

vs-jersey/restexpress/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<dependency>
1414
<groupId>com.strategicgains</groupId>
1515
<artifactId>RestExpress</artifactId>
16-
<version>0.11.0</version>
16+
<version>0.11.3</version>
1717
</dependency>
1818
<dependency>
1919
<groupId>junit</groupId>
@@ -26,7 +26,7 @@
2626
<dependency>
2727
<groupId>com.jayway.restassured</groupId>
2828
<artifactId>rest-assured</artifactId>
29-
<version>2.4.0</version>
29+
<version>2.8.0</version>
3030
<scope>test</scope>
3131
</dependency>
3232
</dependencies>

0 commit comments

Comments
 (0)