37
37
import net .openhft .chronicle .queue .impl .table .ReadonlyTableStore ;
38
38
import net .openhft .chronicle .queue .impl .table .SingleTableBuilder ;
39
39
import net .openhft .chronicle .queue .internal .domestic .QueueOffsetSpec ;
40
+ import net .openhft .chronicle .queue .providers .EnterpriseQueueFactories ;
40
41
import net .openhft .chronicle .threads .MediumEventLoop ;
41
42
import net .openhft .chronicle .threads .Pauser ;
42
43
import net .openhft .chronicle .threads .TimeoutPauser ;
47
48
48
49
import javax .crypto .spec .SecretKeySpec ;
49
50
import java .io .File ;
50
- import java .lang .reflect .Constructor ;
51
51
import java .nio .file .Path ;
52
52
import java .time .LocalTime ;
53
53
import java .time .ZoneId ;
@@ -68,7 +68,6 @@ public class SingleChronicleQueueBuilder extends SelfDescribingMarshallable impl
68
68
public static final long SMALL_BLOCK_SIZE = OS .isWindows () ? OS .SAFE_PAGE_SIZE : OS .pageSize (); // the smallest safe block size on Windows 8+
69
69
70
70
public static final long DEFAULT_SPARSE_CAPACITY = 512L << 30 ;
71
- private static final Constructor ENTERPRISE_QUEUE_CONSTRUCTOR ;
72
71
private static final WireStoreFactory storeFactory = SingleChronicleQueueBuilder ::createStore ;
73
72
private static final Supplier <TimingPauser > TIMING_PAUSER_SUPPLIER = DefaultPauserSupplier .INSTANCE ;
74
73
@@ -78,17 +77,6 @@ public class SingleChronicleQueueBuilder extends SelfDescribingMarshallable impl
78
77
CLASS_ALIASES .addAlias (SCQRoll .class , "SCQSRoll" );
79
78
CLASS_ALIASES .addAlias (SCQIndexing .class , "SCQSIndexing" );
80
79
CLASS_ALIASES .addAlias (SingleChronicleQueueStore .class , "SCQStore" );
81
-
82
- {
83
- Constructor co ;
84
- try {
85
- co = ((Class ) Class .forName ("software.chronicle.enterprise.queue.EnterpriseSingleChronicleQueue" )).getDeclaredConstructors ()[0 ];
86
- Jvm .setAccessible (co );
87
- } catch (Exception e ) {
88
- co = null ;
89
- }
90
- ENTERPRISE_QUEUE_CONSTRUCTOR = co ;
91
- }
92
80
}
93
81
94
82
private BufferMode writeBufferMode = BufferMode .None ;
@@ -235,7 +223,7 @@ static SingleChronicleQueueStore createStore(@NotNull RollingChronicleQueue queu
235
223
}
236
224
237
225
public static boolean areEnterpriseFeaturesAvailable () {
238
- return ENTERPRISE_QUEUE_CONSTRUCTOR != null ;
226
+ return EnterpriseQueueFactories . get (). areEnterpriseFeaturesAvailable () ;
239
227
}
240
228
241
229
private static RollCycle loadDefaultRollCycle () {
@@ -300,10 +288,10 @@ public SingleChronicleQueue build() {
300
288
301
289
// It is important to check enterprise features after preBuild()
302
290
// Enterprise-only config options can be loaded from the metadata
303
- if (checkEnterpriseFeaturesRequested ())
304
- chronicleQueue = buildEnterprise ( );
305
- else
306
- chronicleQueue = new SingleChronicleQueue (this );
291
+ if (checkEnterpriseFeaturesRequested () && ! areEnterpriseFeaturesAvailable ()) {
292
+ throw new IllegalStateException ( "Enterprise features requested but Chronicle Queue Enterprise is not in the class path!" );
293
+ }
294
+ chronicleQueue = EnterpriseQueueFactories . get (). newInstance (this );
307
295
308
296
postBuild (chronicleQueue );
309
297
@@ -342,23 +330,11 @@ private boolean checkEnterpriseFeaturesRequested() {
342
330
}
343
331
344
332
public static boolean onlyAvailableInEnterprise (final String feature ) {
345
- if (ENTERPRISE_QUEUE_CONSTRUCTOR == null )
333
+ if (! areEnterpriseFeaturesAvailable () )
346
334
Jvm .warn ().on (SingleChronicleQueueBuilder .class , feature + " is only supported in Chronicle Queue Enterprise. If you would like to use this feature, please contact sales@chronicle.software for more information." );
347
335
return true ;
348
336
}
349
337
350
- @ NotNull
351
- private SingleChronicleQueue buildEnterprise () {
352
- if (ENTERPRISE_QUEUE_CONSTRUCTOR == null )
353
- throw new IllegalStateException ("Enterprise features requested but Chronicle Queue Enterprise is not in the class path!" );
354
-
355
- try {
356
- return (SingleChronicleQueue ) ENTERPRISE_QUEUE_CONSTRUCTOR .newInstance (this );
357
- } catch (Exception e ) {
358
- throw new IllegalStateException ("Couldn't create an instance of Enterprise queue" , e );
359
- }
360
- }
361
-
362
338
public SingleChronicleQueueBuilder aesEncryption (@ Nullable byte [] keyBytes ) {
363
339
if (keyBytes == null ) {
364
340
codingSuppliers (null , null );
0 commit comments