Package org.jboss.mx.metadata

Examples of org.jboss.mx.metadata.MethodMapper


      if (null == resource)
      {
         throw new IllegalArgumentException("resource cannot be null");
      }

      MethodMapper mmap = new MethodMapper(resource.getClass());
      ReflectedMBeanDispatcher dispatcher = new ReflectedMBeanDispatcher(info, resolver, resource);

      String flag = PropertyAccess.getProperty(OPTIMIZE_REFLECTED_DISPATCHER, "false");
      if (flag.equalsIgnoreCase("true"))
      {
         // FIXME: subclassing for now so I can rely on the reflection based implementation for the parts
         // that aren't implemented yet
         dispatcher = OptimizedMBeanDispatcher.create(info, resource /*, parent classloader */);
      }

      MBeanAttributeInfo[] attributes = info.getAttributes();
      for (int i = 0; i < attributes.length; i++)
      {
         MBeanAttributeInfo attribute = attributes[i];
         Method getter = null;
         Method setter = null;

         if (attribute.isReadable())
         {
            if (attribute instanceof ModelMBeanAttributeInfo)
            {
               ModelMBeanAttributeInfo mmbAttribute = (ModelMBeanAttributeInfo) attribute;
               Descriptor desc = mmbAttribute.getDescriptor();
               if (desc != null && desc.getFieldValue("getMethod") != null)
               {
                  getter = mmap.lookupGetter(mmbAttribute);
                  if (getter == null)
                  {
                     throw new IntrospectionException("no getter method found for attribute: " + attribute.getName());
                  }
               }
            }
            else
            {
               getter = mmap.lookupGetter(attribute);
               if (getter == null)
               {
                  throw new IntrospectionException("no getter method found for attribute: " + attribute.getName());
               }
            }
         }

         if (attribute.isWritable())
         {
            if (attribute instanceof ModelMBeanAttributeInfo)
            {
               ModelMBeanAttributeInfo mmbAttribute = (ModelMBeanAttributeInfo) attribute;
               Descriptor desc = mmbAttribute.getDescriptor();
               if (desc != null && desc.getFieldValue("setMethod") != null)
               {
                  setter = mmap.lookupSetter(mmbAttribute);
                  if (setter == null)
                  {
                     throw new IntrospectionException("no setter method found for attribute: " + attribute.getName());
                  }
               }
            }
            else
            {
               setter = mmap.lookupSetter(attribute);
               if (setter == null)
               {
                  throw new IntrospectionException("no setter method found for attribute: " + attribute.getName());
               }
            }
         }

         dispatcher.bindAttributeAt(i, getter, setter);
      }

      MBeanOperationInfo[] operations = info.getOperations();
      for (int i = 0; i < operations.length; i++)
      {
         MBeanOperationInfo operation = operations[i];
         Method method = mmap.lookupOperation(operation);
         if (method == null)
         {
            throw new IntrospectionException("no method found for operation: " + operation.getName()); // FIXME better error!
         }

View Full Code Here


/*  73 */     if (null == resource)
/*     */     {
/*  75 */       throw new IllegalArgumentException("resource cannot be null");
/*     */     }
/*     */
/*  78 */     MethodMapper mmap = new MethodMapper(resource.getClass());
/*  79 */     ReflectedMBeanDispatcher dispatcher = new ReflectedMBeanDispatcher(info, resolver, resource);
/*     */
/*  81 */     String flag = PropertyAccess.getProperty("jbossmx.optimized.dispatcher", "false");
/*  82 */     if (flag.equalsIgnoreCase("true"))
/*     */     {
/*  86 */       dispatcher = OptimizedMBeanDispatcher.create(info, resource);
/*     */     }
/*     */
/*  89 */     MBeanAttributeInfo[] attributes = info.getAttributes();
/*  90 */     for (int i = 0; i < attributes.length; i++)
/*     */     {
/*  92 */       MBeanAttributeInfo attribute = attributes[i];
/*  93 */       Method getter = null;
/*  94 */       Method setter = null;
/*     */
/*  96 */       if (attribute.isReadable())
/*     */       {
/*  98 */         if ((attribute instanceof ModelMBeanAttributeInfo))
/*     */         {
/* 100 */           ModelMBeanAttributeInfo mmbAttribute = (ModelMBeanAttributeInfo)attribute;
/* 101 */           Descriptor desc = mmbAttribute.getDescriptor();
/* 102 */           if ((desc != null) && (desc.getFieldValue("getMethod") != null))
/*     */           {
/* 104 */             getter = mmap.lookupGetter(mmbAttribute);
/* 105 */             if (getter == null)
/*     */             {
/* 107 */               throw new IntrospectionException("no getter method found for attribute: " + attribute.getName());
/*     */             }
/*     */           }
/*     */         }
/*     */         else
/*     */         {
/* 113 */           getter = mmap.lookupGetter(attribute);
/* 114 */           if (getter == null)
/*     */           {
/* 116 */             throw new IntrospectionException("no getter method found for attribute: " + attribute.getName());
/*     */           }
/*     */         }
/*     */       }
/*     */
/* 121 */       if (attribute.isWritable())
/*     */       {
/* 123 */         if ((attribute instanceof ModelMBeanAttributeInfo))
/*     */         {
/* 125 */           ModelMBeanAttributeInfo mmbAttribute = (ModelMBeanAttributeInfo)attribute;
/* 126 */           Descriptor desc = mmbAttribute.getDescriptor();
/* 127 */           if ((desc != null) && (desc.getFieldValue("setMethod") != null))
/*     */           {
/* 129 */             setter = mmap.lookupSetter(mmbAttribute);
/* 130 */             if (setter == null)
/*     */             {
/* 132 */               throw new IntrospectionException("no setter method found for attribute: " + attribute.getName());
/*     */             }
/*     */           }
/*     */         }
/*     */         else
/*     */         {
/* 138 */           setter = mmap.lookupSetter(attribute);
/* 139 */           if (setter == null)
/*     */           {
/* 141 */             throw new IntrospectionException("no setter method found for attribute: " + attribute.getName());
/*     */           }
/*     */         }
/*     */       }
/*     */
/* 146 */       dispatcher.bindAttributeAt(i, getter, setter);
/*     */     }
/*     */
/* 149 */     MBeanOperationInfo[] operations = info.getOperations();
/* 150 */     for (int i = 0; i < operations.length; i++)
/*     */     {
/* 152 */       MBeanOperationInfo operation = operations[i];
/* 153 */       Method method = mmap.lookupOperation(operation);
/* 154 */       if (method == null)
/*     */       {
/* 156 */         throw new IntrospectionException("no method found for operation: " + operation.getName());
/*     */       }
/*     */
View Full Code Here

TOP

Related Classes of org.jboss.mx.metadata.MethodMapper

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.