Package org.jboss.beans.metadata.plugins

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


   public static final BeanDependsInterceptor INTERCEPTOR = new BeanDependsInterceptor();

   public void add(Object parent, Object child, QName name)
   {
      AbstractBeanMetaData bean = (AbstractBeanMetaData) parent;
      AbstractDependencyMetaData dependency = (AbstractDependencyMetaData) child;
      Set<DependencyMetaData> depends = bean.getDepends();
      if (depends == null)
      {
         depends = new HashSet<DependencyMetaData>();
         bean.setDepends(depends);
View Full Code Here


      return value;
   }

   public void setValue(QName qname, ElementBinding element, Object owner, Object value)
   {
      AbstractDependencyMetaData depends = (AbstractDependencyMetaData) owner;
      depends.setDependency(value);
   }
View Full Code Here

         ((AbstractBeanMetaData)beanMetaData).setDepends(dependencies);
      }
      List<MetaDataVisitorNode> nodes = new ArrayList<MetaDataVisitorNode>();
      for(String depends : annotation.value())
      {
         AbstractDependencyMetaData dependency = new AbstractDependencyMetaData(depends);
         if (dependencies.add(dependency))
            nodes.add(dependency);
      }
      return nodes;
   }
View Full Code Here

   /** The handler */
   public static final DependsHandler HANDLER = new DependsHandler();

   public Object startElement(Object parent, QName name, ElementBinding element)
   {
      return new AbstractDependencyMetaData();
   }
View Full Code Here

   {
   }
  
   public Object endElement(Object o, QName qName, ElementBinding element)
   {
      AbstractDependencyMetaData x = (AbstractDependencyMetaData) o;
      String name = (String) x.getDependency();
      if (name == null || name.trim().length() == 0)
         throw new IllegalArgumentException("Null or empty dependency.");
      return o;
   }
View Full Code Here

      beanType.pushInterceptor(dependsQName, new DefaultElementInterceptor()
      {
         public void add(Object parent, Object child, QName name)
         {
            AbstractBeanMetaData bean = (AbstractBeanMetaData) parent;
            AbstractDependencyMetaData dependency = (AbstractDependencyMetaData) child;
            Set<DependencyMetaData> depends = bean.getDepends();
            if (depends == null)
            {
               depends = new HashSet<DependencyMetaData>();
               bean.setDepends(depends);
            }
            depends.add(dependency);
         }
      });

      // beanfactory has a set of depends
      beanFactoryType.pushInterceptor(dependsQName, new DefaultElementInterceptor()
      {
         public void add(Object parent, Object child, QName name)
         {
            org.jboss.beans.metadata.plugins.factory.GenericBeanFactoryMetaData bean = (org.jboss.beans.metadata.plugins.factory.GenericBeanFactoryMetaData) parent;
            AbstractDependencyMetaData dependency = (AbstractDependencyMetaData) child;
            Set<DependencyMetaData> depends = bean.getDepends();
            if (depends == null)
            {
               depends = new HashSet<DependencyMetaData>();
               bean.setDepends(depends);
            }
            depends.add(dependency);
         }
      });

      // bean has a set of demands
      beanType.pushInterceptor(demandQName, new DefaultElementInterceptor()
      {
         public void add(Object parent, Object child, QName name)
         {
            AbstractBeanMetaData bean = (AbstractBeanMetaData) parent;
            AbstractDemandMetaData demand = (AbstractDemandMetaData) child;
            Set<DemandMetaData> demands = bean.getDemands();
            if (demands == null)
            {
               demands = new HashSet<DemandMetaData>();
               bean.setDemands(demands);
            }
            demands.add(demand);
         }
      });

      // beanfactory has a set of demands
      beanFactoryType.pushInterceptor(demandQName, new DefaultElementInterceptor()
      {
         public void add(Object parent, Object child, QName name)
         {
            AbstractBeanMetaData bean = (AbstractBeanMetaData) parent;
            AbstractDemandMetaData demand = (AbstractDemandMetaData) child;
            Set<DemandMetaData> demands = bean.getDemands();
            if (demands == null)
            {
               demands = new HashSet<DemandMetaData>();
               bean.setDemands(demands);
            }
            demands.add(demand);
         }
      });

      // bean has a set of supplies
      beanType.pushInterceptor(supplyQName, new DefaultElementInterceptor()
      {
         public void add(Object parent, Object child, QName name)
         {
            AbstractBeanMetaData bean = (AbstractBeanMetaData) parent;
            AbstractSupplyMetaData supply = (AbstractSupplyMetaData) child;
            Set<SupplyMetaData> supplies = bean.getSupplies();
            if (supplies == null)
            {
               supplies = new HashSet<SupplyMetaData>();
               bean.setSupplies(supplies);
            }
            supplies.add(supply);
         }
      });

      // beanfactory has a set of supplies
      beanFactoryType.pushInterceptor(supplyQName, new DefaultElementInterceptor()
      {
         public void add(Object parent, Object child, QName name)
         {
            AbstractBeanMetaData bean = (AbstractBeanMetaData) parent;
            AbstractSupplyMetaData supply = (AbstractSupplyMetaData) child;
            Set<SupplyMetaData> supplies = bean.getSupplies();
            if (supplies == null)
            {
               supplies = new HashSet<SupplyMetaData>();
               bean.setSupplies(supplies);
            }
            supplies.add(supply);
         }
      });

      // property binding
      TypeBinding propertyType = schemaBinding.getType(propertyTypeQName);
      configureValueBindings(propertyType);
      propertyType.setHandler(new DefaultElementHandler()
      {
         public Object startElement(Object parent, QName name, ElementBinding element)
         {
            return new AbstractPropertyMetaData();
         }

         public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
         {
            AbstractPropertyMetaData property = (AbstractPropertyMetaData) o;
            for (int i = 0; i < attrs.getLength(); ++i)
            {
               String localName = attrs.getLocalName(i);
               if ("name".equals(localName))
                  property.setName(attrs.getValue(i));
               else if ("preinstantiate".equals(localName))
                  property.setPreInstantiate(Boolean.parseBoolean(attrs.getValue(i)));
               else if ("class".equals(localName) || "replace".equals(localName) || "trim".equals(localName))
               {
                  StringValueMetaData svmd;
                  ValueMetaData vmd = property.getValue();
                  if (vmd == null || vmd instanceof StringValueMetaData == false)
                  {
                     svmd = new StringValueMetaData();
                     property.setValue(svmd);
                  }
                  else
                  {
                     svmd = (StringValueMetaData)vmd;
                  }
                  if ("class".equals(localName))
                     svmd.setType(attrs.getValue(i));
                  else if ("replace".equals(localName))
                     svmd.setReplace(Boolean.parseBoolean(attrs.getValue(i)));
                  else if ("trim".equals(localName))
                     svmd.setTrim(Boolean.parseBoolean(attrs.getValue(i)));
               }
            }
         }
        
         public Object endElement(Object o, QName qName, ElementBinding element)
         {
            AbstractPropertyMetaData x = (AbstractPropertyMetaData) o;
            String name = x.getName();
            if (name == null || name.trim().length() == 0)
               throw new IllegalArgumentException("Null or empty property name.");
            return o;
         }
      });

      // property can take a value
      propertyType.setSimpleType(new CharactersHandler()
      {
         public Object unmarshal(QName qName, TypeBinding typeBinding, NamespaceContext nsCtx, org.jboss.xb.binding.metadata.ValueMetaData valueMetaData, String value)
         {
            return new StringValueMetaData(value);
         }

         public void setValue(QName qName, ElementBinding element, Object owner, Object value)
         {
            AbstractPropertyMetaData property = (AbstractPropertyMetaData) owner;
            StringValueMetaData svmd = (StringValueMetaData) value;
            ValueMetaData vmd = property.getValue();
            if (vmd != null && vmd instanceof StringValueMetaData)
            {
               StringValueMetaData previous = (StringValueMetaData) vmd;
               svmd.setReplace(previous.isReplace());
               svmd.setTrim(previous.isTrim());
               String type = previous.getType();
               if (type != null)
                  svmd.setType(type);
            }
            property.setValue(svmd);
         }
      });

      // dependency binding
      TypeBinding dependsType = schemaBinding.getType(dependsTypeQName);
      dependsType.setHandler(new DefaultElementHandler()
      {
         public Object startElement(Object parent, QName name, ElementBinding element)
         {
            return new AbstractDependencyMetaData();
         }

         public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
         {
         }
        
         public Object endElement(Object o, QName qName, ElementBinding element)
         {
            AbstractDependencyMetaData x = (AbstractDependencyMetaData) o;
            String name = (String) x.getDependency();
            if (name == null || name.trim().length() == 0)
               throw new IllegalArgumentException("Null or empty dependency.");
            return o;
         }
      });

      // depends can take a value
      dependsType.setSimpleType(new CharactersHandler()
      {
         public Object unmarshal(QName qName, TypeBinding typeBinding, NamespaceContext nsCtx, org.jboss.xb.binding.metadata.ValueMetaData valueMetaData, String value)
         {
            return value;
         }

         public void setValue(QName qname, ElementBinding element, Object owner, Object value)
         {
            AbstractDependencyMetaData depends = (AbstractDependencyMetaData) owner;
            depends.setDependency(value);
         }
      });

      // demand binding
      TypeBinding demandType = schemaBinding.getType(demandTypeQName);
View Full Code Here

      if (dependencies == null)
      {
         dependencies = new HashSet<DependencyMetaData>();
         beanMetaData.setDepends(dependencies);
      }
      dependencies.add(new AbstractDependencyMetaData(dependency));
      return this;
   }
View Full Code Here

      if (dependencies == null)
      {
         dependencies = new HashSet<DependencyMetaData>();
         beanMetaData.setDepends(dependencies);
      }
      dependencies.add(new AbstractDependencyMetaData(dependency));
      return this;
   }
View Full Code Here

/* 57 */       ((AbstractBeanMetaData)beanMetaData).setDepends(dependencies);
/*    */     }
/* 59 */     List nodes = new ArrayList();
/* 60 */     for (String depends : annotation.value())
/*    */     {
/* 62 */       AbstractDependencyMetaData dependency = new AbstractDependencyMetaData(depends);
/* 63 */       if (dependencies.add(dependency))
/* 64 */         nodes.add(dependency);
/*    */     }
/* 66 */     return nodes;
/*    */   }
View Full Code Here

/* 46 */     return value;
/*    */   }
/*    */
/*    */   public void setValue(QName qname, ElementBinding element, Object owner, Object value)
/*    */   {
/* 51 */     AbstractDependencyMetaData depends = (AbstractDependencyMetaData)owner;
/* 52 */     depends.setDependency(value);
/*    */   }
View Full Code Here

TOP

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

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.