All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.antelopeframework.remoting.server.HessianServiceGroupFactory Maven / Gradle / Ivy

There is a newer version: 1.1.5
Show newest version
package com.github.antelopeframework.remoting.server;

import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.core.Ordered;
import org.springframework.core.PriorityOrdered;

import com.github.antelopeframework.remoting.server.auth.RemoteCallAuthenticate;

import lombok.Getter;
import lombok.Setter;

public class HessianServiceGroupFactory implements BeanFactoryPostProcessor, PriorityOrdered {

	@Setter
	private Map, Object> services = new HashMap<>();  
	
	@Getter
	@Setter
	private int order = Ordered.LOWEST_PRECEDENCE;
	
	@Setter
	private RemoteCallAuthenticate remoteCallAuthenticate;

	@Override
	public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
		if (services == null || services.isEmpty()) {
			return;
		}
		
		DefaultListableBeanFactory listableBeanFactory = (DefaultListableBeanFactory) beanFactory;
		
		for (Entry, Object> entry : services.entrySet()) {
			String beanName = "/" + entry.getKey().getName();

			BeanDefinitionBuilder beanDefinitionBuilder= BeanDefinitionBuilder.rootBeanDefinition(HessianServiceExporter.class);
            beanDefinitionBuilder.addPropertyValue("serviceInterface", entry.getKey());
            beanDefinitionBuilder.addPropertyValue("service", entry.getValue());
            beanDefinitionBuilder.addPropertyValue("remoteCallAuthenticate", remoteCallAuthenticate);
            
            listableBeanFactory.registerBeanDefinition(beanName, beanDefinitionBuilder.getBeanDefinition());
		}
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy