Search in sources :

Example 1 with ProjectNameKeySerializer

use of com.google.gerrit.server.events.ProjectNameKeySerializer in project gerrit by GerritCodeReview.

the class StreamEvents method start.

@Override
public void start(final Environment env) throws IOException {
    try {
        parseCommandLine();
    } catch (UnloggedFailure e) {
        String msg = e.getMessage();
        if (!msg.endsWith("\n")) {
            msg += "\n";
        }
        err.write(msg.getBytes(UTF_8));
        err.flush();
        onExit(1);
        return;
    }
    stdout = toPrintWriter(out);
    eventListenerRegistration = eventListeners.add(new UserScopedEventListener() {

        @Override
        public void onEvent(final Event event) {
            if (subscribedToEvents.isEmpty() || subscribedToEvents.contains(event.getType())) {
                offer(event);
            }
        }

        @Override
        public CurrentUser getUser() {
            return currentUser;
        }
    });
    gson = new GsonBuilder().registerTypeAdapter(Supplier.class, new SupplierSerializer()).registerTypeAdapter(Project.NameKey.class, new ProjectNameKeySerializer()).create();
}
Also used : Project(com.google.gerrit.reviewdb.client.Project) ProjectNameKeySerializer(com.google.gerrit.server.events.ProjectNameKeySerializer) GsonBuilder(com.google.gson.GsonBuilder) SupplierSerializer(com.google.gerrit.server.events.SupplierSerializer) Event(com.google.gerrit.server.events.Event) Supplier(com.google.common.base.Supplier) UserScopedEventListener(com.google.gerrit.common.UserScopedEventListener)

Aggregations

Supplier (com.google.common.base.Supplier)1 UserScopedEventListener (com.google.gerrit.common.UserScopedEventListener)1 Project (com.google.gerrit.reviewdb.client.Project)1 Event (com.google.gerrit.server.events.Event)1 ProjectNameKeySerializer (com.google.gerrit.server.events.ProjectNameKeySerializer)1 SupplierSerializer (com.google.gerrit.server.events.SupplierSerializer)1 GsonBuilder (com.google.gson.GsonBuilder)1