Versions Compared

Key

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

[10:51:19 CDT(-0500)] <fairwinds> apetro: good afternoon. Well I am almost there with my handler. Have the java now in maven that does the connecting to couch to verify password over secure connection using Basic auth. So next step is putting into AuthenticationHandler class and to set up something so connection parameters can be set in xml configuration
[10:52:08 CDT(-0500)] <fairwinds> apetro: I have to say I am rubbish with maven so it was a bit bumpy
[11:34:39 CDT(-0500)] <fairwinds> apetro: I guess I will need a bean factory to get couchdb properties.
[11:35:40 CDT(-0500)] <fairwinds> was looking at memcached client. perhaps I can use org.springframework.beans.factory.FactoryBean
[13:18:54 CDT(-0500)] <apetro> fairwinds, how's it going?
[13:19:09 CDT(-0500)] <fairwinds> apetro: pretty good actually
[13:19:12 CDT(-0500)] <fairwinds> (smile)
[13:19:23 CDT(-0500)] <fairwinds> weather is cooler and code going well
[13:19:39 CDT(-0500)] <apetro> glad to hear it
[13:20:03 CDT(-0500)] <fairwinds> I am just getting xml configuration to work for my db connection
[13:20:40 CDT(-0500)] <fairwinds> so creating a bean for couchdbConnection
[13:21:55 CDT(-0500)] <fairwinds> apetro: and will get hold of that object in my handler through spring ApplicationContext is way I am going at it
[13:26:09 CDT(-0500)] <fairwinds> sort of an interesting adventure. I don't really program in Java
[13:31:32 CDT(-0500)] <apetro> k
[13:31:42 CDT(-0500)] <apetro> if you've got code you'd like looked over at some point
[13:31:57 CDT(-0500)] <apetro> mostly you probably shouldn't have to be calling out to the ApplicationContext from Java code
[13:32:02 CDT(-0500)] <apetro> the idea is that Spring wires it all together for you
[13:32:15 CDT(-0500)] <apetro> so mostly your code is a victim of rather than an invoker of Spring, as it were
[13:32:22 CDT(-0500)] <apetro> but whatever works for you
[13:39:47 CDT(-0500)] <fairwinds> apetro: it would be great if you could have a look. I am going to finish it up first so that the thing all works. Then it can be made better from there. I am a bit ignorant of much of the structure so there will no doubt be some likely improvements after I finish this first go of it
[13:40:45 CDT(-0500)] <apetro> that's fine. getting to working code is certainly the most important consideration – can infinitely refactor from there
[13:42:01 CDT(-0500)] <fairwinds> apetro: I mean I will want to know if there is a better place to put somethings or some better classes to use. I have been careful to minimize dependencies
[13:43:41 CDT(-0500)] <apetro> that all sounds fair. having myself gone down the road of static factories invoking Spring and so forth, I know it is possible to get pretty stuck. Don't stay stuck. (smile)
[13:48:51 CDT(-0500)] <fairwinds> So far I am good but will make some noise if things get painful. I am having fun with this in general. I mostly code with javascript on server these days which is quite a bit faster that Java but obviously no CAS server there yet.
[16:25:19 CDT(-0500)] <fairwinds> apetro: ping
[16:25:28 CDT(-0500)] <apetro> pong
[16:27:13 CDT(-0500)] <fairwinds> hi.. I have created some xml and a class to instantiate my couchdb connection. I am wondering how to get a handle on it
[16:28:12 CDT(-0500)] <fairwinds> apetro. I was going to use ApplicationContext and ClassPathXMLApplicationContext
[16:28:36 CDT(-0500)] <apetro> yeah. You're going down a road that's not going to work very well.
[16:29:34 CDT(-0500)] <apetro> Let's talk about Spring for a bit.
[16:29:54 CDT(-0500)] <fairwinds> ie. ApplicationContext context = new ClassPathXMLApplicationContext("some.xml");
[16:29:58 CDT(-0500)] <fairwinds> CouchDBConnection couchDBConn = (CouchDBConnection) context.getBean("couchDBConnection");
[16:30:02 CDT(-0500)] <fairwinds> somethign like that
[16:30:05 CDT(-0500)] <apetro> yeah
[16:30:10 CDT(-0500)] <apetro> you could do that
[16:30:23 CDT(-0500)] <fairwinds> is there a better way
[16:30:27 CDT(-0500)] <apetro> there is
[16:30:55 CDT(-0500)] <apetro> so you have an XML file that defines some Spring beans?
[16:31:00 CDT(-0500)] <apetro> that's what some.xml is?
[16:31:33 CDT(-0500)] <fairwinds> well I put my bean in deployerConfigContext.xml for time being until I talked to you
[16:31:41 CDT(-0500)] <apetro> if so, simply drop it into the spring-configuration directory, and CAS will bootstrap it in among the spring-wired beans
[16:32:02 CDT(-0500)] <apetro> then, rather than your code instantiating a context and doing context.getBean()
[16:32:36 CDT(-0500)] <apetro> simply expose as JavaBean property (i.e. getCouchDbConnection() and setCouchDbConnection() ) in your AuthenticationHandler implementation
[16:33:15 CDT(-0500)] <apetro> and then in deployerConfigContext, where you declare your custom AuthenticationHandler implementation, wire into it the couchDBConnection
[16:34:25 CDT(-0500)] <apetro> I guess the main advice I'm offering is, don't write any Java that itself creates new Spring ApplicationContexts
[16:34:38 CDT(-0500)] <apetro> rather, whatever your object needs, let Spring provide it via dependency injection
[16:34:58 CDT(-0500)] <apetro> and wire up those dependencies in XML, whether in deployerConfigContext.xml, or in another XML file, as you liek.
[16:35:01 CDT(-0500)] <apetro> like, even.
[16:35:33 CDT(-0500)] <fairwinds> right. I was looking at code for memcached and jdbc. These things are configured in deployerConfigContext.xml are they not?
[16:35:41 CDT(-0500)] <apetro> yes
[16:35:44 CDT(-0500)] <fairwinds> I mean the connection itself
[16:35:48 CDT(-0500)] <apetro> well
[16:35:58 CDT(-0500)] <apetro> in the case of JDBC, the DataSource, that is, the connection factory
[16:36:05 CDT(-0500)] <fairwinds> right
[16:36:15 CDT(-0500)] <fairwinds> I read the datasource thing
[16:36:26 CDT(-0500)] <apetro> I don't know enough about what a CouchDbConnection is to be comfortable saying whether you should be wiring up that or a factory for that in deployerConfigContext.xml
[16:36:37 CDT(-0500)] <apetro> but yes, that's generally the idea
[16:37:07 CDT(-0500)] <apetro> in the case of JDBC, one wires up a DataSource, and then injects that DataSource into the JDBCWhateverWhateverAuthenticationHandler
[16:37:14 CDT(-0500)] <fairwinds> well, my CouchDBConnection is just a simple object that creates a hostAddress really.
[16:37:27 CDT(-0500)] <fairwinds> with the properties from the xml configuration
[16:37:27 CDT(-0500)] <apetro> cool
[16:37:31 CDT(-0500)] <apetro> yeah
[16:37:45 CDT(-0500)] <apetro> so, what properties does it need?
[16:38:07 CDT(-0500)] <apetro> and what XML configuration is this? (smile)
[16:38:23 CDT(-0500)] <apetro> Unfortunately, I know zero about CouchDb.
[16:38:29 CDT(-0500)] <apetro> but given that
[16:38:32 CDT(-0500)] <fairwinds> hey, let me paste waht I have
[16:38:37 CDT(-0500)] <apetro> that'd be fine
[16:39:18 CDT(-0500)] <apetro> bonus points for using gist (smile)
[16:42:00 CDT(-0500)] <apetro> but mostly the game is this:
[16:42:14 CDT(-0500)] <apetro> whatever your AuthenticationHandler needs, express it as JavaBean properties
[16:42:25 CDT(-0500)] <apetro> that is, methods with names getSomething() and setSomething()
[16:42:49 CDT(-0500)] <apetro> then, in deployerConfigContext.xml , declare your AuthenticationHandler, fulfilling its required setSomething()s by injection
[16:43:36 CDT(-0500)] <apetro> for getting started, I'd suggest sticking with simple such properties (integers and strings) and just put them all right in AuthenticationHandler, refactor out to a more complex external connection factory and so forth later after you've got working code
[16:44:01 CDT(-0500)] <apetro> and mostly, at that point , you should need no additional XML files and no manual bootstrapping of Spring contexts (smile)
[16:44:31 CDT(-0500)] <fairwinds> apetro: k, here is first gist
[16:44:36 CDT(-0500)] <fairwinds> https://gist.github.com/31a3f419468b602a06ac
[16:44:44 CDT(-0500)] <fairwinds> this is just the bean
[16:45:38 CDT(-0500)] <apetro> k
[16:45:40 CDT(-0500)] <apetro> that looks fine
[16:45:49 CDT(-0500)] <apetro> you can put that right in deployerConfigContext.xml
[16:45:56 CDT(-0500)] <fairwinds> yup, I did
[16:45:57 CDT(-0500)] <apetro> as a child of <beans/>
[16:45:59 CDT(-0500)] <apetro> cool
[16:46:04 CDT(-0500)] <fairwinds> k, here is next
[16:46:07 CDT(-0500)] <fairwinds> https://gist.github.com/3a276edcb351c653fe0f
[16:46:19 CDT(-0500)] <fairwinds> this is the class I want to instantiate with it
[16:47:00 CDT(-0500)] <apetro> yup
[16:47:06 CDT(-0500)] <apetro> that looks just fine
[16:49:25 CDT(-0500)] <fairwinds> k, next up is what I will be turning into the authentication handler
[16:49:29 CDT(-0500)] <fairwinds> https://gist.github.com/367ab3152b25fdfcb975