Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

shibboleth.BiFunctions.Compose 4.1 starts a function composition chain with a BiFunction. It is a static version of the BiFunction.andThen() method and connects a BiFunction "f" returning a type T that is then input to a function "g", returning its value. Given inputs "x" and "y", this represents g(f(x,y)).

...

Non-contrived examples are difficult, but the most common use is to compose functions together that either navigate the IdP ProfileRequestContext tree of objects and/or to return a value from a context object. This allows any data in the tree to be reached declaratively using wired up function beans even when the path to the data is potentially very complex. But note that it doesn't allow the wiring to be simple, only possible.

...

The following demonstrates combining a function that takes a ProfileRequestContext and returns a child context of type SessionContext with a function that takes a SessionContext and returns the session ID from it.

Thus, "f" is of type Function< Function<ProfileRequestContext, SessionContext> and "g" is of type Function< Function<SessionContext, String>, so composing them produces Function< Function<ProfileRequestContext,String> and reuses two primitive building blocks to produce a more complex tool.

By convention named arguments are used, but if the names are left out the order of arguments is the outer function and then the inner function.

...

...

Function<ProfileRequestContext,String> returning Session ID
Code Block
languagexml
<bean parent="shibboleth.Functions.Compose">
	<constructor-arg name="g">
		<bean class="net.shibboleth.idp.session.context.navigate.SessionContextIDLookupFunction" />
	</constructor-arg>
	<constructor-arg name="f">
		<ref bean="shibboleth.ChildLookup.SessionContext" />
	</constructor-arg>
</bean>

...