Package org.jboss.beans.metadata.plugins

Examples of org.jboss.beans.metadata.plugins.AbstractListMetaData


      AbstractBeanMetaData bmd = new AbstractBeanMetaData(SimpleBean.class.getName());
     
      ArrayList<ParameterMetaData> constructorParams = new ArrayList<ParameterMetaData>();
      AbstractParameterMetaData pmd = new AbstractParameterMetaData();
      pmd.setType("java.util.List");
      AbstractListMetaData collection = new AbstractListMetaData();
      collection.setConfigurator(configurator);
      collection.setElementType("java.lang.String");
      collection.add(new StringValueMetaData("1"));
      collection.add(new StringValueMetaData("2"));
      pmd.setValue(collection);
      constructorParams.add(pmd);
      AbstractConstructorMetaData cmd = new AbstractConstructorMetaData();
      bmd.setConstructor(cmd);
      cmd.setParameters(constructorParams);
View Full Code Here


      KernelConfigurator configurator = kernel.getConfigurator();
     
      AbstractBeanMetaData bmd = new AbstractBeanMetaData();
      AbstractConstructorMetaData cmd = new AbstractConstructorMetaData();
      bmd.setConstructor(cmd);
      AbstractListMetaData vmd = new AbstractListMetaData();
      cmd.setValue(vmd);

      return instantiate(configurator, bmd);
   }
View Full Code Here

      BeanMetaDataBuilder builder = BeanMetaDataBuilderFactory.createBuilder("PropHolder", PropHolder.class.getName());
      builder.addConstructorParameter(String.class.getName(), vfmd1);
      builder.addPropertyMetaData("value", vfmd1);
     
      AbstractListMetaData listMD = new AbstractListMetaData();
      listMD.add(vfmd1);
      // default from 2nd param
      AbstractValueFactoryMetaData vfmd2 = new AbstractValueFactoryMetaData("ldap", "getValue");
      List<ParameterMetaData> parameters2 = new ArrayList<ParameterMetaData>();
      vfmd2.setParameters(parameters2);
      parameters2.add(new AbstractParameterMetaData(String.class.getName(), "foo.bar.key"));
      parameters2.add(new AbstractParameterMetaData(String.class.getName(), "qaz"));
      listMD.add(vfmd2);
      // with transformer
      AbstractValueFactoryMetaData vfmd3 = new AbstractValueFactoryMetaData("ldap", "getValue");
      List<ParameterMetaData> parameters3 = new ArrayList<ParameterMetaData>();
      vfmd3.setParameters(parameters3);
      parameters3.add(new AbstractParameterMetaData(String.class.getName(), "xyz.key"));
      parameters3.add(new AbstractParameterMetaData(String.class.getName(), "xyz"));
      // instantiate transformer
      BeanMetaDataBuilder tranformer = BeanMetaDataBuilderFactory.createBuilder("t", TrimTransformer.class.getName());
      assertNotNull(instantiate(controller, tranformer.getBeanMetaData()));
      parameters3.add(new AbstractParameterMetaData(Transformer.class.getName(), tranformer.getBeanMetaData()));
      listMD.add(vfmd3);
      // null, use default
      AbstractValueFactoryMetaData vfmd4 = new AbstractValueFactoryMetaData("ldap", "getValue", "QWERT");
      List<ParameterMetaData> parameters4 = new ArrayList<ParameterMetaData>();
      vfmd4.setParameters(parameters4);
      parameters4.add(new AbstractParameterMetaData(String.class.getName(), "no.such.key"));
      listMD.add(vfmd4);
      builder.addPropertyMetaData("list", listMD);
      return (PropHolder)instantiate(controller, builder.getBeanMetaData());
   }
View Full Code Here

      builder = BeanMetaDataBuilder.createBuilder("prop", SimpleObjectWithBeans.class.getName());
      builder.addPropertyMetaData("simpleBean", new AbstractBeanMetaData(null, SimpleBeanImpl.class.getName()));
      beans.add((BeanMetaDataFactory)builder.getBeanMetaData());

      builder = BeanMetaDataBuilder.createBuilder("list", SimpleObjectWithBeans.class.getName());
      AbstractListMetaData list = new AbstractListMetaData();
      list.add(new AbstractBeanMetaData(null, SimpleBeanImpl.class.getName()));
      builder.addPropertyMetaData("list", list);
      beans.add((BeanMetaDataFactory)builder.getBeanMetaData());

      builder = BeanMetaDataBuilder.createBuilder("set", SimpleObjectWithBeans.class.getName());
      AbstractSetMetaData set = new AbstractSetMetaData();
View Full Code Here

      StringValueMetaData vmd1 = new StringValueMetaData(string1);
      StringValueMetaData vmd2 = new StringValueMetaData(string2);
      StringValueMetaData vmd3 = new StringValueMetaData(string1);

      AbstractListMetaData smd = new AbstractListMetaData();
      smd.setElementType("java.lang.String");
      smd.add(vmd1);
      smd.add(vmd2);
      smd.add(vmd2); // tests duplicates
      smd.add(vmd3); // tests duplicates

      AbstractPropertyMetaData pmd1 = new AbstractPropertyMetaData("preInstantiatedList", smd);
      properties.add(pmd1);

      return (SimplerBean) instantiate(controller, bmd);
View Full Code Here

      // Add any dependencies based on @DependsOn/depends-on elements
      JBossSessionBean31MetaData sessionBeanMetaData = (JBossSessionBean31MetaData) container.getMetaData();
      String[] dependsOn = sessionBeanMetaData.getDependsOn();
      if (dependsOn != null)
      {
         AbstractListMetaData containerDependencies = new AbstractListMetaData();
         EjbLinkResolver ejbLinkResolver = new EjbLinkResolver();
         for (String dependency : dependsOn)
         {
            // resolve the EJB through the ejb link in depends-on
            JBossEnterpriseBeanMetaData dependencyBean = ejbLinkResolver.resolveEJB(dependency, unit);
            if (dependencyBean == null)
            {
               throw new RuntimeException("Could not resolve bean for @DependsOn/depends-on with ejb-name: "
                     + dependency + " while processing EJB named " + container.getEJBName());
            }
            if (isSingletonBean(dependencyBean) == false)
            {
               throw new RuntimeException("@DependsOn/depends-on can only refer to Singleton beans. "
                     + dependencyBean.getEjbClass() + " is not a singleton bean");
            }
            // when a singleton bean depends on the other singleton bean, we add:
            // 1) A dependency on the target EJB container. This we do by injecting the target EJB container
            // into this container being installed. The injected target containers will then be used
            // to instantiate the target @Depends bean (at the appropriate time)
            // 2) A dependency on each of the exposed JNDI names of the target EJB (so that the
            // target EJB can be accessed through JNDI within the dependent EJB)
           
            // get the exposed JNDI names
            List<String> jndiNames = this.getExposedJNDINames((JBossSessionBean31MetaData) dependencyBean);
            for (String jndiName : jndiNames)
            {
               // add each jndi name as a dependency
               // Note: The dependency resolution of a dependency with prefix JNDIKernelRegistryPlugin.JNDI_DEPENDENCY_PREFIX
               // is handled by JNDIKernelRegistryPlugin, which does a JNDI lookup to see if the dependency is resolved.
               // Effectively, none of the MC beans have to add the jndi name as an explicit supply. So when the
               // corresponding jndi binder binds this jndi name to JNDI tree, the dependency will be marked as resolved
               containerDependencyPolicy.addDependency(JNDIKernelRegistryPlugin.JNDI_DEPENDENCY_PREFIX + jndiName);
            }
            String dependencyBeanContainerName = dependencyBean.getContainerName();
            // create a @Inject
            AbstractInjectionValueMetaData containerDependencyInjection = new AbstractInjectionValueMetaData(dependencyBeanContainerName);
            // add the @Inject to a list which will then be set on the container
            containerDependencies.add(containerDependencyInjection);
         }
         // add the list of @Inject(s)
         containerBMDBuilder.addPropertyMetaData("singletonDependsOn", containerDependencies);
      }
View Full Code Here

   }

   @SuppressWarnings("unchecked")
   public List<ValueMetaData> createList(String listType, String elementType)
   {
      AbstractListMetaData collection = new AbstractListMetaData();
      if (listType != null)
         collection.setType(listType);
      if (elementType != null)
         collection.setElementType(elementType);
      return (List) collection;
   }
View Full Code Here

      super(ListValue.class);
   }

   public ValueMetaData createValueMetaData(ListValue annotation)
   {
      AbstractListMetaData list = new AbstractListMetaData();
      if (isAttributePresent(annotation.clazz()))
         list.setType(annotation.clazz().getName());
      if (isAttributePresent(annotation.elementClass()))
         list.setElementType(annotation.elementClass().getName());
      for(Value value : annotation.value())
         list.add(createValueMetaData(value));
      return list;
   }
View Full Code Here

   }

   @SuppressWarnings("unchecked")
   public List<ValueMetaData> createList(String listType, String elementType)
   {
      AbstractListMetaData collection = new AbstractListMetaData();
      if (listType != null)
         collection.setType(listType);
      if (elementType != null)
         collection.setElementType(elementType);
      return (List) collection;
   }
View Full Code Here

      super(ListValue.class);
   }

   public ValueMetaData createValueMetaData(ListValue annotation)
   {
      AbstractListMetaData list = new AbstractListMetaData();
      if (isAttributePresent(annotation.clazz()))
         list.setType(annotation.clazz());
      if (isAttributePresent(annotation.elementClass()))
         list.setElementType(annotation.elementClass());
      for(Value value : annotation.value())
         list.add(createValueMetaData(value));
      return list;
   }
View Full Code Here

TOP

Related Classes of org.jboss.beans.metadata.plugins.AbstractListMetaData

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.