Skip to content

Commit ab3e21b

Browse files
committed
output: remove setOptions from OutputFactory
1 parent 56d8d81 commit ab3e21b

File tree

5 files changed

+30
-16
lines changed

5 files changed

+30
-16
lines changed

jooby/src/main/java/io/jooby/Server.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@ default Server init(@NonNull Jooby application) {
150150
return this;
151151
}
152152

153+
/**
154+
* Output buffer required for using native/server buffers.
155+
*
156+
* @return Output buffer required for using native/server buffers.
157+
*/
153158
OutputFactory getOutputFactory();
154159

155160
/**

jooby/src/main/java/io/jooby/output/ByteBufferedOutputFactory.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public Output wrap(@NonNull byte[] bytes, int offset, int length) {
4848
}
4949
}
5050

51-
private OutputOptions options;
51+
private final OutputOptions options;
5252

5353
public ByteBufferedOutputFactory(OutputOptions options) {
5454
this.options = options;
@@ -59,12 +59,6 @@ public OutputOptions getOptions() {
5959
return options;
6060
}
6161

62-
@Override
63-
public OutputFactory setOptions(@NonNull OutputOptions options) {
64-
this.options = options;
65-
return this;
66-
}
67-
6862
@Override
6963
public BufferedOutput allocate(boolean direct, int size) {
7064
return new ByteBufferedOutput(direct, size);

jooby/src/main/java/io/jooby/output/OutputFactory.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,13 @@ static OutputFactory create() {
3737
return create(new OutputOptions());
3838
}
3939

40+
/**
41+
* Configuration options.
42+
*
43+
* @return Configuration options.
44+
*/
4045
OutputOptions getOptions();
4146

42-
OutputFactory setOptions(@NonNull OutputOptions options);
43-
4447
/**
4548
* Creates a new byte buffered output.
4649
*

jooby/src/main/java/io/jooby/output/OutputOptions.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,18 @@
55
*/
66
package io.jooby.output;
77

8+
/**
9+
* Configuration options for output buffers.
10+
*
11+
* @author edgar
12+
* @since 4.0.0
13+
*/
814
public class OutputOptions {
915
private int size;
1016

1117
private boolean directBuffers;
1218

19+
/** Creates a default options. */
1320
public OutputOptions() {
1421
long maxMemory = Runtime.getRuntime().maxMemory();
1522
// smaller than 64mb of ram we use 512b buffers
@@ -68,10 +75,21 @@ public OutputOptions setSize(int size) {
6875
return this;
6976
}
7077

78+
/**
79+
* True when using direct buffers.
80+
*
81+
* @return True when using direct buffers.
82+
*/
7183
public boolean isDirectBuffers() {
7284
return directBuffers;
7385
}
7486

87+
/**
88+
* Set to true for using direct buffers.
89+
*
90+
* @param directBuffers True for direct buffers.
91+
* @return This options.
92+
*/
7593
public OutputOptions setDirectBuffers(boolean directBuffers) {
7694
this.directBuffers = directBuffers;
7795
return this;

modules/jooby-netty/src/main/java/io/jooby/internal/netty/NettyOutputFactory.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public NettyContextOutputFactory(ByteBufAllocator allocator, OutputOptions optio
5656
}
5757

5858
private final ByteBufAllocator allocator;
59-
private OutputOptions options;
59+
private final OutputOptions options;
6060

6161
public NettyOutputFactory(ByteBufAllocator allocator, OutputOptions options) {
6262
this.allocator = allocator;
@@ -72,12 +72,6 @@ public ByteBufAllocator getAllocator() {
7272
return options;
7373
}
7474

75-
@Override
76-
@NonNull public OutputFactory setOptions(@NonNull OutputOptions options) {
77-
this.options = options;
78-
return this;
79-
}
80-
8175
@Override
8276
public @NonNull BufferedOutput allocate(boolean direct, int size) {
8377
return new NettyByteBufOutput(

0 commit comments

Comments
 (0)