Instantiates the listener of given type and caches it.

@param listenerClass
the listener type
@return the instantiated object
333370
private Object loadListener(Class<?> listenerClass) {
    synchronized (listenerClass) {
      Object listener = listeners.get(listenerClass);
      if (listener == null) {
        listener = IntrospectionUtils.instantiateObject(listenerClass);
        listeners.put(listenerClass, listener);
      }
      return listener;
    }
  }
862207
@SuppressWarnings("unchecked")
  private static <T> T newInstance(Class<?> type) {
    try {
      return (T) type.newInstance();
    } catch (InstantiationException | IllegalAccessException e) {
      throw new ServiceException("Cannot instantiate service class " + type, e);
    }
  }
130771
protected final <T extends EventListener> void addListener(Class<T> listenerType, T listener) {
		if (this.listeners == null) {
			this.listeners = new ListenerCollection<>();
		}
		this.listeners.add(listenerType, listener);
	}
273136
public final Cache2kBuilder<K, V> addCacheClosedListener(CacheClosedListener listener) {
    config().getCacheClosedListeners().add(wrapCustomizationInstance(listener));
    return this;
  }
960789
private void processExternalListener(Class<?> listenerClass) {
    ExternalListenerMetadata listenerMetadata = ExternalListenerIntrospector
        .introspect(listenerClass);
    Map<CallbackType, Method> callbacks = listenerMetadata.getCallbacks();
    if (callbacks != null) {
      for (Map.Entry<CallbackType, Method> entry : callbacks.entrySet()) {
        validateExternalCallback(entry.getValue(), entry.getKey());
      }
    }
  }
464216
function(type, callback, scope){
            var listeners = _cache[type];
            if (!listeners) {
                return this;
            }
            if(callback){
                var len = listeners.length,
                    tmp = [];
                
                for(var i=0; i<len; i++) {
                    var listener = listeners[i];
                    if(listener.callback == callback && listener.scope == scope) {
                    } else {
                        tmp.push(listener);
                    }
                }
                listeners = tmp;
            }else{
                listeners.length = 0;
            }
            return this;
        }
1321984
public void initListeners() {
        instanceStateChangedListener.watch(ChangedType.UPDATED);
        dataSourceStateChangedListener.watch(ChangedType.UPDATED, ChangedType.DELETED);
    }
1144309
private Class instantiate(final String taskClass) {

		try {

			return Class.forName(taskClass);

		} catch (Throwable ignore) {}

		return null;
	}
747853
private static <T> T instantiate(Class<T> pojoClass) throws InstantiationException, IllegalAccessException, java.lang.reflect.InvocationTargetException {
        try {
            Constructor<T> constructor = pojoClass.getDeclaredConstructor();
            constructor.setAccessible(true);
            return constructor.newInstance();
        } catch (NoSuchMethodException e) {
            Function<Class<?>,Object> fn = unsafeInstantiator.get();
            if (fn == null) {
                throw new HecateException(e, "Unable to instantiate object of type %s (no-arg constructor missing).", pojoClass.getCanonicalName());
            }
            return (T) fn.apply(pojoClass);
        }
    }
1089562
@SuppressWarnings("unchecked")
  private <T extends Indexer> T createIndexer(Class<T> indexerClass) {
    synchronized (indexerClass) {
      Indexer indexer = cache.get(indexerClass);
      if (indexer == null) {
        indexer = (Indexer) IntrospectionUtils.instantiateObject(indexerClass);
        cache.put(indexerClass, indexer);
      }
      return (T) indexer;
    }
  }
358634
@Override
    public <T extends EventListener> T  createListener(Class<T> classToCreate) throws ServletException {        
        boolean valid = false;
        
        T listener = super.createListener(classToCreate);
        
        for (Class c : validListenerClasses) {
            if (c != null && c.isAssignableFrom(classToCreate)) {
                valid = true;
            }
        }
        
        if (!valid) {
            throw new IllegalArgumentException(nls.getString("exception.occurred.while.creating.listener.instance"));
        }
        
        return listener;
    }
276668
public static <T> RuntimeSchema<T> createFrom(Class<T> typeClass)
    {
        return createFrom(typeClass, NO_EXCLUSIONS, ID_STRATEGY);
    }
1326377
private <T extends Rdp4jListener> void notifyListeners(Class<T> listenerType, Notifier<T> notifier)
            throws InterruptedException {
        for (Rdp4jListener listener : listeners) {
            if (isInstanceOf(listener, listenerType)) {
                /*
                 * This cast is correct, since we check if listener
                 * is instance of listenerType.
                 */
                @SuppressWarnings("unchecked")
                T listener2 = (T) listener;
                try {
                    notifier.notify(listener2);
                } catch (InterruptedException e) {
                    throw e;
                } catch (Throwable e) {
                    logErrorMessage(e);
                }
            }
        }
    }
45913
public LifecycleListener createLifecycleListener() {
        return new LifecycleListener() {

            @Override
            public void onForegrounded(Context context) {
                synchronized (lock) {
                    if (!isForegrounded) {
                        isForegrounded = true;
                        connectSocket();
                        if (receiver == null) {
                            receiver = new InternetConnectionReceiver(socketConnection);
                        }
                        context.registerReceiver(receiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
                    }
                    lock.notifyAll();
                }
            }

            @Override
            public void onBackgrounded(Context context) {
                synchronized (lock) {
                    if (isForegrounded) {
                        isForegrounded = false;
                        disconnectSocket();
                        if (receiver != null && !isForegrounded) {
                            context.unregisterReceiver(receiver);
                        }
                    }
                    lock.notifyAll();
                }
            }
        };
    }
524285
public static <L> ListenerList<L> addListener (ListenerList<L> list, L listener)
    {
        if (list == null) {
            list = new ListenerList<L>();
        }
        list.add(listener);
        return list;
    }
1047981
protected Object loadListener(String lClassName) throws InjectionException, Throwable //596191 :: PK97815
    {
        Object listener = null;

        try {
            if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.FINE))
                logger.logp(Level.FINE, CLASS_NAME, "loadListener", "loadListener Classloader " + getClassLoader());
            // PK16542 end
            // instantiate the listener
            listener = java.beans.Beans.instantiate(getClassLoader(), lClassName);
        } catch (Throwable th) {
            // some exception, log error.
            logError("Failed to load listener: " + lClassName, th);
            if (WCCustomProperties.STOP_APP_STARTUP_ON_LISTENER_EXCEPTION) { //PI58875
                throw th;
            }
        }
        return listener;
    }
281575
public ProxyDataSourceBuilder listener(JdbcLifecycleEventListener listener) {
        JdbcLifecycleEventExecutionListener executionListener = new JdbcLifecycleEventExecutionListener(listener);
        this.queryExecutionListeners.add(executionListener);
        this.methodExecutionListeners.add(executionListener);
        return this;
    }