Sets the new service and notifies the listener that the service was changed.

@param newService the new service
354435
private synchronized void setService( final T newService )
    {
        if( m_service != newService )
        {
            LOG.debug( "Service changed [" + m_service + "]  -> [" + newService + "]" );
            final T oldService = m_service;
            m_service = newService;
            if( m_serviceListener != null )
            {
                m_serviceListener.serviceChanged( oldService, m_service );
            }
        }
    }
930650
@Reference
    protected void setSecurityService(SecurityService securityService) {
        SibTr.entry(tc, CLASS_NAME + "setSecurityService", securityService);

        this.securityService = securityService;

        SibTr.exit(tc, CLASS_NAME + "setSecurityService");
    }
1236802
public void setSession(Session newSession) {
        if (newSession == null) {
            if (session != null) {
                // We're current tracking a Session. Remove the callback
                // and start tracking the active Session.
                session.removeCallback(callback);
                session = null;
                addBroadcastReceiver();
                if (getSession() != null) {
                    getSession().addCallback(callback);
                }
            }
        } else {
            if (session == null) {
                // We're currently tracking the active Session, but will be
                // switching to tracking a different Session object.
                Session activeSession = Session.getActiveSession();
                if (activeSession != null) {
                    activeSession.removeCallback(callback);
                }
                broadcastManager.unregisterReceiver(receiver);
            } else {
                // We're currently tracking a Session, but are now switching 
                // to a new Session, so we remove the callback from the old 
                // Session, and add it to the new one.
                session.removeCallback(callback);
            }
            session = newSession;
            session.addCallback(callback);
        }
    }
206660
protected void setConfigurationService(ConfigurationService configService) {
        if (log.isLoggable(Level.FINER)) {
            log.finer("Set configuration service = " + configService);
        }

        configurationService = configService;

        if (configurationService != null) {
            initConfig();
        }
    }
226089
private void updateSortedServices() {
    List<T> copiedList = new ArrayList<T>(serviceMap.values());
    sortedServices = Collections.unmodifiableList(copiedList);
    if (changeListener != null) {
      changeListener.changed();
    }
  }
55742
public void setSubscribe(boolean subscribe) {
        addField(ConfigureNodeFields.subscribe, FormField.Type.bool);
        setAnswer(ConfigureNodeFields.subscribe.getFieldName(), subscribe);
    }
773682
public void removeNotificationHandler(String serviceName, NotificationHandler handler) {

        ServiceInstanceUtils.validateServiceName(serviceName);
        if (handler == null) {
            throw new ServiceException(ErrorCode.SERVICE_DIRECTORY_NULL_ARGUMENT_ERROR,
                    ErrorCode.SERVICE_DIRECTORY_NULL_ARGUMENT_ERROR.getMessageTemplate(),
                    "NotificationHandler");
        }
        List<InstanceChangeListener<ModelServiceInstance>> list = changeListenerMap.get(serviceName);
        if (list != null) {
            boolean found = false;
            for (InstanceChangeListener<ModelServiceInstance> listener : list) {
                if (listener instanceof NotificationHandlerAdapter
                        && ((NotificationHandlerAdapter) listener).getAdapter() == handler) {
                    list.remove(listener);
                    found = true;
                    break;
                }
            }
            if (!found) {
               LOGGER.error(ErrorCode.NOTIFICATION_HANDLER_DOES_NOT_EXIST.getMessageTemplate());
            }
        } else {
            LOGGER.error(String.format(ErrorCode.SERVICE_DOES_NOT_EXIST.getMessageTemplate(), serviceName));
        }

    }
157404
private void updateServiceCache(String serviceName, ConcurrentHashMap<String, List<URL>> serviceUrls, boolean needNotify) {
        if (serviceUrls != null && !serviceUrls.isEmpty()) {
            List<URL> urls = serviceCache.get(serviceName);
            if (urls == null) {
                if(logger.isDebugEnabled()) {
                    try {
                        logger.debug("serviceUrls = " + Config.getInstance().getMapper().writeValueAsString(serviceUrls));
                    } catch(Exception e) {
                    }
                }
                serviceCache.put(serviceName, serviceUrls.get(serviceName));
            }
            for (Map.Entry<String, List<URL>> entry : serviceUrls.entrySet()) {
                boolean change = true;
                if (urls != null) {
                    List<URL> newUrls = entry.getValue();
                    if (newUrls == null || newUrls.isEmpty() || ConsulUtils.isSame(newUrls, urls)) {
                        change = false;
                    } else {
                        serviceCache.put(serviceName, newUrls);
                    }
                }
                if (change && needNotify) {
                    notifyExecutor.execute(new NotifyService(entry.getKey(), entry.getValue()));
                    logger.info("light service notify-service: " + entry.getKey());
                    StringBuilder sb = new StringBuilder();
                    for (URL url : entry.getValue()) {
                        sb.append(url.getUri()).append(";");
                    }
                    logger.info("consul notify urls:" + sb.toString());
                }
            }
        }
    }
530124
public void setRoleService(
		com.liferay.portal.kernel.service.RoleService roleService) {
		this.roleService = roleService;
	}
1258485
public void setServiceType(java.util.Collection<ServiceTypeDetail> serviceType) {
        if (serviceType == null) {
            this.serviceType = null;
            return;
        }

        this.serviceType = new com.amazonaws.internal.SdkInternalList<ServiceTypeDetail>(serviceType);
    }
542697
@Override
    public final SessionDestroyedListener addingService(ServiceReference<SessionDestroyedListener> serviceReference) {
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Listener [" + serviceReference + "] has been added.");
        }

        final SessionDestroyedListener listener = context.getService(serviceReference);
        handler.addListener(listener);

        return listener;
    }
24403
async def set_headline(self, name, level, message):
        

        if name not in self.services:
            raise ArgumentError("Unknown service name", short_name=name)

        self.services[name]['state'].set_headline(level, message)

        headline = self.services[name]['state'].headline.to_dict()
        await self._notify_update(name, 'new_headline', headline)
374308
func NewService(config ServiceConfig) (*Service, error) {
	// Dependencies.
	if config.K8sClient == nil {
		return nil, microerror.Maskf(invalidConfigError, "config.K8sClient must not be empty")
	}
	if config.Logger == nil {
		return nil, microerror.Maskf(invalidConfigError, "config.Logger must not be empty")
	}

	newService := &Service{
		// Dependencies.
		k8sClient: config.K8sClient,
		logger:    config.Logger,
	}

	return newService, nil
}
1100126
private synchronized void setSocket(final Socket newSocket) {
    connector = null;
    socketNode = new SocketNode13(newSocket, this);
    socketNode.addSocketNodeEventListener(this);

    synchronized (listenerList) {
        for (Iterator iter = listenerList.iterator(); iter.hasNext();) {
            SocketNodeEventListener listener =
                    (SocketNodeEventListener) iter.next();
            socketNode.addSocketNodeEventListener(listener);
        }
    }
    new Thread(socketNode).start();
  }
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();
		}
	}
588464
public void changeStatus(int newStatus)
    {
        if (tc.isEntryEnabled())
            Tr.entry(tc, "changeStatus", new java.lang.Object[] { this, new Integer(newStatus) });

        _status = newStatus;

        if (tc.isEntryEnabled())
            Tr.exit(tc, "changeStatus");
    }
1371960
protected void broadcastServicesChanged(boolean local) {
		Tree message = new Tree();
		message.put("localService", true);
		eventbus.broadcast("$services.changed", message, null, true);
	}