0

My real question is about how to look up the expectations on the methods (the 'contract' for a method) in Spring. I keep hitting questions, where unless I find some blogger or a stack-overflow that addresses that specific issue, there seems to be no informative documentation. Am I looking the wrong places? Do I need to buy some book?

In the current specific case: I have working looking up a user/password by making my SQL table map to Spring's defaults, but when a user is absent it's hitting a null pointer exception. I see JdbcUserDetailsManager's "void setUserExistsSql( anSQLString)", and I want to know if that sql-string should return a boolean? a null? and what it should be 'named.' Googling is not turning up any usage examples, nor any documentation. The javadocs I'm finding are uncommented. I can guess-and-test, but it seems there should be a better way to look-it-up?

Matt S.
  • 878
  • 10
  • 21
  • I just googled JdbcUserDetailsManagerConfigurer and hit the first result, and then jumped to the section on authoritiesByUsernameQuery by searching for it within the page. It was easy to find and the docs seem pretty clear and contain an example. What problem are you really having? Do you not understand the concepts of principal (which isn't mentioned in that method at all afaik) or authority? API documentation doesn't usually teach the underlying subject matter. – Software Engineer Oct 26 '15 at 23:43
  • @Engineer Dollery - In that example with JdbcUserDetailsManagerConfigurer - how does one know from the docs that username must be named 'principal'? The more relevant question/example is on setUserExistsSql -- where there's no comment in the docs – Matt S. Oct 27 '15 at 00:12
  • What makes you think that it needs to be called principle? I assume that you know what a principle is in this context? That you've read the introduction to spring security and have the background necessary to understand what these methods are for? Thats a necessary precursor to doing anything in spring, despite my answer below. – Software Engineer Oct 27 '15 at 00:20
  • @Engineer Dollery - would seem I emulated what a couple of folks had marked up as working: http://stackoverflow.com/a/19598587/155631 As you point out - seems the renaming is not needed. Thanks! – Matt S. Oct 27 '15 at 00:31

1 Answers1

1

Ok, I've been working with spring since version 1, and many other open-source projects follow the same pattern. Documentation is hard and expensive to produce, and programmers donating their time for free often don't want to write it. Spring though is one of the better projects as far as documentation is concerned.

However, I've always found it necessary to link spring's source code into my project. If you're using maven you can download the sources along with the jars, and tools like IntelliJ (and probably eclipse) will allow you to drill down into the source and to trace its execution with their debuggers.

With these types of projects it is almost always necessary at some point to drill down and read the source, and that's a good thing because the source is always up to date and always exactly describes the behaviour you're trying to use. Documentation on the other hand is often badly written using an informal language (e.g. English) and it can never accurately describe anything, especially if it's being written or read by someone who isn't a native speaker, which is often the case.

So, to answer your question -- look to the source.

Software Engineer
  • 15,457
  • 7
  • 74
  • 102