Register a default producer for events to use.
        :param producer: the default producer to to dispatch events on.
336716
def register_producer(cls, producer):
        
        log.info('@Registry.register_producer `{}`'
                 .format(producer.__class__.__name__))
        cls._producer = (cls._producer or producer)
933952
def register(cls, name):
        

        def decorate(klazz):
            """ Decorator. """
            if name in cls._events:
                raise GerritError("Duplicate event: %s" % name)
            cls._events[name] = [klazz.__module__, klazz.__name__]
            klazz.name = name
            return klazz
        return decorate
422446
def register_event(self, *names):
        
        for name in names:
            if name in self.__events:
                continue
            self.__events[name] = Event(name)
996845
def register_fetcher(self, name, fetcher):
        
        assert name not in self.fetchers
        self.fetchers[name] = fetcher
1356198
public void addRewardProducer(IRewardProducer producer) {
        if (this.producers == null) {
            this.producers = new ArrayList<IRewardProducer>();
        }
        this.producers.add(producer);
    }
92463
public synchronized SerializerRegistry registerDefault(Class<?> baseType, TypeSerializerFactory factory) {
    defaultFactories.put(baseType, factory);
    return this;
  }
1057545
def register(self, request_class: Request, handler_factory: Callable[[], Handler]) -> None:
        
        key = request_class.__name__
        is_command = request_class.is_command()
        is_event = request_class.is_event()
        is_present = key in self._registry
        if is_command and is_present:
            raise ConfigurationException("A handler for this request has already been registered")
        elif is_event and is_present:
            self._registry[key].append(handler_factory)
        elif is_command or is_event:
            self._registry[key] = [handler_factory]
1265933
public void detachAllProducersForNewInputHandler(ProducerInputHandler newHandler)throws SIException
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "detachAllProducersForNewInputHandler", newHandler);

    //detach all producers and update
    synchronized (_producers)
    {
      Iterator<MessageProducer> it = _producers.iterator();
      while(it.hasNext())
      {
        ProducerSessionImpl prod = (ProducerSessionImpl)it.next();
        it.remove();
        //attach this to the new input handler
        newHandler.attachProducer(prod);
        prod.updateInputHandler(newHandler);
      }
    }

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "detachAllProducersForNewInputHandler");
  }
1192387
def service_changed(self, event):
        # type: (ServiceEvent) -> None
        
        kind = event.get_kind()
        if kind == ServiceEvent.REGISTERED:
            # iPOPO service registered: register to factory events
            with use_ipopo(self.__context) as ipopo:
                ipopo.add_listener(self)
1253329
def setup(self, settings):
        '''
        
        '''
        self.producer = self._create_producer(settings)
        self.topic_prefix = settings['KAFKA_TOPIC_PREFIX']

        self.use_appid_topics = settings['KAFKA_APPID_TOPICS']

        self.logger.debug("Successfully connected to Kafka in {name}"
                              .format(name=self.__class__.__name__))
748448
def _create_producer(self, settings):
        """"""
        try:
            brokers = settings['KAFKA_HOSTS']
            self.logger.debug("Creating new kafka producer using brokers: " +
                               str(brokers))

            return KafkaProducer(bootstrap_servers=brokers,
                                 value_serializer=lambda m: json.dumps(m),
                                 retries=3,
                                 linger_ms=settings['KAFKA_PRODUCER_BATCH_LINGER_MS'],
                                 buffer_memory=settings['KAFKA_PRODUCER_BUFFER_BYTES'])
        except KeyError as e:
            self.logger.error('Missing setting named ' + str(e),
                               {'ex': traceback.format_exc()})
        except:
            self.logger.error("Couldn't initialize kafka producer in plugin.",
                               {'ex': traceback.format_exc()})
            raise
243911
def register_event(self, event_type, pattern, handler):
        
        if event_type not in self._supported_events:
            raise ValueError("Unsupported event type {}".format(event_type))
        if event_type != "CHANGE" and not isinstance(pattern, Pattern) and not isinstance(pattern, basestring):
            raise ValueError("Expected pattern to be a Pattern or string")
        if event_type == "CHANGE" and not (len(pattern)==2 and isinstance(pattern[0], int) and isinstance(pattern[1], numpy.ndarray)):
            raise ValueError("For \"CHANGE\" events, ``pattern`` should be a tuple of ``min_changed_pixels`` and the base screen state.")

        # Create event object
        event = {
            "pattern": pattern,
            "event_type": event_type,
            "count": 0,
            "handler": handler,
            "name": uuid.uuid4(),
            "active": True
        }
        self._events[event["name"]] = event
        return event["name"]
38438
def register_handler(alias: str, handler: callable):
        
        if SignalDispatcher.handlers.get(alias) is None:
            SignalDispatcher.handlers[alias] = [handler]
        else:
            SignalDispatcher.handlers.get(alias).append(handler)
192567
public static <T> void registerWriter(Class<?> cls, JsonWriterI<T> writer) {
		defaultWriter.registerWriter(writer, cls);
	}
24275
private void registerRunnerBeanDefinition() {
        DefaultListableBeanFactory beanFactory = (DefaultListableBeanFactory)
                ((ConfigurableApplicationContext) applicationContext).getBeanFactory();
        jobRunnerBeanName = "LTS_".concat(jobRunnerClass.getSimpleName());
        if (!beanFactory.containsBean(jobRunnerBeanName)) {
            BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(jobRunnerClass);
            if (jobRunnerClass == JobDispatcher.class) {
                builder.setScope(BeanDefinition.SCOPE_SINGLETON);
                builder.setLazyInit(false);
                builder.getBeanDefinition().getPropertyValues().addPropertyValue("shardField", shardField);
            } else {
                builder.setScope(BeanDefinition.SCOPE_PROTOTYPE);
            }
            beanFactory.registerBeanDefinition(jobRunnerBeanName, builder.getBeanDefinition());
        }
    }
574289
def producer(self):
        
        if self._producer:
            return self._producer

        self._producer = KafkaProducer(
            bootstrap_servers=self.hosts,
            value_serializer=lambda v: self._serializer_class().dumps(v).encode('utf-8'),
            **self._kwargs
        )

        return self._producer
987712
def register(self, event, callable, priority=10):
        """"""
        logger.debug('registered: ' + event + ': ' + repr(callable) + ' [' + repr(self) + ']')
        return EventReceiver(event, callable, manager=self, priority=priority)