We add mapping information for our Messages Classes.

todo: It should be dynamic for non default entity_manager name
481162
public function prepend(ContainerBuilder $container)
    {
        $bundles = $container->getParameter('kernel.bundles');

        if (isset($bundles['DoctrineBundle'])) {
            $mappingConfig = [
                'orm' => [
                    'entity_managers' => [
                        'default' => [
                            'mappings' => [
                                'HMLBDDDBundle' => [
                                    'mapping' => true,
                                    'type' => 'xml',
                                    'dir' => __DIR__.'/../Resources/config/doctrine',
                                    'prefix' => 'HMLB\DDD',
                                    'is_bundle' => false,
                                ],
                            ],
                        ],
                    ],
                ],
            ];

            $container->getExtension('doctrine');
            $container->prependExtensionConfig('doctrine', $mappingConfig);
        }

        $container->prependExtensionConfig(
            'command_bus',
            [
                'command_name_resolver_strategy' => 'named_message',
            ]
        );
        $container->prependExtensionConfig(
            'event_bus',
            [
                'event_name_resolver_strategy' => 'named_message',
            ]
        );
    }
1043015
public void setPayloadProperties(BaseMessage message, Object msg)
   {
       MessageDataDesc messageDataDesc = message.getMessageDataDesc(null);   // Top level only
       if (messageDataDesc != null)
       {
           Map<String,Class<?>> mapPropertyNames = messageDataDesc.getPayloadPropertyNames(null);
           if (mapPropertyNames != null)
           {
               for (String strKey : mapPropertyNames.keySet())
               {
                   Class<?> classKey = mapPropertyNames.get(strKey);
                   this.setPayloadProperty(message, msg, strKey, classKey);
               }
           }
       }
       if (message.get("Version") == null)
           this.setPayloadProperty(DEFAULT_VERSION, msg, "Version", Float.class);
       this.setPayloadProperty(this.getTimeStamp(), msg, "TimeStamp", org.joda.time.DateTime.class); // Current timestamp
   }
430955
def _message_to_entity(msg, modelclass):
  
  ent = modelclass()
  for prop_name, prop in modelclass._properties.iteritems():
    if prop._code_name == 'blob_':  # TODO: Devise a cleaner test.
      continue  # That's taken care of later.
    value = getattr(msg, prop_name)
    if value is not None and isinstance(prop, model.StructuredProperty):
      if prop._repeated:
        value = [_message_to_entity(v, prop._modelclass) for v in value]
      else:
        value = _message_to_entity(value, prop._modelclass)
    setattr(ent, prop_name, value)
  return ent
752410
public void addEntityMetadata(Class<?> clazz, EntityMetadata entityMetadata)
    {
        getEntityMetadataMap().put(clazz.getName(), entityMetadata);
    }
52243
private function initializeDoctrine()
    {
        if ($this->cm !== null) {
            return;
        }

        if (! self::$entityManager) {
            throw new RuntimeException('No runtime entity manager set. Call PersistentObject#setEntityManager().');
        }

        $this->cm = self::$entityManager->getClassMetadata(static::class);
    }
55011
void autoGenerateAlgorithms(
      EntityMapping mapping,
      EntityType sourceEntityType,
      EntityType targetEntityType,
      MappingProject project) {
    algorithmService.autoGenerateAlgorithm(sourceEntityType, targetEntityType, mapping);
    mappingService.updateMappingProject(project);
  }
334735
private Multimap<Class, SagaType> initializeMessageMappings(final Map<Class<? extends Saga>, SagaHandlersMap> handlersMap) {
        Multimap<Class, SagaType> scannedTypes = LinkedListMultimap.create();

        for (Map.Entry<Class<? extends Saga>, SagaHandlersMap> entry : handlersMap.entrySet()) {
            Class<? extends Saga> sagaClass = entry.getKey();

            Collection<MessageHandler> sagaHandlers = entry.getValue().messageHandlers();
            for (MessageHandler handler : sagaHandlers) {

                // remember all message types where a completely new saga needs to be started.
                if (handler.getStartsSaga()) {
                    scannedTypes.put(handler.getMessageType(), SagaType.startsNewSaga(sagaClass));
                } else {
                    scannedTypes.put(handler.getMessageType(), SagaType.continueSaga(sagaClass));
                }
            }
        }

        return scannedTypes;
    }
274152
public void setupMessageDataDesc()
    {
        super.setupMessageDataDesc();
        
        this.addMessageFieldDesc(UserInfo.USER_NAME, String.class, MessageFieldDesc.REQUIRED, null);
        this.addMessageFieldDesc(UserInfo.PASSWORD, String.class, MessageFieldDesc.REQUIRED, null);
    }
1215287
private Entity toMappingTargetEntity(
      MappingTarget mappingTarget, List<Entity> entityMappingEntities) {
    Entity mappingTargetEntity = new DynamicEntity(mappingTargetMetaData);
    mappingTargetEntity.set(MappingProjectMetadata.IDENTIFIER, mappingTarget.getIdentifier());
    mappingTargetEntity.set(MappingTargetMetadata.TARGET, mappingTarget.getTarget().getId());
    mappingTargetEntity.set(MappingTargetMetadata.ENTITY_MAPPINGS, entityMappingEntities);
    return mappingTargetEntity;
  }
1013224
private void initializeEntityVersionEntityMapper() {
    AvroEntitySchema avroEntitySchema = schemaParser
        .parseEntitySchema(managedSchemaEntityVersionSchema);
    avroEntitySchema = AvroUtils.mergeSpecificStringTypes(
        ManagedSchemaEntityVersion.class, avroEntitySchema);
    AvroEntityComposer<ManagedSchemaEntityVersion> entityComposer = new AvroEntityComposer<ManagedSchemaEntityVersion>(
        avroEntitySchema, true);
    AvroEntitySerDe<ManagedSchemaEntityVersion> entitySerDe = new AvroEntitySerDe<ManagedSchemaEntityVersion>(
        entityComposer, avroEntitySchema, avroEntitySchema, true);
    this.managedSchemaEntityVersionEntityMapper = new BaseEntityMapper<ManagedSchemaEntityVersion>(
        avroEntitySchema, entitySerDe);
  }
1223025
public static Map<String, Message> messageTopics(Message message, String defaultTopic, String dynamicTopicConfigs) {
        List<CanalEntry.Entry> entries;
        if (message.isRaw()) {
            List<ByteString> rawEntries = message.getRawEntries();
            entries = new ArrayList<>(rawEntries.size());
            for (ByteString byteString : rawEntries) {
                CanalEntry.Entry entry;
                try {
                    entry = CanalEntry.Entry.parseFrom(byteString);
                } catch (InvalidProtocolBufferException e) {
                    throw new RuntimeException(e);
                }
                entries.add(entry);
            }
        } else {
            entries = message.getEntries();
        }
        Map<String, Message> messages = new HashMap<>();
        for (CanalEntry.Entry entry : entries) {
            if (entry.getEntryType() == CanalEntry.EntryType.TRANSACTIONBEGIN
                || entry.getEntryType() == CanalEntry.EntryType.TRANSACTIONEND) {
                continue;
            }

            String schemaName = entry.getHeader().getSchemaName();
            String tableName = entry.getHeader().getTableName();

            if (StringUtils.isEmpty(schemaName) || StringUtils.isEmpty(tableName)) {
                put2MapMessage(messages, message.getId(), defaultTopic, entry);
            } else {
                Set<String> topics = matchTopics(schemaName + "." + tableName, dynamicTopicConfigs);
                if (topics != null) {
                    for (String topic : topics) {
                        put2MapMessage(messages, message.getId(), topic, entry);
                    }
                } else {
                    topics = matchTopics(schemaName, dynamicTopicConfigs);
                    if (topics != null) {
                        for (String topic : topics) {
                            put2MapMessage(messages, message.getId(), topic, entry);
                        }
                    } else {
                        put2MapMessage(messages, message.getId(), defaultTopic, entry);
                    }
                }
            }
        }
        return messages;
    }
698624
protected Map<String, Message.Builder> getMessageMap() {
    return new HashMap<String, Message.Builder>(messageMap);
  }
271171
public void putPropertyMetadata(PropertyMetadata propertyMetadata) {
    String mappedName = propertyMetadata.getMappedName();
    PropertyMetadata old = propertyMetadataMap.put(mappedName, propertyMetadata);
    if (old != null) {
      String format = "Class %s has two fields, %s and %s, both mapped to the same property "
          + "name, %s";
      String message = String.format(format, clazz.getName(), old.getName(),
          propertyMetadata.getName(), mappedName);
      throw new EntityManagerException(message);
    }
  }
531789
def add_status_query_managers(sender, **kwargs):
    
    if not issubclass(sender, StatusModel):
        return

    if django.VERSION >= (1, 10):
        # First, get current manager name...
        default_manager = sender._meta.default_manager

    for value, display in getattr(sender, 'STATUS', ()):
        if _field_exists(sender, value):
            raise ImproperlyConfigured(
                "StatusModel: Model '%s' has a field named '%s' which "
                "conflicts with a status of the same name."
                % (sender.__name__, value)
            )
        sender.add_to_class(value, QueryManager(status=value))

    if django.VERSION >= (1, 10):
        # ...then, put it back, as add_to_class is modifying the default manager!
        sender._meta.default_manager_name = default_manager.name
872968
public RepeatedFieldBuilder<MType, BType, IType> addMessage(
      MType message) {
    if (message == null) {
      throw new NullPointerException();
    }
    ensureMutableMessageList();
    messages.add(message);
    if (builders != null) {
      builders.add(null);
    }
    onChanged();
    incrementModCounts();
    return this;
  }
192896
private static MessageInfoType mapMessageInfo(MessageInfo messageInfo) {
        if (messageInfo == null) {
            return null;
        }
        MessageInfoType miType = new MessageInfoType();
        miType.setMessageId(messageInfo.getMessageId());
        miType.setFlowId(messageInfo.getFlowId());
        miType.setPorttype(convertString(messageInfo.getPortType()));
        miType.setOperationName(messageInfo.getOperationName());
        miType.setTransport(messageInfo.getTransportType());
        return miType;
    }
544017
@SuppressWarnings("unchecked")
    private void addCallBackMethod(EntityMetadata metadata, Class<?> jpaAnnotation, CallbackMethod callbackMethod)
    {
        Map<Class<?>, List<? extends CallbackMethod>> callBackMethodsMap = metadata.getCallbackMethodsMap();
        List<CallbackMethod> list = (List<CallbackMethod>) callBackMethodsMap.get(jpaAnnotation);
        if (null == list)
        {
            list = new ArrayList<CallbackMethod>();
            callBackMethodsMap.put(jpaAnnotation, list);
        }
        list.add(callbackMethod);
    }