Skip to content

Commit 1331fd2

Browse files
committed
v2.0.0.RC3
1 parent 6616b2e commit 1331fd2

File tree

34 files changed

+145
-46
lines changed

34 files changed

+145
-46
lines changed

docs/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>io.jooby</groupId>
88
<artifactId>jooby-project</artifactId>
9-
<version>2.0.0.RC3-SNAPSHOT</version>
9+
<version>2.0.0.RC3</version>
1010
</parent>
1111

1212
<modelVersion>4.0.0</modelVersion>

examples/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>io.jooby</groupId>
88
<artifactId>jooby-project</artifactId>
9-
<version>2.0.0.RC3-SNAPSHOT</version>
9+
<version>2.0.0.RC3</version>
1010
</parent>
1111

1212
<modelVersion>4.0.0</modelVersion>

jooby/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>io.jooby</groupId>
88
<artifactId>jooby-project</artifactId>
9-
<version>2.0.0.RC3-SNAPSHOT</version>
9+
<version>2.0.0.RC3</version>
1010
</parent>
1111

1212
<modelVersion>4.0.0</modelVersion>

jooby/src/main/java/io/jooby/Context.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,34 @@ public interface Context extends Registry {
119119
* **********************************************************************************************
120120
*/
121121

122+
/**
123+
* Flash map.
124+
*
125+
* @return Flash map.
126+
*/
122127
default @Nonnull FlashMap flashMap() {
123128
return (FlashMap) getAttributes()
124129
.computeIfAbsent(FlashMap.NAME, key -> FlashMap
125130
.create(this, new Cookie(getRouter().getFlashCookie()).setHttpOnly(true)));
126131
}
127132

133+
/**
134+
* Get a flash attribute.
135+
*
136+
* @param name Attribute's name.
137+
* @return Flash attribute.
138+
*/
128139
default @Nonnull Value flash(@Nonnull String name) {
129140
return Value.create(name, flashMap().get(name));
130141
}
131142

143+
/**
144+
* Set a flash attribute.
145+
*
146+
* @param name Attribute's name.
147+
* @param value Attribute's value.
148+
* @return This context.
149+
*/
132150
default @Nonnull Context flash(@Nonnull String name, @Nonnull String value) {
133151
flashMap().put(name, value);
134152
return this;
@@ -941,6 +959,12 @@ default long getRequestLength() {
941959
*/
942960
@Nonnull Context setResponseHeader(@Nonnull String name, @Nonnull String value);
943961

962+
/**
963+
* Remove a response header.
964+
*
965+
* @param name Header's name.
966+
* @return This context.
967+
*/
944968
@Nonnull Context removeResponseHeader(@Nonnull String name);
945969

946970
/**

jooby/src/main/java/io/jooby/Cookie.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
import java.util.Map;
2525
import java.util.concurrent.TimeUnit;
2626

27-
import static java.util.Objects.requireNonNull;
28-
2927
/**
3028
* Response cookie implementation. Response are send it back to client using
3129
* {@link Context#setResponseCookie(Cookie)}.
@@ -402,9 +400,12 @@ public long getMaxAge() {
402400
/**
403401
* Encode a hash into cookie value, like: <code>k1=v1&amp;...&amp;kn=vn</code>. Also,
404402
* <code>key</code> and <code>value</code> are encoded using {@link URLEncoder}.
403+
*
404+
* @param attributes Map to encode.
405+
* @return URL encoded from map attributes.
405406
*/
406-
public static String encode(Map<String, String> attributes) {
407-
if (attributes.size() == 0) {
407+
public static @Nonnull String encode(@Nullable Map<String, String> attributes) {
408+
if (attributes == null || attributes.size() == 0) {
408409
return "";
409410
}
410411
try {
@@ -429,8 +430,11 @@ public static String encode(Map<String, String> attributes) {
429430
* Decode a cookie value using, like: <code>k=v</code>, multiple <code>k=v</code> pair are
430431
* separated by <code>&amp;</code>. Also, <code>k</code> and <code>v</code> are decoded using
431432
* {@link URLDecoder}.
433+
*
434+
* @param value URL encoded value.
435+
* @return Decoded as map.
432436
*/
433-
public static Map<String, String> decode(String value) {
437+
public static @Nonnull Map<String, String> decode(@Nullable String value) {
434438
if (value == null || value.length() == 0) {
435439
return Collections.emptyMap();
436440
}

jooby/src/main/java/io/jooby/Environment.java

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,26 @@ public Environment(@Nonnull ClassLoader classLoader, @Nonnull Config conf, @Nonn
7272
this.conf = conf;
7373
}
7474

75+
/**
76+
* Get a property under the given key or use the given default value when missing.
77+
*
78+
* @param key Property key.
79+
* @param defaults Default value.
80+
* @return Property or default value.
81+
*/
7582
public @Nonnull String getProperty(@Nonnull String key, @Nonnull String defaults) {
7683
if (conf.hasPath(key)) {
7784
return conf.getString(key);
7885
}
7986
return defaults;
8087
}
8188

89+
/**
90+
* Get a property under the given key or <code>null</code> when missing.
91+
*
92+
* @param key Property key.
93+
* @return Property value or <code>null</code> when missing.
94+
*/
8295
public @Nullable String getProperty(@Nonnull String key) {
8396
if (conf.hasPath(key)) {
8497
return conf.getString(key);
@@ -125,6 +138,12 @@ public boolean isActive(@Nonnull String name, String... names) {
125138
return classLoader;
126139
}
127140

141+
/**
142+
* Loaded class or empty.
143+
*
144+
* @param className Class name.
145+
* @return Load a class or get an empty value.
146+
*/
128147
public @Nonnull Optional<Class> loadClass(@Nonnull String className) {
129148
try {
130149
return Optional.of(classLoader.loadClass(className));
@@ -133,10 +152,6 @@ public boolean isActive(@Nonnull String name, String... names) {
133152
}
134153
}
135154

136-
public boolean isClassPresent(String className) {
137-
return loadClass(className).isPresent();
138-
}
139-
140155
@Override public String toString() {
141156
return actives + "\n" + toString(conf).trim();
142157
}

jooby/src/main/java/io/jooby/Extension.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@
1818
*/
1919
public interface Extension {
2020

21+
/**
22+
* True when extension needs to run while starting the application. Defaults is false, starts
23+
* immediately.
24+
*
25+
* @return True when extension needs to run while starting the application. Defaults is false,
26+
* starts immediately.
27+
*/
2128
default boolean lateinit() {
2229
return false;
2330
}

jooby/src/main/java/io/jooby/FlashMap.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,35 @@
88
import io.jooby.internal.FlashMapImpl;
99

1010
import javax.annotation.Nonnull;
11-
import javax.annotation.Nullable;
12-
import java.util.HashMap;
1311
import java.util.Map;
1412

1513
/**
16-
* Flash scope.
14+
* Flash map.
1715
*
1816
* @author edgar
1917
* @since 2.0.0
2018
*/
2119
public interface FlashMap extends Map<String, String> {
2220

21+
/** Flash map attribute. */
2322
String NAME = "flash";
2423

2524
/**
2625
* Creates a new flash-scope using the given cookie.
2726
*
28-
* @param ctx
29-
* @param template
30-
* @return
27+
* @param ctx Web context.
28+
* @param template Cookie template.
29+
* @return A new flash map.
3130
*/
32-
static @Nonnull FlashMap create(Context ctx, Cookie template) {
31+
static @Nonnull FlashMap create(@Nonnull Context ctx, @Nonnull Cookie template) {
3332
return new FlashMapImpl(ctx, template);
3433
}
3534

3635
/**
3736
* Keep flash cookie for next request.
37+
*
38+
* @return This flash map.
3839
*/
39-
FlashMap keep();
40+
@Nonnull FlashMap keep();
4041

4142
}

jooby/src/main/java/io/jooby/RegistryException.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,27 @@
77

88
import javax.annotation.Nonnull;
99

10+
/**
11+
* Thrown when a required service is not available.
12+
*
13+
*/
1014
public class RegistryException extends StatusCodeException {
15+
16+
/**
17+
* Constructor.
18+
*
19+
* @param message Error message.
20+
* @param cause Cause.
21+
*/
1122
public RegistryException(@Nonnull String message, Throwable cause) {
1223
super(StatusCode.SERVER_ERROR, message, cause);
1324
}
1425

26+
/**
27+
* Constructor.
28+
*
29+
* @param message Error message.
30+
*/
1531
public RegistryException(@Nonnull String message) {
1632
super(StatusCode.SERVER_ERROR, message);
1733
}

jooby/src/main/java/io/jooby/Route.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ public interface After extends Serializable {
148148
*
149149
* @param ctx Web context.
150150
* @param result Response generated by route handler.
151-
* @return Response to send.
152151
* @throws Exception If something goes wrong.
153152
*/
154153
@Nonnull void apply(@Nonnull Context ctx, Object result) throws Exception;
@@ -253,6 +252,7 @@ public interface Handler extends Serializable {
253252
* @param returnType Return type.
254253
* @param handler Route handler.
255254
* @param before Before pipeline.
255+
* @param decorator Decorator.
256256
* @param after After pipeline.
257257
* @param renderer Route renderer.
258258
* @param parsers Route parsers.
@@ -385,14 +385,19 @@ public Route(@Nonnull String method,
385385
}
386386

387387
/**
388-
* After decorator or <code>null</code>.
388+
* After filter or <code>null</code>.
389389
*
390-
* @return After decorator or <code>null</code>.
390+
* @return After filter or <code>null</code>.
391391
*/
392392
public @Nullable After getAfter() {
393393
return after;
394394
}
395395

396+
/**
397+
* Decorator or <code>null</code>.
398+
*
399+
* @return Decorator or <code>null</code>.
400+
*/
396401
public @Nullable Decorator getDecorator() {
397402
return decorator;
398403
}

0 commit comments

Comments
 (0)