Building The Adapter
The SDK fails fast: if a required bean is missing, the Spring context does not start.
The quickest way to discover what is still missing is to run the adapter and read the
startup error. This page walks through the beans the SDK asks for, one at a time. For the
full list, see List of Required Beans.
First run
With no handlers implemented yet, run the adapter:
./gradlew runAdapterStartup fails while creating the SDK's AuthenticationController, because no
AuthenticationHandler bean is available. Spring Boot prints exactly which bean is missing:
> Task :runAdapter
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of constructor in com.stibo.leap.adapter.internal.api.authentication.controller.AuthenticationController required a bean of type 'com.stibo.leap.adapter.api.handler.auth.AuthenticationHandler' that could not be found.
Action:
Consider defining a bean of type 'com.stibo.leap.adapter.api.handler.auth.AuthenticationHandler' in your configuration.
> Task :runAdapter FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':runAdapter'.
> Process 'command 'java'' finished with non-zero exit value 1
BUILD FAILED in 6sThis indicates that a bean implementing AuthenticationHandler is required.
Simplest AuthenticationHandler implementation
A minimal AuthenticationHandler accepts any request. In a real adapter you would verify
the supplied credentials against your external system and store them for use during
submission. (See FakeAuthenticationHandler in the Getting Started project.)
package sdk.getting.started.adapter.handlers;
import com.stibo.leap.adapter.api.handler.auth.AuthenticationHandler;
import com.stibo.leap.adapter.api.handler.auth.model.AuthenticationRequest;
import com.stibo.leap.adapter.api.handler.auth.model.AuthenticationResponse;
import com.stibo.leap.adapter.api.handler.auth.model.AuthenticationResponseBuilder;
import org.springframework.stereotype.Service;
@Service
public class FakeAuthenticationHandler implements AuthenticationHandler {
@Override
public AuthenticationResponse authenticate(AuthenticationRequest authenticationRequest) {
// In production: verify authenticationRequest.getProperties() against your system
// and persist the credentials keyed by (clientId, channelId, accountId).
return AuthenticationResponseBuilder.success().build();
}
}Next required bean
Run it again:
./gradlew runAdapterStartup gets further this time, then fails because the submit consumer needs a
SubmissionDispatcher:
> Task :runAdapter
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of constructor in com.stibo.leap.adapter.internal.api.submit.consumer.SubmitEventConsumer required a bean of type 'com.stibo.leap.adapter.internal.api.submit.consumer.SubmissionDispatcher' that could not be found.
Action:
Consider defining a bean of type 'com.stibo.leap.adapter.internal.api.submit.consumer.SubmissionDispatcher' in your configuration.
> Task :runAdapter FAILED
BUILD FAILED in 6sSubmissionDispatcher is not public. It is implemented internally by three dispatchers —
RegularSubmitDispatcher, FamilyBasedSubmitDispatcher, and PackagingBasedSubmitDispatcher —
one of which is activated depending on the submission mode you use. You
select the mode by implementing the matching public handler interface: RegularSubmitHandler,
FamilyBasedSubmitHandler, or PackagingBasedSubmitHandler.
Simplest SubmitHandler implementation
A minimal RegularSubmitHandler marks every product in the batch as accepted:
package sdk.getting.started.adapter.handlers;
import com.stibo.leap.adapter.api.handler.submit.RegularSubmitHandler;
import com.stibo.leap.adapter.api.handler.submit.context.ContextProvider;
import com.stibo.leap.adapter.api.handler.submit.model.Product;
import com.stibo.leap.adapter.api.service.status.model.ItemStatus;
import com.stibo.leap.adapter.api.service.status.model.SubmitStatus;
import com.stibo.leap.adapter.api.service.status.model.SubmitStatusBuilder;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class SubmitHandler implements RegularSubmitHandler {
@Override
public SubmitStatus submitBatch(String clientId, String channelId, String submissionId,
List<Product> allSummaryProducts, ContextProvider additionalContextProvider) {
SubmitStatusBuilder status = SubmitStatus.success().withMessage("Submission successful");
allSummaryProducts.forEach(product ->
status.withItem(ItemStatus.accepted(product.getId(), "Sent").build()));
return status.build();
}
}The SDK also requires a ClientChannelDeletedEventHandler bean — see
List of Required Beans for a minimal no-op implementation and
the complete set of mandatory beans.
Tip: If the application exits with no visible stack trace, make sure your
logback.xml
defines a root logger so Spring Boot / SDK startup errors are printed to the console.
