[hibernate-dev] HSEARCH-429

Amin Mohammed-Coleman aminmc at gmail.com
Fri Dec 4 05:35:59 EST 2009


Hi Emmanuel,

I have not used Hg or Git (although I've heard of Git).

I'm not sure if I follow with regards to "and a String (configuration)".  I
was thinking that what I needed to cater for was a Class and object
reference being passed as was the initial case with the ProgrammaticAPI
test.   Would be possible to get some clarification on that.

"I think the code should not be in SearchConfigurationFromHibernateCore as
it is equally useful for non Hibernate Core usages". Makes sense. I'll
change it and add it to the search initialisation.


Thanks for your comments.


Cheers
Amin

On Fri, Dec 4, 2009 at 9:49 AM, Emmanuel Bernard <emmanuel at hibernate.org>wrote:

> Hello,
> I'll review your patches today hopefully.
> I am wondering if using Hg or Git could help you / us and what would be the
> impact on the existing architecture.
>
> wrt HSEARCH-429
> hibernate.search.mapping_model should be both a Class and a String
> (configuration). The code must account for that.
> I think the code should not be in SearchConfigurationFromHibernateCore as
> it is equally useful for non Hibernate Core usages. It but be next to the
> core of Hibernate Search's initialization.
>
> On 4 déc. 09, at 09:36, Amin Mohammed-Coleman wrote:
>
> Hi
>
> I had a go at using the @Factory and did something like this:
>
> public class SearchMappingFactory {
>
>    @Factory
>     public SearchMapping build() {
>       SearchMapping mapping = new SearchMapping();
>        ....build mapping
>
>       return mapping;
>     }
> }
>
> cfg.getProperties().put( "hibernate.search.mapping_model",
> SearchMappingFactory.class );
>
>
> In SearchConfigurationFromHibernateCore i changed :
>
>
> public SearchMapping getProgrammaticMapping() {
> if (getProperties().get( "hibernate.search.mapping_model" ) == null) {
> return null;
> }
> Class<?> clazz = (Class<?>) getProperties().get(
> "hibernate.search.mapping_model" );
> Method[] methods = clazz.getMethods();
> SearchMapping mapping = null;
> boolean hasFactoryAnn = false;
> int count = 0;
> for (Method method : methods) {
> if (method.isAnnotationPresent(Factory.class)) {
> count++;
> hasFactoryAnn = true;
> if ( !method.isAccessible() ) {
> method.setAccessible( true );
> }
> try {
> Object instance = clazz.newInstance();
> mapping = (SearchMapping) method.invoke(instance, new Object[] {});
> } catch (Exception e) {
> throw new SearchException(e);
> }
> }
> }
> if (!hasFactoryAnn) {
> throw new SearchException("No @Factory method defined for building
> programmatic api.");
> }
> if (count > 1) {
> throw new SearchException("Multiple @Factory methods defined. Only one
> factory method required.");
> }
> return mapping;
> }
>
> I was going to create a patch but I've got stuff such as dynamic boost and
> classbridge mapping which would've been included in patch and caused mayhem!
>
>
> It's an initial idea...probably has holes i'm sure.  I didn't know whether
> to send it to the entire group.
>
>
> Cheers
> Amin
>
>
>
>
> On Thu, Dec 3, 2009 at 9:26 AM, Emmanuel Bernard <emmanuel at hibernate.org>wrote:
>
>> Sounds good.
>> If you go the interface route then fine
>> If you go the annotation route, use the existing @Factory annotation we
>> have. You can also check the code to see how it's implemented for filter.
>>
>>
>> On 2 déc. 09, at 19:29, Sanne Grinovero wrote:
>>
>>  Hi Amin,
>>> no problem go ahead do some experiments and keep the list informed; to
>>> get that right we will need some different points of view and
>>> situations, my case was very situational and would have needed some
>>> work to integrate :-)
>>>
>>> Sanne
>>>
>>> 2009/12/2 Amin Mohammed-Coleman <aminmc at gmail.com>:
>>>
>>>> Hi Sanne
>>>> Apologies again for bothering you but I just found this issue on JIRA.
>>>>  I'm
>>>> not sure whether to send an email to the mailing list or add a comment
>>>> on
>>>> JIRA but do you have any objections (unless you have started work on it)
>>>> of
>>>> me having a look at this? I've just finished 2 more mapping classes
>>>> which
>>>> Emmanuel is having a look and i'm finishing teh documentation for them.
>>>>  I've finished 2 job interviews so I'm free to take a look at things.  I
>>>> wanted to run this past you first before I made a move or started any
>>>> coding.
>>>>
>>>> Cheers
>>>> Amin
>>>>
>>>
>>
>
>



More information about the hibernate-dev mailing list