Fix lifecycle instance initiating issue

feature/appm-store/pbac
lasanthaDLPDS 6 years ago
parent 911bc6f9a0
commit 0cb26066c5

@ -927,6 +927,8 @@ public class ApplicationManagerImpl implements ApplicationManager {
throw new ApplicationManagementException("Failed to get application and application management", e);
} catch (LifeCycleManagementDAOException e) {
throw new ApplicationManagementException("Failed to get lifecycle state from database", e);
} finally {
ConnectionManagerUtil.closeDBConnection();
}
return lifecycleState;
}

@ -77,6 +77,13 @@ public class ApplicationManagementServiceComponent {
ApplicationManagementDAOFactory.init(dataSourceName);
// ApplicationManagementDAOFactory.initDatabases();
List<LifecycleState> lifecycleStates = ConfigurationManager.getInstance().
getConfiguration().getLifecycleStates();
LifecycleStateManger lifecycleStateManger = ApplicationManagementUtil.getLifecycleStateMangerInstance();
lifecycleStateManger.init(lifecycleStates);
DataHolder.getInstance().setLifecycleStateManger(lifecycleStateManger);
bundleContext.registerService(LifecycleStateManger.class.getName(), lifecycleStateManger, null);
ApplicationManager applicationManager = ApplicationManagementUtil.getApplicationManagerInstance();
DataHolder.getInstance().setApplicationManager(applicationManager);
bundleContext.registerService(ApplicationManager.class.getName(), applicationManager, null);
@ -94,12 +101,6 @@ public class ApplicationManagementServiceComponent {
DataHolder.getInstance().setApplicationStorageManager(applicationStorageManager);
bundleContext.registerService(ApplicationStorageManager.class.getName(), applicationStorageManager, null);
List<LifecycleState> lifecycleStates = ConfigurationManager.getInstance().
getConfiguration().getLifecycleStates();
LifecycleStateManger lifecycleStateManger = new LifecycleStateManger(lifecycleStates);
DataHolder.getInstance().setLifecycleStateManger(lifecycleStateManger);
bundleContext.registerService(LifecycleStateManger.class.getName(), lifecycleStateManger, null);
UIConfiguration uiConfiguration = ConfigurationManager.getInstance().
getConfiguration().getUiConfiguration();
ConfigManager configManager = new ConfigManagerImpl(uiConfiguration);

@ -15,7 +15,7 @@ public class LifecycleStateManger {
private Map<String, State> lifecycleStates;
public LifecycleStateManger(List<LifecycleState> states) {
public void init(List<LifecycleState> states){
lifecycleStates = new HashMap<>();
for (LifecycleState s : states) {
if (s.getProceedingStates() != null) {

@ -27,6 +27,7 @@ import org.wso2.carbon.device.application.mgt.common.services.ReviewManager;
import org.wso2.carbon.device.application.mgt.common.services.SubscriptionManager;
import org.wso2.carbon.device.application.mgt.core.config.ConfigurationManager;
import org.wso2.carbon.device.application.mgt.core.config.Extension;
import org.wso2.carbon.device.application.mgt.core.lifecycle.LifecycleStateManger;
import java.lang.reflect.Constructor;
@ -63,6 +64,12 @@ public class ApplicationManagementUtil {
return getInstance(extension, ApplicationStorageManager.class);
}
public static LifecycleStateManger getLifecycleStateMangerInstance() throws InvalidConfigurationException {
ConfigurationManager configurationManager = ConfigurationManager.getInstance();
Extension extension = configurationManager.getExtension(Extension.Name.LifecycleStateManager);
return getInstance(extension, LifecycleStateManger.class);
}
private static <T> T getInstance(Extension extension, Class<T> cls) throws InvalidConfigurationException {
try {
Class theClass = Class.forName(extension.getClassName());

@ -25,7 +25,8 @@ public class LifecycleManagementTest {
ConfigurationManager configurationManager = ConfigurationManager.getInstance();
Configuration configuration = configurationManager.getConfiguration();
lifecycleStates = configuration.getLifecycleStates();
lifecycleStateManger = new LifecycleStateManger(lifecycleStates);
lifecycleStateManger = new LifecycleStateManger();
lifecycleStateManger.init(lifecycleStates);
}
@Test

Loading…
Cancel
Save