The similar behavior is achieved in Java with IJavaAggregationProcessor.getAggregationDocumentType() and IJavaTransformationProcessor.getTransformationDocumentType().
The code above is equivalent to Java Example 1. You do not find for which source it is associated to, because it is defined in the Administration Console as shown below.
Although it is not explicitly visible in the method signature, the process method receives the current document being processed (transformation or aggregation) using the special it variable. You can see it in the above example with it.getUri(), which is the equivalent of IConsolidationDocument.getUri().