Starting from this thread (Make a 3D tube with a bezier curve), I figured that the curve modifier had to be used somewhere. First the spline and the length however.
Use the following spline settings:
For the length of your object, you can use the array modifier with "Fit Type" set to 'Fit Curve' and then select the curve you want to trace. Then pick your start & end cap. Next up append the curve modifier and take the beziercurve as the object. (deformation Axis = x)
Lastly figure out how to reposition your endcaps so the vertices close up. (I haven't fully grasped the math behind this myself).
EDIT: Considering the end caps. Turns out the array matches them perfectly when you just 'snap attach' them in edit mode to the middle section that you want to array. As in the picture below.