2013/4/5 Witold Szczerba <[email protected]>:
> Oh, yes, that was the very long thread, I have lost my way going through it,
> hehe :)
>
> As to the:
> with(configuration)
> .select....
>
> Is this a real use case? I mean, in any given class responsible for talking
> to database, why should I care about configuration object, if all I need is
> the other object (factory instance), exchanged for configuration instance?
>
> I believe (am I alone?), each class should ask only for things it does care
> for. In the case above, we do not care about configuration, we care about
> that contextual factory instance. All we use configuration for, is to
> quickly exchange it for something else. That means we should never ask for a
> configuration, but the contextual factory instance (or a provider of that)
> instead.
The point is that a contextual factory needs the context (=
Configuration) somehow.
> Of course, having the code you provided I can create a provider or a
> producer like this:
>
> //you are right, the name ContextualFacotry is not fortunate...
> Provider<ContextualFactory> {
> ContextualFactory get() {
> Configuration config = ...get it from somewhere...
> return with(config);
> }
> }
>
> MyClassTalkingToDatabase {
>
> @Inject ContextualFactory jooq;
>
> //or like this, depends on this instances lifecycle
> @Inject Provider<ContextualFactory> jooq;
>
> Something get(...) {
> return jooq.select(...).fetch....
> // or if provider was used explicitly, ugly and can always be avoided:
> jooq.get().select(...).fetch.... but this can always be exchanged for
> the direct use above
> }
> }
Yes, you can wrap the jOOQ DSL entry point with whatever wrapper API
you find most suitable. But abstracting these things out of jOOQ and
jOOQ's DSL even further isn't going to help making things easy to
understand.
The #1 question raised by Christopher is really: "Do we need a
contextual factory"? #2 question: If yes, what's the simplest, least
painful way to create it from within jOOQ.
> The good news is, now it is possible to easily separate the
> "with(configuration)", which is going to be exactly the same all over the
> place in entire application, for a provider. The question remains: is the
> contextual factory an interface like FactoryOperations was in JOOQ 2.6?
It probably will be, if #1 is answered as yes.
Cheers
Lukas
--
You received this message because you are subscribed to the Google Groups "jOOQ
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.