This method automatically adds discovered hibernate event listeners into
the hibernate service registry.

@param registry The service registry.
964321
private void injectEventListeners(final ServiceRegistry registry) {

        EventListenerRegistry eventRegistry = registry
                .getService(EventListenerRegistry.class);

        List<PostInsertEventListener> postInsertEvents = locator
                .getAllServices(PostInsertEventListener.class);
        for (PostInsertEventListener piEventListener : postInsertEvents) {
            logger.trace("Registering PostInsert: " + piEventListener
                    .getClass().getCanonicalName());
            eventRegistry.appendListeners(EventType.POST_INSERT,
                    piEventListener);
        }

        List<PostUpdateEventListener> postUpdateEvents = locator
                .getAllServices(PostUpdateEventListener.class);
        for (PostUpdateEventListener puEventListener : postUpdateEvents) {
            logger.trace("Registering PostUpdate: " + puEventListener
                    .getClass().getCanonicalName());
            eventRegistry.appendListeners(EventType.POST_UPDATE,
                    puEventListener);
        }

        List<PostDeleteEventListener> postDeleteEvents = locator
                .getAllServices(PostDeleteEventListener.class);
        for (PostDeleteEventListener pdEventListener : postDeleteEvents) {
            logger.trace("Registering PostDelete: " + pdEventListener
                    .getClass().getCanonicalName());
            eventRegistry.appendListeners(EventType.POST_DELETE,
                    pdEventListener);
        }

        List<PreInsertEventListener> preInsertEvents = locator
                .getAllServices(PreInsertEventListener.class);
        for (PreInsertEventListener piEventListener : preInsertEvents) {
            logger.trace("Registering PreInsert: " + piEventListener
                    .getClass().getCanonicalName());
            eventRegistry.appendListeners(EventType.PRE_INSERT,
                    piEventListener);
        }

        List<PreUpdateEventListener> preUpdateEvents = locator
                .getAllServices(PreUpdateEventListener.class);
        for (PreUpdateEventListener puEventListener : preUpdateEvents) {
            logger.trace("Registering PreUpdate: " + puEventListener
                    .getClass().getCanonicalName());
            eventRegistry.appendListeners(EventType.PRE_UPDATE,
                    puEventListener);
        }

        List<PreDeleteEventListener> preDeleteEvents = locator
                .getAllServices(PreDeleteEventListener.class);
        for (PreDeleteEventListener pdEventListener : preDeleteEvents) {
            logger.trace("Registering PreDelete: " + pdEventListener
                    .getClass().getCanonicalName());
            eventRegistry.appendListeners(EventType.PRE_DELETE,
                    pdEventListener);
        }

        List<PostCommitInsertEventListener> pciEvents = locator
                .getAllServices(PostCommitInsertEventListener.class);
        for (PostCommitInsertEventListener cpiEventListener : pciEvents) {
            logger.trace("Registering PostCommitInsert: " + cpiEventListener
                    .getClass().getCanonicalName());
            eventRegistry.appendListeners(EventType.POST_COMMIT_INSERT,
                    cpiEventListener);
        }

        List<PostCommitUpdateEventListener> pcuEvents = locator
                .getAllServices(PostCommitUpdateEventListener.class);
        for (PostCommitUpdateEventListener cpuEventListener : pcuEvents) {
            logger.trace("Registering PostCommitUpdate: " + cpuEventListener
                    .getClass().getCanonicalName());
            eventRegistry.appendListeners(EventType.POST_COMMIT_UPDATE,
                    cpuEventListener);
        }

        List<PostCommitDeleteEventListener> pcdEvents = locator
                .getAllServices(PostCommitDeleteEventListener.class);
        for (PostCommitDeleteEventListener cpdEventListener : pcdEvents) {
            logger.trace("Registering PostCommitDelete: " + cpdEventListener
                    .getClass().getCanonicalName());
            eventRegistry.appendListeners(EventType.POST_COMMIT_DELETE,
                    cpdEventListener);
        }
    }
195012
@Override
	public void addListeners(String serviceName, Service service) {

		// Service name with version
		String name = (serviceName == null || serviceName.isEmpty()) ? service.getName() : serviceName;
		Class<? extends Service> clazz = service.getClass();
		Field[] fields = clazz.getFields();

		boolean hasListener = false;
		writeLock.lock();
		try {

			// Initialize listeners in service
			for (Field field : fields) {

				// Register event listener
				if (Listener.class.isAssignableFrom(field.getType())) {
					hasListener = true;

					// Name of the action (eg. "service.action")
					String listenerName = nameOf(name, field);

					// Process "Subscribe" annotation
					Subscribe s = field.getAnnotation(Subscribe.class);
					String subscribe = null;
					if (s != null) {
						subscribe = s.value();
					}
					if (subscribe == null || subscribe.isEmpty()) {
						subscribe = listenerName;
					}

					// Process "Group" annotation
					String group = null;
					Group g = field.getAnnotation(Group.class);
					if (g != null) {
						group = g.value();
					}
					if (group == null || group.isEmpty()) {
						group = name;
					}

					// Register listener in EventBus
					field.setAccessible(true);
					Listener listener = (Listener) field.get(service);

					// Get or create group map
					HashMap<String, Strategy<ListenerEndpoint>> groups = listeners.get(subscribe);
					if (groups == null) {
						groups = new HashMap<String, Strategy<ListenerEndpoint>>();
						listeners.put(subscribe, groups);
					}

					// Get or create strategy
					Strategy<ListenerEndpoint> strategy = groups.get(group);
					if (strategy == null) {
						strategy = this.strategy.create();
						groups.put(group, strategy);
					}

					// Add endpoint to strategy
					strategy.addEndpoint(new LocalListenerEndpoint(executor, nodeID, name, group, subscribe, listener,
							asyncLocalInvocation));
				}
			}
		} catch (Exception cause) {
			logger.error("Unable to register local listener!", cause);
		} finally {

			// Clear caches
			if (hasListener) {
				emitterCache.clear();
				broadcasterCache.clear();
				localBroadcasterCache.clear();
			}

			// Unlock reader threads
			writeLock.unlock();
		}
	}
907783
public void addEventListener(EventListener listener)
    throws IllegalArgumentException
    {
        
        if (listener instanceof HttpSessionAttributeListener)
            _sessionAttributeListeners.add(listener);
        if (listener instanceof HttpSessionListener)
            _sessionListeners.add(listener);
    }
1268177
public void addServiceDescriptor(KEY key, MethodDescriptor<KEY> serviceDescriptor) {
        Preconditions.checkNotNull(key, "Key cannot be null");
        Preconditions.checkState(instance != null, "ServiceRegistry not init yet");

        //        if (serviceDescriptors.containsKey(key)) {
        //            LOG.warn("Ignore key=" + key + " since it is already registered with "
        //                    + serviceDescriptor);
        //        }

        this.serviceDescriptors.putIfAbsent(key, serviceDescriptor);
    }
155435
private void registerSessionListener() {
        ISessionLifecycle sessionTracker = new ISessionLifecycle() {
            
            @Override
            public void onSessionCreate(Session session) {
                try {
                    AppContextFinder.createAppContext(session.getPage());
                } catch (Exception e) {
                    throw new SessionInitException(e);
                }
            }
            
            @Override
            public void onSessionDestroy(Session session) {
                AppContextFinder.destroyAppContext(session.getPage());
            }
            
        };

        Sessions.getInstance().addLifecycleListener(sessionTracker);
    }
749140
private void registerListeners() {
    protocol.registerExecuteHandler(this::execute);
    protocol.registerBackupHandler(this::backup);
    protocol.registerRestoreHandler(this::restore);
    protocol.registerCloseHandler(this::close);
    protocol.registerMetadataHandler(this::metadata);
  }
1232346
void loadAdditionalServices(ServiceRegistry registry) {
        for (ResourceLoader loader : getResourceLoaders()) {
            for (Metadata<Service> metadata : ServiceLoader.load(Service.class, loader)) {
                Service service = metadata.getValue();
                for (Class<? extends Service> serviceInterface : Services.identifyServiceInterfaces(service.getClass(), new HashSet<>())) {
                    Services.put(registry, serviceInterface, service);
                }
            }
        }
    }
450112
public void addEntityChangeListener(I_CmsEntityChangeListener changeListener, String changeScope) {

        if (m_observerdEntity == null) {
            throw new RuntimeException("The Observer has been cleared, no listener registration possible.");
        }
        if (!m_changeListeners.containsKey(changeScope)) {
            m_changeListeners.put(changeScope, new ArrayList<I_CmsEntityChangeListener>());
            // if changeScope==null, it is a global change listener, and we don't need a scope value
            if (changeScope != null) {
                // save the current change scope value
                m_scopeValues.put(changeScope, CmsContentDefinition.getValueForPath(m_observerdEntity, changeScope));
            }
        }
        m_changeListeners.get(changeScope).add(changeListener);
    }
812839
@Override
    public void addSynchronizationObserver(Observer<Registry<KEY, ENTRY>,Long> observer) {
        synchronisationObservable.addObserver(observer);
    }
82532
public void registerBeans(BeanDefinitionRegistry registry) {
        finalizeDeferredProperties();

        if (registry instanceof GenericApplicationContext) {
            GenericApplicationContext ctx = (GenericApplicationContext) registry;
            ctx.setClassLoader(classLoader);
            ctx.getBeanFactory().setBeanClassLoader(classLoader);
        }

        springConfig.registerBeansWithRegistry(registry);
    }
755802
private void loadListeners(ServiceLoader<LifecycleListener> loader) {
        Iterator<LifecycleListener> iterator = loader.iterator();
        while (hasNextSafely(iterator)) {
            try {
                LifecycleListener listener = iterator.next();
                listeners.add(listener);
                LOGGER.info(String.format("Found %s: %s", LifecycleListener.class, listener.getClass()));
            } catch (ServiceConfigurationError e) {
                LOGGER.error("iterator.next() failed", e);
            }
        }
    }
910685
private void registerPerformanceMonitor(String beanName,
                                            BeanDefinitionRegistry registry) {

        String perfMonitorName = beanName + "PerformanceMonitor";
        if (!registry.containsBeanDefinition(perfMonitorName))  {
            BeanDefinitionBuilder initializer =
                BeanDefinitionBuilder.rootBeanDefinition(PerformanceMonitorBean.class);
            registry.registerBeanDefinition(perfMonitorName, initializer.getBeanDefinition());
        }
    }
151158
private void registerTypeMappings(
      TypeMapping registryTypeMapping, List<TypeMapping> typeMappings) {
    Preconditions.checkNotNull(registryTypeMapping, "Null registry type mapping");
    Preconditions.checkNotNull(typeMappings, "Null type mappings");
    Preconditions.checkArgument(!typeMappings.isEmpty(), "Empty type mappings");
    for (TypeMapping typeMapping : typeMappings) {
      for (Class<?> mappingClass : typeMapping.getAllClasses()) {
        QName classQName = typeMapping.getTypeQName(mappingClass);
        DeserializerFactory deserializer = typeMapping.getDeserializer(mappingClass, classQName);
        if (deserializer != null && !registryTypeMapping.isRegistered(mappingClass, classQName)) {
          registryTypeMapping.register(
              mappingClass, classQName, (SerializerFactory) null, deserializer);
        }
      }
    }
  }
1366706
public List<RegistryListener<K, V>> getListeners() {
        return new LinkedList<RegistryListener<K, V>>(listeners);
    }
918413
public static void registerListener(ListenerInfo information) {
        if (isServiceLoaderDisabled()) {
            // Donot even attempt register any listeners if the user doesnt want them to be managed.
            return;
        }
        logger.entering(information);
        listenerMap.put(information.getListenerClassName(), information);
    }
952748
public void setListeners(Collection<CustomizationSupplier<CacheEntryOperationListener<K,V>>> c) {
    getListeners().addAll(c);
  }
387233
public <T> void registerRefListener(T oldObject, final Listener<T> listener) {
    checkNotNull(oldObject);
    checkNotNull(listener);
    Object oldMapping = mappings.get(oldObject);
    if (oldMapping == null) {
      // store the listener so it will be run when the old object mapping is registered
      mappings.put(oldObject, listener);
    } else if (oldMapping instanceof Listener) {
      // chain the listeners
      @SuppressWarnings("unchecked") // Listener<T> can only be registered with a T
      final Listener<T> oldListener = (Listener) oldMapping;
      mappings.put(oldObject, chainListeners(listener, oldListener));
    } else {
      // if there was a value mapped to the old object it must have been a T
      @SuppressWarnings("unchecked")
      T typedValue = (T) oldMapping;
      listener.newVersion(typedValue);
    }
  }