/** * {@inheritDoc} */ @Override public VersionedAggregateIdentifier resolveTarget(CommandMessage<?> command) { String aggregateIdentifier; Long aggregateVersion; try { aggregateIdentifier = findIdentifier(command); aggregateVersion = findVersion(command); } catch (InvocationTargetException e) { throw new IllegalArgumentException("An exception occurred while extracting aggregate " + "information form a command", e); } catch (IllegalAccessException e) { throw new IllegalArgumentException("The current security context does not allow extraction of " + "aggregate information from the given command.", e); } catch (NumberFormatException e) { throw new IllegalArgumentException("The value provided for the version is not a number.", e); } if (aggregateIdentifier == null) { throw new IllegalArgumentException( format("Invalid command. It does not identify the target aggregate. " + "Make sure at least one of the fields or methods in the [%s] class contains the " + "@TargetAggregateIdentifier annotation and that it returns a non-null value.", command.getPayloadType().getSimpleName())); } return new VersionedAggregateIdentifier(aggregateIdentifier, aggregateVersion); }
int publisherSegment = 0; if (commandHandlerInvokers.length > 1 || publisherCount > 1) { String aggregateIdentifier = commandTargetResolver.resolveTarget(command).getIdentifier(); if (aggregateIdentifier != null) { int idHash = aggregateIdentifier.hashCode() & Integer.MAX_VALUE;
int publisherSegment = 0; if (commandHandlerInvokers.length > 1 || publisherCount > 1) { String aggregateIdentifier = commandTargetResolver.resolveTarget(command).getIdentifier(); if (aggregateIdentifier != null) { int idHash = aggregateIdentifier.hashCode() & Integer.MAX_VALUE;
@Override public VersionedAggregateIdentifier resolveTarget(CommandMessage<?> command) { String identifier = (String) command.getMetaData().get(identifierKey); Assert.notNull(identifier, () -> "The MetaData for the command does not exist or contains a null value"); Long version = (Long) (versionKey == null ? null : command.getMetaData().get(versionKey)); return new VersionedAggregateIdentifier(identifier, version); } }
@Override public VersionedAggregateIdentifier resolveTarget(CommandMessage<?> command) { String aggregateIdentifier; Long aggregateVersion; try { aggregateIdentifier = findIdentifier(command); aggregateVersion = findVersion(command); } catch (InvocationTargetException e) { throw new IllegalArgumentException("An exception occurred while extracting aggregate " + "information form a command", e); } catch (IllegalAccessException e) { throw new IllegalArgumentException("The current security context does not allow extraction of " + "aggregate information from the given command.", e); } catch (NumberFormatException e) { throw new IllegalArgumentException("The value provided for the version is not a number.", e); } if (aggregateIdentifier == null) { throw new IllegalArgumentException( format("Invalid command. It does not identify the target aggregate. " + "Make sure at least one of the fields or methods in the [%s] class contains the " + "@TargetAggregateIdentifier annotation and that it returns a non-null value.", command.getPayloadType().getSimpleName())); } return new VersionedAggregateIdentifier(aggregateIdentifier, aggregateVersion); }
@Override public VersionedAggregateIdentifier resolveTarget(CommandMessage<?> command) { String identifier = (String) command.getMetaData().get(identifierKey); Assert.notNull(identifier, () -> "The MetaData for the command does not exist or contains a null value"); Long version = (Long) (versionKey == null ? null : command.getMetaData().get(versionKey)); return new VersionedAggregateIdentifier(identifier, version); } }