Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a DomainRegistry providing programmatic access to domain elements #5

Closed
pith opened this issue Apr 3, 2015 · 1 comment
Closed
Assignees
Milestone

Comments

@pith
Copy link
Member

pith commented Apr 3, 2015

Currently Domain elements are accessible via injection. It is possible using injection and qualifier to get a certain implementation, but it is static. There is no problem with that, but we also want the possibility to do the same thing programmatically. This will be done by adding a domain registry. This will be particularly useful for policies.

The API can look like this:

@Inject
DomainRegistry domain;
BonusCalculationPolicy myPolicy = domain.policy(BonusCalculationPolicy.class, "qualifier-1").get();

RegistrationService myService = domain.service(RegistrationService.class, "qualifier-1").get();

CustomerFactory myFactory = domain.factory(CustomerFactory.class, "qualifier-1").get();

CustomerRepository myRepository = domain.repository(CustomerRepository.class, aQualifierAnnotation).get();

Ps: Of course the qualifier can also be an annotation.

@pith
Copy link
Member Author

pith commented Apr 3, 2015

We will also study the possibility to pass constructor parameters. In order to have - not stateful objects but - preinitialized immutable objects.

For instance,

TaxePolicy twentyTaxeRatePolicy = domain.policy(TaxePolicy.class, "FR").get(new TaxeRate(20));

This may require the use of Guice assisted factories, but implementation is not fixed yet.

@pith pith self-assigned this Apr 3, 2015
@pith pith added this to the 15.4.1 Freesia rev. 1 milestone Apr 3, 2015
@pith pith modified the milestones: 2.0.0 Final, 2.0.0 M3 May 18, 2015
@pith pith removed this from the 2.0.0 Final milestone Jul 16, 2015
@adrienlauer adrienlauer assigned tbouvet and unassigned pith Sep 23, 2015
@adrienlauer adrienlauer added this to the 2.1.0 milestone Sep 23, 2015
@tbouvet tbouvet added in progress and removed ready labels Sep 28, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants