Package org.springframework.ide.eclipse.beans.core.model

Examples of org.springframework.ide.eclipse.beans.core.model.IBean


   */
  private static void addBeanReferencesForValue(IModelElement element, Object value, IModelElement context,
      Set<BeansConnection> references, Set<IBean> referencedBeans, boolean recursive) {
    if (value instanceof IBeanReference) {
      String beanName = ((IBeanReference) value).getBeanName();
      IBean bean = getBean(beanName, context);
      if (addBeanReference(BeanType.STANDARD, element, bean, context, references, referencedBeans) && recursive) {
        addBeanReferencesForBean(bean, context, recursive, references, referencedBeans);
      }
    }
    else if (value instanceof IBeansList) {

      // Add bean property's interceptors
      if (element instanceof IBeanProperty && element.getElementName().equals("interceptorNames")) {
        IType type = getBeanType((IBean) element.getElementParent(), context);
        if (type != null) {
          if (type.getFullyQualifiedName().equals("org.springframework.aop.framework.ProxyFactoryBean")) {
            for (IModelElement child : ((IBeansList) value).getElementChildren()) {
              if (child instanceof IBeansTypedString) {
                IBean interceptor = getBean(((IBeansTypedString) child).getString(), context);
                if (addBeanReference(BeanType.INTERCEPTOR, element, interceptor, context, references,
                    referencedBeans) && recursive) {
                  addBeanReferencesForBean(interceptor, context, recursive, references,
                      referencedBeans);
                }
View Full Code Here


      // Add referenced beans from bean element
      Bean bean = (Bean) element;

      // For a child bean add the parent bean
      if (bean.isChildBean()) {
        IBean parentBean = getBean(bean.getParentName(), context);
        if (addBeanReference(BeanType.PARENT, bean, parentBean, context, references, referencedBeans)
            && recursive) {
          // Now add all parent beans and all beans which are
          // referenced by the parent beans
          // The HashSet is used to detect a cycle
          Set<String> beanNames = new HashSet<String>();
          beanNames.add(bean.getElementName());
          beanNames.add(parentBean.getElementName());
          while (parentBean != null && parentBean.isChildBean()) {
            String parentName = parentBean.getParentName();
            if (beanNames.contains(parentName)) {
              // break from cycle
              break;
            }
            beanNames.add(parentName);
            parentBean = getBean(parentName, context);
            if (addBeanReference(BeanType.PARENT, bean, parentBean, context, references, referencedBeans)
                && recursive) {
              addBeanReferencesForBean(parentBean, context, recursive, references, referencedBeans);
            }
          }
        }
      }

      // Get bean's merged or standard bean definition
      AbstractBeanDefinition bd;
      if (recursive) {
        bd = (AbstractBeanDefinition) getMergedBeanDefinition(bean, context);
      }
      else {
        bd = (AbstractBeanDefinition) (bean).getBeanDefinition();
      }

      // Add bean's factoy bean
      if (bd.getFactoryBeanName() != null) {
        IBean factoryBean = getBean(bd.getFactoryBeanName(), context);
        if (addBeanReference(BeanType.FACTORY, bean, factoryBean, context, references, referencedBeans)
            && recursive) {
          addBeanReferencesForBean(factoryBean, context, recursive, references, referencedBeans);
        }
      }

      // Add bean's depends-on beans
      if (bd.getDependsOn() != null) {
        for (String dependsOnBeanId : bd.getDependsOn()) {
          IBean dependsOnBean = getBean(dependsOnBeanId, context);
          if (addBeanReference(BeanType.DEPENDS_ON, bean, dependsOnBean, context, references, referencedBeans)
              && recursive) {
            addBeanReferencesForBean(dependsOnBean, context, recursive, references, referencedBeans);
          }
        }
      }

      // Add beans from bean's MethodOverrides
      if (!bd.getMethodOverrides().isEmpty()) {
        for (Object methodOverride : bd.getMethodOverrides().getOverrides()) {
          if (methodOverride instanceof LookupOverride) {
            String beanName = ((LookupOverride) methodOverride).getBeanName();
            IBean overrideBean = getBean(beanName, context);
            if (addBeanReference(BeanType.METHOD_OVERRIDE, bean, overrideBean, context, references,
                referencedBeans) && recursive) {
              addBeanReferencesForBean(overrideBean, context, recursive, references, referencedBeans);
            }
          }
          else if (methodOverride instanceof ReplaceOverride) {
            String beanName = ((ReplaceOverride) methodOverride).getMethodReplacerBeanName();
            IBean overrideBean = getBean(beanName, context);
            if (addBeanReference(BeanType.METHOD_OVERRIDE, bean, overrideBean, context, references,
                referencedBeans) && recursive) {
              addBeanReferencesForBean(overrideBean, context, recursive, references, referencedBeans);
            }
          }
View Full Code Here

      type = extractTypeFromFactoryMethod(bd, type);
    }
    // 2. factory-method on factory-bean
    else if (bd.getFactoryMethodName() != null && bd.getFactoryBeanName() != null) {
      try {
        IBean factoryB = getBeanWithConfigSets(bd.getFactoryBeanName(), beansConfig);
        if (factoryB != null) {
          BeanDefinition factoryBd = BeansModelUtils.getMergedBeanDefinition(factoryB, null);
          IType factoryBeanType = extractBeanClass(factoryBd, bean, factoryBd.getBeanClassName(), beansConfig);
          if (factoryBeanType != null) {
            type = extractTypeFromFactoryMethod(bd, factoryBeanType);
View Full Code Here

      }
    }
    // 2. factory-method on factory-bean
    else if (bd.getFactoryMethodName() != null && bd.getFactoryBeanName() != null) {
      try {
        IBean factoryB = getBeanWithConfigSets(bd.getFactoryBeanName(), beansConfig);
        if (factoryB != null) {
          BeanDefinition factoryBd = BeansModelUtils.getMergedBeanDefinition(factoryB, null);
          String factoryBeanTypeName = extractBeanClassAsString(factoryBd, bean, factoryBd.getBeanClassName(), beansConfig);
          if (factoryBeanTypeName != null) {
            IType factoryBeanType = JdtUtils.getJavaType(BeansModelUtils.getProject(bean).getProject(), factoryBeanTypeName);
View Full Code Here

    allowedRefs.put("nestedTestBean1", new Integer[] { 317 });
    allowedRefs.put("nestedTestBean2", new Integer[] { 317 });

    AutowireDependencyProvider provider = new AutowireDependencyProvider(config, config);
    Map<IBean, Set<IBeanReference>> references = provider.resolveAutowiredDependencies();
    IBean bean = BeansModelUtils.getBean("annotatedBean", config);

    assertEquals(1, references.size());
    assertTrue(references.containsKey(bean));

    Set<IBeanReference> refs = references.get(bean);
View Full Code Here

    allowedRefs.put("nestedTestBean1", new Integer[] { 361 });
    allowedRefs.put("nestedTestBean2", new Integer[] { 361 });

    AutowireDependencyProvider provider = new AutowireDependencyProvider(config, config);
    Map<IBean, Set<IBeanReference>> references = provider.resolveAutowiredDependencies();
    IBean bean = BeansModelUtils.getBean("annotatedBean", config);

    assertEquals(1, references.size());
    assertTrue(references.containsKey(bean));

    Set<IBeanReference> refs = references.get(bean);
View Full Code Here

    allowedRefs.put("testBean1", new Integer[] { 394 });
    allowedRefs.put("testBean2", new Integer[] { 394 });

    AutowireDependencyProvider provider = new AutowireDependencyProvider(config, config);
    Map<IBean, Set<IBeanReference>> references = provider.resolveAutowiredDependencies();
    IBean bean = BeansModelUtils.getBean("annotatedBean", config);

    assertEquals(1, references.size());
    assertTrue(references.containsKey(bean));

    Set<IBeanReference> refs = references.get(bean);
View Full Code Here

    allowedRefs.put("testBean1", new Integer[] { 407 });
    allowedRefs.put("testBean2", new Integer[] { 407 });

    AutowireDependencyProvider provider = new AutowireDependencyProvider(config, config);
    Map<IBean, Set<IBeanReference>> references = provider.resolveAutowiredDependencies();
    IBean bean = BeansModelUtils.getBean("annotatedBean", config);

    assertEquals(1, references.size());
    assertTrue(references.containsKey(bean));

    Set<IBeanReference> refs = references.get(bean);
View Full Code Here

        .toArray(new IPropertyDescriptor[descriptors.size()]);
  }

  public Object getPropertyValue(Object id) {
    if (P_ID_BEAN.equals(id)) {
      IBean bean = (IBean) constructorArg.getElementParent();
      if (bean.isRootBean()) {
        return new RootBeanProperties(bean);
      } else if (bean.isChildBean()) {
        return new ChildBeanProperties(bean);
      } else {
        // FIXME add factory bean support
        // return new FactoryBeanProperties(bean);
      }
View Full Code Here

    Map<String, Integer[]> allowedRefs = new HashMap<String, Integer[]>();
    allowedRefs.put("testBean", new Integer[] { 423 });

    AutowireDependencyProvider provider = new AutowireDependencyProvider(config, config);
    Map<IBean, Set<IBeanReference>> references = provider.resolveAutowiredDependencies();
    IBean bean = BeansModelUtils.getBean("annotatedBean", config);

    assertEquals(1, references.size());
    assertTrue(references.containsKey(bean));

    Set<IBeanReference> refs = references.get(bean);
View Full Code Here

TOP

Related Classes of org.springframework.ide.eclipse.beans.core.model.IBean

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.