+ per plugin scoped adapters + could be swapped during runtime +per EventAdapter now has manifest and is configurable ai la serializers + json examples in docs + including "completely manual" example in case one wants to add metadata TO the persisted event + better error reporting when misconfigured bindings + manifest is handled by in memory plugin - did not check if it works with LevelDB plugin yet > TODO: json example uses Gson, as that's simplest to do, can we use +per allows 1:n adapters, multiple adapters can be bound to 1 class
32 lines
No EOL
727 B
Java
32 lines
No EOL
727 B
Java
/*
|
|
* Copyright (C) 2015 Typesafe Inc. <http://www.typesafe.com>
|
|
*/
|
|
|
|
package docs.persistence;
|
|
|
|
import akka.persistence.journal.EventAdapter;
|
|
import akka.persistence.journal.EventSeq;
|
|
|
|
public class PersistenceEventAdapterDocTest {
|
|
|
|
@SuppressWarnings("unused")
|
|
static
|
|
//#identity-event-adapter
|
|
class MyEventAdapter extends EventAdapter {
|
|
@Override
|
|
public String manifest(Object event) {
|
|
return ""; // if no manifest needed, return ""
|
|
}
|
|
|
|
@Override
|
|
public Object toJournal(Object event) {
|
|
return event; // identity
|
|
}
|
|
|
|
@Override
|
|
public EventSeq fromJournal(Object event, String manifest) {
|
|
return EventSeq.single(event); // identity
|
|
}
|
|
}
|
|
//#identity-event-adapter
|
|
} |