Construct custom directive: Directive.apply vs mapInnerRoute vs Directive.flatMap - scala

I want to define custom directive using some built-in ones and my logic.
As I see all of Directive.apply, BasicDirectives.mapInnerRoute and Directive.tflatMap is suitable.
What is preferable in which cases and what best practices are?

Without knowing anything about the custom directives you wish to create it's impossible to discuss the suitability of the various options you listed.
The documentation on this topic is fairly thorough:
There are essentially three ways of creating custom directives:
By introducing new “labels” for configurations of existing directives
By transforming existing directives
By writing a directive “from scratch”

Related

How to use stubsPerConsumer with restdocs

How do I use the stubsPerConsumer feature when creating a stub from a producer with restdocs?
If this is not supported, is it possible to generate the asciidoc snippets from the groovy DSL contract?
Update
It looks like baseClassMappings is not supported when using spring-cloud-contract with restdocs. Has anyone found a clever way to get this to work using the assembly-plugin (that doesn't require a lot of manual setup for each consumer)?
Currently, it's not supported on the producer side with rest docs out of the box. We treat rest docs as a way to do the producer contract approach. Theoretically what you could do is to create different output snippet directories. Instead of for example target/snippets you could do target/snippets/myconsumer. Then with the assembly plugin you would just pick the target/snippets. At least that's how theory would work.
As for the contracts and adocs you can check out this: https://github.com/spring-cloud-samples/spring-cloud-contract-samples/blob/master/beer_contracts/src/test/java/docs/GenerateAdocsFromContractsTests.java . It's a poor man's version of going through all of the contracts and generation of adoc documentation from them.

How do you prepare styles without StylePropable mixin?

Now that it's no longer recommended (or possible, given ES6 classes) to use the StylePropable mixin (and because libraries like react-mixin, that try to turn them into decorators have been nothing but trouble), and given that an official replacement hasn't been developed to my knowledge, what's the recommended way to incorporate the behavior (such as auto-prefixing) of the functions it provided, such as prepareStyles? I'm using ^0.14.0.

xstream conditionally unmarshall to a class

Because of legacy (unfortunate) reasons, we have the same xml roots for 2 different representations. With xstream, how would we let unmarshaller to use a class we need while unmarshalling.
I am thinking of passing some context (through ThreadContext) so that xstream would use that information to pick the right class during unmarshalling, though I am not sure where to start. Any suggestions are very appreciated.
Notes:
Root tags are same for both XML
No other information (attribute) on root tag is available to distingish 2 representations
Cannot change the xml because of legacy reasons
Ideally I would like the solution to work with Spring-OXM but will take shortcuts if needed
You know in advance which of the two representations you are about to parse.
So you can create two instances of the xStream in the beginning, and configure the converters and aliases differently for each of them, and use one instance per representation.
This approach seems to me cleaner and more controllable than setting a global context variable and then having a bunch of ifs inside the converters, and dealing with potential ambiguities.

Has anyone implement DITA 1.2 Subject scheme in their work?

I would like to know if there is anyone who has implemented the subjectscheme maps of DITA1.2 in their work? If yes, can you please break-up the example to show:
how to do it?
when not to use it?
I am aware of the theory behind it, but I am yet to implement the same and I wanted to know if there are things I must keep in mind during the planning and implementation phase.
An example is here:
How to use DITA subjectSchemes?
The DITA 1.2 spec also has a good example (3.1.5.1.1).
What you can currently do with subject scheme maps is:
define a taxonomy
bind the taxonomy to a profiling or flagging attribute, so that it the attribute only takes a value that you have defined
filter or flag elements that have a defined value with a DITAVAL file.
Advantage 1: Since you have a taxonomy, filtering a parent value also filters its children, which is convenient.
Advantage 2: You can fully define and thus control the list of values, which prevents tag bloat.
Advantage 3: You can reuse the subject scheme map in many topic maps, in the usual modular DITA way, so you can apply the same taxonomies anywhere.
These appear to be the main uses for a subject scheme map at present.
The only disadvantages I have found is that I can think of other hypothetical uses for subject scheme maps such as faceted browsing, but I don't think any implementation exists. The DITA-OT doesn't have anything like that yet anyway.

Avoid namespace conflicts in Java MPI-Bindings

I am using the MPJ-api for my current project. The two implementations I am using are MPJ-express and Fast-MPJ. However, since they both implement the same API, namely the MPJ-API, I cannot simultaneously support both implementations due to name-space collisions.
Is there any way to wrap two different libraries with the same package and class-names such that both can be supported at the same time in Java or Scala?
So far, the only way I can think of is to move the module into separate projects, but I am not sure this would be the way to go.
If your code use only a subset of MPI functions (like most of the MPI code I've reviewed), you can write an abstraction layer (traits or even Cake-Pattern) which defines the ops your are actually using. You can then implement a concrete adapter for each implementation.
This approach will also work with non-MPI communication layers (think Akka, JGroups, etc.)
As a bonus point, you could use the SLF4J approach: the correct implementation is chosen at runtime according to what's actually in the classpath.