vlingo / xoom-turbo

The VLINGO XOOM platform SDK for DOMA and DDD accelerates building highly scalable and high-performance Reactive microservices and applications.
https://vlingo.io
Mozilla Public License 2.0
8 stars 9 forks source link

Persistence annotation with the journal storage type fails to register entity #12

Closed Boerrild closed 3 years ago

Boerrild commented 3 years ago

I'm not sure if it is due to a misconfiguration from my part or an error in the code generator, but when I use the persistence annotation with journal storage type, then the generated CommandModelEntityProvider does not contain a section that registers a new Info with the entity class, like this:

    registry.register(new Info(journal, JournalEntity.class, JournalEntity.class.getSimpleName()));

I've used the Xoom Starter to generate a system with a single entity, called "Journal", and with Xoom annotations enabled. If i disable annotations, Xoom Starter generates the class, and in that case, it contains the registration-part.

This is how the xoom-generated code looks (when xoom annotations are enabled):

  @SuppressWarnings({ "unchecked", "unused" })
    public static CommandModelJournalProvider using(final Stage stage, final SourcedTypeRegistry registry, final Dispatcher ...dispatchers) {
      if (instance != null) {
        return instance;
      }

      final EntryAdapterProvider entryAdapterProvider = EntryAdapterProvider.instance(stage.world());

      final Journal<String> journal =
                StoreActorBuilder.from(stage, Model.COMMAND, Arrays.asList(dispatchers), StorageType.JOURNAL, Settings.properties(), true);

      instance = new CommandModelJournalProvider(journal);

      return instance;
    }

This is how it looks when pre-build by xoom-starter:

@SuppressWarnings({ "unchecked", "unused" })
  public static CommandModelJournalProvider using(final Stage stage, final SourcedTypeRegistry registry, final Dispatcher ...dispatchers) {
    if (instance != null) {
      return instance;
    }

    final EntryAdapterProvider entryAdapterProvider = EntryAdapterProvider.instance(stage.world());

    entryAdapterProvider.registerAdapter(NotesAdded.class, new NotesAddedAdapter());
    entryAdapterProvider.registerAdapter(JournalCreated.class, new JournalCreatedAdapter());
    entryAdapterProvider.registerAdapter(AgeSpecified.class, new AgeSpecifiedAdapter());

    final Journal<String> journal =
              StoreActorBuilder.from(stage, Model.COMMAND, Arrays.asList(dispatchers), StorageType.JOURNAL, Settings.properties(), true);

    registry.register(new Info(journal, JournalEntity.class, JournalEntity.class.getSimpleName()));

    instance = new CommandModelJournalProvider(journal);

    return instance;
  }
Boerrild commented 3 years ago

Btw, the above code-snippets was created by an earlier version of Xoom Starter (1.4.?-snapshot), but I'm experiencing the same issue with code build from Xoom Starter 1.5.1-snapshot.

VaughnVernon commented 3 years ago

@Boerrild Yes you are correct. We dug in and found this. It's assigned an will be fixed asap.

As a temporary workaround, regenerate without annotations. You will get the correct code. You can then copy that code and paste that into your annotated project.

VaughnVernon commented 3 years ago

Fixed by https://github.com/vlingo/vlingo-xoom/commit/00a699f55c4e1c8ada7d9a7bbf0accd9127a51f3