/** * {@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); }
@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); }