public ProxyBean(MBeanInfo originalBeanInfo, ObjectName originalName, OpenTypeCache typeCache) { _originalName = originalName; _typeCache = typeCache; List <MBeanAttributeInfo> attributes = new List <MBeanAttributeInfo>(); List <MBeanOperationInfo> operations = new List <MBeanOperationInfo>(); List <MBeanConstructorInfo> constructors = new List <MBeanConstructorInfo>(); foreach (MBeanAttributeInfo attributeInfo in originalBeanInfo.Attributes) { if (attributeInfo.Readable) { Type attributeType = Type.GetType(attributeInfo.Type, true); OpenType mappedType = _typeCache.MapType(attributeType); if (mappedType != null) { Descriptor descriptor = new Descriptor(); //TODO: Copty fields descriptor.SetField(OpenTypeDescriptor.Field, mappedType); MBeanAttributeInfo openInfo = new MBeanAttributeInfo( attributeInfo.Name, attributeInfo.Description, mappedType.Representation.AssemblyQualifiedName, attributeInfo.Readable, false, descriptor); attributes.Add(openInfo); _attributeTypes[attributeInfo.Name] = new OpenAndClrType(attributeType, mappedType); } } } foreach (MBeanOperationInfo operationInfo in originalBeanInfo.Operations) { Type returnType = Type.GetType(operationInfo.ReturnType, true); OpenType mappedReturnType = _typeCache.MapType(returnType); if (mappedReturnType == null) { continue; } Descriptor descriptor = new Descriptor(); descriptor.SetField(OpenTypeDescriptor.Field, mappedReturnType); bool success = true; List <MBeanParameterInfo> openParameters = new List <MBeanParameterInfo>(); foreach (MBeanParameterInfo parameterInfo in operationInfo.Signature) { OpenType mappedParamType = _typeCache.MapType(Type.GetType(parameterInfo.Type, true)); if (mappedParamType == null || mappedParamType.Kind != OpenTypeKind.SimpleType) { success = false; break; } Descriptor paramDescriptor = new Descriptor(); //TODO: Copy fields paramDescriptor.SetField(OpenTypeDescriptor.Field, mappedParamType); openParameters.Add(new MBeanParameterInfo(parameterInfo.Name, parameterInfo.Description, mappedParamType.Representation.AssemblyQualifiedName, paramDescriptor)); } if (!success) { continue; } MBeanOperationInfo openInfo = new MBeanOperationInfo(operationInfo.Name, operationInfo.Description, mappedReturnType.Representation.AssemblyQualifiedName, openParameters, operationInfo.Impact, descriptor); operations.Add(openInfo); _operationReturnTypes[operationInfo.Name] = new OpenAndClrType(returnType, mappedReturnType); } _info = new MBeanInfo(originalBeanInfo.ClassName, originalBeanInfo.Description, attributes, constructors, operations, originalBeanInfo.Notifications); }
public ProxyBean(MBeanInfo originalBeanInfo, ObjectName originalName, OpenTypeCache typeCache) { _originalName = originalName; _typeCache = typeCache; List<MBeanAttributeInfo> attributes = new List<MBeanAttributeInfo>(); List<MBeanOperationInfo> operations = new List<MBeanOperationInfo>(); List<MBeanConstructorInfo> constructors = new List<MBeanConstructorInfo>(); foreach (MBeanAttributeInfo attributeInfo in originalBeanInfo.Attributes) { if (attributeInfo.Readable) { Type attributeType = Type.GetType(attributeInfo.Type, true); OpenType mappedType = _typeCache.MapType(attributeType); if (mappedType != null) { Descriptor descriptor = new Descriptor(); //TODO: Copty fields descriptor.SetField(OpenTypeDescriptor.Field, mappedType); MBeanAttributeInfo openInfo = new MBeanAttributeInfo( attributeInfo.Name, attributeInfo.Description, mappedType.Representation.AssemblyQualifiedName, attributeInfo.Readable, false, descriptor); attributes.Add(openInfo); _attributeTypes[attributeInfo.Name] = new OpenAndClrType(attributeType, mappedType); } } } foreach (MBeanOperationInfo operationInfo in originalBeanInfo.Operations) { Type returnType = Type.GetType(operationInfo.ReturnType, true); OpenType mappedReturnType = _typeCache.MapType(returnType); if (mappedReturnType == null) { continue; } Descriptor descriptor = new Descriptor(); descriptor.SetField(OpenTypeDescriptor.Field, mappedReturnType); bool success = true; List<MBeanParameterInfo> openParameters = new List<MBeanParameterInfo>(); foreach (MBeanParameterInfo parameterInfo in operationInfo.Signature) { OpenType mappedParamType = _typeCache.MapType(Type.GetType(parameterInfo.Type, true)); if (mappedParamType == null || mappedParamType.Kind != OpenTypeKind.SimpleType) { success = false; break; } Descriptor paramDescriptor = new Descriptor(); //TODO: Copy fields paramDescriptor.SetField(OpenTypeDescriptor.Field, mappedParamType); openParameters.Add(new MBeanParameterInfo(parameterInfo.Name, parameterInfo.Description, mappedParamType.Representation.AssemblyQualifiedName, paramDescriptor)); } if (!success) { continue; } MBeanOperationInfo openInfo = new MBeanOperationInfo(operationInfo.Name, operationInfo.Description, mappedReturnType.Representation.AssemblyQualifiedName, openParameters, operationInfo.Impact, descriptor); operations.Add(openInfo); _operationReturnTypes[operationInfo.Name] = new OpenAndClrType(returnType, mappedReturnType); } _info = new MBeanInfo(originalBeanInfo.ClassName, originalBeanInfo.Description, attributes, constructors, operations, originalBeanInfo.Notifications); }