Skip to content

Commit 85699c7

Browse files
committed
Format only changes
- sorts Context/Jex members - adds auto-formatter
1 parent 14dff41 commit 85699c7

File tree

4 files changed

+125
-106
lines changed

4 files changed

+125
-106
lines changed

.github/workflows/format.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Auto-Format
2+
on: [push, workflow_dispatch]
3+
jobs:
4+
format:
5+
permissions:
6+
contents: write
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v4
10+
with:
11+
ref: ${{ github.head_ref }}
12+
- name: Set up Java
13+
uses: actions/setup-java@v4
14+
with:
15+
java-version: 21
16+
distribution: 'zulu'
17+
- name: Format Code
18+
uses: axel-op/googlejavaformat-action@v3
19+
with:
20+
args: "--skip-sorting-imports --replace"

avaje-jex/src/main/java/io/avaje/jex/DJex.java

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,28 @@ public DJexConfig config() {
2121
}
2222

2323
@Override
24-
public Jex routing(Routing.HttpService routes) {
25-
routing.add(routes);
24+
public Jex config(Consumer<JexConfig> configure) {
25+
configure.accept(config);
2626
return this;
2727
}
2828

2929
@Override
30-
public Jex routing(Collection<Routing.HttpService> routes) {
31-
routing.addAll(routes);
30+
public Jex configureWith(BeanScope beanScope) {
31+
lifecycle.onShutdown(beanScope::close);
32+
for (JexPlugin plugin : beanScope.list(JexPlugin.class)) {
33+
plugin.apply(this);
34+
}
35+
routing.addAll(beanScope.list(Routing.HttpService.class));
36+
beanScope.getOptional(JsonService.class).ifPresent(this::jsonService);
37+
beanScope.getOptional(HttpsConfigurator.class).ifPresent(config()::httpsConfig);
38+
beanScope.getOptional(HttpServerProvider.class).ifPresent(config()::serverProvider);
3239
return this;
3340
}
3441

3542
@Override
36-
public Routing routing() {
37-
return routing;
43+
public Jex contextPath(String contextPath) {
44+
config.contextPath(contextPath);
45+
return this;
3846
}
3947

4048
@Override
@@ -44,53 +52,45 @@ public Jex jsonService(JsonService jsonService) {
4452
}
4553

4654
@Override
47-
public Jex plugin(JexPlugin plugin) {
48-
plugin.apply(this);
49-
return this;
55+
public AppLifecycle lifecycle() {
56+
return lifecycle;
5057
}
5158

5259
@Override
53-
public Jex configureWith(BeanScope beanScope) {
54-
lifecycle.onShutdown(beanScope::close);
55-
for (JexPlugin plugin : beanScope.list(JexPlugin.class)) {
56-
plugin.apply(this);
57-
}
58-
routing.addAll(beanScope.list(Routing.HttpService.class));
59-
beanScope.getOptional(JsonService.class).ifPresent(this::jsonService);
60-
beanScope.getOptional(HttpsConfigurator.class).ifPresent(config()::httpsConfig);
61-
beanScope.getOptional(HttpServerProvider.class).ifPresent(config()::serverProvider);
60+
public Jex plugin(JexPlugin plugin) {
61+
plugin.apply(this);
6262
return this;
6363
}
6464

6565
@Override
66-
public Jex config(Consumer<JexConfig> configure) {
67-
configure.accept(config);
66+
public Jex port(int port) {
67+
config.port(port);
6868
return this;
6969
}
7070

7171
@Override
72-
public Jex port(int port) {
73-
config.port(port);
72+
public Jex register(TemplateRender renderer, String... extensions) {
73+
for (String extension : extensions) {
74+
config.renderer(extension, renderer);
75+
}
7476
return this;
7577
}
7678

7779
@Override
78-
public Jex contextPath(String contextPath) {
79-
config.contextPath(contextPath);
80-
return this;
80+
public Routing routing() {
81+
return routing;
8182
}
8283

8384
@Override
84-
public Jex register(TemplateRender renderer, String... extensions) {
85-
for (String extension : extensions) {
86-
config.renderer(extension, renderer);
87-
}
85+
public Jex routing(Collection<Routing.HttpService> routes) {
86+
routing.addAll(routes);
8887
return this;
8988
}
9089

9190
@Override
92-
public AppLifecycle lifecycle() {
93-
return lifecycle;
91+
public Jex routing(Routing.HttpService routes) {
92+
routing.add(routes);
93+
return this;
9494
}
9595

9696
@Override

avaje-jex/src/main/java/io/avaje/jex/DJexConfig.java

Lines changed: 68 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,21 @@ final class DJexConfig implements JexConfig {
3131
private HttpServerProvider serverProvider;
3232

3333
@Override
34-
public JexConfig host(String host) {
35-
this.host = host;
36-
return this;
34+
public CompressionConfig compression() {
35+
return compression;
3736
}
3837

3938
@Override
40-
public JexConfig port(int port) {
41-
this.port = port;
39+
public JexConfig compression(Consumer<CompressionConfig> consumer) {
40+
consumer.accept(compression);
4241
return this;
4342
}
4443

44+
@Override
45+
public String contextPath() {
46+
return contextPath;
47+
}
48+
4549
@Override
4650
public JexConfig contextPath(String contextPath) {
4751
if (!this.contextPath.equals(contextPath)) {
@@ -55,79 +59,74 @@ public JexConfig contextPath(String contextPath) {
5559
}
5660

5761
@Override
58-
public JexConfig socketBacklog(int socketBacklog) {
59-
this.socketBacklog = socketBacklog;
60-
return this;
61-
}
62-
63-
@Override
64-
public JexConfig health(boolean health) {
65-
this.health = health;
66-
return this;
62+
public Executor executor() {
63+
if (executor == null) {
64+
executor =
65+
Executors.newThreadPerTaskExecutor(
66+
Thread.ofVirtual().name("avaje-jex-http-", 0).factory());
67+
}
68+
return executor;
6769
}
6870

6971
@Override
70-
public JexConfig ignoreTrailingSlashes(boolean ignoreTrailingSlashes) {
71-
this.ignoreTrailingSlashes = ignoreTrailingSlashes;
72+
public JexConfig executor(Executor executor) {
73+
this.executor = executor;
7274
return this;
7375
}
7476

7577
@Override
76-
public JexConfig jsonService(JsonService jsonService) {
77-
this.jsonService = jsonService;
78-
return this;
78+
public boolean health() {
79+
return health;
7980
}
8081

8182
@Override
82-
public JexConfig renderer(String extension, TemplateRender renderer) {
83-
renderers.put(extension, renderer);
83+
public JexConfig health(boolean health) {
84+
this.health = health;
8485
return this;
8586
}
8687

8788
@Override
88-
public Executor executor() {
89-
if (executor == null) {
90-
executor =
91-
Executors.newThreadPerTaskExecutor(
92-
Thread.ofVirtual().name("avaje-jex-http-", 0).factory());
93-
}
94-
return executor;
89+
public String host() {
90+
return host;
9591
}
9692

9793
@Override
98-
public JexConfig executor(Executor executor) {
99-
this.executor = executor;
94+
public JexConfig host(String host) {
95+
this.host = host;
10096
return this;
10197
}
10298

10399
@Override
104-
public String host() {
105-
return host;
100+
public HttpsConfigurator httpsConfig() {
101+
return httpsConfig;
106102
}
107103

108104
@Override
109-
public int port() {
110-
return port;
105+
public JexConfig httpsConfig(HttpsConfigurator httpsConfig) {
106+
this.httpsConfig = httpsConfig;
107+
return this;
111108
}
112109

113110
@Override
114-
public String contextPath() {
115-
return contextPath;
111+
public boolean ignoreTrailingSlashes() {
112+
return ignoreTrailingSlashes;
116113
}
117114

118115
@Override
119-
public int socketBacklog() {
120-
return socketBacklog;
116+
public JexConfig ignoreTrailingSlashes(boolean ignoreTrailingSlashes) {
117+
this.ignoreTrailingSlashes = ignoreTrailingSlashes;
118+
return this;
121119
}
122120

123121
@Override
124-
public boolean health() {
125-
return health;
122+
public int initialStreamBufferSize() {
123+
return bufferInitial;
126124
}
127125

128126
@Override
129-
public boolean ignoreTrailingSlashes() {
130-
return ignoreTrailingSlashes;
127+
public JexConfig initialStreamBufferSize(int initialSize) {
128+
bufferInitial = initialSize;
129+
return this;
131130
}
132131

133132
@Override
@@ -136,67 +135,68 @@ public JsonService jsonService() {
136135
}
137136

138137
@Override
139-
public Map<String, TemplateRender> renderers() {
140-
return renderers;
138+
public JexConfig jsonService(JsonService jsonService) {
139+
this.jsonService = jsonService;
140+
return this;
141141
}
142142

143143
@Override
144-
public String scheme() {
145-
return httpsConfig == null ? "http" : "https";
144+
public long maxStreamBufferSize() {
145+
return bufferMax;
146146
}
147147

148148
@Override
149-
public HttpsConfigurator httpsConfig() {
150-
return httpsConfig;
149+
public JexConfig maxStreamBufferSize(long maxSize) {
150+
bufferMax = maxSize;
151+
return this;
151152
}
152153

153154
@Override
154-
public JexConfig httpsConfig(HttpsConfigurator httpsConfig) {
155-
this.httpsConfig = httpsConfig;
156-
return this;
155+
public int port() {
156+
return port;
157157
}
158158

159159
@Override
160-
public JexConfig compression(Consumer<CompressionConfig> consumer) {
161-
consumer.accept(compression);
160+
public JexConfig port(int port) {
161+
this.port = port;
162162
return this;
163163
}
164164

165165
@Override
166-
public CompressionConfig compression() {
167-
return compression;
166+
public JexConfig renderer(String extension, TemplateRender renderer) {
167+
renderers.put(extension, renderer);
168+
return this;
168169
}
169170

170171
@Override
171-
public long maxStreamBufferSize() {
172-
return bufferMax;
172+
public Map<String, TemplateRender> renderers() {
173+
return renderers;
173174
}
174175

175176
@Override
176-
public int initialStreamBufferSize() {
177-
return bufferInitial;
177+
public String scheme() {
178+
return httpsConfig == null ? "http" : "https";
178179
}
179180

180181
@Override
181-
public JexConfig initialStreamBufferSize(int initialSize) {
182-
bufferInitial = initialSize;
183-
return this;
182+
public HttpServerProvider serverProvider() {
183+
return this.serverProvider != null ? serverProvider : HttpServerProvider.provider();
184184
}
185185

186186
@Override
187-
public JexConfig maxStreamBufferSize(long maxSize) {
188-
bufferMax = maxSize;
187+
public JexConfig serverProvider(HttpServerProvider serverProvider) {
188+
this.serverProvider = serverProvider;
189189
return this;
190190
}
191191

192192
@Override
193-
public HttpServerProvider serverProvider() {
194-
return this.serverProvider != null ? serverProvider : HttpServerProvider.provider();
193+
public int socketBacklog() {
194+
return socketBacklog;
195195
}
196196

197197
@Override
198-
public JexConfig serverProvider(HttpServerProvider serverProvider) {
199-
this.serverProvider = serverProvider;
198+
public JexConfig socketBacklog(int socketBacklog) {
199+
this.socketBacklog = socketBacklog;
200200
return this;
201201
}
202202
}

0 commit comments

Comments
 (0)