X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=cms%2Forg.argeo.slc.spring%2Fsrc%2Forg%2Fargeo%2Fslc%2Fcore%2Fexecution%2FDefaultExecutionSpec.java;fp=cms%2Forg.argeo.slc.spring%2Fsrc%2Forg%2Fargeo%2Fslc%2Fcore%2Fexecution%2FDefaultExecutionSpec.java;h=0000000000000000000000000000000000000000;hb=6fc94d69efe089414ac9e63bde3efab1cbf7b7ca;hp=e603f71a72342cdaee9b71788b8a041561b18043;hpb=b36c62642bd0db11b3133b369cc026fd4b7a1ec6;p=gpl%2Fargeo-slc.git diff --git a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/DefaultExecutionSpec.java b/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/DefaultExecutionSpec.java deleted file mode 100644 index e603f71a7..000000000 --- a/cms/org.argeo.slc.spring/src/org/argeo/slc/core/execution/DefaultExecutionSpec.java +++ /dev/null @@ -1,98 +0,0 @@ -package org.argeo.slc.core.execution; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.argeo.slc.execution.ExecutionSpecAttribute; -import org.argeo.slc.execution.RefSpecAttribute; -import org.argeo.slc.execution.RefValueChoice; -import org.springframework.beans.factory.BeanNameAware; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.NoSuchBeanDefinitionException; -import org.springframework.beans.factory.config.BeanDefinition; -import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; -import org.springframework.context.ConfigurableApplicationContext; - -/** Spring based implementation of execution specifications. */ -@Deprecated -public class DefaultExecutionSpec extends org.argeo.slc.runtime.DefaultExecutionSpec - implements BeanNameAware, ApplicationContextAware, InitializingBean { - private static final long serialVersionUID = 5159882223926926539L; - private final static Log log = LogFactory.getLog(DefaultExecutionSpec.class); - private transient ApplicationContext applicationContext; - - public DefaultExecutionSpec() { - super(); - } - - public void setBeanName(String name) { - setName(name); - } - - private ConfigurableListableBeanFactory getBeanFactory() { - return ((ConfigurableApplicationContext) applicationContext).getBeanFactory(); - } - - public void setApplicationContext(ApplicationContext applicationContext) { - this.applicationContext = applicationContext; - } - - public void afterPropertiesSet() throws Exception { - if (getDescription() == null) { - try { - setDescription(getBeanFactory().getBeanDefinition(getName()).getDescription()); - } catch (NoSuchBeanDefinitionException e) { - // silent - } - } - - for (String key : getAttributes().keySet()) { - ExecutionSpecAttribute attr = getAttributes().get(key); - if (attr instanceof RefSpecAttribute) { - RefSpecAttribute rsa = (RefSpecAttribute) attr; - if (rsa.getChoices() == null) { - List choices = buildRefValueChoices(rsa); - rsa.setChoices(choices); - } - if (log.isTraceEnabled()) - log.debug("Spec attr " + key + " has " + rsa.getChoices().size() + " choices"); - } - } - } - - /** - * Generates a list of ref value choices based on the bean available in the - * application context. - */ - protected List buildRefValueChoices(RefSpecAttribute rsa) { - List choices = new ArrayList(); - if (applicationContext == null) { - log.warn("No application context declared," + " cannot scan ref value choices."); - return choices; - } - - beanNames: for (String beanName : getBeanFactory().getBeanNamesForType(rsa.getTargetClass(), true, false)) { - - // Since Spring 3, systemProperties is implicitly defined but has no - // bean definition - if (beanName.equals("systemProperties")) - continue beanNames; - - BeanDefinition bd = getBeanFactory().getBeanDefinition(beanName); - RefValueChoice choice = new RefValueChoice(); - choice.setName(beanName); - choice.setDescription(bd.getDescription()); - if (log.isTraceEnabled()) - log.debug("Found choice " + beanName + " for " + rsa); - - choices.add(choice); - - } - return choices; - } - -}