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

Key: CMP-620
Type: New Feature New Feature
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Shay Banon
Reporter: Piotr Zieleziński
Votes: 0
Watchers: 0
Operations

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

Dynamc Compass - modification of compass mappings during runtime

Created: 15/Apr/08 02:50 AM   Updated: 12/Jun/08 01:59 PM
Component/s: Compass::Core
Affects Version/s: None
Fix Version/s: 2.1.0 M1

File Attachments: 1. Zip Archive dynamic_compass.zip (7 kB)



 Description  « Hide
The OSGi environment supports the functionality to install and uninstall bundles (plugins) during runtime. In some cases those bundles may contain domain classes which are to be indexed by Compass. It would be great to have functionality to add classes to compass mapping during runtime.

Example use case could look like this:
The osgi env starts up, the Compass bundle has no knowledge of any class that it should index. Compass exposes some service that allows adding classes to its configuration, searching and storing in index (mainly Compass interface).
When other bundles with domain classes start they register each class in Compass and from this point Compass can index them. When the are uninstalled they unregister the classes and Compass forgets about them.

I've managed to do something like this by extending LocalCompassBean and some tricks with InternalCompass interface. I have a list of registered classes and when any method from InternalCompass is called I check if any class was added or removed to the config and rebuild Compass if needed. I'm sure You could do this on much lower level and more integrated. I can provide You with some code if needed.

I'm sure such a functionality would be a great asset to Compass and would make it more commonly used especially in newly created software.



 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Shay Banon added a comment - 17/Apr/08 09:19 AM
I agree that this is actually a really cool feature. Actually, the way you implemented it now is how I see it being implemented in Compass. The main reason for this is the fact that adding the ability to add mappings in runtime, something like Compass#addMapping, would really hurt performance because of thread safety concerns as well as complicate the current configuration model in Compass.

Maybe you can attach an example of what you did, and we can move forward from there?


Piotr Zieleziński added a comment - 22/Apr/08 07:34 AM
I cannot attach files to this issue. I will send You an email to the given address with zipped sources.

Shay Banon added a comment - 22/Apr/08 03:57 PM
I have enabled attachments, can you try and load it now.

Piotr Zieleziński added a comment - 24/Apr/08 04:51 AM
The files are:
context.xml - example of spring configuration
6 java files that make Compass a bit more dynamic

I hope javadocs will explain everything.


Shay Banon added a comment - 05/Jun/08 08:01 PM
Added the ability to dynamically manage mappings with Compass. The way to use it is:

Compass compass = ...

....

compass.getConfig().addXXX();
compass.getConfig().removeMappingByXXX();
compass.rebuild();