Collection<TubeCreator> tubeCreators = tubelineAssemblyController.getTubeCreators(context);
for (TubeCreator tubeCreator : tubeCreators) {
tubeCreator.updateContext(context);
}
TubelineAssemblyDecorator decorator = TubelineAssemblyDecorator.composite(
ServiceFinder.find(TubelineAssemblyDecorator.class, context.getEndpoint().getContainer()));
boolean first = true;
for (TubeCreator tubeCreator : tubeCreators) {
final MessageDumpingInfo msgDumpInfo = setupMessageDumping(tubeCreator.getMessageDumpPropertyBase(), Side.Endpoint);
final Tube oldTubelineHead = context.getTubelineHead();
LoggingDumpTube afterDumpTube = null;
if (msgDumpInfo.dumpAfter) {
afterDumpTube = new LoggingDumpTube(msgDumpInfo.logLevel, LoggingDumpTube.Position.After, context.getTubelineHead());
context.setTubelineHead(afterDumpTube);
}
if (!context.setTubelineHead(decorator.decorateServer(tubeCreator.createTube(context), context))) { // no new tube has been created
if (afterDumpTube != null) {
context.setTubelineHead(oldTubelineHead); // removing possible "after" message dumping tube
}
} else {
final String loggedTubeName = context.getTubelineHead().getClass().getName();
if (afterDumpTube != null) {
afterDumpTube.setLoggedTubeName(loggedTubeName);
}
if (msgDumpInfo.dumpBefore) {
final LoggingDumpTube beforeDumpTube = new LoggingDumpTube(msgDumpInfo.logLevel, LoggingDumpTube.Position.Before, context.getTubelineHead());
beforeDumpTube.setLoggedTubeName(loggedTubeName);
context.setTubelineHead(beforeDumpTube);
}
}
if (first) {
context.setTubelineHead(decorator.decorateServerTail(context.getTubelineHead(), context));
first = false;
}
}
return decorator.decorateServerHead(context.getTubelineHead(), context);
}