class CommandCreationWorker implements DispatchWorker {

    @Override
    public void handle(final DispatchTask task) {
        final BaseCmd cmd = task.getCmd();

        if (cmd instanceof BaseAsyncCreateCmd) {
            try {
                CallContext.current().setEventDisplayEnabled(cmd.isDisplay());
                ((BaseAsyncCreateCmd)cmd).create();
            } catch (final ResourceAllocationException e) {
                throw new ServerApiException(ApiErrorCode.RESOURCE_ALLOCATION_ERROR,
                        e.getMessage(), e);
            }
        } else {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR,
                    ATTEMP_TO_CREATE_NON_CREATION_CMD);
        }
    }

}