Reputation: 1105
I'm new to DDD.
Right now I'm working on a project that requires me to access a web service API, where JSON
is returned and used to persist my entities.
My question is what layer does accessing the web service belong to?
And what are some best practices that should be followed for implementing this.
Do I need a service that is responsible for inflating my entities and persisting them?
I'm a bit confused.
Thanks in advance.
Upvotes: 2
Views: 446
Reputation: 7283
Have you read about Repository Pattern ?
public class SampleEntity {
}
public interface SampleEntityRepository {
void store(SampleEntity entity);
SampleEntity fineBy(Identity id);
//omitted other finders
}
Implements SampleRepository with a web service adapter.
public class WsSampleEntityRepositoryImpl implements SampleEntityRepository {
@Override
public void store(SampleEntity entity) {
//transform to JSON and invoke ws
}
@Override
public SampleEntity fineBy(Identity id) {
//transform to JSON and invoke ws
//transform JSON to SampleEntity
}
//omitted other finders
}
Upvotes: 3