Skip to content

Commit 6cb9ead

Browse files
authored
Executor and Executor Factories in Options can be created via properties (#1257)
1 parent 1962352 commit 6cb9ead

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

Diff for: src/main/java/io/nats/client/Options.java

+19-1
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ public class Options {
6161
// PROTOCOL CONNECT OPTION CONSTANTS * not related to options, but here because Options code uses them
6262
// CLASS VARIABLES * add a variable to the class
6363
// BUILDER VARIABLES * add a variable in builder
64-
// BUILDER COPY CONSTRUCTOR * update builder constructor to ensure new variables are set
6564
// BUILD CONSTRUCTOR PROPS * update build props constructor to read new props
6665
// BUILDER METHODS * add a chainable method in builder for new variable
6766
// BUILD IMPL * update build() implementation if needed
67+
// BUILDER COPY CONSTRUCTOR * update builder constructor to ensure new variables are set
6868
// CONSTRUCTOR * update constructor to ensure new variables are set from builder
6969
// GETTERS * update getter to be able to retrieve class variable value
7070
// HELPER FUNCTIONS * just helpers
@@ -502,6 +502,21 @@ public class Options {
502502
* Property used to configure a builder from a Properties object. {@value}, see {@link Builder#forceFlushOnRequest() forceFlushOnRequest}.
503503
*/
504504
public static final String PROP_FORCE_FLUSH_ON_REQUEST = PFX + "force.flush.on.request";
505+
/**
506+
* Property used to set class name for the Executor Service (executor) class
507+
* {@link Builder#executor(ExecutorService) executor}.
508+
*/
509+
public static final String PROP_EXECUTOR_SERVICE_CLASS = "executor.service.class";
510+
/**
511+
* Property used to set class name for the Connect Thread Factory
512+
* {@link Builder#connectThreadFactory(ThreadFactory) connectThreadFactory}.
513+
*/
514+
public static final String PROP_CONNECT_THREAD_FACTORY_CLASS = "connect.thread.factory.class";
515+
/**
516+
* Property used to set class name for the Callback Thread Factory
517+
* {@link Builder#callbackThreadFactory(ThreadFactory) callbackThreadFactory}.
518+
*/
519+
public static final String PROP_CALLBACK_THREAD_FACTORY_CLASS = "callback.thread.factory.class";
505520

506521
// ----------------------------------------------------------------------------------------------------
507522
// PROTOCOL CONNECT OPTION CONSTANTS
@@ -896,6 +911,9 @@ public Builder properties(Properties props) {
896911

897912
classnameProperty(props, PROP_SERVERS_POOL_IMPLEMENTATION_CLASS, o -> this.serverPool = (ServerPool) o);
898913
classnameProperty(props, PROP_DISPATCHER_FACTORY_CLASS, o -> this.dispatcherFactory = (DispatcherFactory) o);
914+
classnameProperty(props, PROP_EXECUTOR_SERVICE_CLASS, o -> this.executor = (ExecutorService) o);
915+
classnameProperty(props, PROP_CONNECT_THREAD_FACTORY_CLASS, o -> this.connectThreadFactory = (ThreadFactory) o);
916+
classnameProperty(props, PROP_CALLBACK_THREAD_FACTORY_CLASS, o -> this.callbackThreadFactory = (ThreadFactory) o);
899917

900918
return this;
901919
}

0 commit comments

Comments
 (0)