Tidyup as part of RM-1945 and RM-1946. Attempt to fix the failing build.

Although the Alfresco server starts fine on my machine, there is a timing/dependency issue which means that on Bamboo, ClassificationServiceImpl.initConfiguredClassificationLevels attempts to use the Alfresco DB before it is fully ready.
This check-in changes the service startup so that instead of using a spring init-method, it uses a LifecycleBean to run the initialisation after the server has fully started up.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@99962 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Neil McErlean
2015-03-24 11:32:44 +00:00
parent bcf5516259
commit 5451568517
3 changed files with 81 additions and 2 deletions

View File

@@ -49,4 +49,11 @@
</value>
</property>
</bean>
<bean id="classificationServiceBootstrap"
class="org.alfresco.module.org_alfresco_module_rm.classification.ClassificationServiceBootstrap">
<constructor-arg ref="rm.authenticationUtil"/>
<constructor-arg ref="classificationService"/> <!-- Intentionally using the small 'c' here -->
<constructor-arg ref="TransactionService"/>
</bean>
</beans>

View File

@@ -0,0 +1,72 @@
/*
* Copyright (C) 2005-2015 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.classification;
import org.alfresco.module.org_alfresco_module_rm.util.AuthenticationUtil;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.transaction.TransactionService;
import org.springframework.context.ApplicationEvent;
import org.springframework.extensions.surf.util.AbstractLifecycleBean;
/**
* This class is responsible for initialising any Classification-specific data on server bootstrap.
*
* @author Neil Mc Erlean
* @since 3.0
*/
public class ClassificationServiceBootstrap extends AbstractLifecycleBean
{
private final AuthenticationUtil authenticationUtil;
private final ClassificationServiceImpl classificationService;
private final TransactionService transactionService;
public ClassificationServiceBootstrap(AuthenticationUtil authUtil,
ClassificationServiceImpl cService,
TransactionService txService)
{
this.authenticationUtil = authUtil;
this.classificationService = cService;
this.transactionService = txService;
}
@Override protected void onBootstrap(ApplicationEvent event)
{
authenticationUtil.runAsSystem(new org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork<Void>()
{
public Void doWork()
{
RetryingTransactionCallback<Void> callback = new RetryingTransactionCallback<Void>()
{
public Void execute()
{
classificationService.initConfiguredClassificationLevels();
return null;
}
};
transactionService.getRetryingTransactionHelper().doInTransaction(callback);
return null;
}
});
}
@Override protected void onShutdown(ApplicationEvent event)
{
// Intentionally empty.
}
}

View File

@@ -54,7 +54,7 @@ public class ClassificationServiceImpl extends ServiceBaseImpl
public void setAttributeService(AttributeService service) { this.attributeService = service; }
public void initConfiguredClassificationLevels()
void initConfiguredClassificationLevels()
{
final List<ClassificationLevel> allPersistedLevels = getPersistedLevels();
final List<ClassificationLevel> configuredLevels = getConfiguredLevels();