com.talk2object.plum.interaction.application.Plum Maven / Gradle / Ivy
package com.talk2object.plum.interaction.application;
import org.apache.log4j.Logger;
import com.talk2object.common.ApplicationContextUtils;
import com.talk2object.plum.interaction.session.SessionContext;
import com.talk2object.plum.interaction.session.SessionManager;
import com.talk2object.plum.repository.biz.TransactionExecutor;
import com.talk2object.plum.repository.biz.interafce.Repository;
import com.talk2object.plum.repository.context.RepositoryContextUtils;
import com.talk2object.plum.security.SecurityService;
import com.talk2object.plum.viewgeneration.ViewFactory;
/**
* top object of PLUM framework
*
* @author jack
*
*/
public class Plum {
private final Logger logger = Logger.getLogger(Plum.class);
private TransactionExecutor transactionExecutor;
private ViewFactory viewFactory;
private Repository repository;
private SessionManager sessionManager;
private SecurityService securityService;
@Deprecated
private void initFromApplicationContext() {
transactionExecutor = ApplicationContextUtils.getTransactionExecutor();
viewFactory = PlumApplicationContextUtils.getViewFactory();
repository = RepositoryContextUtils.getRepository();
sessionManager = PlumApplicationContextUtils.getSessionManager();
securityService = PlumApplicationContextUtils.getSecurityService();
}
/**
* refresh all kinds of Contexts.
*/
private void refreshContexts() {
ApplicationContextUtils.setTransactionExecutor(transactionExecutor);
PlumApplicationContextUtils.setViewFactory(viewFactory);
RepositoryContextUtils.setRepository(repository);
PlumApplicationContextUtils.setSessionManager(sessionManager);
PlumApplicationContextUtils.setSecurityService(securityService);
PlumApplicationContextUtils.setPlum(this);
}
public void start() {
refreshContexts();
viewFactory.scanDomainObjects();
}
public void stop() {
logger.info(String.format("try to stop %d UI threads", sessionManager
.getSessionContextList().size()));
for (SessionContext sessionCtx : sessionManager.getSessionContextList()) {
sessionCtx.getView().closeWindow();
}
logger.info("PLUM stopped");
}
public TransactionExecutor getTransactionExecutor() {
return transactionExecutor;
}
public void setTransactionExecutor(TransactionExecutor transactionExecutor) {
this.transactionExecutor = transactionExecutor;
}
public Repository getRepository() {
return repository;
}
public void setRepository(Repository repository) {
this.repository = repository;
}
public ViewFactory getViewFactory() {
return viewFactory;
}
public void setViewFactory(ViewFactory viewFactory) {
this.viewFactory = viewFactory;
}
public SessionManager getSessionManager() {
return sessionManager;
}
public void setSessionManager(SessionManager sessionManager) {
this.sessionManager = sessionManager;
}
public SecurityService getSecurityService() {
return securityService;
}
public void setSecurityService(SecurityService securityService) {
this.securityService = securityService;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy