Unlike previous versions, CAS 5 attempts to automate all required Spring Webflow changes on a per-module basis. This aligns well with the new IDD
(Intention-Driven Development) model where all one should have to do is, declare the appropriate module in the build script…and voilà. CAS will take care of the rest.
You may ask: Wait! What’s really happening? How can it accomplish everything that we had to apply manually before? Why am I being asked to do less work? What exactly do the CAS internals look like? Did machines finally take over? Most importantly, Turkey’s tombili died?!
Some answers follow.
Stop worrying. Stop coding. You are no longer required to become a Spring Webflow ninja or Java champion overnight to apply a myriad of XML configuration snippets here and there to get something to work. That’s all taken care of for you. Sit back and relax.
More importantly, avoid making ad-hoc changes to the Webflow as much as possible. Consider how the change you have in mind might be more suitable as a direct contribution to CAS itself so you can just take advantage of its configuration; NOT its maintenance.
If you find something that is broken where the auto-configuration strategy fails to deliver as advertised, discuss that with the project community. Submit an issue and/or file a patch. Avoid one-off changes.
You may have been illusioned to think that the auto-configuration strategy is less powerful because much of the configuration is hidden away and you no longer have the flexibility to change anything and everything.
Consider:
In fact, you can do A LOT MORE.
So in the olden days, the following recipe was more or less what was done:
Action
in Java that does X.XML
that configures that action class.Wait. I may have missed a few steps. The recipe did also include:
What is also inconsistent with this strategy is that a perhaps-simple change spanned across multiple unfamiliar barriers. Even if you learned and mastered all the underlying technologies, you still needed to touch Java, Spring XML and Spring Webflow XML configuration to get something to work.
Is that verbosity the same thing as flexibility?
Every CAS module that needs to dynamically augment the Spring Webflow routes simply takes on the following form:
public class SomethingWebflowConfigurer extends AbstractCasWebflowConfigurer {
@Override
protected void doInitialize() throws Exception {
final Flow flow = super.getLoginFlow();
// Magic happens; Call 'super' to see what you have access to...
}
}
CAS modules register their WebflowConfigurer
instances in @Configuration
classes:
@Configuration("SomethingConfiguration")
public class SomethingConfiguration {
@Autowired
@Qualifier("loginFlowRegistry")
private FlowDefinitionRegistry loginFlowDefinitionRegistry;
@Autowired
private FlowBuilderServices flowBuilderServices;
@ConditionalOnMissingBean(name = "somethingWebflowConfigurer")
@Bean
public CasWebflowConfigurer somethingWebflowConfigurer() {
final SomethingWebflowConfigurer w = new SomethingWebflowConfigurer();
w.setLoginFlowDefinitionRegistry(this.loginFlowDefinitionRegistry);
w.setFlowBuilderServices(this.flowBuilderServices);
...
return w;
}
}
When CAS comes up, it scans the context to find @Configuration
classes and then will invoke each and every WebflowConfigurer
to execute changes.
CAS itself handles Spring Webflow changes related to its first-class features by default automatically. That strategy equally applies, should you need to write your own configurers if you absolutely need to.
What if you have two WebflowConfigurer
s who all decide to inject actions and state into the same Spring Webflow areas? What if multiple WebflowConfigurer
s are competing to set themselves up as starting points of the CAS webflow? Who wins, who mourns?
Indeed, these are questions you ought to be thinking about as a developer. With power comes responsibility.
Today:
That’s all.
Monday-Friday
9am-6pm, Central European Time
7am-1pm, U.S. Eastern Time
Monday-Friday
9am-6pm, Central European Time