Service Facade

Service facades are meant to represent coarse grained business processes. The ultimate goal is for a service facade to collaborate with various domain services to achieve a certain process outcome.

"... does not contain business rules or knowledge, but only coordinates tasks and delegates work to collaborations of domain objects in the next layer down. It does not have state reflecting the business situation, but it can have state that reflects the progress of a task for the user or the program." :

package org.mifos.application.admin.servicefacade;

import java.util.Locale;
import java.util.Map;

import org.springframework.security.access.prepost.PreAuthorize;

public interface CustomizedTextServiceFacade {

    @PreAuthorize("isFullyAuthenticated() and hasRole('ROLE_CAN_DEFINE_LABELS')")
	Map<String, String> retrieveCustomizedText();

	String replaceSubstitutions(String message);

    @PreAuthorize("isFullyAuthenticated() and hasRole('ROLE_CAN_DEFINE_LABELS')")
	void addOrUpdateCustomizedText(String originalText, String customText);

    @PreAuthorize("isFullyAuthenticated() and hasRole('ROLE_CAN_DEFINE_LABELS')")
	void removeCustomizedText(String oldMessage);

	CustomizedTextDto getCustomizedTextDto(String oldMessage);

	void convertMigratedLabelKeysToLocalizedText(Locale locale);

}

  • Think of ServiceFacade as possibly a construct to expose as "web service" with clearly defined explicit boundaries and contracts.
  • CustomizedTextDto is one such contract. The web application (e.g. CustomizeTextController) knows nothing about the underlying domain. All it knows is a value object, CustomizedTextDto.
  • service methods are operations. they take in a request object like CustomizedTextDto (see implementation org.mifos.application.messagecustomizer.CustomizedTextServiceFacadeWebTier ).

see also: DAOs DomainServices