Hi,
(I'm offline at the moment, so my research abilities are diminished.)
Yes, I think that that's a bit of tragic naming. Last time I looked at
the *Handler / @Strategy dichotomy, my conclusion was that it seemed
like the annotation should be renamed @Handler. But I've never really
chased down all the code pathways sufficiently to validate that.
It doesn't look like it'd be that difficult to support FieldStrategies
as well as ValueHandlers in MappingRepository, but it would definitely
be worth digging through the svn history for MappingRepository (in
particular, MappingRepository.namedHandler()) for more details.
Also, I seem to remember something wonky about requiring a pair of
parentheses at the end of a <something> in order for it to be parsed
correctly. I can't remember the details, and it's amazingly difficult
to search through email history for (). But the gist was that someone
was trying to set some configuration point (which I think might have
been a strategy) to a classname, and our parser was getting tripped
up. IIRC, it thought that the classname was supposed to be an alias,
so was routing it to the wrong branch. Adding an open and close parens
was sufficient to convince the parser that the thing had a classname
component, and the right behavior ensued. However, the issue may or
may not have had to do with strategies and handlers, and also it might
have been an issue with unqualified classnames / package-less
classnames.
But in any event, it might be worth changing your test like so:
@Strategy("org.apache.openjpa...MyCustomFieldStrategy()")
HTH,
-Patrick
On Nov 24, 2008, at 11:47 AM, Kevin Sutter wrote:
Hi,
A question has surfaced about the use of ValueHandlers vs
FieldStrategies.
According to the OpenJPA documentation [1], a user should be able to
specify
either a custom ValueHandler implementation or FieldStrategy
implementation
via the @Strategy annotation. This does not seem to be the case. Our
OpenJPA implementation is quite dependent on a ValueHandler
implementation
for the value of the @Strategy annotation. After instantiating the
Class
that is specified in the annotation, OpenJPA explicitly attempts to
assign
it as a ValueHandler. If it can't pass this test, then we return
null and
process as if nothing was specified. No warning message or anything.
FYI, the FieldStrategy can be specified in the persistence.xml as a
MappingDefault (also documented in [1]). This approach works, but
then
we're specifying the FieldStrategy for all instances of that type --
not
specific attribute instances.
Although we are losing a few of the original development team
members, I'm
wondering if anybody has any history with these ValueHandlers and/or
FieldStrategies?
o Are ValueHandlers meant for individual field processing, and the
FieldStrategies meant for more global type processing? This
definition fits
well with the current implementation, but I'm not ready to declare
that as
gospel.
o A warning message of some type would be good for the case where the
Strategy can't be properly instantiated and used.
o I also re-discovered the problem that was recently identified via
JIRA
OPENJPA-758 [2].
o The documentation needs to be clarified, at a minimum. No matter
what we
come up with for a final solution, this section needs a bit of work.
Comments and suggestions are welcome, especially from our past
experts from
BEA and SolarMetric... :-)
Thanks,
Kevin
[1]
http://openjpa.apache.org/builds/1.2.0/apache-openjpa-1.2.0/docs/manual/manual.html#ref_guide_mapping_custom_field
[2] https://issues.apache.org/jira/browse/OPENJPA-758
--
Patrick Linskey
202 669 5907