Trigger Commands

The generated SDK provides command facades which allow to easily trigger commands from other places in the service.

Namespace command facade

For each domain namespace, a facade is generated where all the commands defined in the namespace are grouped together. The facades can be injected and used as shown in the example below.

In the below example both (CcCommand & OpsCommand) are domain namespace facades that group all the commands in their respective namespaces where cc & ops are the namespace acronyms.

// Importing cc namespace command facade that provides access to all of its commands.
import de.cards.sdk.domain.cc.facade.CcCommand;

// Importing ops namespace service facade that provides access to all of its commands.
import de.cards.sdk.domain.ops.facade.OpsCommand;

// Declare and Inject Command Facades
@Autowired
private CcCommand ccCommand;

@Autowired
private OpsCommand opsCommand;

// Use namespace command facade to call UpdateCreditCardDetails & CreateProfile commands within that namespace

// Calling UpdateCreditCardDetails instance command that belongs to a root entity with local identifier "CreditCard"
CreditCard creditCardEntity = ccCommand.getCreditCard().updateCreditCardDetails(instance, cardDetails);

// Calling CreateProfile factory command that belongs to a root entity with local identifier "CustomerProfile"
CustomerProfile customerProfileEntity = opsCommand.getCustomerProfile().createProfile(customerData);

General command facade

Besides Namespace command facades, the SDK also provides a Command facade which holds all commands in domain namespaces.

// Import overall Command facade class
import de.cards.sdk.domain.facade.Command;

// Declare & Inject Command Facade
@Autowired
private Command command;
      
// Calling commands inside a namespace with prefix "cc" 
// UpdateCreditCardDetails is a command that belongs to a root entity with local identifier "CreditCard"
CreditCard creditCardEntity = command.getCc().getCreditCard().updateCreditCardDetails(instance, cardDetails);