Пример #1
0
 internal BeanInfo PutBeanInfo(Class type, BeanInfo info)
 {
     if (this.BeanInfoCache == null)
     {
         this.BeanInfoCache = new WeakHashMap <>();
     }
     return(this.BeanInfoCache[type] = info);
 }
Пример #2
0
        private static BeanInfo getExplicitBeanInfo(java.lang.Class beanClass)
        {
            String beanInfoClassName = beanClass.getName() + "BeanInfo"; //$NON-NLS-1$

            try
            {
                return(loadBeanInfo(beanInfoClassName, beanClass));
            }
            catch (Exception)
            {
                // fall through
            }

            int    index        = beanInfoClassName.lastIndexOf('.');
            String beanInfoName = index >= 0 ? beanInfoClassName
                                  .substring(index + 1) : beanInfoClassName;
            BeanInfo       theBeanInfo    = null;
            BeanDescriptor beanDescriptor = null;

            for (int i = 0; i < searchPath.Length; i++)
            {
                beanInfoClassName = searchPath[i] + "." + beanInfoName; //$NON-NLS-1$
                try
                {
                    theBeanInfo = loadBeanInfo(beanInfoClassName, beanClass);
                }
                catch (Exception)
                {
                    // ignore, try next one
                    continue;
                }
                beanDescriptor = theBeanInfo.getBeanDescriptor();
                if (beanDescriptor != null &&
                    beanClass == beanDescriptor.getBeanClass())
                {
                    return(theBeanInfo);
                }
            }
            if (new java.lang.Class(typeof(BeanInfo)).isAssignableFrom(beanClass))
            {
                try
                {
                    return(loadBeanInfo(beanClass.getName(), beanClass));
                }
                catch (Exception)
                {
                    // fall through
                }
            }
            return(null);
        }
Пример #3
0
        /// <summary> init is responsible for checking the class to make sure
        /// it implements addPropertyChangeListener(java.beans.PropertyChangeListener)
        /// and removePropertyChangeListener(java.beans.PropertyChangeListener).
        /// We don't require the classes extend PropertyChangeSupport.
        /// </summary>
        public void init()
        {
            try
            {
                INFO = Introspector.getBeanInfo(OBJECT_CLASS);
                // we have to filter out the class PropertyDescriptor
                PropertyInfo[] pd   = INFO.getPropertyDescriptors();
                List <Object>  list = new List <Object>();
                for (int idx = 0; idx < pd.Length; idx++)
                {
                    if (pd[idx].Name.Equals("class"))
                    {
                        // don't Add
                    }
                    else
                    {
                        // we map the methods using the PropertyDescriptor.getName for
                        // the key and the PropertyDescriptor as the value
                        methods.Put(pd[idx].Name, pd[idx]);
                        list.Add(pd[idx]);
                    }
                }
                PropertyInfo[] newpd = new PropertyInfo[list.Count];

                list.CopyTo(newpd, 0);
                PROPS = (PropertyInfo[])newpd;
                // logic for filtering the PropertyDescriptors
                if (ObjectFilter.lookupFilter(OBJECT_CLASS) != null)
                {
                    // Remove the props that should be invisible
                    BeanFilter bf = ObjectFilter.lookupFilter(OBJECT_CLASS);
                    PROPS = bf.filter(PROPS);
                }
                if (checkBean())
                {
                    ISBEAN = true;
                }
                // we clean up the array and List<Object>
                list.Clear();
                pd = null;
            }
            catch (System.Exception e)
            {
                // we should log this and throw an exception
            }
        }
Пример #4
0
        private static StandardBeanInfo getBeanInfoImpl(java.lang.Class beanClass, java.lang.Class stopClass,
                                                        int flags)
        {//throws IntrospectionException {
            BeanInfo explicitInfo = null;

            if (flags == USE_ALL_BEANINFO)
            {
                explicitInfo = getExplicitBeanInfo(beanClass);
            }
            StandardBeanInfo beanInfo = new StandardBeanInfo(beanClass, explicitInfo, stopClass);

            if (beanInfo.additionalBeanInfo != null)
            {
                for (int i = beanInfo.additionalBeanInfo.Length - 1; i >= 0; i--)
                {
                    BeanInfo info = beanInfo.additionalBeanInfo[i];
                    beanInfo.mergeBeanInfo(info, true);
                }
            }

            // recursive get beaninfo for super classes
            java.lang.Class beanSuperClass = beanClass.getSuperclass();
            if (beanSuperClass != stopClass)
            {
                if (beanSuperClass == null)
                {
                    throw new IntrospectionException(
                              "Stop class is not super class of bean class"); //$NON-NLS-1$
                }
                int superflags = flags == IGNORE_IMMEDIATE_BEANINFO ? USE_ALL_BEANINFO
                        : flags;
                BeanInfo superBeanInfo = getBeanInfoImpl(beanSuperClass, stopClass,
                                                         superflags);
                if (superBeanInfo != null)
                {
                    beanInfo.mergeBeanInfo(superBeanInfo, false);
                }
            }
            return(beanInfo);
        }
Пример #5
0
        /// <summary> init is responsible for checking the class to make sure
        /// it implements addPropertyChangeListener(java.beans.PropertyChangeListener)
        /// and removePropertyChangeListener(java.beans.PropertyChangeListener).
        /// We don't require the classes extend PropertyChangeSupport.
        /// </summary>
        public void init()
        {
            try
            {
                INFO = Introspector.getBeanInfo(OBJECT_CLASS);
                // we have to filter out the class PropertyDescriptor
                PropertyInfo[] pd = INFO.getPropertyDescriptors();
                List<Object> list = new List<Object>();
                for (int idx = 0; idx < pd.Length; idx++)
                {
                    if (pd[idx].Name.Equals("class"))
                    {
                        // don't Add
                    }
                    else
                    {
                        // we map the methods using the PropertyDescriptor.getName for
                        // the key and the PropertyDescriptor as the value
                        methods.Put(pd[idx].Name, pd[idx]);
                        list.Add(pd[idx]);
                    }
                }
                PropertyInfo[] newpd = new PropertyInfo[list.Count];

                list.CopyTo(newpd,0);
                PROPS = (PropertyInfo[])newpd;
                // logic for filtering the PropertyDescriptors
                if (ObjectFilter.lookupFilter(OBJECT_CLASS) != null)
                {
                    // Remove the props that should be invisible
                    BeanFilter bf = ObjectFilter.lookupFilter(OBJECT_CLASS);
                    PROPS = bf.filter(PROPS);
                }
                if (checkBean())
                {
                    ISBEAN = true;
                }
                // we clean up the array and List<Object>
                list.Clear();
                pd = null;
            }
            catch (System.Exception e)
            {
                // we should log this and throw an exception
            }
        }
Пример #6
0
 internal void mergeBeanInfo(BeanInfo beanInfo, bool force)
 {
 }
Пример #7
0
 internal StandardBeanInfo(java.lang.Class beanClass, BeanInfo explicitBeanInformations, java.lang.Class stopClass)
 {//throws IntrospectionException {
     this.beanClass = beanClass;
 }