cancel
Showing results for 
Search instead for 
Did you mean: 

Delaying initialization of spring beans until repository fully initialized

mkolas
Champ in-the-making
Champ in-the-making

I'm working on installing Solr on an Alfresco 4.1.5 instance that was previously exclusively using Lucene.

As part of our existing customizations, we have a number of beans that extend Alfresco's DictionaryListener and execute Lucene queries onDictionaryInit. However, now with Solr, the beans are not bootstrapping properly because Solr does not allow for queries to be executed until the repository is fully initialized.

Is there any sort of analogous class to DictionaryListener, such as RepositoryListener, that would tell me when it is safe to execute queries? Alternatively, is there any sort of known paradigm to delay the initialization of these beans? I've played around with some wait() and sleep() functionality in a bean that my beans "depends-on" in my context, but the solution seems hacky and isn't working any way.

I also know that queries against the database can be executed during repository bootstrap- but those are only available starting in 4.2. Upgrading is an stretch option, but having to upgrade the repository and then modify a bunch of SearchService code isn't really practical for what is right now a simple proof-of-concept.

1 ACCEPTED ANSWER

kaynezhang
World-Class Innovator
World-Class Innovator

You can have several options to implement it

         Option 1,check if there is a bean named “repositoryEndBootstrapBean” defined in alfresco\bootstrap-context.xml,if yes , You can try to set your bean depends-on "repositoryEndBootstrapBean".

         Option 2 ,I think you can try to write a timer in your bean and execute your task once after a period that is long enough for alfresco to start.

View answer in original post

3 REPLIES 3

kaynezhang
World-Class Innovator
World-Class Innovator

You can have several options to implement it

         Option 1,check if there is a bean named “repositoryEndBootstrapBean” defined in alfresco\bootstrap-context.xml,if yes , You can try to set your bean depends-on "repositoryEndBootstrapBean".

         Option 2 ,I think you can try to write a timer in your bean and execute your task once after a period that is long enough for alfresco to start.

mkolas
Champ in-the-making
Champ in-the-making

Thanks, that was exactly what I was looking for! It did exist on my 4.1.5 instance, but I don't see it on a 5.1.1 instance. Any idea why this might have been deprecated?

kaynezhang
World-Class Innovator
World-Class Innovator

You mean bean repositoryEndBootstrapBean?  it still exists in alfresco 5