-
Notifications
You must be signed in to change notification settings - Fork 4.9k
/
MainConfigurationProperties.java
861 lines (762 loc) · 30.9 KB
/
MainConfigurationProperties.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.camel.main;
import java.util.ArrayList;
import java.util.List;
import java.util.StringJoiner;
import org.apache.camel.CamelConfiguration;
import org.apache.camel.RoutesBuilder;
import org.apache.camel.builder.LambdaRouteBuilder;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.spi.BootstrapCloseable;
import org.apache.camel.spi.Configurer;
import org.apache.camel.spi.Metadata;
/**
* Global configuration for Camel Main to configure context name, stream caching and other global configurations.
*/
@Configurer(bootstrap = true)
public class MainConfigurationProperties extends DefaultConfigurationProperties<MainConfigurationProperties>
implements BootstrapCloseable {
@Metadata(enums = "dev,test,prod")
private String profile;
private boolean autoConfigurationEnabled = true;
private boolean autoConfigurationEnvironmentVariablesEnabled = true;
private boolean autoConfigurationSystemPropertiesEnabled = true;
private boolean autoConfigurationFailFast = true;
private boolean autoConfigurationLogSummary = true;
private int durationHitExitCode;
private int extraShutdownTimeout = 15;
private String basePackageScan;
private boolean basePackageScanEnabled = true;
private String routesBuilderClasses;
private String configurationClasses;
private List<RoutesBuilder> routesBuilders = new ArrayList<>();
private List<CamelConfiguration> configurations = new ArrayList<>();
// extended configuration
private HealthConfigurationProperties healthConfigurationProperties;
private LraConfigurationProperties lraConfigurationProperties;
private OtelConfigurationProperties otelConfigurationProperties;
private MetricsConfigurationProperties metricsConfigurationProperties;
private ThreadPoolConfigurationProperties threadPoolProperties;
private Resilience4jConfigurationProperties resilience4jConfigurationProperties;
private FaultToleranceConfigurationProperties faultToleranceConfigurationProperties;
private RestConfigurationProperties restConfigurationProperties;
private VaultConfigurationProperties vaultConfigurationProperties;
private HttpServerConfigurationProperties httpServerConfigurationProperties;
private SSLConfigurationProperties sslConfigurationProperties;
private DebuggerConfigurationProperties debuggerConfigurationProperties;
private TracerConfigurationProperties tracerConfigurationProperties;
private RouteControllerConfigurationProperties routeControllerConfigurationProperties;
@Override
public void close() {
if (healthConfigurationProperties != null) {
healthConfigurationProperties.close();
healthConfigurationProperties = null;
}
if (lraConfigurationProperties != null) {
lraConfigurationProperties.close();
lraConfigurationProperties = null;
}
if (otelConfigurationProperties != null) {
otelConfigurationProperties.close();
otelConfigurationProperties = null;
}
if (metricsConfigurationProperties != null) {
metricsConfigurationProperties.close();
metricsConfigurationProperties = null;
}
if (threadPoolProperties != null) {
threadPoolProperties.close();
threadPoolProperties = null;
}
if (resilience4jConfigurationProperties != null) {
resilience4jConfigurationProperties.close();
resilience4jConfigurationProperties = null;
}
if (faultToleranceConfigurationProperties != null) {
faultToleranceConfigurationProperties.close();
faultToleranceConfigurationProperties = null;
}
if (restConfigurationProperties != null) {
restConfigurationProperties.close();
restConfigurationProperties = null;
}
if (vaultConfigurationProperties != null) {
vaultConfigurationProperties.close();
vaultConfigurationProperties = null;
}
if (httpServerConfigurationProperties != null) {
httpServerConfigurationProperties.close();
httpServerConfigurationProperties = null;
}
if (sslConfigurationProperties != null) {
sslConfigurationProperties.close();
sslConfigurationProperties = null;
}
if (debuggerConfigurationProperties != null) {
debuggerConfigurationProperties.close();
debuggerConfigurationProperties = null;
}
if (tracerConfigurationProperties != null) {
tracerConfigurationProperties.close();
tracerConfigurationProperties = null;
}
if (routeControllerConfigurationProperties != null) {
routeControllerConfigurationProperties.close();
routeControllerConfigurationProperties = null;
}
if (routesBuilders != null) {
routesBuilders.clear();
routesBuilders = null;
}
if (configurations != null) {
configurations.clear();
configurations = null;
}
}
// extended
// --------------------------------------------------------------
/**
* To configure Health Check
*/
public HealthConfigurationProperties health() {
if (healthConfigurationProperties == null) {
healthConfigurationProperties = new HealthConfigurationProperties(this);
}
return healthConfigurationProperties;
}
/**
* Whether there has been any health check configuration specified
*/
public boolean hasHealthCheckConfiguration() {
return healthConfigurationProperties != null;
}
/**
* To configure Saga LRA
*/
public LraConfigurationProperties lra() {
if (lraConfigurationProperties == null) {
lraConfigurationProperties = new LraConfigurationProperties(this);
}
return lraConfigurationProperties;
}
/**
* Whether there has been any Saga LRA configuration specified
*/
public boolean hasLraConfiguration() {
return lraConfigurationProperties != null;
}
/**
* To configure OpenTelemetry.
*/
public OtelConfigurationProperties otel() {
if (otelConfigurationProperties == null) {
otelConfigurationProperties = new OtelConfigurationProperties(this);
}
return otelConfigurationProperties;
}
/**
* Whether there has been any OpenTelemetry configuration specified
*/
public boolean hasOtelConfiguration() {
return otelConfigurationProperties != null;
}
/**
* To configure Micrometer metrics.
*/
public MetricsConfigurationProperties metrics() {
if (metricsConfigurationProperties == null) {
metricsConfigurationProperties = new MetricsConfigurationProperties(this);
}
return metricsConfigurationProperties;
}
/**
* Whether there has been any Micrometer metrics configuration specified
*/
public boolean hasMetricsConfiguration() {
return metricsConfigurationProperties != null;
}
/**
* To configure embedded HTTP server (for standalone applications; not Spring Boot or Quarkus)
*/
public HttpServerConfigurationProperties httpServer() {
if (httpServerConfigurationProperties == null) {
httpServerConfigurationProperties = new HttpServerConfigurationProperties(this);
}
return httpServerConfigurationProperties;
}
/**
* Whether there has been any embedded HTTP server configuration specified
*/
public boolean hasHttpServerConfiguration() {
return httpServerConfigurationProperties != null;
}
/**
* To configure SSL.
*/
public SSLConfigurationProperties sslConfig() {
if (sslConfigurationProperties == null) {
sslConfigurationProperties = new SSLConfigurationProperties(this);
}
return sslConfigurationProperties;
}
/**
* Whether there has been any SSL configuration specified.
*/
public boolean hasSslConfiguration() {
return sslConfigurationProperties != null;
}
/**
* To configure Debugger.
*/
public DebuggerConfigurationProperties debuggerConfig() {
if (debuggerConfigurationProperties == null) {
debuggerConfigurationProperties = new DebuggerConfigurationProperties(this);
}
return debuggerConfigurationProperties;
}
/**
* Whether there has been any Debugger configuration specified.
*/
public boolean hasDebuggerConfiguration() {
return debuggerConfigurationProperties != null;
}
/**
* To configure Tracer.
*/
public TracerConfigurationProperties tracerConfig() {
if (tracerConfigurationProperties == null) {
tracerConfigurationProperties = new TracerConfigurationProperties(this);
}
return tracerConfigurationProperties;
}
/**
* Whether there has been any Tracer configuration specified.
*/
public boolean hasTracerConfiguration() {
return tracerConfigurationProperties != null;
}
/**
* To configure Route Controller.
*/
public RouteControllerConfigurationProperties routeControllerConfig() {
if (routeControllerConfigurationProperties == null) {
routeControllerConfigurationProperties = new RouteControllerConfigurationProperties(this);
}
return routeControllerConfigurationProperties;
}
/**
* Whether there has been any Route Controller configuration specified.
*/
public boolean hasRouteControllerConfiguration() {
return routeControllerConfigurationProperties != null;
}
/**
* To configure thread pools
*/
public ThreadPoolConfigurationProperties threadPool() {
if (threadPoolProperties == null) {
threadPoolProperties = new ThreadPoolConfigurationProperties(this);
}
return threadPoolProperties;
}
/**
* Whether there has been any thread pool configuration specified
*/
public boolean hasThreadPoolConfiguration() {
return threadPoolProperties != null;
}
/**
* To configure Circuit Breaker EIP with Resilience4j
*/
public Resilience4jConfigurationProperties resilience4j() {
if (resilience4jConfigurationProperties == null) {
resilience4jConfigurationProperties = new Resilience4jConfigurationProperties(this);
}
return resilience4jConfigurationProperties;
}
/**
* Whether there has been any Resilience4j EIP configuration specified
*/
public boolean hasResilience4jConfiguration() {
return resilience4jConfigurationProperties != null;
}
/**
* To configure Circuit Breaker EIP with MicroProfile Fault Tolerance
*/
public FaultToleranceConfigurationProperties faultTolerance() {
if (faultToleranceConfigurationProperties == null) {
faultToleranceConfigurationProperties = new FaultToleranceConfigurationProperties(this);
}
return faultToleranceConfigurationProperties;
}
/**
* Whether there has been any MicroProfile Fault Tolerance EIP configuration specified
*/
public boolean hasFaultToleranceConfiguration() {
return faultToleranceConfigurationProperties != null;
}
/**
* To configure Rest DSL
*/
public RestConfigurationProperties rest() {
if (restConfigurationProperties == null) {
restConfigurationProperties = new RestConfigurationProperties(this);
}
return restConfigurationProperties;
}
/**
* Whether there has been any rest configuration specified
*/
public boolean hasRestConfiguration() {
return restConfigurationProperties != null;
}
/**
* To configure access to AWS vaults
*/
public VaultConfigurationProperties vault() {
if (vaultConfigurationProperties == null) {
vaultConfigurationProperties = new VaultConfigurationProperties(this);
}
return vaultConfigurationProperties;
}
/**
* Whether there has been any vault configuration specified
*/
public boolean hasVaultConfiguration() {
return vaultConfigurationProperties != null;
}
// getter and setters
// --------------------------------------------------------------
public String getProfile() {
return profile;
}
/**
* Camel profile to use when running.
*
* The dev profile is for development, which enables a set of additional developer focus functionality, tracing,
* debugging, and gathering additional runtime statistics that are useful during development. However, those
* additional features has a slight overhead cost, and are not enabled for production profile.
*
* The default profile is prod.
*/
public void setProfile(String profile) {
this.profile = profile;
}
public boolean isAutoConfigurationEnabled() {
return autoConfigurationEnabled;
}
/**
* Whether auto configuration of components, dataformats, languages is enabled or not. When enabled the
* configuration parameters are loaded from the properties component. You can prefix the parameters in the
* properties file with: - camel.component.name.option1=value1 - camel.component.name.option2=value2 -
* camel.dataformat.name.option1=value1 - camel.dataformat.name.option2=value2 - camel.language.name.option1=value1
* - camel.language.name.option2=value2 Where name is the name of the component, dataformat or language such as
* seda,direct,jaxb.
* <p/>
* The auto configuration also works for any options on components that is a complex type (not standard Java type)
* and there has been an explicit single bean instance registered to the Camel registry via the
* {@link org.apache.camel.spi.Registry#bind(String, Object)} method or by using the
* {@link org.apache.camel.BindToRegistry} annotation style.
* <p/>
* This option is default enabled.
*/
public void setAutoConfigurationEnabled(boolean autoConfigurationEnabled) {
this.autoConfigurationEnabled = autoConfigurationEnabled;
}
public boolean isAutoConfigurationEnvironmentVariablesEnabled() {
return autoConfigurationEnvironmentVariablesEnabled;
}
/**
* Whether auto configuration should include OS environment variables as well. When enabled this allows to overrule
* any configuration using an OS environment variable. For example to set a shutdown timeout of 5 seconds:
* CAMEL_MAIN_SHUTDOWNTIMEOUT=5.
* <p/>
* This option is default enabled.
*/
public void setAutoConfigurationEnvironmentVariablesEnabled(boolean autoConfigurationEnvironmentVariablesEnabled) {
this.autoConfigurationEnvironmentVariablesEnabled = autoConfigurationEnvironmentVariablesEnabled;
}
public boolean isAutoConfigurationSystemPropertiesEnabled() {
return autoConfigurationSystemPropertiesEnabled;
}
/**
* Whether auto configuration should include JVM system properties as well. When enabled this allows to overrule any
* configuration using a JVM system property. For example to set a shutdown timeout of 5 seconds: -D
* camel.main.shutdown-timeout=5.
* <p/>
* Note that JVM system properties take precedence over OS environment variables.
* <p/>
* This option is default enabled.
*/
public void setAutoConfigurationSystemPropertiesEnabled(boolean autoConfigurationSystemPropertiesEnabled) {
this.autoConfigurationSystemPropertiesEnabled = autoConfigurationSystemPropertiesEnabled;
}
public boolean isAutoConfigurationFailFast() {
return autoConfigurationFailFast;
}
/**
* Whether auto configuration should fail fast when configuring one ore more properties fails for whatever reason
* such as a invalid property name, etc.
* <p/>
* This option is default enabled.
*/
public void setAutoConfigurationFailFast(boolean autoConfigurationFailFast) {
this.autoConfigurationFailFast = autoConfigurationFailFast;
}
public boolean isAutoConfigurationLogSummary() {
return autoConfigurationLogSummary;
}
/**
* Whether auto configuration should log a summary with the configured properties.
* <p/>
* This option is default enabled.
*/
public void setAutoConfigurationLogSummary(boolean autoConfigurationLogSummary) {
this.autoConfigurationLogSummary = autoConfigurationLogSummary;
}
public String getBasePackageScan() {
return basePackageScan;
}
/**
* Package name to use as base (offset) for classpath scanning of {@link RouteBuilder},
* {@link org.apache.camel.TypeConverter}, {@link CamelConfiguration} classes, and also classes annotated with
* {@link org.apache.camel.Converter}, or {@link org.apache.camel.BindToRegistry}.
*
* If you are using Spring Boot then it is instead recommended to use Spring Boots component scanning and annotate
* your route builder classes with `@Component`. In other words only use this for Camel Main in standalone mode.
*/
public void setBasePackageScan(String basePackageScan) {
this.basePackageScan = basePackageScan;
}
public boolean isBasePackageScanEnabled() {
return basePackageScanEnabled;
}
/**
* Whether base package scan is enabled.
*/
public void setBasePackageScanEnabled(boolean basePackageScanEnabled) {
this.basePackageScanEnabled = basePackageScanEnabled;
}
public int getDurationHitExitCode() {
return durationHitExitCode;
}
/**
* Sets the exit code for the application if duration was hit
*/
public void setDurationHitExitCode(int durationHitExitCode) {
this.durationHitExitCode = durationHitExitCode;
}
public int getExtraShutdownTimeout() {
return extraShutdownTimeout;
}
/**
* Extra timeout in seconds to graceful shutdown Camel.
*
* When Camel is shutting down then Camel first shutdown all the routes (shutdownTimeout). Then additional services
* is shutdown (extraShutdownTimeout).
*/
public void setExtraShutdownTimeout(int extraShutdownTimeout) {
this.extraShutdownTimeout = extraShutdownTimeout;
}
// getter and setters - configurations
// --------------------------------------------------------------
public String getConfigurationClasses() {
return configurationClasses;
}
/**
* Sets classes names that will be used to configure the camel context as example by providing custom beans through
* {@link org.apache.camel.BindToRegistry} annotation.
*/
public void setConfigurationClasses(String configurations) {
this.configurationClasses = configurations;
}
/**
* Adds configuration object to the known list of configurations objects.
*/
@SuppressWarnings("unchecked")
private void addConfigurationClass(Class<? extends CamelConfiguration>... configuration) {
StringJoiner existing = new StringJoiner(",");
if (configurationClasses != null && !configurationClasses.isEmpty()) {
existing.add(configurationClasses);
}
if (configuration != null) {
for (Class<? extends CamelConfiguration> clazz : configuration) {
existing.add(clazz.getName());
}
}
setConfigurationClasses(existing.toString());
}
/**
* Adds configuration object to the known list of configurations objects.
*/
public void addConfiguration(CamelConfiguration configuration) {
configurations.add(configuration);
}
/**
* Adds configuration object to the known list of configurations objects.
*/
public void addConfiguration(Class<? extends CamelConfiguration> configuration) {
addConfigurationClass(configuration);
}
public List<CamelConfiguration> getConfigurations() {
return configurations;
}
/**
* Sets the configuration objects used to configure the camel context.
*/
public void setConfigurations(List<CamelConfiguration> configurations) {
this.configurations = configurations;
}
// getter and setters - routes builders
// --------------------------------------------------------------
public String getRoutesBuilderClasses() {
return routesBuilderClasses;
}
/**
* Sets classes names that implement {@link RoutesBuilder}.
*/
public void setRoutesBuilderClasses(String builders) {
this.routesBuilderClasses = builders;
}
public List<RoutesBuilder> getRoutesBuilders() {
return this.routesBuilders;
}
/**
* Sets the RoutesBuilder instances.
*/
public void setRoutesBuilders(List<RoutesBuilder> routesBuilders) {
this.routesBuilders = routesBuilders;
}
/**
* Add an additional {@link RoutesBuilder} object to the known list of builders.
*/
public void addRoutesBuilder(RoutesBuilder routeBuilder) {
this.routesBuilders.add(routeBuilder);
}
/**
* Add an additional {@link RoutesBuilder} class to the known list of builders.
*/
public void addRoutesBuilder(Class<?>... routeBuilder) {
StringJoiner existing = new StringJoiner(",");
if (routesBuilderClasses != null && !routesBuilderClasses.isEmpty()) {
existing.add(routesBuilderClasses);
}
if (routeBuilder != null) {
for (Class<?> clazz : routeBuilder) {
existing.add(clazz.getName());
}
}
setRoutesBuilderClasses(existing.toString());
}
/**
* Add an additional {@link LambdaRouteBuilder} object to the known list of builders.
*/
public void addLambdaRouteBuilder(LambdaRouteBuilder routeBuilder) {
this.routesBuilders.add(new RouteBuilder() {
@Override
public void configure() throws Exception {
routeBuilder.accept(this);
}
});
}
// fluent builders
// --------------------------------------------------------------
/**
* Camel profile to use when running.
*
* The dev profile is for development, which enables a set of additional developer focus functionality, tracing,
* debugging, and gathering additional runtime statistics that are useful during development. However, those
* additional features has a slight overhead cost, and are not enabled for production profile.
*
* The default profile is prod.
*/
public MainConfigurationProperties withProfile(String profile) {
this.profile = profile;
return this;
}
/**
* Whether auto configuration of components/dataformats/languages is enabled or not. When enabled the configuration
* parameters are loaded from the properties component and configured as defaults (similar to spring-boot
* auto-configuration). You can prefix the parameters in the properties file with: -
* camel.component.name.option1=value1 - camel.component.name.option2=value2 - camel.dataformat.name.option1=value1
* - camel.dataformat.name.option2=value2 - camel.language.name.option1=value1 - camel.language.name.option2=value2
* Where name is the name of the component, dataformat or language such as seda,direct,jaxb.
* <p/>
* The auto configuration also works for any options on components that is a complex type (not standard Java type)
* and there has been an explicit single bean instance registered to the Camel registry via the
* {@link org.apache.camel.spi.Registry#bind(String, Object)} method or by using the
* {@link org.apache.camel.BindToRegistry} annotation style.
* <p/>
* This option is default enabled.
*/
public MainConfigurationProperties withAutoConfigurationEnabled(boolean autoConfigurationEnabled) {
this.autoConfigurationEnabled = autoConfigurationEnabled;
return this;
}
/**
* Whether auto configuration should include OS environment variables as well. When enabled this allows to overrule
* any configuration using an OS environment variable. For example to set a shutdown timeout of 5 seconds:
* CAMEL_MAIN_SHUTDOWNTIMEOUT=5.
* <p/>
* This option is default enabled.
*/
public MainConfigurationProperties withAutoConfigurationEnvironmentVariablesEnabled(
boolean autoConfigurationEnvironmentVariablesEnabled) {
this.autoConfigurationEnvironmentVariablesEnabled = autoConfigurationEnvironmentVariablesEnabled;
return this;
}
/**
* Whether auto configuration should include JVM system properties as well. When enabled this allows to overrule any
* configuration using a JVM system property. For example to set a shutdown timeout of 5 seconds: -D
* camel.main.shutdown-timeout=5.
* <p/>
* Note that JVM system properties take precedence over OS environment variables.
* <p/>
* This option is default enabled.
*/
public MainConfigurationProperties withAutoConfigurationSystemPropertiesEnabled(
boolean autoConfigurationSystemPropertiesEnabled) {
this.autoConfigurationSystemPropertiesEnabled = autoConfigurationSystemPropertiesEnabled;
return this;
}
/**
* Whether auto configuration should fail fast when configuring one ore more properties fails for whatever reason
* such as a invalid property name, etc.
* <p/>
* This option is default enabled.
*/
public MainConfigurationProperties withAutoConfigurationFailFast(boolean autoConfigurationFailFast) {
this.autoConfigurationFailFast = autoConfigurationFailFast;
return this;
}
/**
* Whether auto configuration should log a summary with the configured properties.
* <p/>
* This option is default enabled.
*/
public MainConfigurationProperties withAutoConfigurationLogSummary(boolean autoConfigurationLogSummary) {
this.autoConfigurationLogSummary = autoConfigurationLogSummary;
return this;
}
/**
* Sets the exit code for the application if duration was hit
*/
public MainConfigurationProperties withDurationHitExitCode(int durationHitExitCode) {
this.durationHitExitCode = durationHitExitCode;
return this;
}
/**
* Extra timeout in seconds to graceful shutdown Camel.
*
* When Camel is shutting down then Camel first shutdown all the routes (shutdownTimeout). Then additional services
* is shutdown (extraShutdownTimeout).
*/
public MainConfigurationProperties withExtraShutdownTimeout(int extraShutdownTimeout) {
this.extraShutdownTimeout = extraShutdownTimeout;
return this;
}
/**
* Package name to use as base (offset) for classpath scanning of {@link RouteBuilder},
* {@link org.apache.camel.TypeConverter}, {@link CamelConfiguration} classes, and also classes annotated with
* {@link org.apache.camel.Converter}, or {@link org.apache.camel.BindToRegistry}.
*
* If you are using Spring Boot then it is instead recommended to use Spring Boots component scanning and annotate
* your route builder classes with `@Component`. In other words only use this for Camel Main in standalone mode.
*/
public MainConfigurationProperties withBasePackageScan(String basePackageScan) {
this.basePackageScan = basePackageScan;
return this;
}
/**
* Whether base package scan is enabled.
*/
public MainConfigurationProperties withBasePackageScanEnabled(boolean basePackageScanEnabled) {
this.basePackageScanEnabled = basePackageScanEnabled;
return this;
}
// fluent builders - configurations
// --------------------------------------------------------------
/**
* Adds classes names that will be used to configure the camel context as example by providing custom beans through
* {@link org.apache.camel.BindToRegistry} annotation.
*/
public MainConfigurationProperties withConfigurations(String configurations) {
if (this.configurationClasses == null) {
this.configurationClasses = "";
}
if (this.configurationClasses.isEmpty()) {
this.configurationClasses = configurations;
} else {
this.configurationClasses = "," + configurations;
}
return this;
}
/**
* Adds a configuration class to the known list of configurations classes.
*/
@SuppressWarnings("unchecked")
public MainConfigurationProperties withConfigurations(
Class<? extends CamelConfiguration>... configuration) {
addConfigurationClass(configuration);
return this;
}
/**
* Sets the configuration objects used to configure the camel context.
*/
public MainConfigurationProperties withConfigurations(List<CamelConfiguration> configurations) {
setConfigurations(configurations);
return this;
}
// fluent builder - routes builders
// --------------------------------------------------------------
/**
* Sets classes names that implement {@link RoutesBuilder}.
*/
public MainConfigurationProperties withRoutesBuilderClasses(String builders) {
setRoutesBuilderClasses(builders);
return this;
}
/**
* Sets the RoutesBuilder instances.
*/
public MainConfigurationProperties withRoutesBuilders(List<RoutesBuilder> builders) {
setRoutesBuilders(builders);
return this;
}
/**
* Add an additional {@link RoutesBuilder} object to the known list of builders.
*/
public MainConfigurationProperties withAdditionalRoutesBuilder(RoutesBuilder builder) {
addRoutesBuilder(builder);
return this;
}
/**
* Add an additional {@link RoutesBuilder} class to the known list of builders.
*/
public MainConfigurationProperties withAdditionalRoutesBuilder(Class... builders) {
addRoutesBuilder(builders);
return this;
}
/**
* Add an additional {@link LambdaRouteBuilder} object to the known list of builders.
*/
public MainConfigurationProperties withAdditionalLambdaRouteBuilder(LambdaRouteBuilder builder) {
addLambdaRouteBuilder(builder);
return this;
}
}