Package javax.management.openmbean

Examples of javax.management.openmbean.OpenMBeanAttributeInfo


      mbeanInfo = (OpenMBeanInfo) mbeanServerConnection.getMBeanInfo(objectName);
      Map<String, OpenMBeanAttributeInfo> attributesMap = new HashMap<String, OpenMBeanAttributeInfo>();
      MBeanAttributeInfo[] attributes = mbeanInfo.getAttributes();
      for (int i = 0; i < attributes.length; ++i)
      {
         OpenMBeanAttributeInfo openAttribute = (OpenMBeanAttributeInfo) attributes[i];
         attributesMap.put(openAttribute.getName(), openAttribute);
      }
      MBeanOperationInfo[] operations = mbeanInfo.getOperations();
     
      Map<Method, Action> result = new HashMap<Method, Action>();

      Class[] interfaces = proxy.getClass().getInterfaces();
      for (int i = 0; i < interfaces.length; ++i)
      {
         if (NotificationBroadcaster.class.isAssignableFrom(interfaces[i]))
         {
            result.put(ADD_NOTIFICATION_LISTENER, new AddNotificationListenerAction());
            result.put(GET_NOTIFICATION_INFO, new GetNotificationInfoAction());
            result.put(REMOVE_NOTIFICATION_LISTENER, new RemoveNotificationListenerAction());
            result.put(REMOVE_NOTIFICATION_LISTENER_TRIPLET, new RemoveNotificationListenerTripletAction());
         }
         else
         {
            Method[] methods = interfaces[i].getMethods();
            for (Method method : methods)
            {
               String methodName = method.getName();
               Class returnType = method.getReturnType();
               Class[] parameterTypes = method.getParameterTypes();

               // Getter
               if (methodName.startsWith("get"&&
                   methodName.length() > 3 &&
                   Void.TYPE.equals(returnType) == false &&
                   parameterTypes.length == 0)
               {
                  String name = methodName.substring(3);
                  OpenMBeanAttributeInfo attribute = attributesMap.get(name);
                  if (attribute != null)
                  {
                     Type type = method.getGenericReturnType();
                     result.put(method, new GetAction(attribute, type));
                     continue;
                  }
               }
               // Getter (is)
               else if(methodName.startsWith("is"&&
                     methodName.length() > 2 &&
                     Boolean.TYPE.equals(returnType) &&
                     parameterTypes.length == 0)
               {
                  String name = methodName.substring(2);
                  OpenMBeanAttributeInfo attribute = attributesMap.get(name);
                  if (attribute != null)
                  {
                     Type type = method.getGenericReturnType();
                     result.put(method, new GetAction(attribute, type));
                     continue;
                  }
               }
               // Setter
               else if(methodName.startsWith("set"&&
                     methodName.length() > 3 &&
                     Void.TYPE.equals(returnType) &&
                     parameterTypes.length == 1)
               {
                  String name = methodName.substring(3);
                  OpenMBeanAttributeInfo attribute = attributesMap.get(name);
                  if (attribute != null)
                  {
                     result.put(method, new SetAction(attribute));
                     continue;
                  }
View Full Code Here


            customize(MBeanAttributeInfo ai,
                      String description) {
        if (equal(description, ai.getDescription()))
            return ai;
        if (ai instanceof OpenMBeanAttributeInfo) {
            OpenMBeanAttributeInfo oai = (OpenMBeanAttributeInfo) ai;
            return new OpenMBeanAttributeInfoSupport(ai.getName(),
                                                     description,
                                                     oai.getOpenType(),
                                                     ai.isReadable(),
                                                     ai.isWritable(),
                                                     ai.isIs(),
                                                     ai.getDescriptor());
        } else {
View Full Code Here

/* 201 */     this.mbeanInfo = ((OpenMBeanInfo)this.mbeanServerConnection.getMBeanInfo(this.objectName));
/* 202 */     Map attributesMap = new HashMap();
/* 203 */     MBeanAttributeInfo[] attributes = this.mbeanInfo.getAttributes();
/* 204 */     for (int i = 0; i < attributes.length; i++)
/*     */     {
/* 206 */       OpenMBeanAttributeInfo openAttribute = (OpenMBeanAttributeInfo)attributes[i];
/* 207 */       attributesMap.put(openAttribute.getName(), openAttribute);
/*     */     }
/* 209 */     MBeanOperationInfo[] operations = this.mbeanInfo.getOperations();
/*     */
/* 211 */     Map result = new HashMap();
/*     */
/* 213 */     Class[] interfaces = proxy.getClass().getInterfaces();
/* 214 */     for (int i = 0; i < interfaces.length; i++)
/*     */     {
/* 216 */       if (NotificationBroadcaster.class.isAssignableFrom(interfaces[i]))
/*     */       {
/* 218 */         result.put(ADD_NOTIFICATION_LISTENER, new AddNotificationListenerAction(null));
/* 219 */         result.put(GET_NOTIFICATION_INFO, new GetNotificationInfoAction(null));
/* 220 */         result.put(REMOVE_NOTIFICATION_LISTENER, new RemoveNotificationListenerAction(null));
/* 221 */         result.put(REMOVE_NOTIFICATION_LISTENER_TRIPLET, new RemoveNotificationListenerTripletAction(null));
/*     */       }
/*     */       else
/*     */       {
/* 225 */         Method[] methods = interfaces[i].getMethods();
/* 226 */         for (Method method : methods)
/*     */         {
/* 228 */           String methodName = method.getName();
/* 229 */           Class returnType = method.getReturnType();
/* 230 */           Class[] parameterTypes = method.getParameterTypes();
/*     */
/* 233 */           if ((methodName.startsWith("get")) && (methodName.length() > 3) && (!Void.TYPE.equals(returnType)) && (parameterTypes.length == 0))
/*     */           {
/* 238 */             String name = methodName.substring(3);
/* 239 */             OpenMBeanAttributeInfo attribute = (OpenMBeanAttributeInfo)attributesMap.get(name);
/* 240 */             if (attribute != null)
/*     */             {
/* 242 */               Type type = method.getGenericReturnType();
/* 243 */               result.put(method, new GetAction(attribute, type));
/* 244 */               continue;
/*     */             }
/*     */
/*     */           }
/* 248 */           else if ((methodName.startsWith("is")) && (methodName.length() > 2) && (Boolean.TYPE.equals(returnType)) && (parameterTypes.length == 0))
/*     */           {
/* 253 */             String name = methodName.substring(2);
/* 254 */             OpenMBeanAttributeInfo attribute = (OpenMBeanAttributeInfo)attributesMap.get(name);
/* 255 */             if (attribute != null)
/*     */             {
/* 257 */               Type type = method.getGenericReturnType();
/* 258 */               result.put(method, new GetAction(attribute, type));
/* 259 */               continue;
/*     */             }
/*     */
/*     */           }
/* 263 */           else if ((methodName.startsWith("set")) && (methodName.length() > 3) && (Void.TYPE.equals(returnType)) && (parameterTypes.length == 1))
/*     */           {
/* 268 */             String name = methodName.substring(3);
/* 269 */             OpenMBeanAttributeInfo attribute = (OpenMBeanAttributeInfo)attributesMap.get(name);
/* 270 */             if (attribute != null)
/*     */             {
/* 272 */               result.put(method, new SetAction(attribute));
/* 273 */               continue;
/*     */             }
View Full Code Here

/*     */
/*     */   public Object getAttribute(String attribute) throws AttributeNotFoundException, MBeanException, ReflectionException
/*     */   {
/*     */     try
/*     */     {
/* 169 */       OpenMBeanAttributeInfo attributeInfo = (OpenMBeanAttributeInfo)this.attributeMapping.get(attribute);
/* 170 */       if (attributeInfo == null)
/* 171 */         throw new AttributeNotFoundException(attribute);
/* 172 */       MBeanAttributeInfo mbeanAttributeInfo = (MBeanAttributeInfo)attributeInfo;
/* 173 */       if (!mbeanAttributeInfo.isReadable()) {
/* 174 */         throw new AttributeNotFoundException("Attribute is not readable: " + attribute);
/*     */       }
/* 176 */       Method method = (Method)this.getters.get(attribute);
/* 177 */       if (method == null) {
/* 178 */         throw new NoSuchMethodException("No method to get attribute: " + attribute);
/*     */       }
/* 180 */       Object result = method.invoke(this.implementation, new Object[0]);
/*     */
/* 182 */       return MXBeanUtils.construct(attributeInfo.getOpenType(), result, "Get attribute: " + attribute);
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 186 */       JMException result = ExceptionHandler.handleException(e);
/* 187 */       if ((result instanceof AttributeNotFoundException))
View Full Code Here

/*     */     throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException
/*     */   {
/*     */     try
/*     */     {
/* 201 */       String attributeName = attribute.getName();
/* 202 */       OpenMBeanAttributeInfo attributeInfo = (OpenMBeanAttributeInfo)this.attributeMapping.get(attributeName);
/* 203 */       if (attributeInfo == null)
/* 204 */         throw new AttributeNotFoundException(attributeName);
/* 205 */       MBeanAttributeInfo mbeanAttributeInfo = (MBeanAttributeInfo)attributeInfo;
/* 206 */       if (!mbeanAttributeInfo.isWritable()) {
/* 207 */         throw new AttributeNotFoundException("Attribute is not writable: " + attributeName);
View Full Code Here

/* 364 */     this.cachedMBeanInfo = info;
/* 365 */     Map attributeMapping = new HashMap();
/* 366 */     MBeanAttributeInfo[] attributes = info.getAttributes();
/* 367 */     for (int i = 0; i < attributes.length; i++)
/*     */     {
/* 369 */       OpenMBeanAttributeInfo attribute = (OpenMBeanAttributeInfo)attributes[i];
/* 370 */       attributeMapping.put(attribute.getName(), attribute);
/*     */     }
/* 372 */     this.attributeMapping = attributeMapping;
/*     */     try
/*     */     {
/* 376 */       HashMap getters = new HashMap();
View Full Code Here

/* 235 */       String[] keys = (String[])getters.keySet().toArray(new String[getters.size()]);
/* 236 */       for (String key : keys)
/*     */       {
/* 238 */         Method getter = (Method)getters.remove(key);
/* 239 */         Method setter = (Method)setters.remove(key);
/* 240 */         OpenMBeanAttributeInfo info = buildAttribute(key, getter, setter);
/* 241 */         attrInfo.add(info);
/*     */       }
/*     */
/* 244 */       for (String key : setters.keySet())
/*     */       {
/* 246 */         Method setter = (Method)setters.remove(key);
/* 247 */         OpenMBeanAttributeInfo info = buildAttribute(key, null, setter);
/* 248 */         attrInfo.add(info);
/*     */       }
/*     */
/* 251 */       OpenMBeanAttributeInfo[] attributeInfo = (OpenMBeanAttributeInfo[])attrInfo.toArray(new OpenMBeanAttributeInfo[attrInfo.size()]);
/* 252 */       Collection operations = operInfo.values();
View Full Code Here

TOP

Related Classes of javax.management.openmbean.OpenMBeanAttributeInfo

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.