Package javax.management.openmbean

Examples of javax.management.openmbean.OpenDataException


        } else {
            Class<?> targetType;
            try {
                targetType = classLoader.loadClass(typeName);
            } catch (ClassNotFoundException ex) {
                OpenDataException odex = new OpenDataException("Cannot load target type: " + typeName);
                odex.initCause(ex);
                throw odex;
            }
            Constructor<?> ctor = null;
            boolean isDefaultCtor = false;
            for (Constructor<?> aux : targetType.getConstructors()) {
                isDefaultCtor = aux.getParameterTypes().length == 0;
                if (isDefaultCtor) {
                    ctor = aux;
                    break;
                } else if (aux.getAnnotation(ConstructorProperties.class) != null) {
                    ctor = aux;
                }
            }
            IllegalStateAssertion.assertNotNull(ctor, "Cannot mxbean compliant constructor for: " + targetType.getName());
            try {
                if (isDefaultCtor) {
                    result = ctor.newInstance((Object[]) null);
                    for (String key : ctype.keySet()) {
                        OpenType<?> itemType = ctype.getType(key);
                        Object itemValue = cdata.get(key);
                        Object javaValue = fromOpenData(itemType, classLoader, itemValue);
                        invokeSetter(result, key, javaValue);
                    }
                } else {
                    List<Object> params = new ArrayList<>();
                    ConstructorProperties props = ctor.getAnnotation(ConstructorProperties.class);
                    for (String key : props.value()) {
                        OpenType<?> itemType = ctype.getType(key);
                        Object itemValue = cdata.get(key);
                        Object javaValue = fromOpenData(itemType, classLoader, itemValue);
                        params.add(javaValue);
                    }
                    Class<?>[] paramTypes = ctor.getParameterTypes();
                    for (Object param : params) {
                        int index = params.indexOf(param);
                        Class<?> paramType = paramTypes[index];
                        param = toTargetType(paramType, param);
                        if (param != params.get(index)) {
                            params.set(index, param);
                        }
                    }
                    result = ctor.newInstance(params.toArray());
                }
            } catch (Exception ex) {
                OpenDataException odex = new OpenDataException("Cannot construct object from: " + cdata);
                odex.initCause(ex);
                throw odex;
            }
        }
        return result;
    }
View Full Code Here


            IllegalStateAssertion.assertNotNull(method, "Cannot find setter: " + beanClass.getName() + "." + methodName);
            Class<?> paramType = method.getParameterTypes()[0];
            value = toTargetType(paramType, value);
            method.invoke(target, value);
        } catch (Exception ex) {
            OpenDataException odex = new OpenDataException("Cannot invoke setter for: " + itemName);
            odex.initCause(ex);
            throw odex;
        }
    }
View Full Code Here

                compType = TabularData.class;
            } else {
                compType = classLoader.loadClass(elementType.getTypeName());
            }
        } catch (ClassNotFoundException ex) {
            OpenDataException odex = new OpenDataException("Cannot load array type: " + atype);
            odex.initCause(ex);
            throw odex;
        }
        return Array.newInstance(compType, dimension);
    }
View Full Code Here

                compType = Class.forName(atype.getTypeName()).getComponentType();
            } else {
                compType = classLoader.loadClass(elementType.getTypeName());
            }
        } catch (ClassNotFoundException ex) {
            OpenDataException odex = new OpenDataException("Cannot load array type: " + atype);
            odex.initCause(ex);
            throw odex;
        }
        return Array.newInstance(compType, dimension);
    }
View Full Code Here

TOP

Related Classes of javax.management.openmbean.OpenDataException

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.