Package org.jboss.beans.metadata.plugins

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


      deploymentType.pushInterceptor(classloaderQName, new DefaultElementInterceptor()
      {
         public void add(Object parent, Object child, QName name)
         {
            AbstractKernelDeployment deployment = (AbstractKernelDeployment) parent;
            AbstractClassLoaderMetaData classloader = (AbstractClassLoaderMetaData) child;
            deployment.setClassLoader(classloader);
         }
      });

      // deployment has a list beans
      deploymentType.pushInterceptor(beanQName, new DefaultElementInterceptor()
      {
         public void add(Object parent, Object child, QName name)
         {
            AbstractKernelDeployment deployment = (AbstractKernelDeployment) parent;
            AbstractBeanMetaData bean = (AbstractBeanMetaData) child;
            List beans = deployment.getBeans();
            if (beans == null)
            {
               beans = new ArrayList();
               deployment.setBeans(beans);
            }
            beans.add(bean);
         }
      });

      // deployment has a list beanfactorys
      deploymentType.pushInterceptor(beanFactoryQName, new DefaultElementInterceptor()
      {
         public void add(Object parent, Object child, QName name)
         {
            AbstractKernelDeployment deployment = (AbstractKernelDeployment) parent;
            AbstractBeanMetaData bean = (AbstractBeanMetaData) child;
            List beans = deployment.getBeans();
            if (beans == null)
            {
               beans = new ArrayList();
               deployment.setBeans(beans);
            }
            beans.add(bean);
         }
      });

      // bean binding
      TypeBinding beanType = schemaBinding.getType(beanTypeQName);
      beanType.setHandler(new DefaultElementHandler()
      {
         public Object startElement(Object parent, QName name, ElementBinding element)
         {
            return new AbstractBeanMetaData();
         }

         public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
         {
            AbstractBeanMetaData bean = (AbstractBeanMetaData) o;
            for (int i = 0; i < attrs.getLength(); ++i)
            {
               String localName = attrs.getLocalName(i);
               if ("name".equals(localName))
                  bean.setName(attrs.getValue(i));
               else if ("class".equals(localName))
                  bean.setBean(attrs.getValue(i));
               else if ("mode".equals(localName))
                  bean.setMode(new ControllerMode(attrs.getValue(i)));
            }
         }
      });

      // beanfactory binding
      TypeBinding beanFactoryType = schemaBinding.getType(beanFactoryTypeQName);
      beanFactoryType.setHandler(new DefaultElementHandler()
      {
         public Object startElement(Object parent, QName name, ElementBinding element)
         {
            return new GenericBeanFactoryMetaData();
         }

         public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
         {
            GenericBeanFactoryMetaData bean = (GenericBeanFactoryMetaData) o;
            for (int i = 0; i < attrs.getLength(); ++i)
            {
               String localName = attrs.getLocalName(i);
               if ("name".equals(localName))
                  bean.setName(attrs.getValue(i));
               else if ("class".equals(localName))
                  bean.setBeanClass(attrs.getValue(i));
               else if ("mode".equals(localName))
                  bean.setMode(new ControllerMode(attrs.getValue(i)));
            }
         }
      });

      // bean has a classloader
      beanType.pushInterceptor(classloaderQName, new DefaultElementInterceptor()
      {
         public void add(Object parent, Object child, QName name)
         {
            AbstractBeanMetaData bean = (AbstractBeanMetaData) parent;
            AbstractClassLoaderMetaData classloader = (AbstractClassLoaderMetaData) child;
            bean.setClassLoader(classloader);
         }
      });

      // beanfactory has a classloader
      beanFactoryType.pushInterceptor(classloaderQName, new DefaultElementInterceptor()
      {
         public void add(Object parent, Object child, QName name)
         {
            GenericBeanFactoryMetaData bean = (GenericBeanFactoryMetaData) parent;
            AbstractClassLoaderMetaData classloader = (AbstractClassLoaderMetaData) child;
            bean.setClassLoader(classloader);
         }
      });

      // bean has a constructor
      beanType.pushInterceptor(constructorQName, new DefaultElementInterceptor()
      {
         public void add(Object parent, Object child, QName name)
         {
            AbstractBeanMetaData bean = (AbstractBeanMetaData) parent;
            AbstractConstructorMetaData constructor = (AbstractConstructorMetaData) child;
            bean.setConstructor(constructor);
         }
      });

      // beanfactory has a constructor
      beanFactoryType.pushInterceptor(constructorQName, new DefaultElementInterceptor()
      {
         public void add(Object parent, Object child, QName name)
         {
            GenericBeanFactoryMetaData bean = (GenericBeanFactoryMetaData) parent;
            AbstractConstructorMetaData constructor = (AbstractConstructorMetaData) child;
            bean.setBeanConstructor(constructor);
         }
      });

      // classloader binding
      TypeBinding classloaderType = schemaBinding.getType(classloaderTypeQName);
      configureValueBindings(classloaderType);
      classloaderType.setHandler(new DefaultElementHandler()
      {
         public Object startElement(Object parent, QName name, ElementBinding element)
         {
            return new AbstractClassLoaderMetaData();
         }

         public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
         {
         }
View Full Code Here


            AbstractPropertyMetaData valueMetaData = (AbstractPropertyMetaData) parent;
            valueMetaData.setValue(new AbstractValueMetaData());
         }
         else if (parent instanceof AbstractClassLoaderMetaData)
         {
            AbstractClassLoaderMetaData valueMetaData = (AbstractClassLoaderMetaData) parent;
            valueMetaData.setClassLoader(new AbstractValueMetaData());
         }
         else
         {
            AbstractValueMetaData valueMetaData = (AbstractValueMetaData) parent;
            valueMetaData.setValue(new AbstractValueMetaData());
         }
      }
View Full Code Here

            ValueMetaData value = (ValueMetaData) child;
            valueMetaData.setValue(value);
         }
         else if (parent instanceof AbstractClassLoaderMetaData)
         {
            AbstractClassLoaderMetaData valueMetaData = (AbstractClassLoaderMetaData) parent;
            ValueMetaData value = (ValueMetaData) child;
            valueMetaData.setClassLoader(value);
         }
         else
         {
            AbstractValueMetaData valueMetaData = (AbstractValueMetaData) parent;
            ValueMetaData value = (ValueMetaData) child;
            valueMetaData.setValue(value);
         }
      }
View Full Code Here

      String bean1Type = "org.jboss.test.kernel.dependency.classloader.SimpleBeanImpl";
      AbstractBeanMetaData metaData1 = new AbstractBeanMetaData("VFSBean1", bean1Type);
      HashSet attributes1 = new HashSet();
      attributes1.add(new AbstractPropertyMetaData("string", "String1"));
      metaData1.setProperties(attributes1);
      metaData1.setClassLoader(new AbstractClassLoaderMetaData(vfsCL));

      AbstractBeanMetaData metaData2 = new AbstractBeanMetaData("VFSBean2",
         "org.jboss.test.kernel.dependency.classloader.SimpleBeanWithConstructorClassLoaderImpl");
      HashSet attributes2 = new HashSet();
      attributes2.add(new AbstractPropertyMetaData("string", "String2"));
      metaData2.setProperties(attributes2);
      metaData2.setClassLoader(new AbstractClassLoaderMetaData(vfsCL));
      ArrayList constructor2 = new ArrayList();
      String bean1Iface = "org.jboss.test.kernel.dependency.classloader.SimpleBean";
      AbstractDependencyValueMetaData bean2Depends = new AbstractDependencyValueMetaData("VFSBean1");
      AbstractParameterMetaData param = new AbstractParameterMetaData(bean1Iface, bean2Depends);
      constructor2.add(param);
View Full Code Here

      String bean1Type = "org.jboss.test.kernel.dependency.classloader.SimpleBeanImpl";
      AbstractBeanMetaData metaData1 = new AbstractBeanMetaData("VFSBean1", bean1Type);
      HashSet attributes1 = new HashSet();
      attributes1.add(new AbstractPropertyMetaData("string", "String1"));
      metaData1.setProperties(attributes1);
      metaData1.setClassLoader(new AbstractClassLoaderMetaData(vfsCL));

      AbstractBeanMetaData metaData2 = new AbstractBeanMetaData("VFSBean2",
         "org.jboss.test.kernel.dependency.classloader.SimpleBeanWithConstructorClassLoaderImpl");
      HashSet attributes2 = new HashSet();
      attributes2.add(new AbstractPropertyMetaData("string", "String2"));
      metaData2.setProperties(attributes2);
      metaData2.setClassLoader(new AbstractClassLoaderMetaData(vfsCL));
      ArrayList constructor2 = new ArrayList();
      String bean1Iface = "org.jboss.test.kernel.dependency.classloader.SimpleBean";
      AbstractDependencyValueMetaData bean2Depends = new AbstractDependencyValueMetaData("VFSBean1");
      AbstractParameterMetaData param = new AbstractParameterMetaData(bean1Iface, bean2Depends);
      constructor2.add(param);
View Full Code Here

      String bean1Type = "org.jboss.test.kernel.dependency.classloader.SimpleBeanImpl";
      AbstractBeanMetaData metaData1 = new AbstractBeanMetaData("VFSBean1", bean1Type);
      HashSet attributes1 = new HashSet();
      attributes1.add(new AbstractPropertyMetaData("string", "String1"));
      metaData1.setProperties(attributes1);
      metaData1.setClassLoader(new AbstractClassLoaderMetaData(vfsCL));

      AbstractBeanMetaData metaData2 = new AbstractBeanMetaData("VFSBean2",
         "org.jboss.test.kernel.dependency.classloader.SimpleBeanWithConstructorClassLoaderImpl");
      HashSet attributes2 = new HashSet();
      attributes2.add(new AbstractPropertyMetaData("string", "String2"));
      metaData2.setProperties(attributes2);
      metaData2.setClassLoader(new AbstractClassLoaderMetaData(vfsCL));
      ArrayList constructor2 = new ArrayList();
      String bean1Iface = "org.jboss.test.kernel.dependency.classloader.SimpleBean";
      AbstractDependencyValueMetaData bean2Depends = new AbstractDependencyValueMetaData("VFSBean1");
      AbstractParameterMetaData param = new AbstractParameterMetaData(bean1Iface, bean2Depends);
      constructor2.add(param);
View Full Code Here

         {
            // Hack, if it doesn't have a classloader use the "null" classloader
            // we don't want it to gain itself as the classloader
            BeanMetaData classLoaderBean = (BeanMetaData) classLoader;
            if (classLoaderBean.getClassLoader() == null)
               classLoaderBean.setClassLoader(new AbstractClassLoaderMetaData(new AbstractValueMetaData()));
            result.add((BeanMetaData) classLoader);
         }
      }

      List<BeanMetaDataFactory> factories = getBeanFactories();
      if (factories != null && factories.isEmpty() == false)
      {
         for (BeanMetaDataFactory factory : factories)
         {
            if (factory == null)
               throw new IllegalArgumentException("BeanMetaDataFactory cannot be null.");

            List<BeanMetaData> beans = factory.getBeans();
            if (beans != null && beans.isEmpty() == false)
            {
               for (BeanMetaData bmd : beans)
               {
                  if (bmd == null)
                     throw new IllegalArgumentException("Bean meta data cannot be null.");

                  // check annotations
                  if (annotations != null && annotations.isEmpty() == false)
                  {
                     Set<AnnotationMetaData> annotationsBMD = bmd.getAnnotations();
                     if (annotationsBMD == null)
                     {
                        annotationsBMD = new HashSet<AnnotationMetaData>();
                        bmd.setAnnotations(annotationsBMD);
                     }
                     annotationsBMD.addAll(annotations);
                  }

                  // impl specific
                  if (bmd instanceof AbstractBeanMetaData)
                  {
                     AbstractBeanMetaData bean = (AbstractBeanMetaData)bmd;
                     // set deployment defaults, if not already set per bean
                     if (bean.getCreate() == null && getCreate() != null)
                     {
                        bean.setCreate(getCreate());
                     }
                     if (bean.getStart() == null && getStart() != null)
                     {
                        bean.setStart(getStart());
                     }
                     if (bean.getStop() == null && getStop() != null)
                     {
                        bean.setStop(getStop());
                     }
                     if (bean.getDestroy() == null && getDestroy() != null)
                     {
                        bean.setDestroy(getDestroy());
                     }

                     // controller mode
                     if (bean.getMode() == null && getMode() != null)
                     {
                        bean.setMode(getMode());
                     }
                  }

                  // Use any deployment classloader if present and the bean doesn't have one
                  ClassLoaderMetaData beanClassLoader = bmd.getClassLoader();
                  if (beanClassLoader == null)
                  {
                     ClassLoaderMetaData deploymentClassLoader = getClassLoader();
                     if (deploymentClassLoader != null)
                     {
                        // If the deployment classloader is a bean, replace it with an injection
                        ValueMetaData classLoader = deploymentClassLoader.getClassLoader();
                        if (classLoader instanceof BeanMetaData)
                        {
                           classLoader = new AbstractDependencyValueMetaData(((BeanMetaData) classLoader).getName());
                           beanClassLoader = new AbstractClassLoaderMetaData(classLoader);
                        }
                        else
                        {
                           beanClassLoader = deploymentClassLoader;
                        }
View Full Code Here

    * @param classLoader the classloader value
    * @return the classloader metadata
    */
   protected ClassLoaderMetaData createClassLoaderMetaData(ValueMetaData classLoader)
   {
      return new AbstractClassLoaderMetaData(classLoader);
   }
View Full Code Here

      String bean1Type = "org.jboss.test.kernel.dependency.classloader.SimpleBeanImpl";
      AbstractBeanMetaData metaData1 = new AbstractBeanMetaData("VFSBean1", bean1Type);
      HashSet<PropertyMetaData> attributes1 = new HashSet<PropertyMetaData>();
      attributes1.add(new AbstractPropertyMetaData("string", "String1"));
      metaData1.setProperties(attributes1);
      metaData1.setClassLoader(new AbstractClassLoaderMetaData(vfsCL));

      AbstractBeanMetaData metaData2 = new AbstractBeanMetaData("VFSBean2",
         "org.jboss.test.kernel.dependency.classloader.SimpleBeanWithConstructorClassLoaderImpl");
      HashSet<PropertyMetaData> attributes2 = new HashSet<PropertyMetaData>();
      attributes2.add(new AbstractPropertyMetaData("string", "String2"));
      metaData2.setProperties(attributes2);
      metaData2.setClassLoader(new AbstractClassLoaderMetaData(vfsCL));
      ArrayList<ParameterMetaData> constructor2 = new ArrayList<ParameterMetaData>();
      String bean1Iface = "org.jboss.test.kernel.dependency.classloader.SimpleBean";
      AbstractDependencyValueMetaData bean2Depends = new AbstractDependencyValueMetaData("VFSBean1");
      AbstractParameterMetaData param = new AbstractParameterMetaData(bean1Iface, bean2Depends);
      constructor2.add(param);
View Full Code Here

      String bean1Type = "org.jboss.test.kernel.dependency.classloader.SimpleBeanImpl";
      AbstractBeanMetaData metaData1 = new AbstractBeanMetaData("VFSBean1", bean1Type);
      HashSet<PropertyMetaData> attributes1 = new HashSet<PropertyMetaData>();
      attributes1.add(new AbstractPropertyMetaData("string", "String1"));
      metaData1.setProperties(attributes1);
      metaData1.setClassLoader(new AbstractClassLoaderMetaData(vfsCL));

      AbstractBeanMetaData metaData2 = new AbstractBeanMetaData("VFSBean2",
         "org.jboss.test.kernel.dependency.classloader.SimpleBeanWithConstructorClassLoaderImpl");
      HashSet<PropertyMetaData> attributes2 = new HashSet<PropertyMetaData>();
      attributes2.add(new AbstractPropertyMetaData("string", "String2"));
      metaData2.setProperties(attributes2);
      metaData2.setClassLoader(new AbstractClassLoaderMetaData(vfsCL));
      ArrayList<ParameterMetaData> constructor2 = new ArrayList<ParameterMetaData>();
      String bean1Iface = "org.jboss.test.kernel.dependency.classloader.SimpleBean";
      AbstractDependencyValueMetaData bean2Depends = new AbstractDependencyValueMetaData("VFSBean1");
      AbstractParameterMetaData param = new AbstractParameterMetaData(bean1Iface, bean2Depends);
      constructor2.add(param);
View Full Code Here

TOP

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

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.