-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Possible to paramaterize indexBase in persistence.xml
PostPosted: Mon Nov 30, 2009 6:36 pm 
Newbie

Joined: Thu Sep 17, 2009 5:43 pm
Posts: 7
I'm using Hibernate Search 3.1.1.GA and JPA (hence persistence.xml) and deploying to WebSphere Application Server 6.1.

The deployment will be clustered, and the desired target directories for the search indexes will include the unique node names. Therefore, it would be a huge help if I could include a reference to a WebSphere variable in the indexBase definition in the persistence.xml file. e.g.:
Code:
   <persistence-unit name="PersistenceUnitName" transaction-type="JTA">
      <properties>
         <property name="hibernate.search.default.directory_provider"
            value="org.hibernate.search.store.FSDirectoryProvider" />
         <property name="hibernate.search.default.indexBase"
            value="${LOG_DIR}/lucene/indexes" />
      </properties>
   </persistence-unit>


I haven't hit upon any standard way or any good reference, so I figured I'd ask to see if anyone can tell me if this is even possible?


Top
 Profile  
 
 Post subject: Re: Possible to paramaterize indexBase in persistence.xml
PostPosted: Tue Dec 01, 2009 4:48 pm 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

I guess there is no standard way of doing this. If you want to go down this path you will have to "intercept" the properties before they are used. You could do this either by sub-classing Configuration or AnnotationConfiguration depending on your setup. Hooking into Configuration would allow you to also modify/add other properties.

In case you are only interested in the directory provider, you could also sub-class FSDirectoryProvider. Just override initialize, expand your property and then call super.initalize(). I guess this would be the easiest to solve just this usecase.

--Hardy


Top
 Profile  
 
 Post subject: Re: Possible to paramaterize indexBase in persistence.xml
PostPosted: Thu Dec 10, 2009 2:48 pm 
Newbie

Joined: Thu Sep 17, 2009 5:43 pm
Posts: 7
Thanks for the reply, Hardy.

I went with sub-classing FSDirectoryProvider, and setting a JVM Custom Property in WebSphere that reads the desired WAS variable into a System Property. If such a System Property is found, I reset the indexBase before calling super.initialize().

The biggest pain was figuring out how working around the use of MaskedProperty, where naturally I managed to try every version that called the methods marked Unsupported until I finally RTFM and found a working solution.

Our middleware team is much more happy now. And now that I've figured the trick for setting System Properties via WebSphere out, we have a couple more tools we're using that will use the same strategy. Always like solutions that can be reused!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.