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 to access to domain objects (repository,factory, service, policy) #62

Merged
merged 1 commit into from
Oct 7, 2015

Conversation

tbouvet
Copy link
Contributor

@tbouvet tbouvet commented Oct 7, 2015

Closed #5

Feature to get a domain object programatically.

@Inject
DomainRegistry domain;
BonusCalculationPolicy myPolicy = domain.getPolicy(BonusCalculationPolicy.class, "qualifier-1");
AnotherPolicy<Client<Long>> myPolicy = domain.getPolicy(new TypeOf<AnotherPolicy<Client<Long>>>(){}, "qualifier-1");

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

CustomerFactory<Customer> myFactory = domain.getFactory(Customer.class, "qualifier-1");

CustomerRepository<Customer,Long> myRepository = domain.getRepository(Customer.class, Long.class, aQualifierAnnotation.class);

@ejemba
Copy link
Member

ejemba commented Oct 7, 2015

Hi @tbouvet @pith , it could be a good opportunity to augment the "getService" , “getPolicy” feature in order to mimic Service as Kind of Closure (not a real closure but the spirit). Service with a constructor.

Constructor → TaxService(Long percent)

// 20% French TVA
TaxService nominalTaxService = domain.getService(TaxService.class, "qualifier-1" , 020l);

// Restaurant TVA Service
TaxService minimalTaxService = domain.getService(TaxService.class, "qualifier-1" , 0.05l);

The same for Policy. Policy with constructor could be obtained the same way.

This means another methods like this one

<T> T getService(Class<T> rawType, String qualifier, Object... args);

@pith
Copy link
Member

pith commented Oct 7, 2015

LGTM

tbouvet added a commit that referenced this pull request Oct 7, 2015
Create a DomainRegistry to access to domain objects (repository,factory, service, policy)
@tbouvet tbouvet merged commit f92db56 into seedstack:master Oct 7, 2015
@pith
Copy link
Member

pith commented Oct 7, 2015

@ejemba we think about this feature but in another issue. I think it would require a Guice assisted factory to do it.

@tbouvet tbouvet deleted the feat-5-domain_registry branch October 7, 2015 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants