<commit_before>package org.jeecqrs.integration.jcommondomain.jeeventstore;

import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.Resource;
import javax.ejb.Asynchronous;
import javax.ejb.EJB;
import org.jeecqrs.command.log.CommandLogEnvelope;
import org.jeecqrs.command.CommandLogger;
import org.jeecqrs.common.commands.Command;
import org.jeecqrs.common.util.Validate;
import org.jeeventstore.ConcurrencyException;
import org.jeeventstore.DuplicateCommitException;
import org.jeeventstore.EventStore;
import org.jeeventstore.WritableEventStream;

public class CommandLoggerService implements CommandLogger<Command> {

    private final static Logger log = Logger.getLogger(CommandLoggerService.class.getName());

    @EJB(name="eventStore")
    private EventStore eventStore;

    @Resource(name="commandBucketId")
    private String commandBucketId = DefaultBucketIds.COMMANDS;

    @Asynchronous
    public void log(Command command) {
        log(command, new HashMap<String, String>());
    }

    @Override
    @Asynchronous
    public void log(Command command, Map<String, String> metadata) {
        Validate.notNull(command, "command must not be null");
        Validate.notNull(metadata, "metadata must not be null");
        String commandId = command.id().toString();
        WritableEventStream stream = streamFor(command);
        CommandLogEnvelope<Command> envelope = new CommandLogEnvelope<>(command, new HashMap<>(metadata));
        log.log(Level.FINE, "Logging command: {0}", envelope);
        stream.append(envelope);
        try {
            stream.commit(commandId);
        } catch (DuplicateCommitException | ConcurrencyException e) {
            throw new RuntimeException(e);
        }
    }

    protected WritableEventStream streamFor(Command command) {
        return eventStore.createStream(commandBucketId, streamIdFor(command));
    }

    protected String streamIdFor(Command command) {
        return command.id().toString();
    }
<commit_msg>Adjust interface of CommandLoggerService due to changes in JCommonDomain/JEECQRS<commit_after>package org.jeecqrs.integration.jcommondomain.jeeventstore;

import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.Resource;
import javax.ejb.Asynchronous;
import javax.ejb.EJB;
import org.jeecqrs.command.log.CommandLogEnvelope;
import org.jeecqrs.command.CommandLogger;
import org.jeecqrs.common.commands.Command;
import org.jeecqrs.common.util.Validate;
import org.jeeventstore.ConcurrencyException;
import org.jeeventstore.DuplicateCommitException;
import org.jeeventstore.EventStore;
import org.jeeventstore.WritableEventStream;

public class CommandLoggerService implements CommandLogger<Command<?>> {

    private final static Logger log = Logger.getLogger(CommandLoggerService.class.getName());

    @EJB(name="eventStore")
    private EventStore eventStore;

    @Resource(name="commandBucketId")
    private String commandBucketId = DefaultBucketIds.COMMANDS;

    @Asynchronous
    public void log(Command<?> command) {
        log(command, new HashMap<String, String>());
    }

    @Override
    @Asynchronous
    public void log(Command<?> command, Map<String, String> metadata) {
        Validate.notNull(command, "command must not be null");
        Validate.notNull(metadata, "metadata must not be null");
        String commandId = command.id().toString();
        WritableEventStream stream = streamFor(command);
        CommandLogEnvelope<Command<?>> envelope = new CommandLogEnvelope<Command<?>>(command,
                new HashMap<>(metadata));
        log.log(Level.FINE, "Logging command: {0}", envelope);
        stream.append(envelope);
        try {
            stream.commit(commandId);
        } catch (DuplicateCommitException | ConcurrencyException e) {
            throw new RuntimeException(e);
        }
    }

    protected WritableEventStream streamFor(Command command) {
        return eventStore.createStream(commandBucketId, streamIdFor(command));
    }

    protected String streamIdFor(Command command) {
        return command.id().toString();
    }

{'fraction_non_alphanumeric': 0.10063784549964565, 'fraction_numerical': 0.0004724781478856603, 'mean_word_length': 4.12590799031477, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4829798', 'n_tokens_mistral': 1173, 'n_tokens_neox': 1170, 'n_words': 252}