/** * Installs type support. This should only be called by either DataSources * or ExpressionLanguage libraries that require support for these types. */ public static void install() { // Install only once if (installed) { return; } // This looks like double-checked locking and in fact it is, but it is // safe because installed is volatile. // If we used an AtomicBoolean instead of the volatile boolean, we would // not need the lock (we could use a compare-and-set operation), but in // this case another thread calling this method might return before the // installation has actually finished. synchronized (installLock) { if (installed) { return; } // Add notification support for all immutable types TypeSupport.addTypeSupport(NotificationSupport.immutableTypeSupport(VType.class)); installed = true; } }
/** * Installs type support. */ public static void install() { // Install only once if (installed) { return; } // This looks like double-checked locking and in fact it is, but it is // safe because installed is volatile. // If we used an AtomicBoolean instead of the volatile boolean, we would // not need the lock (we could use a compare-and-set operation), but in // this case another thread calling this method might return before the // installation has actually finished. synchronized (installLock) { if (installed) { return; } // Add support for lists addList(); addMap(); // Add support for numbers and strings TypeSupport.addTypeSupport(NotificationSupport.immutableTypeSupport(Number.class)); TypeSupport.addTypeSupport(NotificationSupport.immutableTypeSupport(String.class)); installed = true; } }