view src/main/java/org/mpi/openmind/repository/services/ServiceRegistry.java @ 44:23c043a19134

moved servlet lifecycle listener to ismi-richfaces.
author casties
date Thu, 20 Oct 2016 14:04:36 +0200
parents a807a99a7e20
children
line wrap: on
line source

package org.mpi.openmind.repository.services;

import java.io.Serializable;

import org.apache.log4j.Logger;
import org.mpi.openmind.cache.WrapperService;
import org.mpi.openmind.configuration.ConfigurationService;
import org.mpi.openmind.search.SearchService;
import org.mpi.openmind.security.SecurityService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.scheduling.quartz.CronTriggerBean;

/**
 * 
 * @author jurzua
 */
public class ServiceRegistry implements Serializable {
	
	private static final long serialVersionUID = 3883885508641723220L;
	
	public static final String PERSISTENCE_SERVICE = "persistenceService";
	public static final String ONTOLOGY_SERVICE = "ontologyService";
	public static final String IMPORT_SERVICE = "importService";
	public static final String SECURITY_SERVICE = "securityService";
	public static final String CONFIGURATION_SERVICE = "configurationService";
	public static final String SEARCH_SERVICE = "searchService";
	public static final String WRAPPER = "wrapper";
	public static final String CRON = "schedulingCronTrigger";
	
	private static Logger logger = Logger.getLogger(ServiceRegistry.class);
	
	private transient ApplicationContext context;
	private transient WrapperService ws = null;

    public ServiceRegistry() {
        logger.info("Initializing Service Registry");
        context = new ClassPathXmlApplicationContext(new String[] {"openmind-context.xml"});
    }
	
	public WrapperService getWrapper(){
		if(this.ws == null){
			logger.info("Initializing WrapperService");
			this.ws = (WrapperService) this.context.getBean(WRAPPER);
			this.ws.initCache();
		}
		return ws;
	}
	
	/*
	public OntologyService getOntologyService() {
		return (OntologyService) this.context.getBean(ONTOLOGY_SERVICE);
	}*/

	public PersistenceService getPS() {
		return (PersistenceService) context.getBean(PERSISTENCE_SERVICE);
	}

	public SecurityService getSecurityService() {
		return (SecurityService) context.getBean(SECURITY_SERVICE);
	}
	
	public ConfigurationService getConfigurationService(){
		return (ConfigurationService) context.getBean(CONFIGURATION_SERVICE);
	}
	
	
	public SearchService getSearchService(){
		return (SearchService) context.getBean(SEARCH_SERVICE);
	}

	public CronTriggerBean getCron(){
		return (CronTriggerBean) context.getBean(CRON);
	}
	
	public ApplicationContext getApplicationContext() {
	    return this.context;
	}
	
	public static void main(String[] args) {}

}