[morphia] New Dependencies

8 views
Skip to first unread message

Scott Hernandez

unread,
May 21, 2010, 10:41:17 AM5/21/10
to mor...@googlegroups.com
As we have been discussing adding deps to cglib and proxytoy (for
@Reference lazy) and changing logging to use slf4j (from the current
java logging) it seems like a good time to propose a general strategy
for how/when to include deps. In particular I'd like to suggest that
we restrict some of these features and make them soft-deps, based on
the existence of the jars.

The lazy reference support should only be enabled if the proxytoy and
cglib jars are available. If we add support for other proxy
frameworks, the same can hold true.

If we add support for a default jsr303 (bean validation) provider then
I plan to only enable it if the jar is there.

In this way we can keep morphia deployable without requiring jars that
might not be used. At worst, we tell people they will have to copy
some extra jars into their project if they want everything.

Thoughts?

Ólafur Gauti Guðmundsson

unread,
May 21, 2010, 10:46:57 AM5/21/10
to mor...@googlegroups.com
I totally agree, I think Morphia should be usable without these dependencies if possible. It is frustrating to have to include jars that you're not using.

Google Guice does this with the AOP for example. You only need the aopalliance.jar if you're using AOP features.

Uwe Schäfer

unread,
May 21, 2010, 10:50:52 AM5/21/10
to mor...@googlegroups.com
Ólafur Gauti Guðmundsson schrieb:

> I totally agree, I think Morphia should be usable without these
> dependencies if possible. It is frustrating to have to include jars that
> you're not using.

fine for me.

Basic question: what if user tries to use a feature he needs the jars
for? for instance uses @Reference(lazy=true) without cglib/proxytoys?

yell or ignore?

personally, i´d vote for "yell" :)

cu uwe

Scott Hernandez

unread,
May 21, 2010, 10:57:20 AM5/21/10
to mor...@googlegroups.com
2010/5/21 Uwe Schäfer <u...@thomas-daily.de>:
> Ólafur Gauti Guðmundsson schrieb:
>
>> I totally agree, I think Morphia should be usable without these
>> dependencies if possible. It is frustrating to have to include jars that
>> you're not using.
>
> fine for me.
>
> Basic question: what if user tries to use a feature he needs the jars for?
> for instance uses @Reference(lazy=true) without cglib/proxytoys?
>
> yell or ignore?

Yeah, it is a hard question. I vote logging, but no exception. Every
time they try to use that feature, complain (with a stack trace to the
log?). Everything will continue to work without lazy, it just may be
more expensive.

Remember, a lot of the benefit to your model for mongodb is to use
embedded objects. There are cases you want link semantics, but they
are probably more infrequent than you might think. Multiple queries
and I/O hits cost more than transferring extra network data, most
likely.

Uwe Schäfer

unread,
May 21, 2010, 11:42:47 AM5/21/10
to mor...@googlegroups.com
Scott Hernandez schrieb:

>> yell or ignore?
> I vote logging, but no exception. Every
> time they try to use that feature, complain (with a stack trace to the
> log?). Everything will continue to work without lazy, it just may be
> more expensive.

uh, really?

not too strong of an opinion, but i thought:

if a user did explicitly ask for lazy (by setting lazy to true) but did
not provide dependencies, that´d be considered an issue in mapping
validation, that´ll fail and make the user either use non-lazy
references or add dependencies.

see fieldrules.LazyReferenceMissingDependencies

cu uwe

Scott Hernandez

unread,
May 21, 2010, 11:47:29 AM5/21/10
to mor...@googlegroups.com
2010/5/21 Uwe Schäfer <u...@thomas-daily.de>:
> Scott Hernandez schrieb:
>
>>> yell or ignore?
>>
>> I vote logging, but no exception. Every
>> time they try to use that feature, complain (with a stack trace to the
>> log?). Everything will continue to work without lazy, it just may be
>> more expensive.
>
> uh, really?

Well, generally if it is just an optimization, complain but let it run.

> not too strong of an opinion, but i thought:
>
> if a user did explicitly ask for lazy (by setting lazy to true) but did not
> provide dependencies, that´d be considered an issue in mapping validation,
> that´ll fail and make the user either use non-lazy references or add
> dependencies.
>
> see fieldrules.LazyReferenceMissingDependencies

I'm fine either way. I want it to be stringent enough but without
making it hard to use.

> cu uwe
>
>

Uwe Schäfer

unread,
May 21, 2010, 12:34:54 PM5/21/10
to mor...@googlegroups.com
Scott Hernandez schrieb:

> Well, generally if it is just an optimization, complain but let it run.

true as well. i changed it accordingly.

cu uwe

Ólafur Gauti Guðmundsson

unread,
May 21, 2010, 4:06:46 PM5/21/10
to mor...@googlegroups.com
I am used to getting a ClassNotFoundException when I run a program without the required classes. I think we should throw an Exception when we cannot perform the action explicitly requested by the user, no matter whether it is a request for "optimization" or not. 

2010/5/21 Uwe Schäfer <u...@thomas-daily.de>

Scott Hernandez

unread,
May 21, 2010, 4:33:36 PM5/21/10
to mor...@googlegroups.com
It depends what you consider "required". The same is true in guice
(isn't it?), you can write code that will not cause an error, but will
not do anything unless you deploy the AOP jars. Their existence (the
jars) are what turn on those features. This seems like a documentation
issue as well, but I'm fine throwing a custom exception stating that
the jars are missing.

It is a gray area. We should take a poll and see what users say after
we get it working. It is easy enough to change the behavior to an
exception.

2010/5/21 Ólafur Gauti Guðmundsson <oli....@gmail.com>:
Reply all
Reply to author
Forward
0 new messages