SourceForge.net Logo
Main Overview Wiki Issues Forum Build Fisheye
Issue Details (XML | Word | Printable)

Key: CMP-752
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Shay Banon
Reporter: Joe Zulli
Votes: 1
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Compass

Make using LockFactoryProviders more spring friendly.

Created: 22/Oct/08 02:02 PM   Updated: 22/Oct/08 04:18 PM
Component/s: Compass::Core, Compass::Spring
Affects Version/s: 2.1.0 RC
Fix Version/s: 2.1.0 GA

Environment: Java 1.5, OS X


 Description  « Hide
The current mechanism for adding your own custom LockFactory or LockFactoryProvider works well when outside of Spring, but has limitations when using Spring. Currently, to use a custom lock factory you do so like this:

<bean id="compass" class="org.compass.spring.LocalCompassBean">
<property name="compassSettings">
<props>
<prop key="compass.engine.store.lockFactory.type">com.mycompany.MyCustomLockFactory</prop>
...
</props>
</property>
</bean>

With this method, it is Compass, not Spring that instantiates my custom lock factory bean. This means that my bean has to have a default, empty constructor, and I cannot take advantage of Spring's dependency injection.

For example, I want to create a custom lock factory that uses named locks in a database to facilitate locking. I'd like my DatabaseLockFactory to be a singleton with a JDBC DataSource injected into it. So the configuration would look something like:

<bean id="compass" class="org.compass.spring.LocalCompassBean">
<property name="lockFactory"><ref bean="myLockFactory"/></property>
</property>
</bean>

I'm all for backwards compatibility, so maybe we can have this new way of injecting the lock factory in in addition to the current method.



 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Shay Banon added a comment - 22/Oct/08 04:18 PM
I enabled the injection of actual instance of LockFactory or LockFactoryProvider using the settings property (there are other components of Compass you can do just that, such as analyzers, the lock factory got missed when I added this feature). Here is how you use it:

<bean id="compass" class="org.compass.spring.LocalCompassBean">
<property name="settings">
<props>
<prop key="compass.engine.store.lockFactory.type"><ref ... /></prop>
...
</props>
</property>
</bean>