18
18
package org .apache .nlpcraft .model .tools .embedded ;
19
19
20
20
import org .apache .nlpcraft .common .*;
21
- import org .apache .nlpcraft .model .*;
22
21
import org .apache .nlpcraft .model .tools .test .*;
23
22
import org .apache .nlpcraft .probe .*;
24
23
import org .apache .nlpcraft .probe .mgrs .nlp .*;
@@ -81,68 +80,22 @@ private static boolean waitForFuture(CompletableFuture<Integer> fut) {
81
80
}
82
81
83
82
/**
83
+ * Start the embedded probe with optional configuration file and models overrides.
84
84
*
85
- * @param classes
86
- */
87
- private static void checkModelClasses (Class <? extends NCModel >[] classes ) {
88
- if (classes .length == 0 )
89
- throw new NCException ("At least one model class must be provided when starting embedded probe." );
90
- }
91
-
92
- /**
93
- * Start the embedded probe with given configuration file. It is equivalent to starting a probe using
94
- * <code>-config=cfgFile</code> command line argument.
95
- *
96
- * @param cfgFile Configuration file path. It should be either a full path or the file name
85
+ * @param cfgFile Optional configuration file path. It should be either a full path or the file name
97
86
* that can be found in the current working directory or on the classpath as a class loader
98
- * resource.
87
+ * resource. If provided - it is equivalent to starting a probe using <code>-config=cfgFile</code>
88
+ * command line argument. If {@code null} - the probe will start with the default configuration.
89
+ * @param mdlClasses Optional data model classes to be deployed by the embedded probe. If provided -
90
+ * these will override {@code nlpcraft.probe.models} configuration property. If {@code null} - the models
91
+ * defined in the configuration (default or provided via {@code cfgFile} parameter) will be used.
99
92
* @throws NCException Thrown in case of any errors starting the data probe.
100
93
* @return Whether or not probe started ok.
101
94
*/
102
- public static boolean start (String cfgFile ) {
95
+ public static boolean start (String cfgFile , String ... mdlClasses ) {
103
96
CompletableFuture <Integer > fut = new CompletableFuture <>();
104
97
105
- NCProbeBoot$ .MODULE$ .start (cfgFile , fut );
106
-
107
- return waitForFuture (fut );
108
- }
109
-
110
- /**
111
- * Start the embedded probe with given configuration file and models overrides. It is equivalent to starting
112
- * a probe using <code>-config=cfgFile</code> command line argument.
113
- *
114
- * @param cfgFile Configuration file path. It should be either a full path or the file name
115
- * that can be found in the current working directory or on the classpath as a class loader
116
- * resource.
117
- * @param mdlClasses One or more data model classes to be deployed by the embedded probe. These will
118
- * override {@code nlpcraft.probe.models} configuration property in the provided configuration file.
119
- * @throws NCException Thrown in case of any errors starting the data probe.
120
- * @return Whether or not probe started ok.
121
- */
122
- @ SafeVarargs
123
- public static boolean start (String cfgFile , Class <? extends NCModel >... mdlClasses ) {
124
- CompletableFuture <Integer > fut = new CompletableFuture <>();
125
-
126
- NCProbeBoot$ .MODULE$ .start (cfgFile , mdlClasses , fut );
127
-
128
- return waitForFuture (fut );
129
- }
130
-
131
- /**
132
- * Starts the embedded probe with default configuration and specified models to deploy.
133
- *
134
- * @param mdlClasses One or more data model classes to be deployed by the embedded probe. These will
135
- * override {@code nlpcraft.probe.models} configuration property in the default configuration file.
136
- * @throws NCException Thrown in case of any errors starting the data probe.
137
- * @return Whether or not probe started ok.
138
- */
139
- @ SafeVarargs
140
- public static boolean start (Class <? extends NCModel >... mdlClasses ) {
141
- checkModelClasses (mdlClasses );
142
-
143
- CompletableFuture <Integer > fut = new CompletableFuture <>();
144
-
145
- NCProbeBoot$ .MODULE$ .start (mdlClasses , fut );
98
+ NCProbeBoot$ .MODULE$ .startEmbedded (cfgFile , mdlClasses , fut );
146
99
147
100
return waitForFuture (fut );
148
101
}
@@ -154,22 +107,23 @@ public static boolean start(Class<? extends NCModel>... mdlClasses) {
154
107
* @param tok Probe token override.
155
108
* @param upLink Probe up-link to the server override.
156
109
* @param dnLink Probe down-link from the server override.
157
- * @param mdlClasses One or more data model classes overrides to be deployed by the embedded probe.
110
+ * @param mdlClasses One or more data model classes overrides to be deployed by the embedded probe. At least
111
+ * model must be provided.
158
112
* @throws NCException Thrown in case of any errors starting the data probe.
159
113
* @return Whether or not probe started ok.
160
114
*/
161
- @ SafeVarargs
162
115
public static boolean start (
163
116
String probeId ,
164
117
String tok ,
165
118
String upLink ,
166
119
String dnLink ,
167
- Class <? extends NCModel >... mdlClasses ) {
168
- checkModelClasses (mdlClasses );
120
+ String ... mdlClasses ) {
121
+ if (mdlClasses .length == 0 )
122
+ throw new NCException ("At least one model class must be provided when starting embedded probe." );
169
123
170
124
CompletableFuture <Integer > fut = new CompletableFuture <>();
171
125
172
- NCProbeBoot$ .MODULE$ .start (probeId , tok , upLink , dnLink , mdlClasses , fut );
126
+ NCProbeBoot$ .MODULE$ .startEmbedded (probeId , tok , upLink , dnLink , mdlClasses , fut );
173
127
174
128
return waitForFuture (fut );
175
129
}
0 commit comments