
com.terapico.caf.NavigationService Maven / Gradle / Ivy
package com.terapico.caf;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.springframework.beans.MutablePropertyValues;
import org.springframework.beans.PropertyValue;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.config.TypedStringValue;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.terapico.caf.baseelement.MenuItem;
import com.terapico.caf.baseelement.PlainText;
public class NavigationService extends ReflectionTool {
BeanFactory beanFactory;
public NavigationService()
{
}
protected BeanFactory getBeanFactory() {
if (beanFactory == null) {
beanFactory = InternalBeanFactory.getDefaultBeanFactory();
}
return beanFactory;
}
private Map> definitionCache ;
protected void init() {
if(definitionCache!=null){
return;
}
definitionCache = new ConcurrentHashMap>();
SpringBeanFactory springBeanFactory = (SpringBeanFactory) getBeanFactory();
ConfigurableListableBeanFactory internalFactory = springBeanFactory.springFactory();
String[] beanNames = getBeanFactory().getBeanNames();
for (String beanName : beanNames) {
if(beanName.endsWith("DAO")){
continue;
}
try {
definitionCache.put(beanName, createItemsForClass(beanName, internalFactory));
} catch (ClassNotFoundException e) {
this.logInfo("Bean: "+beanName+" fail to load the class "+e.getMessage());
}
}
}
private void logInfo(String string) {
System.out.println(this.getClass().getName()+" "+string);
}
protected MenuItem createItem(String beanName, String methodName) {
MenuItem item = createEmtryItem();
item.setBeanName(beanName);
item.setLink(methodName);
return item;
}
protected MenuItem createEmtryItem() {
MenuItem item = new MenuItem();
return item;
}
protected List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy