Inject configuration into Aggregate

Hi, I am make the new service with lagom 1.6, but I have one problem, the values is in hardcode, example:

    @Override
    public RetentionCriteria retentionCriteria() {
       return RetentionCriteria.snapshotEvery(100, 2);
    }

the 100 and 2 is in hardcode, but the constructor no support many arguments, because the ShoppingServiceImpl only support one argument? this is correct?

    @Inject
    public ShoppingCartServiceImpl(ClusterSharding clusterSharing,
                                   PersistentEntityRegistry persistentEntityRegistry,
                                   ReportRepository reportRepository) {
        this.clusterSharing = clusterSharing;
        this.persistentEntityRegistry = persistentEntityRegistry;
        this.reportRepository = reportRepository;

        // register entity on shard
        this.clusterSharing.init(
                Entity.of(
                        ShoppingCartEntity.ENTITY_TYPE_KEY,
                        ShoppingCartEntity::create
                )
        );
    }

How do I inject these values from the application.conf?

Hi @Miuler,
you can try this:

//ShoppingCartEntity
private ShoppingCartEntity(EntityContext<Command> entityContext, Config config)

//ShoppingCartServiceImpl 
@Inject
    public ShoppingCartServiceImpl(ClusterSharding clusterSharing,
                                   PersistentEntityRegistry persistentEntityRegistry,
                                   ReportRepository reportRepository,
                                   Config config) {
        this.clusterSharing = clusterSharing;
        this.persistentEntityRegistry = persistentEntityRegistry;
        this.reportRepository = reportRepository;

        // register entity on shard
        this.clusterSharing.init(
                Entity.of(
                        ShoppingCartEntity.ENTITY_TYPE_KEY,
                        ctx -> new ShoppingCartEntity(ctx,config)
                )
        );
    }

Hope this helps.

Br,
Alan

what? could that be done? :no_mouth:

Thanks