openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin Sutter" <kwsut...@gmail.com>
Subject Re: ValueHandlers vs FieldStrategies
Date Wed, 26 Nov 2008 00:02:24 GMT
Patrick,
Nice to hear from you...  ;-)

I'm coming to the same conclusion about the Handler vs Strategy argument.
It seems that we have overloaded the Strategy term to mean either a Strategy
or a Handler.  This not only makes the documentation confusing, but also the
code.

Here's what I have found.  When we attempt to install a "Strategy", we check
for a named Strategy first.  Whether we have a ValueHandler or a
FieldStrategy defined using an @Strategy annotation, this check for a named
Strategy always "fails" and we return a null value.  I think this is our
first problem.  From our definition, I believe that the named Strategy
should find a FieldStrategy if it's defined via the @Strategy annotation.
Maybe this is part of the "parsing problem" that you describe below.

(Aside, the problems I am experiencing do not appear to be related to the
missing parens.  And, I haven't seen any code thus far that would trip over
that, so maybe that problem has been resolved.)

After the check for a named Strategy "fails", we drop into the default
Strategy processing.  Here, we attempt to get the Strategy defined for the
Value.  Although the FieldStrategy name is used here, we're expecting a
ValueHandler and the creation of the "strategy" fails.  My hypothesis is
that this named FieldStrategy should have been detected previously when
processing the namedStrategy and then we would have never fallen into this
ValueHandler processing.

Anyway, this is where I am at.  I plan to experiment some more with actual
code changes and testing, but if anybody sees any problems with my
self-education at this point, let me know.  Thanks!

Kevin

On Tue, Nov 25, 2008 at 11:47 AM, Patrick Linskey <plinskey@gmail.com>wrote:

> 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
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message