io.vlingo.common.serialization.JsonSerialization Java Examples

The following examples show how to use io.vlingo.common.serialization.JsonSerialization. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProductResource.java    From vlingo-examples with Mozilla Public License 2.0 6 votes vote down vote up
public Completes<Response> defineWith(final ProductDefinition productDefinition) {
    try {
      final Tuple2<ProductId, Product> product =
              Product.defineWith(
                stage,
                Tenant.fromExisting(productDefinition.tenantId),
                ProductOwner.fromExisting(productDefinition.tenantId, productDefinition.ownerId),
                productDefinition.name,
                productDefinition.description,
                productDefinition.hasDiscussion);
      
        return Completes.withSuccess(Response.of(Created, JsonSerialization.serialized(product._1)));
    } catch (Throwable t) {
        this.stage.world().defaultLogger().error("Failed to create the product", t);
        return Completes.withSuccess(Response.of(InternalServerError));
    }
}
 
Example #2
Source File: ExchangeDispatcher.java    From vlingo-examples with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public void dispatch(Dispatchable<Entry<String>, State<String>> dispatchable) {
  logger.debug("Going to dispatch id {}", dispatchable.id());
  dispatchable.entries()
              .forEach(entry -> {
                try {
                  this.exchange.send(JsonSerialization.deserialized(entry.entryData(), entry.typed()));
                } catch (Exception e) {
                  logger.error("Entry {} of dispatch id {} will not be sent", dispatchable.id(), entry.id(), e);
                }
              });
  this.control.confirmDispatched(dispatchable.id(), this);
}
 
Example #3
Source File: ExchangeDispatcher.java    From vlingo-examples with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public void dispatch(Dispatchable<Entry<String>, State<String>> dispatchable) {
    logger.debug("Going to dispatch id {}", dispatchable.id());

    for (Entry<String> entry : dispatchable.entries()) {
        try {
            this.exchange.send(JsonSerialization.deserialized(entry.entryData(), entry.typed()));
        } catch (Exception e) {
            logger.error("Entry {} of dispatch id {} will not be sent", dispatchable.id(), entry.id(), e);
        }
    }
    this.control.confirmDispatched(dispatchable.id(), this);
}
 
Example #4
Source File: ProfileDataStateAdapter.java    From vlingo-examples with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public TextState toRawState(String id, ProfileData state, int stateVersion, Metadata metadata) {
  final String serialization = JsonSerialization.serialized(state);
  return new TextState(id, ProfileData.class, typeVersion(), serialization, stateVersion, metadata);
}
 
Example #5
Source File: EntryAdapters.java    From vlingo-examples with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public TextEntry toEntry(final ForumReopened source, final int version, String id, final Metadata metadata) {
  final String serialization = JsonSerialization.serialized(source);
  return new TextEntry(id, ForumReopened.class, 1, serialization, version, metadata);
}
 
Example #6
Source File: EntryAdapters.java    From vlingo-lattice with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public TextEntry toEntry(final DoStepOne source, final String id, final Metadata metadata) {
  final String serialization = JsonSerialization.serialized(source);
  return new TextEntry(id, DoStepOne.class, 1, serialization, metadata);
}
 
Example #7
Source File: EntryAdapters.java    From vlingo-lattice with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public TextEntry toEntry(final DoStepOne source, final int version, final String id, final Metadata metadata) {
  final String serialization = JsonSerialization.serialized(source);
  return new TextEntry(id, DoStepOne.class, 1, serialization, version, metadata);
}
 
Example #8
Source File: EntryAdapters.java    From vlingo-lattice with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public DoStepFour fromEntry(final TextEntry entry) {
  return JsonSerialization.deserialized(entry.entryData(), DoStepFour.class);
}
 
Example #9
Source File: ProfileStateAdapter.java    From vlingo-examples with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public ProfileState fromRawState(final TextState raw) {
  return JsonSerialization.deserialized(raw.data, raw.typed());
}
 
Example #10
Source File: StatefulEntityTest.java    From vlingo-lattice with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public Entity1State fromRawState(final State<String> raw) {
  return JsonSerialization.deserialized(raw.data, Entity1State.class);
}
 
Example #11
Source File: EntryAdapters.java    From vlingo-examples with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public TextEntry toEntry(final ForumTopicChanged source, final String id, final Metadata metadata) {
  final String serialization = JsonSerialization.serialized(source);
  return new TextEntry(id, ForumTopicChanged.class, 1, serialization, metadata);
}
 
Example #12
Source File: DoCommand1Adapter.java    From vlingo-lattice with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public TextEntry toEntry(final DoCommand1 source, final String id, final Metadata metadata) {
  final String serialization = JsonSerialization.serialized(source);
  return new TextEntry(id, DoCommand1.class, 1, serialization, metadata);
}
 
Example #13
Source File: StatefulEntityTest.java    From vlingo-lattice with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public State<String> toRawState(final String id, final Entity1State state, final int stateVersion, final Metadata metadata) {
  final String serialization = JsonSerialization.serialized(state);
  return new TextState(id, Entity1State.class, typeVersion(), serialization, stateVersion);
}
 
Example #14
Source File: DoCommand3Adapter.java    From vlingo-lattice with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public TextEntry toEntry(final DoCommand3 source, final String id, final Metadata metadata) {
  final String serialization = JsonSerialization.serialized(source);
  return new TextEntry(id, DoCommand3.class, 1, serialization, metadata);
}
 
Example #15
Source File: EntryAdapters.java    From vlingo-examples with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public PostModerated fromEntry(final TextEntry entry) {
  return JsonSerialization.deserialized(entry.entryData(), PostModerated.class);
}
 
Example #16
Source File: DoCommand3Adapter.java    From vlingo-lattice with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public DoCommand3 fromEntry(final TextEntry entry) {
  return JsonSerialization.deserialized(entry.entryData(), DoCommand3.class);
}
 
Example #17
Source File: EntryAdapters.java    From vlingo-examples with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public TextEntry toEntry(final ForumDescribed source, final int version, String id, final Metadata metadata) {
  final String serialization = JsonSerialization.serialized(source);
  return new TextEntry(id, ForumDescribed.class, 1, serialization, version, metadata);
}
 
Example #18
Source File: DoCommand3Adapter.java    From vlingo-lattice with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public TextEntry toEntry(DoCommand3 source, int version, String id, Metadata metadata) {
  final String serialization = JsonSerialization.serialized(source);
  return new TextEntry(id, DoCommand3.class, 1, serialization, version, metadata);
}
 
Example #19
Source File: EntryAdapters.java    From vlingo-examples with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public TextEntry toEntry(final DiscussionStarted source, final int version, String id, final Metadata metadata) {
  final String serialization = JsonSerialization.serialized(source);
  return new TextEntry(id, DiscussionStarted.class, 1, serialization, version, metadata);
}
 
Example #20
Source File: DoCommand2Adapter.java    From vlingo-lattice with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public DoCommand2 fromEntry(final TextEntry entry) {
  return JsonSerialization.deserialized(entry.entryData(), DoCommand2.class);
}
 
Example #21
Source File: CounterIncreasedAdapter.java    From vlingo-examples with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public TextEntry toEntry(final CounterIncreased source, final int version, final String id, final Metadata metadata) {
  final String serialization = JsonSerialization.serialized(source);
  return new TextEntry(id, CounterIncreased.class, 1, serialization, version, metadata);
}
 
Example #22
Source File: EntryAdapters.java    From vlingo-lattice with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public TextEntry toEntry(final DoStepTwo source, final Metadata metadata) {
  final String serialization = JsonSerialization.serialized(source);
  return new TextEntry(DoStepTwo.class, 1, serialization, metadata);
}
 
Example #23
Source File: Test3HappenedAdapter.java    From vlingo-lattice with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public TextEntry toEntry(final Test3Happened source, final Metadata metadata) {
  final String serialization = JsonSerialization.serialized(source);
  return new TextEntry(Test3Happened.class, 1, serialization, metadata);
}
 
Example #24
Source File: UserIdStateAdapter.java    From vlingo-examples with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public UserId fromRawState(State.TextState textState) {
    return JsonSerialization.deserialized(textState.data, textState.typed());
}
 
Example #25
Source File: EntryAdapters.java    From vlingo-examples with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public TextEntry toEntry(final ForumClosed source, final String id, final Metadata metadata) {
  final String serialization = JsonSerialization.serialized(source);
  return new TextEntry(id, ForumClosed.class, 1, serialization, metadata);
}
 
Example #26
Source File: UserDataStateAdapter.java    From vlingo-examples with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public TextState toRawState(String id, UserData state, int stateVersion, Metadata metadata) {
  final String serialization = JsonSerialization.serialized(state);
  return new TextState(id, UserData.class, typeVersion(), serialization, stateVersion, metadata);
}
 
Example #27
Source File: JournalProjectionDispatcherTest.java    From vlingo-lattice with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public TextEntry toEntry(ThreeHappened source, Metadata metadata) {
  final String serialization = JsonSerialization.serialized(source);
  return new TextEntry(ThreeHappened.class, 1, serialization, metadata);
}
 
Example #28
Source File: JournalProjectionDispatcherTest.java    From vlingo-lattice with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public ThreeHappened fromEntry(final TextEntry entry) {
  return JsonSerialization.deserialized(entry.entryData(), ThreeHappened.class);
}
 
Example #29
Source File: JournalProjectionDispatcherTest.java    From vlingo-lattice with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public TextEntry toEntry(final TwoHappened source, final int version, final String id, final Metadata metadata) {
  final String serialization = JsonSerialization.serialized(source);
  return new TextEntry(id, TwoHappened.class, 1, serialization, version, metadata);
}
 
Example #30
Source File: EntryAdapters.java    From vlingo-lattice with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public DoStepTwo fromEntry(final TextEntry entry) {
  return JsonSerialization.deserialized(entry.entryData(), DoStepTwo.class);
}